:root {
  color-scheme: dark;
  --bg: #0b0e1a;
  --sidebar: #0a0d17;
  --panel: #0f1324;
  --panel-2: #161b31;
  --text: #f1f3f9;
  --muted: #8a92ad;
  --border: #1e2441;
  --accent: #4c5fd5;
  --accent-soft: rgba(76, 95, 213, .16);
  --accent-text: #ffffff;
  --link: #7d8ff0;
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 10px;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f5f6fb;
    --sidebar: #ffffff;
    --panel: #ffffff;
    --panel-2: #eef0f8;
    --text: #141729;
    --muted: #61688a;
    --border: #dfe2ee;
    --accent: #4153c9;
    --accent-soft: rgba(65, 83, 201, .1);
    --link: #3646b5;
    --danger: #dc2626;
    --ok: #16a34a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { margin: 0 0 4px; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 22px; }
.title { font-size: 34px; }
.card h2 { font-size: 18px; }
p { margin: 0; }
a { color: var(--link); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.error { color: var(--danger); min-height: 1.5em; margin: 0; }
.status { color: var(--muted); font-size: 13px; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--danger); }

input, textarea, select, button, .button {
  font: inherit;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 7px 10px;
}
input, textarea { width: 100%; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
input[type="color"] { width: 48px; height: 34px; padding: 2px; }
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, .button { cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
button:hover, .button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--link); }
button:disabled { opacity: .5; cursor: default; }

label { display: grid; gap: 4px; font-weight: 500; }
label.inline { display: inline-flex; align-items: center; gap: 8px; }
label.check { display: flex; align-items: center; gap: 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.grow { flex: 1 1 160px; min-width: 0; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  gap: 12px;
  align-content: start;
}
.stack { display: grid; gap: 16px; align-content: start; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; padding: 28px; }
.login-card h1 { font-size: 28px; }

/* Shell: sidebar on the left, page on the right */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.brand { font-size: 26px; font-weight: 800; letter-spacing: -.02em; padding: 18px 20px; }
.menu-toggle { display: none; margin-right: 16px; }
.sidebar-menu { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.nav { display: grid; align-content: start; padding: 8px 0; overflow-y: auto; }
.nav a, .nav summary {
  color: var(--text);
  text-decoration: none;
  padding: 12px 20px;
  font-weight: 500;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.nav a:hover, .nav summary:hover { background: var(--panel-2); }
.nav a[aria-current="page"] { background: var(--accent-soft); border-left-color: var(--accent); }
/* Dropdown groups: a small chevron that turns when open */
.nav summary { list-style: none; display: flex; justify-content: space-between; align-items: center; }
.nav summary::-webkit-details-marker { display: none; }
.nav summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .15s;
}
.nav-group[open] > summary::after { transform: rotate(45deg); }
.nav-group > a { display: block; padding-left: 40px; }
.sidebar-foot { margin-top: auto; padding: 16px 20px; display: grid; gap: 12px; border-top: 1px solid var(--border); }
.sidebar-foot a { color: var(--link); text-decoration: none; }
.sidebar-foot a[aria-current="page"] { font-weight: 700; }
.version {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px;
  border-radius: 6px;
  background: var(--accent-soft);
  font-weight: 700;
  font-size: 13px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.who { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); }

main { padding: 28px; max-width: 1400px; width: 100%; }
.tab { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.tab > .section-head { justify-content: start; }
.pill {
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  padding: 3px 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--link);
}
.pill:hover { background: var(--accent-soft); }

/* Home */
.recent { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.recent-file {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  grid-template-rows: 220px auto;
}
.recent-file .name { padding: 8px 12px; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: grid;
  gap: 6px;
}
.stat-label { color: var(--muted); font-weight: 700; }
.stat-value { font-size: 34px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.legend { display: grid; justify-items: end; font-size: 13px; }
.legend strong { font-size: 16px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid-line { stroke: var(--border); }
.chart .axis { fill: var(--muted); font-size: 12px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .area { fill: var(--accent-soft); }
.chart .point { fill: var(--panel); stroke: var(--accent); stroke-width: 2; }
.table { width: 100%; border-collapse: collapse; margin-top: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table th { font-weight: 800; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; width: 120px; font-variant-numeric: tabular-nums; }

/* Upload */
.dropzone {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 200px;
  padding: 24px 16px;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  font-weight: 400;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.queue li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}
.queue .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.queue li.done .bar > span { background: var(--ok); }
.queue li.failed .bar > span { background: var(--danger); width: 100%; }

/* Files */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.file {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  grid-template-rows: 160px auto;
}
.thumb {
  display: grid;
  place-items: center;
  background: var(--panel-2);
  color: var(--muted);
  overflow: hidden;
  font-weight: 700;
  text-transform: uppercase;
  text-decoration: none;
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.file-body { padding: 10px 12px 12px; display: grid; gap: 6px; min-width: 0; }
.file-body .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-body .meta { color: var(--muted); font-size: 12px; }
.file-body .row button, .file-body .row a { padding: 4px 8px; font-size: 13px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; }

/* Settings */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.preview {
  border-left: 4px solid var(--embed-color, var(--accent));
  background: var(--panel-2);
  border-radius: 4px;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
  max-width: 420px;
}
.preview-site, .preview-author { font-size: 12px; color: var(--muted); }
.preview-author { color: var(--text); font-weight: 500; }
.preview-title { font-weight: 600; color: var(--link); }
.preview-desc { font-size: 13px; white-space: pre-wrap; }
.preview-image {
  margin-top: 6px;
  height: 120px;
  border-radius: 4px;
  background: var(--border);
  display: grid;
  place-items: center;
  color: var(--muted);
}
.preview div:empty { display: none; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recent-file { grid-template-rows: 160px auto; }
}

/* Phones: the sidebar becomes a top bar with a Menu button that drops the full menu down */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-top { border-bottom: 0; }
  .brand { font-size: 22px; padding: 12px 16px; }
  .menu-toggle { display: inline-block; }
  .sidebar-menu { display: none; max-height: calc(100vh - 56px); overflow-y: auto; border-top: 1px solid var(--border); }
  .sidebar.open .sidebar-menu { display: flex; }
  main { padding: 20px 16px; }
  .title { font-size: 28px; }
  .recent { gap: 8px; }
  .recent-file { grid-template-rows: 90px auto; }
  .recent-file .name { padding: 6px 8px; font-size: 12px; }
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 24px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .file { grid-template-rows: 120px auto; }
}
