:root {
  --bg: #f3f3f1; --surface: #ffffff; --surface-2: #f7f7f5; --ink: #111214; --soft: #5d626b; --line: rgba(0,0,0,.09);
  --blue: #1f63ff; --blue-soft: rgba(31,99,255,.1); --red: #e5383b; --green: #12a564; --amber: #c98a00;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(20,25,40,.07);
  --grid: rgba(0,0,0,.045);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17; --surface: #131a26; --surface-2: #0f1520; --ink: #eef2f8; --soft: #95a3b8; --line: rgba(255,255,255,.1);
    --blue: #4d84ff; --blue-soft: rgba(77,132,255,.16); --red: #ff5a5d; --green: #2ccf86; --amber: #f0b429;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35); --grid: rgba(255,255,255,.04);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f17; --surface: #131a26; --surface-2: #0f1520; --ink: #eef2f8; --soft: #95a3b8; --line: rgba(255,255,255,.1);
  --blue: #4d84ff; --blue-soft: rgba(77,132,255,.16); --red: #ff5a5d; --green: #2ccf86; --amber: #f0b429;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35); --grid: rgba(255,255,255,.04);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Inter Tight', 'Noto Sans Malayalam', system-ui, sans-serif; color: var(--ink); background: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 36px 36px; min-height: 100vh; -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2 { letter-spacing: -0.03em; margin: 0; }
.muted { color: var(--soft); } .small { font-size: 13px; }
.eyebrow { font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--soft); }
em { font-family: 'Yellowtail', cursive; font-style: normal; color: var(--blue); font-weight: 400; font-size: 1.25em; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 19px; letter-spacing: -0.03em; display: flex; align-items: center; gap: 8px; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 12px; }
.top-right { display: flex; gap: 8px; align-items: center; }
.who { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.who .email { display: none; }
@media (min-width: 720px) { .who .email { display: inline; color: var(--soft); } }

.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; min-width: 40px; height: 40px;
  display: grid; place-items: center; cursor: pointer; font-size: 22px; line-height: 1; color: var(--ink); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 11px 16px; font-weight: 700;
  cursor: pointer; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.accent { background: var(--blue); color: #fff; border-color: transparent; }
.btn.green { background: var(--green); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger-ghost { background: transparent; color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.btn.wide { width: 100%; margin-top: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.pill { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.pill.ok::before { content: "●"; color: var(--green); margin-right: 6px; }
.pill.bad::before { content: "●"; color: var(--red); margin-right: 6px; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 16px; box-shadow: var(--shadow); margin-top: 12px; }
#gate .card { text-align: center; padding: 32px 20px; margin-top: 40px; }
#gate h2 { font-size: 28px; margin: 8px 0; }

.week-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 6px; }
.week-title { text-align: center; } .week-title h1 { font-size: 26px; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 4px 0 12px; }
.days { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.day { display: grid; grid-template-columns: 58px 1fr; gap: 12px; align-items: stretch; }
.day-date { text-align: center; padding-top: 10px; }
.day-date .dow { font-family: 'JetBrains Mono', monospace; font-size: 11px; text-transform: uppercase; color: var(--soft); letter-spacing: .08em; }
.day-date .dnum { font-size: 26px; font-weight: 800; letter-spacing: -0.04em; }
.day.today .dnum { color: var(--blue); }
.day.past { opacity: .65; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow);
  cursor: pointer; text-align: left; width: 100%; display: flex; gap: 12px; align-items: center; min-height: 76px; }
.tile:hover { border-color: color-mix(in srgb, var(--blue) 40%, var(--line)); }
.tile .thumb { width: 44px; height: 78px; border-radius: 10px; background: var(--surface-2); flex-shrink: 0; object-fit: cover; border: 1px solid var(--line); }
.tile .body { flex: 1; min-width: 0; }
.tile .t { font-weight: 750; font-size: 16px; letter-spacing: -0.02em; line-height: 1.25; }
.tile .h { color: var(--soft); font-size: 13.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .meta { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.tile.empty { border-style: dashed; box-shadow: none; background: transparent; color: var(--soft); cursor: default; font-size: 14px; }
.hint { color: var(--soft); font-size: 14px; line-height: 1.5; margin: 22px 4px; }

.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.chip.draft { color: var(--soft); }
.chip.queued, .chip.rendering { color: var(--amber); }
.chip.review { color: var(--blue); }
.chip.scheduled, .chip.posting { color: var(--green); }
.chip.posted { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.chip.failed { color: var(--red); }

/* sheet */
.sheet { position: fixed; inset: 0; z-index: 10; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-inner { max-width: 760px; margin: 0 auto; padding: 0 16px; padding-top: env(safe-area-inset-top); }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; gap: 12px; align-items: center; padding: 12px 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.sheet-title { flex: 1; min-width: 0; }
.title-input { width: 100%; border: 0; background: transparent; font-size: 20px; font-weight: 800; letter-spacing: -0.03em; padding: 2px 0; outline: none; }
.sheet-foot { position: fixed; bottom: 0; left: 0; right: 0; z-index: 3; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: center; }
.sheet-foot .btn { flex: 1; max-width: 360px; }

.steps { list-style: none; display: flex; gap: 4px; padding: 0; margin: 14px 0 4px; }
.steps li { flex: 1; text-align: center; font-size: 11px; font-weight: 600; color: var(--soft); }
.steps li::before { content: ""; display: block; height: 4px; border-radius: 4px; background: var(--line); margin-bottom: 6px; }
.steps li.done::before { background: var(--blue); }
.steps li.now::before { background: linear-gradient(90deg, var(--blue), var(--blue-soft)); }
.steps li.now { color: var(--ink); }
.banner { border-radius: 14px; padding: 12px 14px; margin-top: 12px; font-size: 14px; line-height: 1.45; border: 1px solid var(--line); background: var(--surface); }
.banner.warn { border-color: color-mix(in srgb, var(--amber) 40%, transparent); background: color-mix(in srgb, var(--amber) 9%, var(--surface)); }
.banner.err { border-color: color-mix(in srgb, var(--red) 40%, transparent); background: color-mix(in srgb, var(--red) 8%, var(--surface)); }
.banner.ok { border-color: color-mix(in srgb, var(--green) 40%, transparent); background: color-mix(in srgb, var(--green) 8%, var(--surface)); }
.bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--blue); transition: width .5s; }

.video-wrap { margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.video-wrap video { width: min(100%, 360px); aspect-ratio: 9/16; border-radius: 22px; background: #000; box-shadow: var(--shadow); }
.video-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 26px 2px 4px; }
.section-head h2 { font-size: 20px; }
.beats { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.beat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px; box-shadow: var(--shadow); margin-top: 10px; }
.beat-top { display: flex; gap: 8px; align-items: center; }
.beat-num { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--blue); font-size: 13px; width: 26px; }
.beat-top select { flex: 1; min-width: 0; }
.beat-tools { display: flex; gap: 4px; }
.beat-tools button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px; width: 32px; height: 32px; cursor: pointer; font-size: 14px; }
.form label, .beat label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 700; color: var(--soft); margin-top: 10px; }
input, textarea, select { width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: 16px; outline: none; font-weight: 500; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.vo { font-family: 'Noto Sans Malayalam', 'Inter Tight', sans-serif; font-size: 16.5px; }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 10px; }
.kind-help { font-size: 12px; color: var(--soft); margin-top: 6px; line-height: 1.4; }
.log ul { padding-left: 18px; font-size: 13px; color: var(--soft); line-height: 1.6; }
.log summary, details summary { cursor: pointer; font-weight: 700; }
.howto { line-height: 1.6; font-size: 14.5px; padding-left: 20px; }
code { font-family: 'JetBrains Mono', monospace; font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

[hidden] { display: none !important; }
