:root {
  --bg: #f4f5f8; --panel: #ffffff; --ink: #1d2030; --muted: #6b7184; --line: #e3e5ec;
  --side: #1f2333; --side-ink: #c9cde0; --side-hi: #ffffff; --accent: #5b5bd6; --accent-2: #ecebff;
  --rec: #e6a100; --rec-bg: #fff4d6; --edit: #2f80ed; --edit-bg: #e3efff; --done: #1f9d55; --done-bg: #ddf5e6;
  --bad: #d64545; --bad-bg: #fde8e8; --radius: 12px; --shadow: 0 1px 2px rgba(20,25,50,.06), 0 4px 14px rgba(20,25,50,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { padding: 60px; text-align: center; color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 18px; padding: 4px 10px 16px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #7b6cff, #ff8ab3); display: grid; place-items: center; font-size: 17px; }
.nav { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--side-ink); text-decoration: none; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; }
.nav:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav.on { background: rgba(123,108,255,.22); color: #fff; font-weight: 600; }
.nav .ic { width: 22px; text-align: center; font-size: 17px; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7d84a3; padding: 14px 12px 4px; }
.me { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.me b { color: #fff; display: block; }
.me .row { display: flex; gap: 8px; margin-top: 8px; }
.me button { background: rgba(255,255,255,.08); border: 0; color: var(--side-ink); padding: 5px 9px; border-radius: 7px; cursor: pointer; font-size: 12px; }
.me button:hover { color: #fff; }
.main { padding: 26px 30px 60px; min-width: 0; }
.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.top h1 { margin: 0; font-size: 24px; }
.top .sub { color: var(--muted); font-size: 14px; }
.top .grow { flex: 1; }
.mobile-bar { display: none; }

/* ---------- pieces ---------- */
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h2 { margin: 0 0 12px; font-size: 16px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 16px 18px; }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.btn { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #c9ccd8; background: #fafbff; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4a4ac4; }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=url], select, textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.f { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
label.f > span { display: block; margin-bottom: 5px; }
label.f .hint { font-weight: 400; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 14px; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.err { background: var(--bad-bg); color: #8f2323; padding: 10px 14px; border-radius: 9px; font-size: 14px; margin-bottom: 12px; }
.note { background: var(--accent-2); color: #3a3a8c; padding: 10px 14px; border-radius: 9px; font-size: 14px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #eef0f5; color: #3d4256; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.st { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.st-rec { background: var(--rec-bg); color: #8a6100; }
.st-edit { background: var(--edit-bg); color: #1d5fb8; }
.st-done { background: var(--done-bg); color: #16703d; }
.mine { box-shadow: inset 3px 0 0 var(--accent); }
.badge-me { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-2); padding: 1px 7px; border-radius: 99px; }
.role { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: #eef0f5; }
.role-owner { background: #fff1c9; color: #7d5a00; }
.role-manager { background: #e6e3ff; color: #4537b8; }
.role-editor { background: #e3efff; color: #1d5fb8; }
.role-voice_actor { background: #ffe6f0; color: #a3285e; }
.role-thumbnail { background: #ddf5e6; color: #16703d; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }

/* ---------- channel chips ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 11px; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 14%, #fff); }
.chip.off { opacity: .55; }
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; background: #e9ebf1; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cal .dow { background: #fafbfd; font-size: 12px; font-weight: 700; color: var(--muted); padding: 8px; text-transform: uppercase; }
.cal .day { background: #fff; min-height: 116px; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.cal .day.other { background: #fafbfd; }
.cal .day.other .num { color: #b2b6c4; }
.cal .day.today { background: #fbfaff; }
.cal .day.today .num { background: var(--accent); color: #fff; }
.cal .num { font-size: 12px; font-weight: 700; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.ev { display: flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 6px; border-radius: 6px; background: color-mix(in srgb, var(--c) 13%, #fff); border-left: 3px solid var(--c); cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border-top: 0; border-right: 0; border-bottom: 0; text-align: left; width: 100%; }
.ev:hover { background: color-mix(in srgb, var(--c) 24%, #fff); }
.ev .t { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.ev .s { flex: none; font-size: 11px; }
.ev.me { outline: 2px solid var(--accent); outline-offset: -1px; }
.more { font-size: 12px; color: var(--muted); background: none; border: 0; cursor: pointer; text-align: left; padding: 2px 6px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 12px; }
.weekstrip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.wday { background: #fff; border-radius: 10px; padding: 8px; min-height: 120px; border: 1px solid var(--line); }
.wday.today { border-color: var(--accent); }
.wday h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; display: flex; justify-content: space-between; }
.wday h4 b { color: var(--ink); }
.agenda .aday { margin-bottom: 16px; }
.agenda h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); }

/* ---------- board / video cards ---------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.col { background: #eceef3; border-radius: var(--radius); padding: 10px; }
.col h3 { margin: 4px 6px 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.col h3 .n { color: var(--muted); font-weight: 600; }
.vc { background: #fff; border-radius: 10px; padding: 11px 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.05); cursor: pointer; border-left: 4px solid var(--c, #ccc); display: block; width: 100%; text-align: left; border-top: 0; border-right: 0; border-bottom: 0; }
.vc:hover { box-shadow: 0 2px 8px rgba(0,0,0,.09); }
.vc .tt { font-weight: 600; font-size: 14px; margin-bottom: 6px; word-break: break-word; }
.vc .meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); align-items: center; }
.jobs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.job { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: #f2f3f7; display: inline-flex; gap: 4px; align-items: center; }
.job.ok { background: var(--done-bg); color: #16703d; }
.job.wait { background: var(--rec-bg); color: #8a6100; }
.job.me { outline: 1.5px solid var(--accent); }

/* ---------- discord board ---------- */
.dc { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; border-top: 4px solid var(--c, #ccc); }
.dc .tt { font-weight: 700; margin-bottom: 4px; }
.prog { height: 8px; border-radius: 99px; background: #eceef3; overflow: hidden; margin: 8px 0; }
.prog > i { display: block; height: 100%; background: var(--done); border-radius: 99px; }
.people { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.person { font-size: 13px; padding: 3px 9px; border-radius: 99px; background: #f2f3f7; }
.person.ok { background: var(--done-bg); }
.person.late { background: var(--bad-bg); }

/* ---------- drawer / modal / toast ---------- */
.drawer-bg, .modal-bg { position: fixed; inset: 0; background: rgba(15,18,30,.35); z-index: 40; }
.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(480px, 100vw); background: #fff; z-index: 41; overflow-y: auto; padding: 22px; box-shadow: -10px 0 40px rgba(0,0,0,.15); }
.drawer h2 { margin: 0 0 4px; font-size: 19px; word-break: break-word; }
.x { position: absolute; right: 14px; top: 14px; border: 0; background: #f0f1f5; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 16px; }
.modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow-y: auto; background: #fff; border-radius: 16px; z-index: 41; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { margin: 0 0 14px; font-size: 19px; }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 10px 12px; font-size: 14px; margin: 16px 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1d2030; color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 60; font-size: 14px; max-width: calc(100vw - 30px); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 18px; background: #f4f5f8; padding: 12px; border-radius: 9px; text-align: center; letter-spacing: .03em; user-select: all; }

/* ---------- scripts ---------- */
.script { max-width: 760px; }
.script .blk { margin: 4px 0; }
.script .scene { font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-size: 13px; margin-top: 18px; }
.script .line { display: grid; grid-template-columns: 150px 1fr; gap: 10px; padding: 6px 10px; border-radius: 8px; }
.script .line:nth-child(odd) { background: #fafbfd; }
.script .who { font-weight: 700; color: var(--c, var(--ink)); }
.script .dir { font-style: italic; color: var(--muted); padding: 4px 10px; }
.script .line.mineline { background: #f1efff; }
.sd-frame { width: 100%; height: calc(100vh - 150px); border: 0; border-radius: var(--radius); box-shadow: var(--shadow); background: #16171b; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #1f2333 0%, #3b3570 100%); }
.login .card { width: min(400px, 100%); padding: 28px; }
.login h1 { margin: 0 0 4px; font-size: 24px; }
.login .logo { width: 48px; height: 48px; border-radius: 13px; background: linear-gradient(135deg, #7b6cff, #ff8ab3); display: grid; place-items: center; font-size: 24px; margin-bottom: 14px; }

/* ---------- guide ---------- */
.flow { display: flex; gap: 0; align-items: stretch; flex-wrap: wrap; }
.step { flex: 1 1 120px; background: #fff; border-radius: 12px; padding: 14px; text-align: center; box-shadow: var(--shadow); position: relative; margin: 6px 14px 6px 0; }
.step .e { font-size: 28px; }
.step b { display: block; margin: 6px 0 2px; }
.step .who { font-size: 12px; color: var(--muted); }
.step:not(:last-child)::after { content: "→"; position: absolute; right: -14px; top: 50%; transform: translateY(-50%); color: #9aa0b4; font-weight: 700; }
.perm-grid td, .perm-grid th { text-align: center; }
.perm-grid td:first-child, .perm-grid th:first-child { text-align: left; }
.bar { height: 10px; border-radius: 99px; background: var(--c); }
.swatch { width: 22px; height: 22px; border-radius: 6px; display: inline-block; vertical-align: middle; }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 50; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 10px 0 40px rgba(0,0,0,.3); }
  .mobile-bar { display: flex; align-items: center; gap: 10px; background: var(--side); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 30; }
  .mobile-bar button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
  .main { padding: 16px 14px 60px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr; }
  .cal .day { min-height: 70px; }
  .cal .ev .t { display: none; }
  .weekstrip { grid-template-columns: 1fr; }
  .script .line { grid-template-columns: 1fr; gap: 2px; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dt { margin-top: 8px; }
}
