:root {
  --bg: #0f1113; --header: #121417; --panel: #16191c; --panel-2: #121417; --raised: #1c2024;
  --line: #2a2f35; --line-2: #3a4047; --line-3: #4a5058;
  --text: #ecebe4; --card-text: #d8d6d0; --muted: #a3a8ae; --soft: #bfc3c8;
  --accent: #f2a93b; --accent-ink: #15120c; --accent-bg: #1e1a12; --accent-line: #4a3b22;
  --ok: #7fd99a; --ok-bg: #20352a; --ok-line: #355a3f;
  --link: #78b8ff; --info-bg: #26303a; --info-line: #2f4a66;
  --bad: #ff8a7a; --bad-bg: #1a1516; --bad-line: #5a2e2a;
  --mono: ui-monospace, "SF Mono", "IBM Plex Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
  accent-color: var(--accent);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 40px; line-height: 1.1; margin: 0 0 8px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 10px 24px; background: var(--header); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 19px; letter-spacing: -0.02em; min-height: 44px; }
.brand svg { color: var(--accent); }
.title { display: flex; flex-direction: column; line-height: 1.25; padding-left: 20px; border-left: 1px solid var(--line); min-width: 0; }
.title span:first-child { font-weight: 600; }
.title .mono { font-size: 12px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; color: var(--ok); border: 1px solid var(--ok-line); border-radius: 999px; padding: 4px 10px; }
.expiry { color: var(--muted); }
.expiry.soon { color: var(--accent); }

