/* ======================================================================
   Studia —— 自习桌
   纸色底、墨色字；靛蓝是"工作中的墨水"，朱砂是"老师的红笔"，
   青瓷是完成，藤黄是"等你操作"。夜读只换颜色，不改布局。
   ====================================================================== */
:root {
  --paper:   #f7f4ec;
  --paper-2: #efebe1;
  --card:    #fffdf8;
  --well:    #f1ede3;
  --ink:     30 27 22;
  --text:    rgb(var(--ink));
  --text-2:  rgb(var(--ink) / .72);
  --text-3:  rgb(var(--ink) / .50);
  --text-4:  rgb(var(--ink) / .34);
  --line:    rgb(var(--ink) / .09);
  --line-2:  rgb(var(--ink) / .16);
  --hover:   rgb(var(--ink) / .045);

  --indigo:       #2e4b8c;
  --indigo-soft:  rgb(46 75 140 / .10);
  --seal:         #bf3f29;
  --seal-soft:    rgb(191 63 41 / .10);
  --celadon:      #3b7a69;
  --celadon-soft: rgb(59 122 105 / .14);
  --gamboge:      #b47f0f;
  --gamboge-soft: rgb(180 127 15 / .14);

  --mooc: #2c8c86; --zhs: #4a8a3a; --zyk: #8a5a2c;

  --sans:  -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono:  "SF Mono", ui-monospace, Menlo, Consolas, "PingFang SC", monospace;

  --ease: cubic-bezier(.32, .72, 0, 1);
  --shadow-pop: 0 0 0 1px rgb(var(--ink) / .06), 0 18px 48px rgb(40 30 10 / .16);
  color-scheme: light;
}
:root[data-theme="night"] {
  --paper:   #191815;
  --paper-2: #14130f;
  --card:    #201e1a;
  --well:    #1d1b17;
  --ink:     236 230 216;
  --indigo:       #8ea7e6;
  --indigo-soft:  rgb(142 167 230 / .14);
  --seal:         #e56a4f;
  --seal-soft:    rgb(229 106 79 / .14);
  --celadon:      #74bba6;
  --celadon-soft: rgb(116 187 166 / .16);
  --gamboge:      #e0ae45;
  --gamboge-soft: rgb(224 174 69 / .16);
  --shadow-pop: 0 0 0 1px rgb(255 255 255 / .06), 0 18px 48px rgb(0 0 0 / .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.5 var(--sans); color: var(--text); background: var(--paper); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { appearance: none; border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: default; text-align: inherit; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; border-radius: 6px; }
svg { display: block; flex: none; }
code { font: 12px var(--mono); padding: 1px 5px; border-radius: 4px; background: var(--well); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.grow { flex: 1; }

.app { display: grid; grid-template-columns: 236px 1fr; height: 100%; }

/* ---------------------------------------------------------------- sidebar */
.side { display: flex; flex-direction: column; min-height: 0; background: var(--paper-2); border-right: 1px solid var(--line); }
.side_top { position: relative; padding: 18px 14px 10px; }
.brand { display: flex; align-items: center; gap: 9px; padding: 0 6px; height: 28px; }
.seal { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; background: var(--seal); color: #fff;
        font: italic 600 14px/1 var(--serif); box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / .25); transform: rotate(-4deg); }
.brand b { font: 600 18px/1 var(--serif); letter-spacing: .01em; }
.icon_btn { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; color: var(--text-3); transition: background .15s, color .15s; }
.icon_btn:hover { background: var(--hover); color: var(--text); }

.switch { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 14px; padding: 8px 10px; border-radius: 10px;
          background: var(--card); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgb(var(--ink) / .04); transition: box-shadow .2s; }
.switch:hover, .switch[aria-expanded="true"] { box-shadow: 0 0 0 1px var(--line-2), 0 2px 6px rgb(var(--ink) / .06); }
.plat { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 7px; color: #fff; font-weight: 600; font-size: 12px; }
.plat.mooc { background: var(--mooc); } .plat.zhs { background: var(--zhs); } .plat.zyk { background: var(--zyk); }
.who { flex: 1; min-width: 0; line-height: 1.25; }
.who b { display: block; font-size: 13.5px; }
.who small { color: var(--text-3); font-size: 11.5px; }
.switch .chev { color: var(--text-4); }

.menu { position: absolute; left: 14px; right: 14px; top: calc(100% - 4px); z-index: 30; padding: 5px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow-pop); animation: rise .18s var(--ease) both; }
.menu_row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: 8px; }
.menu_row:hover { background: var(--hover); }
.menu_row .plat { width: 24px; height: 24px; font-size: 11px; }
.menu_row .tick { color: var(--indigo); }

.nav { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 14px; }
.nav_item { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 10px; border-radius: 8px; color: var(--text-2); transition: background .12s, color .12s; }
.nav_item:hover { background: var(--hover); color: var(--text); }
.nav_item[aria-current="true"] { background: var(--card); color: var(--text); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgb(var(--ink) / .05); }
.nav_item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav_item .count { font: 11.5px var(--mono); color: var(--text-4); }
.nav_item.quiet { color: var(--text-4); }
.nav_label { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 6px; padding: 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--text-4); }
.live { display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px 1px 6px; border-radius: 99px; background: var(--indigo-soft); color: var(--indigo); font-size: 11px; font-weight: 600; white-space: nowrap; }
.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: breathe 1.6s ease-in-out infinite; }
.live.waiting { background: var(--gamboge-soft); color: var(--gamboge); }
.live.waiting::before { animation: none; }
@keyframes breathe { 50% { opacity: .25; transform: scale(.8); } }
.ring { width: 16px; height: 16px; flex: none; }

