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

:root {
  --bg:           #080b14;
  --surface:      #0f1221;
  --surface-2:    #171b2e;
  --surface-h:    #1e2338;
  --border:       #252840;
  --accent:       #6366f1;
  --accent-h:     #4f46e5;
  --accent-dim:   rgba(99,102,241,.12);
  --text:         #e2e8f0;
  --text-m:       #94a3b8;
  --text-d:       #64748b;
  --danger:       #ef4444;
  --danger-h:     #dc2626;
  --danger-dim:   rgba(239,68,68,.12);
  --success:      #10b981;
  --folder:       #f59e0b;
  --r:            8px;
  --r-sm:         4px;
  --shadow:       0 8px 32px rgba(0,0,0,.5);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Header ─────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 1rem;
}

.header-left { display: flex; align-items: center; gap: .625rem; }

.logo-icon { color: var(--accent); flex-shrink: 0; }

.brand { font-weight: 700; font-size: .9375rem; letter-spacing: -.01em; }

.header-right { display: flex; align-items: center; gap: .875rem; flex-shrink: 0; }

.username-display {
  font-size: .8125rem;
  color: var(--text-m);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Main ────────────────────────────────────────────── */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  position: relative;
}

/* ─── Toolbar ─────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: .125rem;
  flex-wrap: wrap;
  min-width: 0;
}

.crumb {
  background: none;
  border: none;
  color: var(--text-m);
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: var(--r-sm);
  font-size: .8125rem;
  transition: all .15s;
  white-space: nowrap;
}
.crumb:hover           { background: var(--surface-2); color: var(--text); }
.crumb.active          { color: var(--text); font-weight: 600; cursor: default; }
.crumb.active:hover    { background: transparent; }
.crumb-sep             { color: var(--text-d); font-size: .75rem; user-select: none; padding: 0 .125rem; }

.toolbar-actions { display: flex; gap: .625rem; align-items: center; flex-shrink: 0; }

/* ─── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .9375rem;
  border-radius: var(--r);
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary                  { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }

.btn-secondary                { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-h); }

.btn-ghost                    { background: transparent; color: var(--text-m); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-danger                   { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-h); }

.btn-full                     { width: 100%; justify-content: center; }

.upload-label                 { cursor: pointer; }

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

.file-list-header {
  display: grid;
  grid-template-columns: 1fr 90px 155px 190px;
  padding: .625rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-d);
  font-size: .6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  user-select: none;
}

.file-row {
  display: grid;
  grid-template-columns: 1fr 90px 155px 190px;
  padding: .6875rem 1rem;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.file-row:last-child        { border-bottom: none; }
.file-row:hover             { background: var(--surface-h); }
.file-row.folder            { cursor: pointer; }

.file-name {
  display: flex;
  align-items: center;
  gap: .625rem;
  min-width: 0;
}
.file-icon { font-size: 1.125rem; flex-shrink: 0; line-height: 1; }
.file-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: .875rem;
}
.file-row.folder .file-name-text { color: var(--folder); font-weight: 500; }

.file-size, .file-date {
  color: var(--text-m);
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
}

.file-actions {
  display: flex;
  gap: .3rem;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity .15s;
}
.file-row:hover .file-actions { opacity: 1; }

.action-btn {
  padding: .2rem .5rem;
  font-size: .6875rem;
  font-weight: 500;
  border-radius: var(--r-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-m);
  transition: all .15s;
  white-space: nowrap;
}
.action-btn:hover             { background: var(--surface-h); color: var(--text); }
.action-btn.danger            { color: var(--danger); border-color: rgba(239,68,68,.25); }
.action-btn.danger:hover      { background: var(--danger-dim); }

/* ─── States ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text-m);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { margin-bottom: .4rem; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5rem;
}
.spinner {
  width: 30px; height: 30px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Upload progress ─────────────────────────────────── */
