:root {
  color-scheme: dark;
  font: 14px "Aptos", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  --page: #151918; --surface: #1d2320; --edge: #35413a;
  --text: #e6ece6; --muted: #9fac9e; --accent: #efc779; --green: #91b9a0;
  background: var(--page); color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, select, input { font: inherit; color: var(--text); background: #252e28; border: 1px solid #44534a; border-radius: 7px; min-height: 34px; padding: 5px 11px; }
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--green); background: #303c33; }
button:disabled { opacity: .48; cursor: default; }
:where(button, input, select, textarea, a):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { color: #272216; background: var(--accent); border: 1px solid var(--accent); font-weight: 680; }
.primary:hover:not(:disabled) { background: #f9d692; color: #272216; }
.wordmark { color: var(--accent); font: 700 14px ui-monospace, "Cascadia Code", monospace; letter-spacing: .1em; text-decoration: none; white-space: nowrap; }
.mast { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; min-height: 61px; gap: 10px; padding: 10px 21px; border-bottom: 1px solid var(--edge); }
.toolbar, .preview-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.toolbar form { margin: 0; }
[hidden] { display: none !important; }
.workbench { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); min-height: 450px; height: calc(100dvh - 94px); }
.editor-panel, .preview-panel { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.editor-panel { border-right: 1px solid var(--edge); }
.editor-head, .preview-head { min-height: 58px; display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--edge); background: var(--surface); }
.editor-head select { max-width: 42%; }
.editor-head input { flex: 1; min-width: 65px; }
h1 { margin: 0; font-size: 17px; }
.preview-head { justify-content: space-between; }
.source { display: grid; grid-template-columns: 44px minmax(0, 1fr); flex: 1; min-height: 0; background: #171d19; }
#gutter, #editor { font: 15px/25px "Cascadia Code", "Microsoft YaHei UI", monospace; margin: 0; padding-block: 16px; }
#gutter { color: #708474; background: #171d19; overflow: hidden; text-align: right; padding-inline: 4px 9px; user-select: none; }
#editor { color: #e2eee3; background: #1a211c; border: 0; border-left: 1px solid #28382d; padding-inline: 13px; resize: none; border-radius: 0; tab-size: 4; }
#editor:focus-visible { outline-offset: -2px; }
.diagnostics { display: grid; gap: 4px; overflow: auto; max-height: 170px; padding: 9px; border-top: 1px solid var(--edge); }
.diagnostics button { text-align: left; overflow-wrap: anywhere; }
.error { color: #ffab93; }
.warning { color: var(--accent); }
.preview-panel { background: #212820; }
.transcript { flex: 1; min-height: 0; overflow-y: auto; padding: 22px clamp(12px, 3vw, 49px); }
.transcript p { line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; margin: 5px 0 11px; font-size: 15px; }
.transcript .node-name { color: var(--green); font: 650 12px ui-monospace, monospace; letter-spacing: .07em; padding-top: 8px; margin-bottom: 8px; }
.transcript .choice { color: var(--accent); margin-left: 12px; }
.transcript .command, .transcript .ending, .transcript .empty { color: var(--muted); font-size: 13px; }
.options { display: grid; gap: 7px; padding: 0 clamp(12px, 3vw, 49px) 13px; max-height: 34%; overflow: auto; }
.options:empty { padding: 0; }
.option { text-align: left; color: var(--accent); white-space: normal; }
.option:disabled { color: var(--muted); }
#variables { border-top: 1px solid var(--edge); max-height: 28%; overflow: auto; padding: 8px 16px; }
#variables summary { cursor: pointer; color: var(--muted); }
#values { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; overflow-wrap: anywhere; margin-block: 8px 2px; font: 12px ui-monospace, monospace; }
#values dd { margin: 0; }
.footer { display: flex; justify-content: space-between; gap: 8px; min-height: 33px; padding: 7px 15px; color: var(--muted); border-top: 1px solid var(--edge); font-size: 12px; }
.footer span { overflow-wrap: anywhere; }
dialog { width: min(420px, calc(100% - 24px)); background: var(--surface); color: var(--text); border: 1px solid var(--edge); border-radius: 10px; padding: 22px; }
dialog::backdrop { background: #0b0d0bd1; }
dialog h2 { margin-top: 0; font-size: 18px; }
dialog label { display: grid; gap: 7px; }
dialog menu { display: flex; justify-content: end; gap: 8px; margin: 18px 0 0; padding: 0; }
.login-page { display: grid; place-items: center; padding: 18px; }
.login-card { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); width: min(920px, 100%); border: 1px solid var(--edge); background: var(--surface); }
.login-intro { padding: clamp(28px, 4vw, 65px); }
.login-intro h1 { font-size: clamp(32px, 4.5vw, 52px); margin-block: 20px 10px; letter-spacing: -.045em; }
.login-intro p:not(.wordmark) { color: var(--muted); line-height: 1.5; }
.login-intro a { display: inline-block; border-radius: 6px; padding: 10px 15px; margin-top: 20px; text-decoration: none; }
.login-intro .notice { color: #ffab93; }
.login-card pre { height: 100%; margin: 0; display: grid; align-content: center; background: #151c17; padding: clamp(18px, 4vw, 58px); font: clamp(12px, 1.2vw, 16px)/1.8 "Cascadia Code", monospace; overflow: auto; display: block; padding-block: clamp(40px, 9vw, 96px); }
.login-card pre span { color: var(--accent); }
@media (max-width: 740px) {
  .workbench { grid-template-columns: 1fr; height: auto; }
  .editor-panel, .preview-panel { min-height: 440px; }
  .editor-panel { border-right: 0; }
  .source { min-height: 340px; }
  .preview-panel { border-top: 1px solid var(--edge); }
  .transcript { max-height: 430px; }
  .preview-head, .editor-head { flex-wrap: wrap; }
  .editor-head select { max-width: 100%; }
  .login-card { grid-template-columns: 1fr; }
}