/* controls */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line-2); background: transparent; color: var(--text); font: inherit; text-decoration: none; cursor: pointer; }
button:hover, .button:hover { border-color: var(--line-3); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary:hover { border-color: var(--accent); filter: brightness(1.05); }
.cta { min-height: 52px; border-radius: 10px; font-size: 16px; padding: 0 22px; }
.small { min-height: 32px; padding: 0 12px; border-radius: 6px; font-size: 13px; }
.danger { color: var(--bad); border-color: var(--bad-line); }
button:disabled, .button[aria-disabled=true] { cursor: not-allowed; background: var(--line-2); border-color: var(--line-2); color: #8a9096; filter: none; }
textarea, input[type=text], input[type=number] { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; font: inherit; min-height: 44px; }
textarea:focus, input:focus { border-color: var(--accent); outline: none; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; font-weight: 600; }
.chip { display: inline-flex; align-items: center; font-family: var(--mono); font-size: 12px; padding: 4px 8px; border-radius: 6px; background: var(--raised); border: 1px solid var(--line); color: var(--soft); }
.chip.type { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; border-color: var(--info-line); background: transparent; color: var(--link); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.error { color: var(--bad); }
.error:empty { display: none; }

/* page layouts */
main { max-width: 1160px; margin: 0 auto; padding: 32px 24px; }
main.wide { max-width: none; padding: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.dead-end { max-width: 560px; margin: 48px auto; }
.dead-end h1 { font-size: 28px; }

/* new session */
.layout { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; }
.layout > form { flex: 999 1 520px; }
.layout > aside { flex: 1 1 360px; }
.lede { color: var(--muted); margin: 0 0 24px; font-size: 16px; }
.options { display: flex; flex-wrap: wrap; gap: 8px; }
.option { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 8px; cursor: pointer; }
.option input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.option:has(input:checked) { border: 2px solid var(--accent); background: var(--accent-bg); padding: 0 13px; }
.option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.option:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }
.option .ext { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.mode { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.mode .option { flex-direction: column; align-items: flex-start; justify-content: center; padding: 12px 16px; gap: 2px; }
.mode .option:has(input:checked) { padding: 11px 15px; }
.mode .option span:last-child { font-size: 13px; color: var(--muted); }
.size { display: flex; align-items: center; gap: 8px; max-width: 200px; }
.eyebrow { font-family: var(--mono); font-size: 12px; color: var(--ok); letter-spacing: 0.04em; }
.invite-row { display: flex; flex-direction: column; gap: 6px; }
.invite-row .head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.invite { display: flex; gap: 8px; align-items: center; }
.invite code, .invite input { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; color: var(--soft); font-family: var(--mono); font-size: 12px; min-height: 40px; }

/* live session */
.session { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 65px); }
.rail { border-right: 1px solid var(--line); padding: 24px; display: flex; flex-direction: column; gap: 28px; }
.rail h2 { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.rail .stack { gap: 10px; }
.rail p { margin: 0; font-size: 13px; }
.rail details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.main-col { display: flex; flex-direction: column; min-width: 0; }
.timeline { flex: 1; display: flex; flex-direction: column; gap: 20px; padding: 24px 32px 32px; }
.pill { align-self: center; font-family: var(--mono); font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; text-align: center; }
.empty { align-self: center; color: var(--muted); margin: 24px 0; text-align: center; }
.timeline:has(.item) .empty { display: none; }
.banner.approval { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; font-weight: 600; }
.banner { margin: 16px 32px 0; border: 1px solid var(--accent-line); background: var(--accent-bg); color: var(--text); border-radius: 10px; padding: 12px 14px; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.people li { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.people .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-3); }
.people .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .sub { font-size: 12px; color: var(--muted); }
.people .key { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.you { font-size: 11px; color: var(--accent); margin-left: 6px; }

.item { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: start; }
.avatar { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 12px; font-weight: 500; background: var(--raised); color: var(--soft); }
.av-sender { background: var(--info-bg); color: var(--link); }
.av-owner { background: var(--accent-bg); color: var(--accent); }
.av-runner { background: var(--ok-bg); color: var(--ok); }
.item .body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; font-size: 13px; }
.meta strong { font-size: 14px; font-weight: 600; }
.meta .when { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.meta .verified { color: var(--ok); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; max-width: 720px; color: var(--card-text); overflow: hidden; }
.card > p { margin: 0; padding: 12px 16px; white-space: pre-wrap; word-break: break-word; }
.item.mine .card { border-color: var(--accent-line); }
.file-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 14px; }
.file-head .jobid { font-size: 12px; }
.file-head .fname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.file-head .size { font-size: 13px; color: var(--muted); white-space: nowrap; }
.file-head .small { margin-left: auto; }
.card pre { margin: 0; white-space: pre-wrap; word-break: break-word; border-top: 1px solid var(--line); background: var(--panel-2); padding: 12px 16px; max-height: 420px; overflow: auto; color: var(--text); }
.card img { display: block; max-width: 100%; max-height: 360px; border-top: 1px solid var(--line); }
.ziplist { list-style: none; margin: 0; padding: 6px 0; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 13px; color: var(--soft); max-height: 320px; overflow: auto; }
.ziplist li { display: flex; justify-content: space-between; gap: 16px; padding: 6px 14px; }
.ziplist li span:last-child { color: var(--muted); white-space: nowrap; }
.zipnote { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.card .note { padding: 12px 16px; margin: 0; color: var(--muted); font-size: 14px; }
.item.evicted .card { border-style: dashed; border-color: var(--line-3); background: transparent; }
.item.rejected .card { border-color: var(--bad-line); background: var(--bad-bg); }
.item.rejected .card p { color: var(--bad); }
.item.rejected .detail { padding: 0 16px 12px; font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-word; }

html { scroll-padding-bottom: var(--composer-h, 0px); }
.item { scroll-margin-bottom: var(--composer-h, 0px); }
.composer-wrap { max-height: 70vh; overflow-y: auto; position: sticky; bottom: 0; padding: 12px 32px 20px; background: linear-gradient(to bottom, transparent, var(--bg) 24px); }
.composer { background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { border: 0; background: transparent; resize: none; padding: 14px 16px; min-height: 0; }
.composer textarea:focus { border: 0; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; flex-wrap: wrap; }
.icon-btn { width: 44px; padding: 0; }
.pending-file { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; color: var(--soft); max-width: 260px; }
.pending-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar .hint { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.status { margin: 8px 4px 0; font-size: 13px; color: var(--bad); }
.status:empty { display: none; }
.readonly { margin: 0 32px 20px; }

/* execute mode */
.limits { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.field label { font-size: 14px; }
.hint-text { font-size: 12px; }
select { width: 100%; min-height: 44px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; font: inherit; }
select:focus { border-color: var(--accent); outline: none; }
.option.check { min-height: 36px; padding: 0 10px; border-color: var(--line); gap: 8px; }
.option.check input[type=checkbox], .option.check input[type=radio] { position: static; opacity: 1; pointer-events: auto; }
.invite-row + .hint-text code, p code { word-break: break-all; }

.jobpanel { padding: 12px 16px 4px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.jobrow { display: flex; flex-wrap: wrap; gap: 10px; }
.jobrow { flex-wrap: wrap; align-items: flex-end; }
.jobrow .field { flex: 1 1 140px; min-width: 0; gap: 4px; }
.jobrow .field.narrow { flex: 0 0 110px; }
.inputfiles summary { cursor: pointer; min-height: 36px; display: flex; align-items: center; font-size: 13px; color: var(--muted); }
.pickfiles { padding-bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.jobpanel legend { font-size: 13px; margin-bottom: 6px; color: var(--muted); font-weight: 500; }
.toolbar button[aria-pressed=true] { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

.state { font-family: var(--mono); font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--info-line); color: var(--link); overflow-wrap: anywhere; min-width: 0; }
.state.good { color: var(--ok); border-color: var(--ok-line); }
.state.bad { color: var(--bad); border-color: var(--bad-line); }
.file-head .state { margin-left: auto; }
.file-head .state + .small { margin-left: 0; }
.jobmeta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 14px; margin: 0; padding: 4px 14px 10px; font-size: 13px; }
.jobmeta dt { color: var(--muted); }
.jobmeta dd { margin: 0; word-break: break-word; }
.codebox summary { cursor: pointer; padding: 8px 14px; border-top: 1px solid var(--line); color: var(--soft); font-size: 13px; min-height: 36px; }
.result { border-top: 1px solid var(--line-2); }
.result-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 14px; background: var(--panel-2); }
.logblock .logname, .outfiles .logname { display: flex; gap: 8px; align-items: center; padding: 8px 14px 0; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.logblock pre { border-top: 0; max-height: 240px; }
.outfile { margin: 8px 14px 10px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.outfile .file-head { padding: 8px 12px; }
.outfile .small.link { margin: 8px 12px; align-self: flex-start; }
.card .note.error, .item.rejected .card .note { color: var(--bad); }
.item.evline { display: block; }
.item.evline .pill { display: block; align-self: auto; }
.item.evline.rejected .pill { color: var(--bad); border-color: var(--bad-line); }

.runners { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.runner { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.runner.is-rejected { opacity: 0.6; }
.rhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rhead .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.rhead .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-3); flex: none; }
.rhead .dot.on { background: var(--ok); }
.rhead .dot.wait { background: var(--accent); }
.runner .sub { font-size: 12px; color: var(--muted); word-break: break-word; }
.chip.good { color: var(--ok); border-color: var(--ok-line); }
.chip.bad { color: var(--bad); border-color: var(--bad-line); }
.chip.wait { color: var(--accent); border-color: var(--accent-line); }
.chip.warn { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 600; }

@media (max-width: 820px) {
  .session { grid-template-columns: 1fr; }
  .rail { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .timeline { padding: 20px 16px; }
  .composer-wrap { padding: 10px 16px 16px; }
  .banner { margin: 12px 16px 0; }
  .readonly { margin: 0 16px 16px; }
  .title { display: none !important; }
}
@media (max-width: 480px) {
  main { padding: 24px 16px; }
  .top { padding: 8px 16px; }
  h1 { font-size: 32px; }
  .toolbar .hint { display: none; }
}

@media (max-width: 600px) {
  .small { min-height: 44px; padding: 0 14px; }
  .option.check { min-height: 44px; }
  .option input[type=checkbox], .option input[type=radio] { width: 22px; height: 22px; }
  .codebox summary, .inputfiles summary { min-height: 44px; display: flex; align-items: center; }
  .job-head .state { order: 9; flex: 1 1 100%; border-radius: 8px; }
  .jobmeta { grid-template-columns: 1fr; }
  .jobmeta dd { margin-bottom: 6px; }
  .banner.approval { margin: 12px 16px 0; }
}