.upload-progress {
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.upload-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6875rem 1rem;
  border-bottom: 1px solid var(--border);
}
.upload-item:last-child        { border-bottom: none; }
.upload-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .8125rem;
}
.progress-bar {
  width: 100px; height: 3px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width .2s;
  border-radius: 2px;
}
.upload-item.done  .progress-fill { background: var(--success); }
.upload-item.error .progress-fill { background: var(--danger); }
.upload-status {
  font-size: .6875rem;
  color: var(--text-m);
  width: 52px;
  text-align: right;
  flex-shrink: 0;
}

/* Drag-over overlay */
.drag-overlay {
  position: fixed;
  inset: 0;
  background: var(--accent-dim);
  border: 2px dashed var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
  pointer-events: none;
  z-index: 999;
  border-radius: 0;
}

/* ─── Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  animation: modal-in .15s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(-8px); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: .9375rem; font-weight: 600; }
.modal-close {
  background: none; border: none;
  color: var(--text-d); cursor: pointer;
  font-size: 1.375rem; padding: .125rem .375rem;
  border-radius: var(--r-sm); line-height: 1;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.modal-body    { padding: 1.25rem; }
.modal-footer  {
  display: flex;
  justify-content: flex-end;
  gap: .625rem;
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border);
}

.modal-overlay.modal-media .modal {
  max-width: 800px;
}

.modal-media .modal-body {
  padding: .75rem;
}

.modal-media .modal-header h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 500px;
}

/* ─── Preview ──────────────────────────────────────────── */
.preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}

.preview-media {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--r);
  background: #000;
  display: block;
}

.preview-img {
  object-fit: contain;
  background: var(--surface-2);
}

.preview-audio {
  width: 100%;
  margin-top: .5rem;
}

.audio-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  width: 100%;
}

.audio-icon {
  font-size: 3rem;
  line-height: 1;
}

.preview-info {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .25rem 0;
}

.preview-name {
  font-size: .8125rem;
  color: var(--text-m);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.action-btn.preview-btn {
  color: var(--accent);
  border-color: rgba(99,102,241,.25);
}
.action-btn.preview-btn:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ─── Forms ──────────────────────────────────────────── */
.field           { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field label     { display: block; margin-bottom: .375rem; font-size: .8125rem; color: var(--text-m); }

.input {
  width: 100%;
  padding: .5625rem .875rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: .875rem;
  transition: border-color .15s;
  outline: none;
  font-family: inherit;
}
.input:focus       { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input::placeholder { color: var(--text-d); }

/* ─── Login page ─────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo        { text-align: center; margin-bottom: 2rem; }
.login-logo svg    { width: 44px; height: 44px; margin-bottom: .625rem; }
.login-logo h1     { font-size: 1.3125rem; font-weight: 700; }
.login-logo p      { color: var(--text-m); font-size: .8125rem; margin-top: .25rem; }

.error-msg {
  padding: .5625rem .875rem;
  background: var(--danger-dim);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--r);
  color: #fca5a5;
  font-size: .8125rem;
  margin-bottom: 1rem;
}

/* ─── Utils ──────────────────────────────────────────── */
.hidden        { display: none !important; }
.text-muted    { color: var(--text-m); font-size: .8125rem; }
.danger-text   { color: #fca5a5; font-size: .875rem; line-height: 1.6; }
.danger-text strong { color: var(--text); }

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .main    { padding: 1rem; }
  .header  { padding: 0 1rem; }
  .username-display { display: none; }

  .file-list-header,
  .file-row {
    grid-template-columns: 1fr auto;
  }
  .file-list-header > :nth-child(2),
  .file-list-header > :nth-child(3),
  .file-size,
  .file-date { display: none; }

  /* Always show actions on mobile (no hover) */
  .file-actions { opacity: 1; }

  .progress-bar { width: 60px; }
  .upload-status { width: 44px; }
}

@media (max-width: 480px) {
  .login-card        { padding: 1.5rem; }
  .toolbar           { flex-direction: column; align-items: stretch; }
  .toolbar-actions   { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar-actions .btn { justify-content: center; }
  .modal             { max-width: 100%; }
}
