
:root {
  --bg: #faf9f5; --surface: #ffffff; --surface2: #f4f2ec; --hover: #f0eee6;
  --line: #e8e5dc; --line2: #d9d5c9;
  --text: #1f1e1b; --muted: #6b6860; --dim: #a19d92;
  --working: #4a6fa5; --waiting: #d97757; --idle: #5b8a6b; --error: #b4423a; --stale: #b3ada0;
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  --shadow: 0 1px 2px rgba(31, 30, 27, .04), 0 1px 1px rgba(31, 30, 27, .02);
  --shadow-lg: 0 12px 40px rgba(31, 30, 27, .10), 0 2px 6px rgba(31, 30, 27, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 var(--sans); display: grid; grid-template-rows: auto auto 1fr auto; overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
code { font-family: var(--mono); font-size: .92em; }
kbd { font: 10px var(--mono); color: var(--dim); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 6px; background: var(--surface); }

/* ---------- header ---------- */
header { display: flex; align-items: center; gap: 20px; padding: 14px 28px; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--bg); z-index: 5; }
.brand { display: flex; align-items: baseline; gap: 10px; font: 500 22px var(--serif); letter-spacing: -.01em; }
.brand .dotsep { color: var(--waiting); }
.brand small { font: 400 12px var(--sans); color: var(--dim); }
.logo { width: 10px; height: 10px; border-radius: 50%; background: var(--waiting); align-self: center; }
.stats { display: flex; gap: 18px; flex-wrap: wrap; }
.stat { display: flex; align-items: baseline; gap: 6px; }
.stat b { font: 500 18px var(--serif); }
.stat span { color: var(--muted); font-size: 12px; }
.stat.hot b, .stat.hot span { color: var(--waiting); }
.spacer { flex: 1; }
.views { display: flex; padding: 3px; border-radius: 9px; background: var(--surface2); }
.views button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.views button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.pill { border: 1px solid var(--line2); background: var(--surface); padding: 6px 12px; border-radius: 8px; font-weight: 500; color: var(--muted); }
.pill:hover { color: var(--text); }
.pill.on { border-color: var(--waiting); color: var(--waiting); }
.clock { font: 12px var(--mono); color: var(--dim); min-width: 60px; text-align: right; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 28px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: var(--bg); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px 4px 10px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.chip:hover { border-color: var(--line2); color: var(--text); }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--pc); }
.chip b { font-weight: 500; color: var(--dim); font-size: 11px; }
.chip b.hot { color: var(--waiting); }
.chip.on { background: var(--text); color: #fff; border-color: var(--text); }
.chip.on b { color: #c9c5bb; }
.chip.add { border-style: dashed; color: var(--dim); }
.tlabel { font-size: 12px; color: var(--dim); }
.ptag { font: 500 10.5px var(--sans); color: var(--pc); background: color-mix(in srgb, var(--pc) 10%, white); padding: 1px 7px; border-radius: 999px; margin-right: 6px; }

/* ---------- main ---------- */
main { position: relative; overflow: hidden; min-height: 0; }
.view { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .3s; }
.view.on { opacity: 1; pointer-events: auto; }
#grid { overflow-y: auto; padding: 28px 28px 36px; }
.lane { margin-bottom: 32px; }
.lane-h { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; }
.lane-h .ttl { font: 500 19px var(--serif); }
.lane-h .host { font: 12px var(--sans); color: var(--dim); }
.lane-h .count { font: 12px var(--sans); color: var(--muted); }
.lane-h .rule { flex: 1; }
.mdot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; align-self: center; }
.needs .ttl { color: var(--waiting); }
.needs.quiet .ttl { color: var(--muted); }
.empty { color: var(--dim); display: none; font-size: 13px; }
.needs.quiet .empty { display: block; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }

/* ---------- card ---------- */
.card { --c: var(--working); position: relative; border-radius: 12px; padding: 16px 18px 14px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); cursor: pointer; transition: border-color .3s, box-shadow .3s, opacity .3s; animation: enter .5s cubic-bezier(.2, .8, .2, 1) both; overflow: hidden; }
.card:hover { box-shadow: var(--shadow-lg); border-color: var(--line2); }
.card.s-working { --c: var(--working); }
.card.s-working::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--working), transparent) no-repeat; background-size: 35% 100%; animation: slide 1.8s ease-in-out infinite; }
.card.s-waiting { --c: var(--waiting); border-color: color-mix(in srgb, var(--waiting) 55%, var(--line)); background: #fffaf7; }
.card.s-idle { --c: var(--idle); }
.card.s-error { --c: var(--error); border-color: color-mix(in srgb, var(--error) 50%, var(--line)); }
.card.s-stale { --c: var(--stale); opacity: .55; box-shadow: none; background: transparent; }
.card.ping { animation: ping .9s ease-out; }
.c-top { display: flex; align-items: center; gap: 8px; }
.tool { font: 500 10px var(--mono); padding: 2px 6px; border-radius: 5px; letter-spacing: .02em; border: 1px solid var(--line); color: var(--muted); background: var(--surface2); }
.tool.cc { color: #b4573a; border-color: #f0d9cf; background: #fbf1ec; }
.alias { font-weight: 600; font-size: 14px; }
.alias i { font-style: normal; color: var(--dim); font-weight: 400; }
.badge { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--c); white-space: nowrap; }
.badge .sd { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.s-working .badge .sd, .s-waiting .badge .sd { animation: blink 1.6s ease-in-out infinite; }
.c-repo { margin-top: 4px; font: 11.5px var(--mono); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-repo b { color: var(--muted); font-weight: 400; }
.c-repo .dirty { color: var(--waiting); }
.c-goal { margin: -8px 0 14px; font: italic 13.5px/1.35 var(--serif); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.c-goal .gl, .d-goal .gl { font: normal 500 10.5px var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--dim); margin-right: 7px; }
.c-goal .miss, .d-goal .miss { color: var(--waiting); font-style: normal; font-size: 12px; }
.c-goal.done .gl { color: var(--idle); }
.d-goal { margin-top: 8px; font: italic 15px/1.35 var(--serif); color: var(--muted); }
.c-task { margin: 12px 0 14px; font: 400 17px/1.3 var(--serif); min-height: 44px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.c-strip { display: flex; gap: 3px; height: 20px; overflow: hidden; justify-content: flex-end;
  -webkit-mask: linear-gradient(90deg, transparent, #000 35%); mask: linear-gradient(90deg, transparent, #000 35%); }
.ti { flex: none; width: 18px; height: 18px; border-radius: 4px; display: grid; place-items: center; font-size: 10px; font-family: var(--mono);
  background: color-mix(in srgb, var(--tc) 10%, white); color: var(--tc); animation: tin .4s cubic-bezier(.2, .9, .3, 1.2); }
.c-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--dim); font: 11px var(--sans); }
.spark { width: 110px; height: 20px; }
.c-foot .meta { margin-left: auto; white-space: nowrap; }
.unread { background: var(--text); color: #fff; font: 500 10px var(--sans); border-radius: 999px; padding: 1px 7px; animation: pop .3s; }
.c-action { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.s-waiting .c-action { display: flex; align-items: center; gap: 8px; }
.c-action code { flex: 1; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn { border: 1px solid var(--line2); background: var(--surface); border-radius: 7px; padding: 5px 11px; font-weight: 500; font-size: 12px; }
.btn:hover { background: var(--hover); }
.btn.ok { background: var(--text); border-color: var(--text); color: #fff; }
.btn.go { background: var(--text); border-color: var(--text); color: #fff; }
.btn.ok:hover, .btn.go:hover { background: #3a3833; }

#overlay { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 8; }

/* ---------- graph ---------- */
#graph canvas { width: 100%; height: 100%; display: block; }

/* ---------- plan ---------- */
#plan { overflow-y: auto; padding: 28px 28px 40px; }
.pj { margin-bottom: 44px; }
.pj-h { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pj-h h2 { margin: 0; font: 500 26px var(--serif); letter-spacing: -.01em; }
.pj-h .desc { color: var(--dim); }
.pj-h .pct { margin-left: auto; color: var(--muted); }
.pj-h .pct b { font: 500 20px var(--serif); color: var(--text); margin-right: 4px; }
.pbar { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--surface2); margin: 12px 0 20px; }
.pbar i { display: block; height: 100%; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.pbar .d { background: var(--text); } .pbar .w { background: var(--working); } .pbar .n { background: var(--waiting); }
.pj .pbar { margin: 12px 0 8px; }
.ovh { display: grid; grid-template-columns: 200px minmax(0, 1.2fr) minmax(0, 1fr) 110px; gap: 28px; padding: 12px 22px; border-bottom: 1px solid var(--line); font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.ovr-name .nm { display: flex; align-items: baseline; gap: 9px; font: 500 19px var(--serif); }
.hl { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 999px; }
.hl.ok { color: var(--idle); background: color-mix(in srgb, var(--idle) 12%, white); }
.hl.need, .hl.risk { color: var(--waiting); background: color-mix(in srgb, var(--waiting) 12%, white); }
.hl.late { color: var(--error); background: color-mix(in srgb, var(--error) 10%, white); }
.hl.idle { color: var(--muted); background: var(--surface2); }
.pj-h .hl { margin: 0; align-self: center; }
.o-ms { font: 500 16px var(--serif); } .mono { font-family: var(--mono); font-size: .8em; color: var(--dim); }
.o-goal { font: italic 14px/1.35 var(--serif); color: var(--muted); margin-top: 2px; }
.o-bar .pbar { margin: 10px 0 5px; height: 5px; }
.o-foot { font-size: 12px; color: var(--muted); } .o-foot b { color: var(--text); }
.o-now { font-size: 13px; line-height: 1.4; display: flex; flex-direction: column; gap: 5px; }
.o-now div { display: flex; align-items: baseline; gap: 8px; }
.o-now .sd { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--c); transform: translateY(-1px); }
.o-now .more { color: var(--dim); font-size: 12px; }
.o-left { font-size: 13px; color: var(--muted); } .o-left b { font: 500 22px var(--serif); color: var(--text); } .o-left span { font-size: 12px; color: var(--dim); }
.pgoal { font: italic 16px var(--serif); color: var(--muted); margin-top: 6px; }
h3.sec { font: 500 20px var(--serif); margin: 34px 0 12px; display: flex; align-items: baseline; gap: 10px; }
h3.sec span { font: 13px var(--sans); color: var(--dim); }
h3.sec em { font: normal 12px var(--sans); color: var(--dim); margin-left: auto; }
.fold-h { cursor: pointer; }
.now { display: grid; grid-template-columns: 22px minmax(0, 1fr) 240px; gap: 14px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin-bottom: 8px; box-shadow: var(--shadow); }
.now.link { cursor: pointer; } .now.link:hover { box-shadow: var(--shadow-lg); }
.now.need { border-color: color-mix(in srgb, var(--waiting) 50%, var(--line)); background: #fffaf7; }
.now .ring { margin-top: 3px; }
.now-t { font: 400 17px/1.3 var(--serif); }
.now-g { font: italic 13.5px/1.35 var(--serif); color: var(--muted); margin-top: 3px; }
.now-a { font: 11px var(--mono); color: var(--dim); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-r { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.now-r .prog { width: 170px; white-space: nowrap; }
.left-ms { margin-bottom: 14px; }
.left-h { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.left-h .g-due { margin-left: auto; font-size: 12px; color: var(--dim); }
.left-t { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--surface2); font: 15px var(--serif); }
.left-t.done { color: var(--muted); } .left-t .mono { margin-left: auto; }
.empty-l { color: var(--dim); padding: 6px 4px; }
.ov { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.ovr { display: grid; grid-template-columns: 200px minmax(0, 1.2fr) minmax(0, 1fr) 110px; gap: 28px; gap: 24px; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); cursor: pointer; }
.ovr:last-child { border-bottom: 0; }
.ovr:hover { background: var(--bg); }
.ovr-name { padding-top: 0; }
.ovr-name b { display: block; font: 500 18px var(--serif); }
.ovr-name small { color: var(--dim); font-size: 12px; }
.road { display: flex; gap: 6px; }
.seg { min-width: 0; }
.seg .pbar { margin: 0 0 6px; height: 8px; border-radius: 4px; }
.seg-l { font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg-l span { font-family: var(--mono); font-size: 10.5px; }
.seg.cur .seg-l { color: var(--text); }
.ovr { align-items: start; }
.ovr-main .road { margin-top: 14px; }
.goal .g-lbl { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.goal .mono { font-family: var(--mono); text-transform: none; letter-spacing: 0; }
.goal .g-name { font: 500 19px var(--serif); margin-top: 2px; }
.goal .g-goal { font: italic 400 15px/1.35 var(--serif); color: var(--muted); margin-top: 2px; }
.goal .g-bar .pbar { margin: 10px 0 6px; height: 6px; }
.goal .g-foot { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.goal .g-foot b { color: var(--text); font-weight: 600; }
.g-due { color: var(--muted); } .g-due.soon { color: var(--waiting); } .g-due.late { color: var(--error); font-weight: 500; }
.goal.big { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px 26px; box-shadow: var(--shadow); margin: 18px 0 8px; }
.goal.big .g-name { font-size: 30px; letter-spacing: -.01em; }
.goal.big .g-goal { font-size: 18px; margin-top: 4px; }
.goal.big .g-bar .pbar { height: 8px; margin: 16px 0 10px; }
.goal.big .g-foot { font-size: 13px; }
.msl-goal { padding: 8px 4px 4px; font: italic 14px var(--serif); color: var(--muted); }
.msl-goal .g-due { font: 12px var(--sans); }
.mdone .msl-goal { display: none; }
.ovr-st { font-size: 12.5px; color: var(--muted); line-height: 1.5; padding-top: 20px; text-align: right; }
.needtxt { color: var(--waiting); }
.pj-tag { display: inline-flex; align-items: center; gap: 6px; font: 12px var(--sans); color: var(--dim); margin-right: 10px; }
.pj-tag .mdot { width: 6px; height: 6px; }
.fold { border: 0; background: none; color: var(--dim); font-size: 12px; padding: 8px 4px 0 52px; }
.fold:hover { color: var(--text); }
.mdone .msl-h { border-bottom-color: transparent; }
.mdone .msl-h .nm { color: var(--muted); }
.msl { margin-top: 26px; }
.msl-h { display: flex; align-items: baseline; gap: 10px; padding: 0 4px 8px; border-bottom: 1px solid var(--line); }
.msl-h .k { font: 11px var(--mono); color: var(--dim); }
.msl-h .nm { font: 500 17px var(--serif); }
.msl-h .st { font-size: 12px; color: var(--muted); }
.msl-h .st.done { color: var(--idle); } .msl-h .st.doing { color: var(--working); }
.msl-h .mini { margin-left: auto; width: 120px; }
.msl-h .mini .pbar { margin: 0; height: 4px; }
.msl-h .cnt { font-size: 12px; color: var(--dim); min-width: 64px; text-align: right; }
.row { display: grid; grid-template-columns: 22px 34px minmax(0, 1fr) 150px 220px; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--surface2); }
.row.link { cursor: pointer; } .row.link:hover { background: var(--surface); }
.row.need { background: #fffaf7; }
.row .id { font: 11px var(--mono); color: var(--dim); }
.row .nm { font: 400 15px/1.3 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.done .nm { color: var(--muted); }
.row .act { display: block; font: 11px var(--mono); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.row .act.need { color: var(--waiting); }
.row .prog { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--dim); }
.row .prog .pbar { flex: 1; margin: 0; height: 4px; }
.row .who { margin: 0; justify-content: flex-end; }
.ring { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line2); position: relative; }
.ring.doing { border-color: var(--working); background: conic-gradient(var(--working) calc(var(--p) * 1%), transparent 0); box-shadow: inset 0 0 0 2px #fff; }
.ring.need { border-color: var(--waiting); background: conic-gradient(var(--waiting) calc(var(--p) * 1%), transparent 0); box-shadow: inset 0 0 0 2px #fff; }
.ring.done { border-color: var(--text); background: var(--text); }
.ring.done::after { content: ''; position: absolute; left: 4.5px; top: 1.5px; width: 3.5px; height: 7px; border: solid #fff; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.subrow { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0 4px 10px 84px; margin-top: -4px; border-bottom: 1px solid var(--surface2); font-size: 12px; color: var(--muted); }
.subrow span { display: inline-flex; align-items: center; gap: 6px; }
.subrow span::before { content: ''; width: 9px; height: 9px; border-radius: 3px; border: 1.3px solid var(--line2); }
.subrow span.ok { color: var(--dim); text-decoration: line-through; text-decoration-color: var(--line2); }
.subrow span.ok::before { background: var(--text); border-color: var(--text); }
.subrow span.now { color: var(--text); }
.subrow span.now::before { border-color: var(--working); }
.subs { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12.5px; }
.subs li { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: var(--muted); }
.subs li::before { content: ''; flex: none; width: 11px; height: 11px; border-radius: 3px; border: 1.3px solid var(--line2); }
.subs li.ok { color: var(--dim); }
.subs li.ok::before { background: var(--text); border-color: var(--text); box-shadow: inset 0 0 0 2px #fff; }
.subs li.now { color: var(--text); }
.subs li.now::before { border-color: var(--working); }
.task { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.t-ms { font: 10.5px var(--mono); color: var(--dim); }
.t-name { font: 400 15px/1.3 var(--serif); margin: 4px 0 0; }
.who { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.who .sd { width: 6px; height: 6px; border-radius: 50%; background: var(--c); flex: none; }
.who.live .sd { animation: blink 1.6s ease-in-out infinite; }
.t-src { margin-top: 18px; font-size: 12px; color: var(--dim); }
.c-plan { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.c-plan .k { font: 10.5px var(--mono); color: var(--dim); }
.c-plan .nm { overflow: hidden; text-overflow: ellipsis; }
.c-plan .pp { margin-left: auto; display: flex; gap: 2px; flex: none; }
.c-plan .pp i { width: 10px; height: 4px; border-radius: 2px; background: var(--line); }
.c-plan .pp i.ok { background: var(--text); }
@media (max-width: 900px) { .ovr { grid-template-columns: 1fr; gap: 12px; } .ovh { display: none; } .now { grid-template-columns: 22px 1fr; } .now-r { grid-column: 2; align-items: flex-start; } .row { grid-template-columns: 22px minmax(0, 1fr) 90px; } .row .id, .row .who { display: none; } .subrow { padding-left: 38px; } }
.glegend { position: absolute; left: 28px; bottom: 18px; display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.glegend span { display: flex; align-items: center; gap: 6px; }
.glegend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.glegend .dash { width: 16px; height: 0; border-top: 1.5px dashed var(--error); border-radius: 0; }

/* ---------- timeline ---------- */
footer { border-top: 1px solid var(--line); background: var(--surface); z-index: 5; }
.tl-h { display: flex; align-items: baseline; gap: 18px; padding: 12px 28px 4px; }
.tl-h .ttl { font: 500 15px var(--serif); }
.tl-h .lg { display: flex; gap: 14px; color: var(--muted); font-size: 11.5px; flex-wrap: wrap; }
.tl-h .lg span { display: flex; align-items: center; gap: 5px; }
.tl-h .lg i { width: 12px; height: 7px; border-radius: 2px; display: inline-block; }
.tl-h button { margin-left: auto; border: 0; background: none; color: var(--dim); font-size: 12px; }
#tlc { display: block; width: 100%; height: 190px; transition: height .3s; }
footer.collapsed #tlc { height: 0; }

/* ---------- drawer ---------- */
#drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); z-index: 20; background: var(--surface); border-left: 1px solid var(--line);
  transform: translateX(105%); transition: transform .4s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(31, 30, 27, .08); }
#drawer.open { transform: none; }
.d-head { padding: 24px 26px 18px; border-bottom: 1px solid var(--line); position: relative; }
.d-close { position: absolute; top: 18px; right: 18px; border: 0; background: none; width: 28px; height: 28px; border-radius: 6px; color: var(--dim); }
.d-close:hover { background: var(--hover); color: var(--text); }
.d-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.d-sub { font: 11.5px var(--mono); color: var(--dim); margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.d-task { margin-top: 14px; font: 400 22px/1.25 var(--serif); }
.d-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.d-body { flex: 1; overflow-y: auto; padding: 4px 26px 24px; }
.d-sec { margin-top: 22px; }
.d-sec h4 { margin: 0 0 10px; font: 500 15px var(--serif); }
.ev { display: grid; grid-template-columns: 58px 20px 1fr; gap: 10px; align-items: center; padding: 5px 0; font-size: 12px; border-bottom: 1px solid var(--surface2); animation: fadein .3s; }
.ev time { font: 10.5px var(--mono); color: var(--dim); }
.ev .ti { animation: none; }
.ev .tx { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 11.5px var(--mono); color: var(--muted); }
.ev .tx b { font-weight: 500; }
.files { display: flex; flex-wrap: wrap; gap: 6px; }
.files span { font: 11px var(--mono); padding: 3px 8px; border-radius: 5px; background: var(--surface2); color: var(--muted); }
.files span.conf { background: #fbecea; color: var(--error); }
.chat { display: flex; flex-direction: column; gap: 10px; }
.bub { max-width: 90%; padding: 9px 12px; border-radius: 12px; font-size: 13px; animation: fadein .3s; }
.bub small { display: block; font: 10.5px var(--sans); color: var(--dim); margin-bottom: 3px; }
.bub.in { background: var(--surface2); align-self: flex-start; border-bottom-left-radius: 4px; }
.bub.out { background: #eef2f8; align-self: flex-end; border-bottom-right-radius: 4px; }
.bub .via { color: var(--idle); }
.d-send { display: flex; gap: 8px; padding: 14px 26px; border-top: 1px solid var(--line); }
.d-send input { flex: 1; background: var(--bg); border: 1px solid var(--line2); border-radius: 9px; padding: 9px 12px; color: var(--text); font: inherit; outline: none; }
.d-send input:focus { border-color: var(--text); background: var(--surface); }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 24px; bottom: 236px; display: flex; flex-direction: column; gap: 8px; z-index: 30; pointer-events: none; }
.toast { --tc: var(--working); padding: 11px 14px 11px 30px; border-radius: 10px; max-width: 360px; font-size: 13px; position: relative;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: tslide .4s cubic-bezier(.2, .8, .2, 1); }
.toast::before { content: ''; position: absolute; left: 13px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--tc); }
.toast b { font-weight: 600; }
.toast code { color: var(--muted); }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .3s; }

@keyframes slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 35%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
@keyframes blink { 50% { opacity: .3; } }
@keyframes tin { from { opacity: 0; transform: translateX(12px); } }
@keyframes pop { from { transform: scale(.5); } }
@keyframes fadein { from { opacity: 0; } }
@keyframes tslide { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1500px) { .clock, .brand small { display: none; } }
@media (max-width: 720px) {
  header { padding: 12px 16px; gap: 12px; }
  .brand small, .clock, kbd { display: none; }
  #grid { padding: 18px 16px 24px; }
  .cards { grid-template-columns: 1fr; }
  #tlc { height: 150px; }
  #toasts { right: 16px; left: 16px; bottom: 190px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation-duration: .01s !important; animation-iteration-count: 1 !important; } }

/* ---------- live-app ---------- */
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--stale); }
.conn.on i { background: var(--idle); }
.conn.off { color: var(--error); } .conn.off i { background: var(--error); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.c-action .hint { flex: none; font-size: 11.5px; color: var(--muted); }
.card.s-ended { opacity: .45; box-shadow: none; background: transparent; }
.blank { max-width: 560px; margin: 12vh auto; text-align: center; color: var(--muted); }
.blank h2 { font: 500 28px var(--serif); color: var(--text); margin: 0 0 10px; }
.blank code { background: var(--surface2); padding: 2px 6px; border-radius: 5px; }
.d-msg { margin-top: 12px; padding: 10px 12px; border-left: 2px solid var(--line2); background: var(--bg); font-size: 12.5px; color: var(--muted); white-space: pre-wrap; max-height: 180px; overflow: auto; }
.d-pending { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: #fffaf7; border: 1px solid color-mix(in srgb, var(--waiting) 45%, var(--line)); font-size: 12.5px; }
.d-pending code { color: var(--waiting); }

.c-action .btns { display: flex; gap: 6px; flex: none; }
.c-action .hint:empty { display: none; }
.btn:disabled { opacity: .5; cursor: default; }
.d-pending .d-actions { margin-top: 10px; }
.d-send input:disabled { background: var(--surface2); }
.s-waiting .c-action { flex-wrap: wrap; }
.c-action code { flex-basis: 100%; margin-bottom: 2px; }
.c-action .btns { margin-left: auto; }

/* ---------- spørsmål og planer ---------- */
.d-interact h4 { font: 500 17px var(--serif); margin: 4px 0 12px; }
.qform .q { border: 0; padding: 0; margin: 0 0 18px; }
.qform legend { font: 400 16px/1.35 var(--serif); margin-bottom: 8px; padding: 0; }
.qform legend small { display: block; font: 12px var(--sans); color: var(--dim); margin-top: 2px; }
.qh { display: inline-block; font: 500 10.5px var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface2); border-radius: 4px; padding: 1px 6px; margin-right: 8px; vertical-align: 2px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; cursor: pointer; background: var(--surface); }
.opt:hover { border-color: var(--line2); }
.opt:has(input:checked) { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.opt input[type=radio], .opt input[type=checkbox] { margin-top: 2px; accent-color: var(--text); }
.opt span { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.opt b { font-weight: 500; }
.opt em { font-style: normal; color: var(--muted); font-size: 12.5px; }
.opt .otext { margin-top: 6px; border: 1px solid var(--line2); border-radius: 7px; padding: 6px 9px; font: inherit; background: var(--bg); }
.qactions { display: flex; justify-content: flex-end; }
.muted { color: var(--dim); font-size: 12.5px; }
.plan-md { border: 1px solid var(--line); border-radius: 10px; padding: 4px 16px; background: var(--bg); max-height: 320px; overflow: auto; font-size: 13px; }
.plan-md h3, .plan-md h4, .plan-md h5 { font: 500 15px var(--serif); margin: 12px 0 4px; }
.plan-md p, .plan-md li { margin: 4px 0; color: var(--muted); }
.plan-md ul, .plan-md ol { padding-left: 18px; }
.menu-box { margin-top: 12px; }
.menu { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.mopt { display: flex; flex-direction: column; gap: 6px; }
.mopt .btn { text-align: left; padding: 8px 12px; }
.mopt input { border: 1px solid var(--line2); border-radius: 7px; padding: 7px 10px; font: inherit; }
details summary { cursor: pointer; font-size: 12px; color: var(--dim); }
pre.term { font: 11px/1.35 var(--mono); background: #1f1e1b; color: #e8e5dc; border-radius: 8px; padding: 10px 12px; max-height: 280px; overflow: auto; white-space: pre-wrap; }
.btn.refresh { margin-top: 8px; font-size: 11.5px; color: var(--muted); }

/* ---------- skjemaer (ask_form) ---------- */
.ff-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--waiting); }
.fform .ff-title { font: 500 22px/1.25 var(--serif); margin: 2px 0 10px; }
.ff-desc { margin-bottom: 16px; max-height: 220px; }
.fform legend small, .fform .hint { display: block; font: 12px var(--sans); color: var(--dim); margin-top: 2px; }
.fform .hint { margin: -4px 0 8px; }
.rec { font: normal 500 10px var(--sans); color: var(--idle); background: color-mix(in srgb, var(--idle) 12%, white); border-radius: 999px; padding: 1px 7px; margin-left: 8px; vertical-align: 1px; }
.rank { list-style: none; padding: 0; margin: 0; counter-reset: r; }
.rank li { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; background: var(--surface); counter-increment: r; }
.rank li::before { content: counter(r); font: 500 15px var(--serif); color: var(--dim); width: 18px; text-align: center; }
.rank li span { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rank li b { font-weight: 500; } .rank li em { font-style: normal; color: var(--muted); font-size: 12.5px; }
.rank .btn { padding: 2px 8px; }
.scale { display: flex; gap: 6px; flex-wrap: wrap; }
.scale label { flex: 1; min-width: 38px; }
.scale input { position: absolute; opacity: 0; pointer-events: none; }
.scale span { display: block; text-align: center; padding: 9px 0; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; background: var(--surface); font-weight: 500; }
.scale input:checked + span { background: var(--text); color: #fff; border-color: var(--text); }
.scale-l { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--dim); margin-top: 5px; }
.yn label { flex: 0 0 90px; }
.numrow { display: flex; align-items: center; gap: 8px; }
.fform input[type=text]:not(.otext), .fform input[type=number], .fform textarea { width: 100%; border: 1px solid var(--line2); border-radius: 9px; padding: 9px 11px; font: inherit; background: var(--surface); }
.numrow input { max-width: 180px; }
.ff-comment { display: block; font-size: 13px; color: var(--muted); margin: 6px 0 14px; }
.ff-comment textarea { margin-top: 6px; }
.qactions { gap: 8px; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.form-card .c-task { margin-bottom: 6px; }
