:root {
  color-scheme: light;
  --paper: #f7f3e8;
  --card: #fffdf7;
  --rule: #cfe3d6;
  --margin: #d9534f;
  --ink: #1f2a37;
  --ink-2: #4b5563;
  --muted: #7a8190;
  --line: #e4ddca;
  --green: #2f7d5b;
  --red: #b42318;
  --amber: #a8670a;
  --term: #12171d;
  --term-2: #1a2129;
  --term-fg: #dce3ea;
  --t-dim: #7d8a98;
  --t-ok: #7ee2a8;
  --t-err: #ff8a80;
  --t-warn: #f6c177;
  --t-acc: #8bd5f0;
  --serif: "Newsreader", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Menlo, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #15130f; --card: #1d1a15; --rule: #26342c; --ink: #efe9dc; --ink-2: #c8c0b0; --muted: #958c7c; --line: #322d25; --green: #7ed0a2; --red: #ff8f80; --amber: #f2b25a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --paper: #15130f; --card: #1d1a15; --rule: #26342c; --ink: #efe9dc; --ink-2: #c8c0b0; --muted: #958c7c; --line: #322d25; --green: #7ed0a2; --red: #ff8f80; --amber: #f2b25a;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { display: flex; flex-direction: column; margin: 0; background: repeating-linear-gradient(var(--paper) 0 31px, var(--rule) 31px 32px); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { padding: 0; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--margin); outline-offset: 2px; }

.bar { display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 0 22px; background: var(--paper); border-bottom: 1px solid var(--line); }
.logo { display: inline-flex; align-items: center; gap: 10px; font: 600 22px/1 var(--serif); letter-spacing: -0.01em; text-decoration: none; }
.logo svg { width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 0 0 1px var(--line); }
.tag { color: var(--muted); font-size: 14px; }
.spacer { flex: 1; }
.ghost { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; font-weight: 600; text-decoration: none; }
.ghost:hover { border-color: var(--ink); }

.layout { display: grid; flex: 1; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; min-height: 0; padding: 18px 22px 22px; border-left: 2px solid var(--margin); margin-left: 34px; }
.term { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: var(--term); border-radius: 14px; box-shadow: 0 24px 60px rgba(18, 23, 29, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.04) inset; color: var(--term-fg); }
.term-bar { display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; background: var(--term-2); border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #3a434e; }
.term-bar i:nth-child(1) { background: #ff6159; } .term-bar i:nth-child(2) { background: #ffbd2e; } .term-bar i:nth-child(3) { background: #28c941; }
.term-bar span { margin-left: 10px; color: var(--t-dim); font: 500 12.5px var(--mono); }
.screen { flex: 1; min-height: 0; overflow: auto; padding: 14px 16px 18px; font: 13.5px/1.55 var(--mono); cursor: text; }
.log { white-space: pre; }
.log .l { min-height: 1.55em; }
.log .cmd { color: #fff; }
.log .cmd .p { color: var(--t-ok); }
.log .cmd .p.bad { color: var(--t-err); }
.s-b { color: #fff; font-weight: 600; }
.s-dim { color: var(--t-dim); }
.s-ok { color: var(--t-ok); }
.s-err { color: var(--t-err); }
.s-warn { color: var(--t-warn); }
.s-acc { color: var(--t-acc); }
.line { display: flex; align-items: baseline; gap: 8px; }
.prompt { flex: none; color: var(--t-ok); white-space: pre; }
.prompt.bad { color: var(--t-err); }
.prompt.ask { color: var(--t-warn); }
.input { flex: 1; min-width: 0; padding: 0; background: transparent; border: 0; outline: 0; color: #fff; font: inherit; caret-color: var(--t-ok); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px; background: var(--term-2); border-top: 1px solid rgba(255, 255, 255, 0.06); scrollbar-width: thin; }
.chips button { flex: none; padding: 6px 10px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 8px; color: var(--term-fg); font: 500 12.5px var(--mono); white-space: nowrap; }
.chips button:hover { border-color: var(--t-ok); color: #fff; }
.chips button b { color: var(--t-ok); font-weight: 600; }

.side { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: auto; }
.panel { padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.panel h2 { margin-bottom: 12px; font: 600 19px/1.2 var(--serif); }
.panel-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.hint { color: var(--muted); font-size: 12.5px; }
.empty { color: var(--muted); font-size: 14px; }
.empty code, .run code { padding: 1px 5px; background: var(--paper); border: 1px solid var(--line); border-radius: 5px; font: 500 12.5px var(--mono); }
.meter { display: flex; height: 12px; overflow: hidden; margin: 6px 0 10px; border-radius: 99px; background: var(--line); }
.meter i { display: block; height: 100%; }
.run-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.run-nums div { padding: 10px; background: var(--paper); border-radius: 10px; }
.run-nums b { display: block; font: 600 22px/1.1 var(--serif); }
.run-nums span { color: var(--muted); font-size: 12px; }
.run-meta { margin-top: 10px; color: var(--muted); font: 500 12px var(--mono); }
.ex-list { margin-top: 12px; border-top: 1px solid var(--line); }
.ex-list button { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; padding: 8px 2px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13.5px; }
.ex-list button:hover { background: color-mix(in srgb, var(--rule) 40%, transparent); }
.ex-list code { font: 600 12.5px var(--mono); }
.ex-list .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st { padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; }
.st.open { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.st.held { background: color-mix(in srgb, #3d7ea6 16%, transparent); color: #3d7ea6; }
.st.resolved { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.files li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); font: 500 13px var(--mono); }
.files li:last-child { border-bottom: 0; }
.files .name { flex: 1; min-width: 0; overflow: hidden; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.files .name:hover { text-decoration: underline; }
.files .size { color: var(--muted); font-size: 12px; }
.files .dl { color: var(--ink-2); font-size: 12px; text-decoration: underline; }
.files .dir { color: var(--muted); }
.file-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 9px; font-size: 13.5px; font-weight: 600; }
.btn:hover { border-color: var(--ink); }
.btn.small { min-height: 32px; font-size: 13px; }
.btn.ghosty { background: transparent; }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

@media (max-width: 960px) {
  body { height: auto; }
  .layout { grid-template-columns: minmax(0, 1fr); margin-left: 0; padding: 12px; border-left: 0; }
  .term { height: 72vh; min-height: 460px; }
  .tag { display: none; }
  .bar { padding: 0 14px; }
}
@media (max-width: 520px) {
  .screen { font-size: 12px; padding: 12px; }
  .log { white-space: pre-wrap; overflow-wrap: anywhere; }
  .ghost { padding: 6px 10px; font-size: 13px; }
}
/* Touch screens: thumb-sized targets for the command line and the file list. */
@media (pointer: coarse) {
  .input { min-height: 44px; }
  .files li { padding-block: 0; }
  .files .name, .files .dl { display: inline-flex; align-items: center; min-height: 44px; }
  .files .dl { justify-content: center; min-width: 44px; }
}
html.embedded .bar { display: none; }
html.embedded .layout { padding: 12px; margin-left: 0; border-left: 0; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
