:root {
  --bg: #0b0d12;
  --panel: #12151d;
  --panel-2: #181c26;
  --line: #242a37;
  --text: #e8ebf2;
  --muted: #8a93a6;
  --blue: #58c4dd;      /* 3Blue1Brown's signature blue */
  --blue-deep: #236b8e;
  --yellow: #ffd23f;
  --red: #fc6255;
  --green: #83c167;
  --radius: 14px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(11, 13, 18, 0.82); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em; font-size: 17px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 30%, var(--blue), var(--blue-deep));
  color: #0b0d12; font-weight: 800; font-size: 17px;
}
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.user img { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); }
main { max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 80px; }
main.center { min-height: 100vh; display: grid; place-items: center; }

/* ---------- hero / form ---------- */
.hero { padding: 56px 0 28px; }
.hero h1 { font-size: clamp(30px, 4.4vw, 46px); line-height: 1.08; letter-spacing: -0.03em; margin: 0 0 12px; }
.hero h1 .accent { color: var(--blue); }
.hero p { margin: 0 0 28px; color: var(--muted); font-size: 17px; max-width: 640px; line-height: 1.55; }

.compose {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px;
}
.compose input[type=text] {
  flex: 1 1 340px; min-width: 0; background: transparent; border: 0; outline: 0;
  color: var(--text); font: 16px var(--font); padding: 12px 10px;
}
.compose input::placeholder { color: #5d6577; }
.segmented { display: flex; background: var(--panel-2); border-radius: 10px; padding: 3px; }
.segmented button {
  background: transparent; border: 0; color: var(--muted); font: 600 13px var(--font);
  padding: 0 12px; border-radius: 8px; cursor: pointer; min-height: 40px;
}
.segmented button.on { background: var(--line); color: var(--text); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue); color: #061017; border: 0; border-radius: 10px;
  font: 650 15px var(--font); padding: 0 20px; min-height: 46px; cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); min-height: 34px; padding: 0 12px; font-size: 13px; }
.hint { margin-top: 10px; font-size: 13px; color: var(--muted); }
.error { color: var(--red); font-size: 14px; margin-top: 10px; }

/* ---------- jobs ---------- */
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 44px 0 14px; }
.section-title h2 { margin: 0; font-size: 19px; letter-spacing: -0.01em; }
.jobs { display: grid; gap: 12px; }
.job { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.job-head { display: flex; align-items: center; gap: 12px; }
.job-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font: 600 11px var(--font); text-transform: uppercase; letter-spacing: .06em; padding: 4px 9px; border-radius: 99px; background: var(--panel-2); color: var(--muted); }
.pill.running { color: var(--blue); background: rgba(88, 196, 221, .12); }
.pill.done { color: var(--green); background: rgba(131, 193, 103, .12); }
.pill.failed { color: var(--red); background: rgba(252, 98, 85, .12); }
.job-step { margin-top: 10px; color: var(--text); font-size: 14px; display: flex; gap: 10px; align-items: center; }
.job-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(88,196,221,.25); border-top-color: var(--blue); animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 3px; border-radius: 3px; background: var(--panel-2); overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--blue-deep), var(--blue)); transition: width .6s ease; }
details.log { margin-top: 12px; }
details.log summary { cursor: pointer; color: var(--muted); font-size: 13px; user-select: none; }
details.log pre {
  margin: 10px 0 0; max-height: 300px; overflow: auto; background: #07080c; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; font: 12.5px/1.6 var(--mono); color: #c6ccd8; white-space: pre-wrap;
}