.side_foot { display: flex; align-items: center; gap: 6px; padding: 10px 14px 14px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; height: 32px; padding: 0 8px; border-radius: 8px; color: var(--text-2); }
.me:hover { background: var(--hover); }
.avatar { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--indigo-soft); color: var(--indigo); font-size: 11px; font-weight: 700; }
.avatar.big { width: 28px; height: 28px; font-size: 13px; }

.kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--line-2), inset 0 -1px 0 var(--line-2);
       font: 500 10.5px/1 var(--mono); color: var(--text-3); }

/* ---------------------------------------------------------------- main */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: clip; }
.scroll { flex: 1; overflow-y: auto; }
.page { max-width: 860px; margin: 0 auto; padding: 44px 56px 120px; }
.page.enter > * { animation: rise .45s var(--ease) both; }
.page.enter > *:nth-child(2) { animation-delay: .03s; } .page.enter > *:nth-child(3) { animation-delay: .06s; }
.page.enter > *:nth-child(4) { animation-delay: .09s; } .page.enter > *:nth-child(n+5) { animation-delay: .12s; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.crumb { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-3); }
.crumb .dot { width: 7px; height: 7px; border-radius: 50%; }
.dot.mooc { background: var(--mooc); } .dot.zhs { background: var(--zhs); } .dot.zyk { background: var(--zyk); }
.title { margin: 10px 0 0; font-size: 26px; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
.sub { margin: 6px 0 0; color: var(--text-3); font-size: 13px; }
.empty { margin-top: 40px; padding: 28px; border-radius: 12px; text-align: center; color: var(--text-3); box-shadow: inset 0 0 0 1px var(--line); }
.notice { margin-top: 18px; padding: 14px 16px; border-radius: 12px; background: var(--gamboge-soft); color: var(--text-2); line-height: 1.7; }

/* Ledger: the course at a glance */
.ledger { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; margin: 26px 0 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.ledger > div { padding: 14px 18px 16px; }
.ledger > div + div { border-left: 1px solid var(--line); }
.ledger dt { font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--text-4); }
.ledger dd { margin: 6px 0 0; display: flex; align-items: baseline; gap: 8px; }
.big { font: 400 34px/1 var(--serif); letter-spacing: -.01em; font-variant-numeric: lining-nums tabular-nums; }
.big small { font-size: 18px; color: var(--text-3); }
.big.red { color: var(--seal); }
.ledger .note { font-size: 12px; color: var(--text-3); }

.tabs { display: flex; gap: 4px; margin-top: 28px; padding: 3px; width: max-content; border-radius: 10px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); }
.tab { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 14px; border-radius: 7px; color: var(--text-3); font-weight: 500; transition: background .15s, color .15s, box-shadow .15s; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: 0 0 0 1px var(--line), 0 1px 3px rgb(var(--ink) / .08); }
.tab .n { font: 11px var(--mono); color: var(--text-4); }

