:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --surface: #111821;
  --surface-2: #17212c;
  --surface-3: #0f151d;
  --line: #273444;
  --line-strong: #354557;
  --text: #eef3f8;
  --muted: #93a1b1;
  --soft: #c7d1dc;
  --accent: #e23b3b;
  --accent-strong: #ffcc4d;
  --danger: #b32632;
  --radius: 8px;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

a { color: inherit; }

.shell {
  width: min(820px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.panel {
  width: 100%;
  padding: clamp(24px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(32px, 5vw, 52px); line-height: 1.04; }
h2 { font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }

.muted {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

form { display: grid; gap: 14px; margin-top: 28px; }

.drop {
  display: grid;
  place-items: center;
  min-height: 190px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--soft);
  text-align: center;
  padding: 24px;
  cursor: pointer;
}

.drop:hover, .drop.dragging {
  border-color: var(--accent);
  background: #131b24;
}

.drop input { display: none; }

input[type="password"], input[type="text"] {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-3);
  color: var(--text);
  padding: 0 13px;
  outline: none;
}

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

button, .button, .ghost-button, .icon-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  padding: 0 15px;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:hover, .button:hover, .ghost-button:hover, .icon-button:hover { filter: brightness(1.08); }
.ghost-button, .icon-button { background: var(--surface-2); border-color: var(--line); color: var(--soft); }
.danger { background: rgba(179, 38, 50, 0.16); border-color: rgba(255, 96, 110, 0.36); color: #ff9da6; }

.result, .link-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-3);
}

.result { margin-top: 18px; padding: 14px; }
.result a, .link-box code { color: var(--accent-strong); overflow-wrap: anywhere; }

.upload-result, .upload-links { display: grid; gap: 12px; }
.upload-preview { display: grid; grid-template-columns: 126px minmax(0, 1fr); gap: 14px; align-items: center; }
.upload-preview-media {
  width: 126px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #070a0e;
  color: var(--accent-strong);
  font-weight: 900;
}
.upload-preview-media img, .upload-preview-media video { width: 100%; height: 100%; object-fit: cover; }

.preview {
  display: block;
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  margin-top: 24px;
  border-radius: var(--radius);
  background: #070a0e;
}

.audio { width: 100%; margin-top: 24px; }
.generic-file {
  margin-top: 24px;
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--accent-strong);
  font-size: 38px;
  font-weight: 900;
}

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.error { color: #ff9da6; margin: 18px 0 0; }

.admin-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #080b10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  font-weight: 900;
}

.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); }

.admin-nav { display: grid; gap: 8px; }
.admin-nav a {
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--soft);
  text-decoration: none;
}
.admin-nav a.is-active, .admin-nav a:hover { background: var(--surface); border-color: var(--line); color: var(--text); }
.sidebar-logout { margin-top: auto; }

.admin-content {
  min-width: 0;
  padding: 28px;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.admin-header h1 { font-size: clamp(28px, 4vw, 42px); }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metrics div {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  margin-top: 7px;
  font-size: 23px;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-toolbar input { max-width: 520px; }
.admin-toolbar span { color: var(--muted); }

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.files-table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

.files-table th, .files-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.files-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  background: #0d1218;
}

.files-table tr:last-child td { border-bottom: 0; }
.files-table tbody tr.is-selected { background: rgba(255, 204, 77, 0.06); }
.files-table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }

.row-select {
  width: 100%;
  min-height: 0;
  display: flex;
  justify-content: flex-start;
  gap: 11px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.mini-preview {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #070a0e;
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 900;
}

.mini-preview img, .mini-preview video { width: 100%; height: 100%; object-fit: cover; }
.preview-icon { font-size: 10px; font-weight: 900; }

.file-label { min-width: 0; display: grid; gap: 3px; }
.file-label strong { overflow-wrap: anywhere; }
.file-label small { color: var(--muted); overflow-wrap: anywhere; }

.type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  color: var(--soft);
  background: var(--surface-3);
  font-size: 12px;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.table-actions form { margin: 0; display: inline; }
.icon-button { min-height: 32px; padding: 0 10px; font-size: 12px; }

.inspector {
  position: sticky;
  top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.inspector-preview {
  display: grid;
  place-items: center;
  min-height: 220px;
  border-bottom: 1px solid var(--line);
  background: #070a0e;
}

.inspector-preview .preview {
  width: 100%;
  max-height: 280px;
  margin: 0;
  border-radius: 0;
}

.inspector-preview .generic-file { width: 100%; min-height: 220px; margin: 0; border: 0; border-radius: 0; }
.inspector-preview .audio { width: calc(100% - 24px); margin: 0; }

.inspector-body {
  display: grid;
  gap: 13px;
  padding: 15px;
}

.file-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}
.file-meta.compact { grid-template-columns: 1fr 1fr; }
.file-meta dt, .file-meta dd { margin: 0; }
.file-meta dt, .link-box span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.file-meta dd { margin-top: 3px; overflow-wrap: anywhere; }

.link-box {
  display: grid;
  gap: 7px;
  padding: 11px;
}
.link-box button {
  min-height: 32px;
  justify-self: start;
  padding: 0 10px;
  font-size: 12px;
}

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

[hidden] { display: none !important; }

@media (max-width: 1050px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
  }
  .admin-nav { grid-auto-flow: column; }
  .sidebar-logout { margin: 0 0 0 auto; }
  .admin-workspace { grid-template-columns: 1fr; }
  .inspector { position: static; }
}

@media (max-width: 640px) {
  .shell { width: min(100% - 24px, 820px); }
  .admin-content, .admin-sidebar { padding: 16px; }
  .admin-sidebar, .admin-header, .admin-toolbar, .upload-preview { display: grid; grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actions > *, .admin-header .button { width: 100%; }
}
