:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #242836;
  --border: #2e3345;
  --text: #e8eaef;
  --text-muted: #8b919e;
  --accent: #5b8def;
  --accent-hover: #4a7de0;
  --danger: #ef5b5b;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card h1 { font-size: 1.75rem; margin-bottom: 0.25rem; }
.subtitle { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

input[type="password"], input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 1rem;
}

input:focus { outline: none; border-color: var(--accent); }

button, .btn-primary, .btn-secondary {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}

button, .btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
}

button:hover, .btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
  text-decoration: none;
  display: inline-block;
}

.btn-secondary:hover { background: var(--border); }

.error { color: var(--danger); font-size: 0.85rem; margin-top: 0.5rem; }

/* App layout */
#app-screen {
  display: block;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

header h1 { font-size: 1.5rem; }

.tabs { display: flex; gap: 0.5rem; }

.tab {
  width: auto;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.tab.active, .tab:hover {
  background: var(--surface);
  color: var(--text);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

.file-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.file-row {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
  transition: background 0.1s;
}

.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--surface-hover); }

.file-icon { font-size: 1.25rem; width: 1.5rem; text-align: center; flex-shrink: 0; }
.file-name { flex: 1; cursor: pointer; word-break: break-all; }
.file-name:hover { color: var(--accent); }
.file-size { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }

.file-actions { display: flex; gap: 0.5rem; }

.file-actions button {
  width: auto;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-share { background: var(--accent); }
.btn-delete { background: var(--danger); }

.empty-state {
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content { width: 100%; max-width: 440px; }
.modal-content h2 { margin-bottom: 1rem; }
.modal-content label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }
.modal-content .filename { font-weight: 500; margin-bottom: 1rem; word-break: break-all; }

.modal-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
.modal-actions button { width: auto; flex: 1; }

.link-box { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.link-box input { margin-bottom: 0; flex: 1; font-size: 0.85rem; }
.link-box button { width: auto; white-space: nowrap; }
.full-width { width: 100%; }

/* Viewer */
.viewer-body { display: flex; flex-direction: column; height: 100vh; }

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.viewer-header span { font-weight: 500; word-break: break-all; }

.viewer-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 1rem;
}

.viewer-content video,
.viewer-content audio { max-width: 100%; max-height: calc(100vh - 80px); }
.viewer-content img { max-width: 100%; max-height: calc(100vh - 80px); object-fit: contain; }
.viewer-content iframe { width: 100%; height: calc(100vh - 80px); border: none; }

.player-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-wrap video {
  width: 100%;
  max-height: calc(100vh - 80px);
  background: #000;
  border-radius: var(--radius);
}

.player-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  border-radius: var(--radius);
  gap: 1rem;
  z-index: 2;
}

.player-status p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.player-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.viewer-content pre {
  width: 100%;
  max-height: calc(100vh - 80px);
  overflow: auto;
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

#media-fallback { text-align: center; }
#media-fallback p { color: var(--text-muted); margin-bottom: 1rem; }

.share-url-cell {
  font-size: 0.8rem;
  color: var(--accent);
  word-break: break-all;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.share-lock {
  font-size: 0.75rem;
  flex-shrink: 0;
  opacity: 0.85;
}

.share-url-cell:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .file-size { display: none; }
  header { flex-direction: column; align-items: flex-start; }
}