.section { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 30px 0 12px; }
.section h3 { margin: 0; font-size: 14px; font-weight: 600; }
.section .aside { font-size: 12px; color: var(--text-3); }
.link { color: var(--indigo); font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- course grid */
.grid { padding: 16px 18px 14px; border-radius: 12px; background: var(--card); box-shadow: 0 0 0 1px var(--line); }
.grid.loading { color: var(--text-3); text-align: center; padding: 26px; }
.chapter { display: grid; grid-template-columns: 112px 1fr auto; align-items: center; gap: 12px; padding: 5px 0; }
.chapter + .chapter { border-top: 1px dashed var(--line); }
.chapter .name { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter .tally { font: 11px var(--mono); color: var(--text-4); }
.cells { display: flex; flex-wrap: wrap; gap: 4px; }
.cell { display: block; width: 14px; height: 14px; border-radius: 3px; background: rgb(var(--ink) / .07); position: relative; transition: background .4s var(--ease), box-shadow .4s; }
.cell.queued { background: repeating-linear-gradient(135deg, rgb(var(--ink) / .10) 0 2px, rgb(var(--ink) / .03) 2px 4px); }
.cell.done { background: var(--celadon); }
.cell.running { background: repeating-linear-gradient(135deg, var(--indigo) 0 3px, color-mix(in srgb, var(--indigo) 65%, transparent) 3px 6px); background-size: 8.5px 8.5px; animation: flow .9s linear infinite; box-shadow: 0 0 0 3px var(--indigo-soft); }
.cell.waiting { background: linear-gradient(135deg, var(--gamboge) 50%, var(--gamboge-soft) 50%); }
.cell.failed { background: var(--card); box-shadow: inset 0 0 0 1.5px var(--seal); }
.cell.failed::after { content: ""; position: absolute; inset: 3px; background: linear-gradient(45deg, transparent 43%, var(--seal) 43% 57%, transparent 57%), linear-gradient(-45deg, transparent 43%, var(--seal) 43% 57%, transparent 57%); }
.cell.skipped { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); }
@keyframes flow { to { background-position: 8.5px 0; } }
.cells .cell:hover { outline: 2px solid var(--text-3); outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .cell { width: 10px; height: 10px; border-radius: 2px; }
.legend b { font: 500 12px var(--mono); color: var(--text-2); }

.tip { position: fixed; z-index: 50; padding: 7px 10px; border-radius: 8px; background: rgb(var(--ink)); color: var(--paper); font-size: 12px; line-height: 1.45; pointer-events: none;
       opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; max-width: 260px; }
.tip.show { opacity: 1; transform: none; }
.tip .mono { opacity: .7; }

/* ---------------------------------------------------------------- actions */
.acts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px; }
.act { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px 16px 14px; border-radius: 12px; background: var(--card); box-shadow: 0 0 0 1px var(--line);
       text-align: left; transition: box-shadow .2s, transform .2s var(--ease); }
.act:hover { box-shadow: 0 0 0 1px var(--line-2), 0 6px 18px rgb(40 30 10 / .07); transform: translateY(-1px); }
.act_head { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.glyph { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--indigo-soft); color: var(--indigo); }
.act p { margin: 0; color: var(--text-2); font-size: 12.5px; line-height: 1.6; }
.act .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--text-3); }
.act[disabled] { opacity: .55; transform: none; box-shadow: 0 0 0 1px var(--line); }

.btn { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 8px; background: var(--card); box-shadow: 0 0 0 1px var(--line-2), inset 0 -1px 0 var(--line);
       font-weight: 500; color: var(--text); transition: background .15s, box-shadow .15s; white-space: nowrap; }
