:root {
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.72);
  --card: #ffffff;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #0a84ff;
  --safe: #30b158;
  --suggestive: #f5a00a;
  --spicy: #ff375f;
  --danger: #ff3b30;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0d;
    --panel: rgba(28, 28, 30, 0.72);
    --card: #1c1c1e;
    --fg: #f5f5f7;
    --muted: #98989d;
    --line: rgba(255, 255, 255, 0.1);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: -20%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 35% at 15% 10%, rgba(255, 79, 143, 0.16), transparent 70%),
    radial-gradient(45% 40% at 90% 20%, rgba(116, 51, 242, 0.14), transparent 70%),
    radial-gradient(40% 40% at 60% 95%, rgba(10, 132, 255, 0.10), transparent 70%);
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 650; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
a { color: var(--accent); text-decoration: none; }

.glass {
  background: var(--panel);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--line);
}

.logo {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 14px;
  background: linear-gradient(135deg, #ff4f8f, #7433f2);
  position: relative; box-shadow: 0 8px 24px rgba(116, 51, 242, 0.3);
}
.logo::after {
  content: ""; position: absolute; left: 41%; top: 31%;
  border-left: 18px solid #fff; border-top: 12px solid transparent; border-bottom: 12px solid transparent;
}
.logo.small { width: 28px; height: 28px; border-radius: 8px; margin: 0; box-shadow: none; }
.logo.small::after { border-left-width: 8px; border-top-width: 5px; border-bottom-width: 5px; left: 40%; top: 32%; }

/* buttons & inputs */
.btn {
  font: inherit; font-weight: 550; border: 0; border-radius: 999px; padding: 8px 16px; cursor: pointer;
  background: rgba(127, 127, 127, 0.14); color: var(--fg); transition: transform .08s, opacity .15s, background .15s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: rgba(127, 127, 127, 0.22); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #0077ed; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.big { padding: 12px 22px; font-size: 16px; }

input, select, textarea {
  font: inherit; color: var(--fg); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2); }
input[type="range"] { padding: 0; border: 0; background: none; box-shadow: none; accent-color: var(--accent); }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); border-radius: 24px; padding: 34px 28px; text-align: center; box-shadow: var(--shadow); }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