/* ---------- gallery ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; transition: transform .15s ease, border-color .15s ease; text-align: left; padding: 0; color: inherit; font: inherit;
}
.tile:hover { transform: translateY(-2px); border-color: #34405a; }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #000 center / cover no-repeat; }
.thumb .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.72); font: 600 12px var(--font); padding: 3px 7px; border-radius: 6px; }
.thumb .play { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .15s; background: rgba(0,0,0,.25); }
.tile:hover .play { opacity: 1; }
.play span { width: 54px; height: 54px; border-radius: 50%; background: rgba(88,196,221,.92); display: grid; place-items: center; color: #061017; font-size: 20px; padding-left: 4px; }
.tile-body { padding: 14px 16px 16px; }
.tile-title { font-weight: 620; line-height: 1.3; }
.tile-sub { color: var(--muted); font-size: 13px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted); }

/* ---------- player modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(4, 5, 8, 0.86); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; }
.modal-card { width: min(1100px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.modal-card video { width: 100%; display: block; background: #000; aspect-ratio: 16 / 9; }
.modal-body { padding: 18px 22px 22px; display: grid; gap: 10px; }
.modal-body h3 { margin: 0; font-size: 21px; letter-spacing: -0.01em; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.narration { color: #c6ccd8; line-height: 1.65; font-size: 15px; border-left: 2px solid var(--blue-deep); padding-left: 14px; }
.close { position: absolute; top: 18px; right: 22px; background: none; border: 0; color: var(--text); font-size: 30px; cursor: pointer; }

/* ---------- sign-in ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 36px; }
.card.narrow { max-width: 460px; text-align: center; }
.card h1 { margin: 6px 0 10px; font-size: 26px; letter-spacing: -0.02em; }
.card p { line-height: 1.55; }
.google { background: #fff; color: #1f1f1f; margin-top: 14px; }
.google svg { width: 18px; height: 18px; }
.signin-logo { width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 14px; display: grid; place-items: center; background: radial-gradient(circle at 30% 30%, var(--blue), var(--blue-deep)); color: #0b0d12; font-weight: 800; font-size: 28px; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .topbar #username { display: none; }
  .compose { flex-direction: column; }
  .compose input[type=text] { flex: none; width: 100%; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; padding: 0 4px; }
  .compose .btn { width: 100%; }
  .hero { padding-top: 36px; }
  .modal { padding: 0; }
  .modal-card { border-radius: 0; max-height: 100vh; }
}

/* ---------- account / credits / admin ---------- */
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.google { background: #fff; color: #1f1f1f; }
.btn.google svg { width: 18px; height: 18px; }
.credits { font: 600 12px var(--font); padding: 5px 10px; border-radius: 99px; color: var(--yellow); background: rgba(255, 210, 63, .1); border: 1px solid rgba(255, 210, 63, .25); white-space: nowrap; }
.credits.empty { color: var(--red); background: rgba(252, 98, 85, .1); border-color: rgba(252, 98, 85, .3); }
.hint b { color: var(--text); }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 12px 16px; border-bottom: 1px solid var(--line); }
table.users td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users tr:last-child td { border-bottom: 0; }
.u-name { font-weight: 600; }
.small { font-size: 12px; }
@media (max-width: 640px) { .credits { font-size: 11px; padding: 4px 8px; } }

/* ---------- compact hero + paper finder ---------- */
.hero.compact { padding: 40px 0 6px; }
.hero.compact p { margin-bottom: 0; }
.finder { margin-top: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.finder-bar { display: flex; gap: 8px; }
.finder-bar input { flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); font: 15px var(--font); padding: 10px 12px; outline: 0; }
.finder-bar input:focus { border-color: var(--blue-deep); }
.finder-head { display: flex; justify-content: space-between; align-items: center; margin: 14px 4px 8px; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.linkish { background: none; border: 0; color: var(--blue); cursor: pointer; font: 600 13px var(--font); padding: 0; }
.papers { display: grid; gap: 2px; max-height: 520px; overflow-y: auto; }
.paper { display: flex; gap: 14px; align-items: center; padding: 11px 10px; border-radius: 10px; }
.paper:hover { background: var(--panel-2); }
.paper-main { flex: 1; min-width: 0; }
.paper-title { font-weight: 600; font-size: 15px; line-height: 1.35; }
.paper-title a { color: var(--text); }
.paper-meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paper-sum { color: #a9b1c2; font-size: 13px; margin-top: 5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.paper .btn { flex: none; min-height: 34px; padding: 0 14px; font-size: 13px; }
.paper .btn.watch { background: rgba(131,193,103,.15); color: var(--green); }
.papers .empty { padding: 26px; }
@media (max-width: 640px) { .paper-sum { display: none; } .finder { padding: 10px; } }
.compose input.flash { animation: flash .9s ease; }
@keyframes flash { 0% { background: rgba(88,196,221,.25); } 100% { background: transparent; } }

/* ---------- two-column layout: library side panel ---------- */
.layout { max-width: 1380px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px;
          padding: 0 clamp(16px, 3vw, 40px) 80px; align-items: start; }
.layout > main { max-width: none; margin: 0; padding: 0; }
aside.library { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; padding: 4px 4px 20px;
                margin-top: 36px; }
aside.library .section-title { margin: 0 0 12px; }
.lib-list { display: grid; gap: 12px; }
.lib-list .tile { display: block; width: 100%; }
.lib-list .tile-body { padding: 10px 12px 12px; }
.lib-list .tile-title { font-size: 14px; }
.lib-list .tile-sub { font-size: 12px; }
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  aside.library { position: static; max-height: none; overflow: visible; order: -1; margin-top: 24px; }
  .lib-list { grid-auto-flow: column; grid-auto-columns: minmax(230px, 70%); overflow-x: auto; padding-bottom: 6px; }
}

/* ---------- voice picker ---------- */
.voices { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.voices-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.voice-list { display: flex; gap: 6px; flex-wrap: wrap; }
.voice { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line);
         color: var(--muted); border-radius: 99px; padding: 5px 6px 5px 12px; font: 600 13px var(--font); cursor: pointer; }
.voice.on { border-color: var(--blue); color: var(--text); background: rgba(88,196,221,.1); }
.voice .play-btn { width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--panel-2); color: var(--blue);
                   display: grid; place-items: center; font-size: 10px; cursor: pointer; padding: 0; }
.voice .play-btn.playing { background: var(--blue); color: #061017; }