.btn:hover { background: var(--well); }
.btn.primary { background: var(--indigo); color: #fff; box-shadow: inset 0 -1.5px 0 rgb(0 0 0 / .22), 0 1px 2px rgb(var(--ink) / .15); }
.btn.primary:hover { background: color-mix(in srgb, var(--indigo) 88%, black); }
:root[data-theme="night"] .btn.primary { color: #12131a; }
.btn.primary .kbd { color: rgb(255 255 255 / .75); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .3); }
.btn.danger { color: var(--seal); }
.btn.armed { background: var(--seal); color: #fff; box-shadow: none; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.small { height: 26px; font-size: 12px; }

/* ---------------------------------------------------------------- papers */
.papers { border-radius: 12px; background: var(--card); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.paper { display: grid; grid-template-columns: 20px 28px 1fr auto 64px; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 8px 16px; text-align: left; transition: background .12s; }
.paper + .paper { border-top: 1px solid var(--line); }
.paper:hover { background: var(--hover); }
.paper.on { background: var(--indigo-soft); }
.paper.off { color: var(--text-3); }
.paper.none { display: block; color: var(--text-4); }
.box { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 5px; box-shadow: inset 0 0 0 1.5px var(--line-2); transition: background .15s, box-shadow .15s; }
.paper.on .box { background: var(--indigo); box-shadow: none; color: #fff; }
:root[data-theme="night"] .paper.on .box { color: #12131a; }
.paper.off .box { box-shadow: inset 0 0 0 1.5px var(--line); background-image: repeating-linear-gradient(135deg, var(--line) 0 1px, transparent 1px 4px); }
.stamp { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; box-shadow: inset 0 0 0 1.5px currentColor; font-size: 12px; font-weight: 700; transform: rotate(-3deg); color: var(--indigo); }
.stamp.k { color: var(--seal); } .stamp.c { color: var(--celadon); }
.paper .pname { min-width: 0; }
.paper .pname b { font-weight: 500; }
.paper .pname small { display: block; margin-top: 1px; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 500; background: var(--well); color: var(--text-3); white-space: nowrap; vertical-align: 1px; }
.pill.blue { background: var(--indigo-soft); color: var(--indigo); }
.pill.wait { background: var(--gamboge-soft); color: var(--gamboge); }
.pill.red { background: var(--seal-soft); color: var(--seal); }
.score { justify-self: end; position: relative; font: 400 22px/1 var(--serif); color: var(--seal); font-variant-numeric: lining-nums tabular-nums; }
.score::after { content: ""; position: absolute; left: -4px; right: -2px; bottom: -5px; height: 6px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 6' preserveAspectRatio='none'%3E%3Cpath d='M1 4.5C14 2.2 30 1.6 59 2.8' fill='none' stroke='%23bf3f29' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / 100% 100%; opacity: .75; }
.score.none { color: var(--text-4); font-size: 14px; } .score.none::after { display: none; }

.dock { position: sticky; bottom: 16px; z-index: 5; display: flex; align-items: center; gap: 10px; margin-top: 18px; padding: 10px 10px 10px 16px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow-pop); }
.dock .info { flex: 1; color: var(--text-2); }
.dock .info b { font: 500 13px var(--mono); color: var(--text); }

/* ---------------------------------------------------------------- now studying (player) */
.player { position: relative; z-index: 25; display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1.3fr) auto; align-items: center; gap: 20px; height: 68px; padding: 0 18px;
          border-top: 1px solid var(--line); background: color-mix(in srgb, var(--card) 86%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.player[hidden] { display: none; }
.player.enter { animation: slide .5s var(--ease) both; }
@keyframes slide { from { transform: translateY(100%); } }
.player.ended { grid-template-columns: 1fr auto; }
.np { display: flex; align-items: center; gap: 12px; min-width: 0; }
.np .art { position: relative; display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 9px; background: var(--indigo); color: #fff; overflow: hidden; }
.np .art::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, rgb(255 255 255 / .12) 0 4px, transparent 4px 9px); animation: flow2 1.6s linear infinite; background-size: 12.7px 12.7px; }
.np .art.waiting { background: var(--gamboge); } .np .art.waiting::after, .np .art.still::after { display: none; }
.np .art.still { background: var(--well); color: var(--text-3); box-shadow: inset 0 0 0 1px var(--line); }
@keyframes flow2 { to { background-position: 12.7px 0; } }
.np .what { min-width: 0; line-height: 1.3; }
.np .what small { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; }
.np .what b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; }
.scrub { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; min-width: 0; }
.scrub .t { font: 12px var(--mono); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.track { position: relative; height: 4px; border-radius: 4px; background: var(--line-2); }
.track i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--indigo); transition: width .9s linear; }
.track i::after { content: ""; position: absolute; right: -5px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--card); box-shadow: 0 0 0 2px var(--indigo), 0 1px 3px rgb(0 0 0 / .2); }
.track.unknown i { width: 30% !important; animation: sweep 1.4s var(--ease) infinite; }
.track.unknown i::after { display: none; }
@keyframes sweep { from { left: -30%; } to { left: 100%; } }
.np_meta { display: flex; align-items: center; gap: 8px; }
.mini { display: flex; gap: 2px; }
.mini .cell { width: 6px; height: 14px; border-radius: 2px; }
.mini .cell.running { box-shadow: none; }

/* Focus sheet */
.sheet { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--paper); transform: translateY(102%); visibility: hidden; transition: transform .55s var(--ease), visibility 0s .55s; }
.sheet.open { transform: none; visibility: visible; transition: transform .55s var(--ease), visibility 0s; }
.sheet_bar { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.sheet_body { flex: 1; overflow-y: auto; }
.focus { max-width: 960px; margin: 0 auto; padding: 36px 56px 60px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; }
.focus .clock { font: 400 72px/1 var(--serif); letter-spacing: -.02em; font-variant-numeric: lining-nums tabular-nums; }
.focus .clock small { font-size: 16px; font-family: var(--sans); letter-spacing: 0; color: var(--text-4); margin-left: 8px; }
.focus .now { margin-top: 12px; font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.focus .of { margin-top: 4px; color: var(--text-3); overflow-wrap: anywhere; }
.focus .track { height: 6px; margin: 22px 0 8px; }
.focus .ticks { display: flex; justify-content: space-between; font: 11px var(--mono); color: var(--text-4); }
.log { align-self: start; border-radius: 12px; background: var(--card); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.log_head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.log_head .grow { font-weight: 600; }
.chip { height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; color: var(--text-3); }
.chip[aria-pressed="true"] { background: var(--well); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.log_body { max-height: 420px; overflow-y: auto; padding: 6px 0; font: 11.5px/18px var(--mono); }
.line { display: grid; grid-template-columns: 40px 34px 1fr; gap: 8px; padding: 2px 12px; color: var(--text-2); }
.line time { color: var(--text-4); }
.line .lv { color: var(--text-4); }
.line.warn .lv { color: var(--gamboge); } .line.err .lv { color: var(--seal); } .line.ok .lv { color: var(--celadon); }
.line .msg { font-family: var(--sans); font-size: 12px; overflow-wrap: anywhere; }
.line.none { display: block; color: var(--text-4); }

/* ---------------------------------------------------------------- runs */
.runs { border-radius: 12px; background: var(--card); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.run { display: grid; grid-template-columns: 20px 1fr auto auto 84px; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 8px 16px; text-align: left; }
.runs > * + * { border-top: 1px solid var(--line); }
.run:hover { background: var(--hover); }
.run .t1 { min-width: 0; font-weight: 500; }
.run .t1 small { display: block; font-weight: 400; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run .when { font: 12px var(--mono); color: var(--text-3); text-align: right; }
.state { display: inline-flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.state .mono { font-weight: 400; color: var(--text-3); }
.state.done { color: var(--celadon); } .state.error { color: var(--seal); } .state.waiting { color: var(--gamboge); } .state.stopped { color: var(--text-3); }
.state.running, .state.queued { color: var(--indigo); }
.run .fix { display: flex; gap: 6px; }
.run_lines { padding: 4px 0 8px; background: var(--well); }
.run_lines[hidden] { display: none; }

/* ---------------------------------------------------------------- settings, admin, forms */
.models { border-radius: 12px; background: var(--card); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.model { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 14px; padding: 12px 16px; }
.models > * + * { border-top: 1px solid var(--line); }
.model.plain { grid-template-columns: 1fr auto; }
.radio { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-2); transition: box-shadow .2s var(--ease); }
.radio:hover { box-shadow: inset 0 0 0 1.5px var(--indigo); }
.model.on .radio { box-shadow: inset 0 0 0 5px var(--indigo); }
.m1 { min-width: 0; }
.m1 b { font-weight: 500; }
.m1 .pill { margin-left: 6px; }
.m1 small { display: block; font: 11.5px var(--mono); color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m1 small.sans { font-family: var(--sans); font-size: 12px; }
.row_btns { display: flex; gap: 6px; }
.health { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.health::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-4); }
.health.ok { color: var(--celadon); } .health.ok::before { background: var(--celadon); }
.health.error { color: var(--seal); } .health.error::before { background: var(--seal); }
.health.busy::before { animation: breathe 1s ease-in-out infinite; background: var(--indigo); }
.hint { margin: -4px 0 10px; font-size: 12.5px; color: var(--text-3); }

.form_card { padding: 16px 18px 14px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow-pop); margin: 4px 0 12px; }
.models .form_card { margin: 0; border-radius: 0; box-shadow: inset 3px 0 0 var(--indigo); }
.form_card h3 { margin: 0 0 10px; font-size: 14px; }
.field { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 10px; margin: 8px 0; }
.field label { color: var(--text-3); }
.field input { height: 32px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line-2); font-size: 13px; transition: box-shadow .15s; }
.field input:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--indigo), 0 0 0 3px var(--indigo-soft); }
.field input[type="number"] { width: 90px; font-family: var(--mono); }
.form_btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* Platform login */
.login_card { display: flex; gap: 26px; align-items: center; margin-top: 26px; padding: 22px; border-radius: 14px; background: var(--card); box-shadow: 0 0 0 1px var(--line); }
.qr { position: relative; flex: none; width: 176px; height: 176px; padding: 8px; border-radius: 12px; background: #fff; box-shadow: 0 0 0 1px var(--line-2); }
.qr img { width: 100%; height: 100%; display: block; }
.qr .qr_empty { display: grid; place-items: center; height: 100%; color: #888; font-size: 12px; }
.login_status b { display: block; margin-bottom: 6px; font-size: 15px; }
.login_status p { margin: 0 0 14px; color: var(--text-2); line-height: 1.7; }

/* Studia sign-in (hosted) */
body.signed-out .app { display: none; }
.auth { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: var(--paper-2); }
.auth_card { width: 380px; max-width: 100%; padding: 30px 28px 24px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow-pop); }
.auth_card .brand { padding: 0; margin-bottom: 4px; }
.auth_card .brand b { font-size: 24px; }
.auth_card .tabs { margin: 18px 0 14px; }
.auth_card .field { grid-template-columns: 64px 1fr; }
.auth_error { min-height: 18px; margin: 6px 0 8px; font-size: 12.5px; color: var(--seal); }
.auth_submit { width: 100%; justify-content: center; height: 36px; }
.auth_note { margin: 14px 0 0; text-align: center; font-size: 12px; color: var(--text-4); }

/* ---------------------------------------------------------------- palette */
.palette_wrap { position: fixed; inset: 0; z-index: 40; display: none; align-items: flex-start; justify-content: center; padding: 16vh 16px 0; background: rgb(var(--ink) / .12); backdrop-filter: blur(2px); }
.palette_wrap.open { display: flex; }
.palette { width: 520px; max-width: 100%; border-radius: 14px; background: var(--card); box-shadow: var(--shadow-pop); overflow: hidden; animation: rise .2s var(--ease) both; }
.palette input { width: 100%; height: 52px; padding: 0 18px; border: 0; border-bottom: 1px solid var(--line); background: none; outline: none; font-size: 16px; }
.palette .rows { max-height: 50vh; overflow-y: auto; padding: 6px; }
.prow { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border-radius: 8px; }
.prow > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow[aria-selected="true"] { background: var(--indigo-soft); }
.prow .meta { margin-left: auto; font-size: 12px; color: var(--text-4); white-space: nowrap; }
.prow .stamp { width: 18px; height: 18px; font-size: 10px; border-radius: 4px; }
.prow .dot { width: 8px; height: 8px; margin: 0 4px; border-radius: 50%; }
.psep { height: 1px; margin: 4px 8px; background: var(--line); }

.toast { position: fixed; left: 50%; bottom: 96px; z-index: 60; transform: translate(-50%, 10px); max-width: calc(100% - 32px); padding: 9px 14px; border-radius: 10px; background: rgb(var(--ink)); color: var(--paper); font-size: 12.5px; opacity: 0; pointer-events: none; transition: .25s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .nav, .side_foot { display: none; }
  .side_top { padding: 10px 16px; }
  .page { padding: 24px 16px 120px; }
  .ledger { grid-template-columns: 1fr 1fr; } .ledger > div:nth-child(3) { border-left: 0; } .ledger > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .acts { grid-template-columns: 1fr; } .focus { grid-template-columns: 1fr; padding: 24px 16px; }
  .chapter { grid-template-columns: 1fr auto; } .chapter .cells { grid-column: 1 / -1; grid-row: 2; }
  .player { grid-template-columns: 1fr auto; } .scrub, .mini { display: none; }
  .paper { grid-template-columns: 20px 1fr 48px; } .paper .stamp, .paper > span:nth-child(4) { display: none; }
  .run { grid-template-columns: 20px 1fr auto; } .run .fix, .run .when { display: none; }
  .model { grid-template-columns: auto 1fr; } .model .health, .model .row_btns { grid-column: 2; }
  .login_card { flex-direction: column; align-items: flex-start; }
}