/* shell */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100%; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 18px 12px; display: flex; flex-direction: column;
  border-width: 0 1px 0 0;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--fg); font-weight: 500;
}
nav a:hover { background: rgba(127, 127, 127, 0.1); }
nav a.active { background: var(--accent); color: #fff; }
nav .ico { width: 18px; text-align: center; opacity: .8; }
.count { margin-left: auto; font-size: 12px; background: rgba(127,127,127,.2); border-radius: 99px; padding: 1px 8px; }
nav a.active .count { background: rgba(255,255,255,.25); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }
.worker-pill { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #8e8e93; flex: none; }
.dot.on { background: var(--safe); box-shadow: 0 0 0 3px rgba(48, 177, 88, 0.2); }
.dot.busy { background: var(--accent); box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(10, 132, 255, 0.05); } }

main { padding: 28px 32px 60px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* category segmented */
.segmented { display: inline-flex; gap: 3px; padding: 3px; border-radius: 999px; background: rgba(127, 127, 127, 0.13); }
.segmented button {
  font: inherit; font-size: 14px; font-weight: 600; border: 0; background: transparent; color: var(--fg);
  padding: 6px 14px; border-radius: 999px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.segmented button .n { font-size: 12px; opacity: .65; font-weight: 500; }
.segmented button.on { color: #fff; }
.segmented button.on[data-cat="safe"] { background: var(--safe); }
.segmented button.on[data-cat="suggestive"] { background: var(--suggestive); }
.segmented button.on[data-cat="spicy"] { background: var(--spicy); }
.segmented button.on .n { opacity: .9; }

.tag { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: rgba(127,127,127,.15); }
.tag.safe { background: rgba(48, 177, 88, .16); color: var(--safe); }
.tag.suggestive { background: rgba(245, 160, 10, .16); color: #c27c00; }
.tag.spicy { background: rgba(255, 55, 95, .14); color: var(--spicy); }
@media (prefers-color-scheme: dark) { .tag.suggestive { color: var(--suggestive); } }

/* library */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted);
  transition: border-color .15s, background .15s; margin: 18px 0;
}
.dropzone.over { border-color: var(--accent); background: rgba(10, 132, 255, 0.06); color: var(--fg); }
.dropzone strong { color: var(--fg); }
.uploads { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.upload { display: grid; grid-template-columns: 1fr 160px 60px; gap: 12px; align-items: center; font-size: 14px; }
.upload .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 6px; border-radius: 99px; background: rgba(127,127,127,.18); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
.bar.ok > i { background: var(--safe); }
.bar.err > i { background: var(--danger); }
.bar.off > i { background: #8e8e93; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.media {
  position: relative; aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden; background: rgba(127,127,127,.12);
  box-shadow: var(--shadow); transition: transform .15s;
}
.media:hover { transform: translateY(-2px); }
.media img, .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media .meta {
  position: absolute; left: 8px; bottom: 8px; right: 8px; display: flex; gap: 6px; align-items: center;
  font-size: 11px; font-weight: 600; color: #fff;
}
.media .meta span { background: rgba(0,0,0,.5); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); padding: 2px 7px; border-radius: 99px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media .del {
  position: absolute; top: 7px; right: 7px; width: 26px; height: 26px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0,0,0,.5); color: #fff; font-size: 14px; opacity: 0; transition: opacity .15s;
}
.media:hover .del { opacity: 1; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; opacity: .6; }

/* generate */
.gen-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-weight: 600; font-size: 14px; }
.field .hint { font-size: 13px; color: var(--muted); }
.inline { display: flex; align-items: center; gap: 8px; }
.inline input[type="number"] { width: 84px; text-align: center; }
.slider { display: flex; align-items: center; gap: 12px; }
.slider input { flex: 1; }
.slider output { width: 48px; text-align: right; font-variant-numeric: tabular-nums; }
.workers { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.worker { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(127,127,127,.08); }
.worker .sub { font-size: 12px; color: var(--muted); }
.notice { font-size: 13px; padding: 10px 12px; border-radius: 12px; background: rgba(245,160,10,.12); margin-top: 12px; }

/* jobs */
.jobs { display: flex; flex-direction: column; gap: 14px; }
.job { padding: 18px 20px; }
.job-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.job-title { font-weight: 650; font-size: 16px; }
.status { font-size: 12px; font-weight: 650; padding: 3px 10px; border-radius: 99px; text-transform: capitalize; }
.status.queued { background: rgba(127,127,127,.16); }
.status.running { background: rgba(10,132,255,.15); color: var(--accent); }
.status.done { background: rgba(48,177,88,.16); color: var(--safe); }
.status.failed, .status.interrupted { background: rgba(255,59,48,.13); color: var(--danger); }
.status.cancelled { background: rgba(127,127,127,.16); color: var(--muted); }
.job .bar { margin: 14px 0 8px; height: 8px; }
.job-sub { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 8px; background: rgba(127,127,127,.12); display: inline-flex; gap: 5px; align-items: center; }
.chip.rendering { background: rgba(10,132,255,.14); }
.chip.done { background: rgba(48,177,88,.14); }
.chip.failed { background: rgba(255,59,48,.13); }
.clips { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-top: 16px; }
.clip { border-radius: 14px; overflow: hidden; background: #000; box-shadow: var(--shadow); }
.clip video { width: 100%; aspect-ratio: 9 / 16; object-fit: contain; display: block; background: #000; }
.clip .cap { background: var(--card); padding: 8px 10px; font-size: 12px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.clip .cap .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: rgba(30,30,32,.92); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 16px; border-width: 0 0 1px 0; flex-wrap: wrap; }
  .brand { padding: 0; }
  nav { flex-direction: row; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  main { padding: 20px 16px 50px; }
  .gen-layout { grid-template-columns: 1fr; }
  .upload { grid-template-columns: 1fr 90px 50px; }
}
