:root {
  --blue: #364f91;
  --blue-dark: #24386f;
  --red: #d20011;
  --ink: #172238;
  --muted: #6e7890;
  --line: #dfe4ee;
  --surface: #ffffff;
  --page: #f3f5f9;
  --code: #fbfcff;
  --code-line: #dfe4ee;
  --code-ink: #26334d;
  --code-gutter: #f1f4f9;
  --code-muted: #70809c;
  --green: #198754;
  --amber: #a76500;
  --problem-width: 38%;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--page); color: var(--ink); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid rgba(54, 79, 145, .35); outline-offset: 2px; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 clamp(20px, 4vw, 64px); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 15px; min-width: 0; }
.brand-mark { display: flex; align-items: center; width: 106px; height: 38px; }
.brand-mark img { width: 100%; height: auto; display: block; }
.brand-divider { width: 1px; height: 24px; background: #cbd2df; }
.brand-product { color: var(--blue); font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 15px; letter-spacing: .12em; white-space: nowrap; }
.brand-product b { color: var(--red); font-weight: 800; }
.topbar-meta { display: flex; align-items: center; gap: 17px; color: var(--muted); font-size: 12px; }
.compiler-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--blue); font-family: "SFMono-Regular", Consolas, monospace; }
.compiler-pill i, .run-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }
.top-link { color: var(--muted); }
.top-link:hover { color: var(--blue); }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); background: transparent; color: var(--blue); border-radius: 50%; font-size: 18px; line-height: 1; }
.icon-button:hover { border-color: var(--blue); background: #f3f5fb; }
.account-menu { position: relative; }
.account-button, .primary-button { border: 0; color: #fff; background: var(--blue); border-radius: 6px; padding: 7px 12px 7px 8px; font-weight: 700; font-size: 13px; }
.account-button:hover, .primary-button:hover { background: var(--blue-dark); }
.account-button { display: inline-flex; align-items: center; gap: 8px; max-width: 190px; }
.account-avatar { width: 25px; height: 25px; display: inline-flex; flex: 0 0 25px; align-items: center; justify-content: center; overflow: hidden; border-radius: 50%; color: var(--blue); background: #fff; background-position: center; background-size: cover; font-size: 11px; font-weight: 800; }
#accountLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-popover { position: absolute; top: calc(100% + 9px); right: 0; z-index: 30; min-width: 146px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 12px 30px rgba(22, 34, 56, .16); }
.account-popover a, .account-popover button { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 5px; color: var(--ink); background: transparent; text-align: left; font-size: 12px; }
.account-popover a:hover, .account-popover button:hover { color: var(--blue); background: #f0f3fa; }

.main-area { width: 100%; margin: 0 auto; padding: 38px clamp(20px, 3.5vw, 56px) 24px; flex: 1; }
.intro-row { display: flex; align-items: end; justify-content: space-between; gap: 36px; margin-bottom: 34px; }
.kicker, .panel-label { margin: 0 0 10px; color: var(--red); font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; letter-spacing: .18em; font-weight: 800; }
.intro-row h1 { margin: 0; font-size: clamp(30px, 4vw, 54px); line-height: 1.07; letter-spacing: -.05em; font-weight: 800; color: var(--ink); }
.intro-row h1 em { color: var(--blue); font-style: normal; }
.intro-copy { max-width: 610px; color: var(--muted); font-size: 14px; line-height: 1.75; margin: 16px 0 0; }
.intro-note { width: 150px; flex: 0 0 150px; border-left: 2px solid var(--red); padding: 4px 0 5px 17px; display: grid; grid-template-columns: 1fr; gap: 5px; }
.intro-note span { color: var(--red); font: 800 12px "SFMono-Regular", Consolas, monospace; letter-spacing: .08em; }
.intro-note strong { font-size: 14px; }
.intro-note small { color: var(--muted); line-height: 1.45; font-size: 11px; }

.command-bar { display: flex; align-items: end; justify-content: space-between; gap: 22px; margin-bottom: 16px; }
.import-form { width: min(570px, 100%); }
.import-form label { display: block; margin: 0 0 8px; font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
.import-control { height: 43px; display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.import-control:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(54, 79, 145, .12); }
.input-prefix { padding: 0 12px; color: var(--red); font: 800 11px "SFMono-Regular", Consolas, monospace; border-right: 1px solid var(--line); }
.import-control input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 0 13px; color: var(--ink); font: 14px "SFMono-Regular", Consolas, monospace; text-transform: uppercase; }
.import-control input::placeholder { color: #a9b0bf; text-transform: none; }
.import-control button { height: 100%; border: 0; padding: 0 17px; background: var(--ink); color: white; font-size: 12px; font-weight: 700; }
.import-control button:hover { background: var(--blue); }
.import-control button[disabled] { cursor: wait; opacity: .65; }
.command-actions { display: flex; align-items: center; gap: 10px; }
.quiet-button, .small-button { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 6px; font-size: 12px; padding: 10px 13px; }
.quiet-button:hover, .small-button:hover { color: var(--blue); border-color: var(--blue); }
.primary-button { min-width: 111px; }

.panel-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-width: 0; overflow: hidden; }
.workspace-grid { display: grid; grid-template-columns: minmax(270px, var(--problem-width)) 8px minmax(0, 1fr); height: clamp(500px, calc(100vh - 340px), 720px); min-height: 460px; }
.workspace-grid.problem-collapsed { grid-template-columns: 0 0 minmax(0, 1fr); gap: 0; }
.problem-panel { display: flex; flex-direction: column; min-width: 0; border-radius: 8px 0 0 8px; }
.workspace-grid.problem-collapsed .problem-panel { border: 0; visibility: hidden; }
.workspace-grid.problem-collapsed .resizer { display: none; }
.panel-heading, .editor-heading, .saved-heading, .terminal-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.panel-heading { min-height: 75px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.panel-heading > div { min-width: 0; }
.panel-heading h2, .saved-heading h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; font-size: 17px; letter-spacing: -.02em; }
.problem-title-input { display: block; width: min(100%, 420px); min-width: 0; margin: 0; padding: 0 0 2px; border: 0; border-bottom: 1px solid transparent; outline: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); background: transparent; font-family: inherit; font-size: 17px; font-weight: 800; line-height: 1.25; letter-spacing: -.02em; }
.problem-title-input::placeholder { color: var(--ink); opacity: 1; }
.problem-title-input:focus { border-bottom-color: var(--blue); }
.panel-heading .panel-label, .saved-heading .panel-label { margin-bottom: 6px; }
.small-button { padding: 6px 9px; font-size: 11px; flex: 0 0 auto; }
.problem-tabs { display: flex; gap: 2px; padding: 10px 18px 0; border-bottom: 1px solid var(--line); }
.tab-button, .terminal-tab { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 0 5px 10px; border-bottom: 2px solid transparent; }
.tab-button.active, .tab-button:hover { color: var(--blue); border-bottom-color: var(--blue); font-weight: 800; }
.problem-scroll { flex: 1; min-height: 0; overflow: auto; }
.markdown-body { padding: 22px 24px 32px; color: #364154; font-size: 13px; line-height: 1.72; overflow-wrap: anywhere; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { color: var(--ink); line-height: 1.25; letter-spacing: -.025em; }
.markdown-body h1 { font-size: 25px; margin: 0 0 18px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.markdown-body h2 { font-size: 17px; margin: 26px 0 9px; }
.markdown-body h3 { font-size: 14px; margin: 17px 0 7px; }
.markdown-body p { margin: 8px 0; }
.markdown-body ul { margin: 8px 0 14px; padding-left: 22px; }
.markdown-body li { margin: 4px 0; }
.markdown-body blockquote { margin: 14px 0; padding: 7px 14px; border-left: 3px solid var(--blue); background: #f2f4f9; color: var(--muted); }
.markdown-body code { padding: 2px 5px; background: #eef1f7; color: var(--blue-dark); border-radius: 3px; font: 12px "SFMono-Regular", Consolas, monospace; }
.markdown-body pre { margin: 12px 0 16px; padding: 14px; overflow: auto; color: #eaf0ff; background: var(--code); border-radius: 5px; font: 12px/1.65 "SFMono-Regular", Consolas, monospace; }
.markdown-body pre code { padding: 0; background: transparent; color: inherit; }
.markdown-body a { color: var(--blue); text-decoration: underline; }
.markdown-editor { width: 100%; height: 100%; min-height: 300px; display: block; padding: 22px 24px; border: 0; outline: 0; resize: none; color: var(--ink); background: #fbfcfe; font: 13px/1.7 "SFMono-Regular", Consolas, monospace; }
.empty-state { min-height: 280px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 28px; color: var(--muted); }
.empty-state .empty-number { color: var(--red); font: 800 42px Georgia, serif; }
.empty-state strong { margin-top: 12px; color: var(--ink); font-size: 16px; }
.empty-state p { max-width: 260px; line-height: 1.65; font-size: 12px; }
.problem-footer { display: flex; justify-content: space-between; gap: 12px; padding: 9px 18px; border-top: 1px solid var(--line); color: #9aa3b4; font: 10px "SFMono-Regular", Consolas, monospace; }
.problem-footer span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resizer { position: relative; background: #e8ecf3; cursor: col-resize; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.resizer::after { content: ""; position: absolute; width: 2px; height: 34px; border-radius: 2px; top: calc(50% - 17px); left: 3px; background: #c0c8d8; }
.resizer:hover, .resizer:focus { background: #d6deed; }
.resizer:hover::after, .resizer:focus::after { background: var(--blue); }

.editor-panel { display: flex; flex-direction: column; border-radius: 0 8px 8px 0; background: var(--code); border-color: var(--code); }
.editor-heading { height: 49px; flex: 0 0 49px; padding: 0 18px; color: #d7def0; border-bottom: 1px solid var(--code-line); }
.editor-file { display: flex; align-items: center; gap: 9px; font: 12px "SFMono-Regular", Consolas, monospace; }
.file-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.dirty-dot { width: 6px; height: 6px; border-radius: 50%; background: #f0b429; }
.editor-tools { display: flex; align-items: center; gap: 15px; color: #8f9bb3; }
.tools-menu { position: relative; }
.editor-tool-button { border: 1px solid #3b4866; border-radius: 4px; padding: 5px 8px; color: #c7d2eb; background: #1b2740; font: 11px "SFMono-Regular", Consolas, monospace; }
.editor-tool-button:hover, .editor-tool-button[aria-expanded="true"] { border-color: #8296d1; color: #fff; }
.tools-popover { position: absolute; top: calc(100% + 8px); right: 0; z-index: 40; width: 158px; padding: 5px; border: 1px solid #3b4866; border-radius: 6px; background: #1b2740; box-shadow: 0 12px 30px rgba(0,0,0,.3); }
.tools-popover button { display: block; width: 100%; border: 0; border-radius: 4px; padding: 9px 10px; color: #d8e1f3; background: transparent; text-align: left; font-size: 11px; }
.tools-popover button:hover { color: #fff; background: #2a3a5e; }
.font-size-control { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; }
.font-size-control input { width: 70px; accent-color: #8296d1; }
.editor-language { padding: 4px 8px; border: 1px solid #3b4866; border-radius: 4px; color: #abb9d8; font: 10px "SFMono-Regular", Consolas, monospace; }
.code-editor-shell { flex: 1; min-height: 0; display: flex; overflow: hidden; background: var(--code); }
.code-input-wrap { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; }
.line-numbers { flex: 0 0 49px; margin: 0; padding: 16px 13px 30px 0; overflow: hidden; text-align: right; user-select: none; color: #596680; background: #101726; border-right: 1px solid var(--code-line); font: 15px/1.65 "SFMono-Regular", Consolas, monospace; }
#codeEditor { min-width: 0; flex: 1; display: block; resize: none; border: 0; outline: 0; padding: 16px 20px 30px; tab-size: 2; color: #e7edfb; caret-color: #ff6d79; background: var(--code); white-space: pre; overflow: auto; font: 15px/1.65 "SFMono-Regular", Consolas, monospace; }
#codeEditor::selection { background: #30416d; }
.completion-menu { position: absolute; left: 68px; right: 18px; bottom: 18px; z-index: 35; max-height: 235px; overflow: auto; padding: 5px; border: 1px solid #4b5e88; border-radius: 6px; background: #18243a; box-shadow: 0 14px 28px rgba(0,0,0,.34); }
.completion-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; border: 0; border-radius: 4px; padding: 8px 10px; color: #e8eefb; background: transparent; text-align: left; font: 12px "SFMono-Regular", Consolas, monospace; }
.completion-item small { overflow: hidden; color: #91a1c1; text-overflow: ellipsis; white-space: nowrap; font: 10px ui-sans-serif, sans-serif; }
.completion-item:hover, .completion-item.active { color: #fff; background: #2c4170; }
.editor-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 32px; padding: 0 17px; color: #74819b; background: #101726; border-top: 1px solid var(--code-line); font: 10px "SFMono-Regular", Consolas, monospace; }
kbd { color: #c5d0e7; border: 1px solid #495673; border-radius: 3px; padding: 1px 4px; font: 10px "SFMono-Regular", Consolas, monospace; }
.slash { padding: 0 4px; color: #5c6984; }

.bottom-grid { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; margin-top: 16px; }
.terminal-panel { min-height: 306px; display: flex; flex-direction: column; }
.terminal-heading { flex: 0 0 49px; padding: 0 17px; border-bottom: 1px solid var(--line); }
.terminal-tabs { height: 100%; display: flex; align-items: end; gap: 17px; }
.terminal-tab { padding-bottom: 13px; }
.terminal-tab.active, .terminal-tab:hover { color: var(--blue); border-bottom-color: var(--red); font-weight: 800; }
.terminal-tab span { display: inline-flex; min-width: 17px; height: 17px; justify-content: center; align-items: center; margin-left: 4px; border-radius: 9px; color: var(--muted); background: #eef1f6; font: 10px "SFMono-Regular", Consolas, monospace; }
.run-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font: 11px "SFMono-Regular", Consolas, monospace; }
.run-status.busy i { background: var(--amber); animation: pulse 1s ease-in-out infinite; }
.run-status.success { color: var(--green); }
.run-status.error { color: var(--red); }
@keyframes pulse { 50% { opacity: .25; } }
.terminal-body { flex: 1; min-height: 135px; background: #11192a; color: #dbe3f4; }
.terminal-output, .judge-panel { height: 100%; min-height: 135px; overflow: auto; }
.terminal-output { padding: 16px 18px; }
#consoleOutput { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #dbe3f4; font: 12px/1.65 "SFMono-Regular", Consolas, monospace; }
.output-metrics { display: flex; gap: 18px; padding-top: 11px; color: #8391ac; font: 10px "SFMono-Regular", Consolas, monospace; }
.judge-panel { padding: 14px 16px; }
.judge-summary { margin-bottom: 10px; color: #a7b2c8; font: 11px "SFMono-Regular", Consolas, monospace; }
.judge-table-wrap { overflow: auto; }
.judge-panel table { width: 100%; border-collapse: collapse; font: 11px "SFMono-Regular", Consolas, monospace; }
.judge-panel th { color: #8391ac; font-weight: 400; text-align: left; }
.judge-panel th, .judge-panel td { padding: 7px 9px; border-bottom: 1px solid #27334d; white-space: nowrap; }
.judge-panel td { color: #dbe3f4; }
.judge-panel td.output-cell { max-width: 190px; overflow: hidden; text-overflow: ellipsis; color: #9ca8bc; }
.judge-ac { color: #63d69c !important; }
.judge-wa, .judge-re, .judge-ole { color: #ff7983 !important; }
.judge-tle { color: #f1c46a !important; }
.stdin-row { display: grid; grid-template-columns: 125px minmax(0, 1fr) auto; gap: 13px; align-items: center; padding: 13px 17px; border-top: 1px solid var(--line); }
.stdin-label { align-self: start; padding-top: 5px; }
.stdin-label span { display: block; color: var(--blue); font: 800 10px "SFMono-Regular", Consolas, monospace; letter-spacing: .1em; }
.stdin-label small { display: block; margin-top: 4px; color: #a0a9ba; font-size: 10px; line-height: 1.4; }
#stdinEditor { width: 100%; min-height: 51px; max-height: 105px; resize: vertical; padding: 9px 11px; border: 1px solid var(--line); outline: 0; border-radius: 5px; color: var(--ink); background: #fbfcfe; font: 12px/1.5 "SFMono-Regular", Consolas, monospace; }
#stdinEditor:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(54, 79, 145, .1); }
.run-actions { display: flex; align-items: center; gap: 7px; }
.run-button, .judge-button, .sample-button { border: 0; border-radius: 5px; padding: 10px 13px; color: #fff; font-size: 11px; font-weight: 800; white-space: nowrap; }
.run-button { background: var(--red); }
.run-button:hover { background: #aa000e; }
.judge-button { background: var(--blue); }
.judge-button:hover { background: var(--blue-dark); }
.sample-button { color: var(--blue); background: #eef1f8; border: 1px solid #d9dfeb; }
.sample-button:hover { background: #e2e7f3; }
.run-button[disabled], .judge-button[disabled] { cursor: wait; opacity: .6; }

.saved-panel { min-height: 306px; display: flex; flex-direction: column; }
.saved-heading { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.saved-count { color: var(--blue); font: 800 14px "SFMono-Regular", Consolas, monospace; }
.saved-list { flex: 1; min-height: 166px; overflow: auto; }
.saved-empty { height: 100%; min-height: 180px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 20px; color: var(--muted); }
.saved-empty > span { color: var(--red); font-size: 26px; }
.saved-empty p { margin: 9px 0 13px; font-size: 12px; line-height: 1.6; }
.saved-empty button { border: 0; padding: 0; color: var(--blue); background: transparent; font-size: 12px; font-weight: 800; }
.saved-item { display: block; width: 100%; text-align: left; padding: 13px 18px; border: 0; border-bottom: 1px solid #edf0f5; background: transparent; }
.saved-item:hover, .saved-item.active { background: #f5f7fb; }
.saved-item-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 12px; font-weight: 800; }
.saved-item-meta { display: flex; gap: 7px; margin-top: 6px; color: #9ba5b7; font: 10px "SFMono-Regular", Consolas, monospace; }
.saved-item-meta span:first-child { color: var(--red); }
.saved-foot { display: flex; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); color: #a1aaba; font-size: 10px; }
.saved-foot a { color: var(--blue); }

.site-footer { display: flex; justify-content: space-between; gap: 18px; padding: 18px clamp(20px, 4vw, 64px) 25px; color: #929caf; font: 10px "SFMono-Regular", Consolas, monospace; letter-spacing: .04em; }
.exit-fullscreen-button { position: fixed; top: 12px; right: 16px; z-index: 60; display: none; border: 1px solid #4b5e88; border-radius: 5px; padding: 7px 10px; color: #d9e4fb; background: #18243a; font: 11px "SFMono-Regular", Consolas, monospace; }
body.is-fullscreen .exit-fullscreen-button, body.workspace-focus .exit-fullscreen-button { display: block; }
.tool-dialog { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(12, 19, 33, .62); }
.tool-dialog[hidden], .tools-popover[hidden], .completion-menu[hidden] { display: none; }
.tool-dialog-card { width: min(560px, 100%); max-height: min(680px, calc(100vh - 40px)); overflow: auto; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: 0 24px 70px rgba(13, 23, 44, .3); }
.tool-dialog-heading { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.tool-dialog-heading h2 { margin: 0; color: var(--ink); font-size: 16px; }
.tool-dialog-heading .icon-button { font-size: 20px; }
.tool-dialog-content { padding: 18px; color: var(--ink); }
.tool-dialog-content p { margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.snippet-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.snippet-button, .tool-action-button { border: 1px solid var(--line); border-radius: 5px; padding: 10px 12px; color: var(--ink); background: var(--surface); text-align: left; font-size: 12px; }
.snippet-button:hover, .tool-action-button:hover { border-color: var(--blue); color: var(--blue); background: #f5f7fb; }
.tool-input { width: 100%; min-height: 84px; resize: vertical; border: 1px solid var(--line); border-radius: 5px; padding: 10px; color: var(--ink); background: var(--surface); font: 12px/1.55 "SFMono-Regular", Consolas, monospace; }
.tool-input.single { min-height: 0; }
.tool-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.tool-result { margin-top: 14px; overflow: auto; }
.array-result { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 7px; }
.array-cell { border: 1px solid var(--line); border-radius: 4px; padding: 8px; background: #f6f8fc; text-align: center; }
.array-cell small { display: block; color: var(--muted); font: 10px "SFMono-Regular", Consolas, monospace; }
.array-cell strong { display: block; margin-top: 3px; color: var(--blue); font: 13px "SFMono-Regular", Consolas, monospace; }
.bits-result { margin: 0; padding: 12px; border-radius: 5px; color: var(--ink); background: #f6f8fc; white-space: pre-wrap; font: 12px/1.7 "SFMono-Regular", Consolas, monospace; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; max-width: min(440px, calc(100vw - 34px)); transform: translate(-50%, 18px); opacity: 0; pointer-events: none; padding: 11px 16px; border-radius: 5px; color: #fff; background: var(--ink); box-shadow: 0 8px 24px rgba(18, 26, 43, .2); font-size: 12px; transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); }

body.dark { --ink: #edf2fc; --muted: #9ba9c3; --line: #303c55; --surface: #1d2638; --page: #121a2a; --blue-dark: #92a7e6; color-scheme: dark; }
body.dark { --code: #121a2b; --code-line: #202a40; --code-ink: #d7def0; --code-gutter: #101726; --code-muted: #8f9bb3; }
body.dark .topbar, body.dark .panel-card { background: var(--surface); }
body.dark .intro-row h1, body.dark .panel-heading h2, body.dark .problem-title-input, body.dark .saved-heading h2, body.dark .saved-item-title, body.dark .markdown-body h1, body.dark .markdown-body h2, body.dark .markdown-body h3 { color: var(--ink); }
body.dark .markdown-body { color: #c8d2e6; }
body.dark .markdown-body blockquote { background: #263149; }
body.dark .markdown-body code { color: #bdd0ff; background: #2a3550; }
body.dark .markdown-editor, body.dark #stdinEditor { color: var(--ink); background: #182235; }
body.dark .quiet-button, body.dark .small-button, body.dark .icon-button { color: #b8c4da; background: var(--surface); }
body.dark .saved-item:hover, body.dark .saved-item.active { background: #263149; }
body.dark .saved-item { border-bottom-color: #2b354c; }
body.dark .resizer { background: #202b42; border-color: #303c55; }
body.dark .resizer::after { background: #637394; }
body.dark .import-control { background: #1d2638; }
body.dark .import-control input { color: var(--ink); }
body.dark .terminal-tab span { background: #2a3550; }
body.dark .sample-button { color: #cbd7f3; background: #2a3550; border-color: #3a4864; }
body.dark .account-popover { box-shadow: 0 12px 30px rgba(0, 0, 0, .35); }
body.dark .account-popover a:hover, body.dark .account-popover button:hover { background: #263149; }
body.dark .snippet-button:hover, body.dark .tool-action-button:hover { background: #263149; }
body.dark .array-cell, body.dark .bits-result { background: #263149; }

/* The code surface follows the interface theme unless a code theme is chosen. */
.editor-panel { background: var(--code); border-color: var(--code-line); }
.editor-heading { color: var(--code-ink); border-bottom-color: var(--code-line); }
.editor-tools { color: var(--code-muted); }
.editor-tool-button { border-color: var(--code-line); color: var(--code-ink); background: var(--surface); }
.editor-tool-button:hover, .editor-tool-button[aria-expanded="true"] { border-color: var(--blue); color: var(--blue); }
.tools-popover { border-color: var(--line); background: var(--surface); box-shadow: 0 12px 30px rgba(18, 26, 43, .18); }
.tools-popover button { color: var(--ink); }
.tools-popover button:hover { color: var(--blue); background: color-mix(in srgb, var(--blue) 9%, var(--surface)); }
.editor-language { border-color: var(--line); color: var(--muted); }
.code-editor-shell { background: var(--code); }
.code-theme-control { display: inline-flex; align-items: center; gap: 6px; color: var(--code-muted); font: 10px "SFMono-Regular", Consolas, monospace; }
.code-theme-control select { max-width: 112px; border: 1px solid var(--code-line); border-radius: 4px; padding: 4px 5px; color: var(--code-ink); background: var(--surface); font: 10px "SFMono-Regular", Consolas, monospace; }
#codeEditor, #codeEditor.ace_editor { position: relative; z-index: 2; pointer-events: auto; }
#codeEditor .ace_text-input { z-index: 5; pointer-events: auto !important; }
#codeEditor .ace_gutter { color: var(--code-muted); background: var(--code-gutter); }
#codeEditor .ace_scroller { background: var(--code); }
.editor-footer { color: var(--code-muted); background: var(--code-gutter); border-top-color: var(--code-line); }
kbd { color: var(--code-ink); border-color: var(--code-line); }
.terminal-body { color: var(--ink); background: var(--surface); }
#consoleOutput { color: var(--ink); }
.output-metrics, .judge-summary { color: var(--muted); }
.judge-panel th { color: var(--muted); }
.judge-panel th, .judge-panel td { border-bottom-color: var(--line); }
.judge-panel td { color: var(--ink); }
.judge-panel td.output-cell { color: var(--muted); }

body.is-fullscreen, body.workspace-focus { overflow: hidden; }
body.is-fullscreen .topbar, body.is-fullscreen .intro-row, body.is-fullscreen .command-bar, body.is-fullscreen .site-footer,
body.workspace-focus .topbar, body.workspace-focus .intro-row, body.workspace-focus .command-bar, body.workspace-focus .site-footer { display: none; }
body.is-fullscreen .main-area, body.workspace-focus .main-area { width: 100%; max-width: none; height: 100vh; padding: 9px 12px; }
body.is-fullscreen .workspace-grid, body.workspace-focus .workspace-grid { height: calc(100vh - 330px); min-height: 360px; }
body.is-fullscreen .bottom-grid, body.workspace-focus .bottom-grid { margin-top: 9px; }
body.is-fullscreen .editor-heading, body.workspace-focus .editor-heading { padding-right: 92px; }

@media (max-width: 1060px) {
  .top-link { display: none; }
  .bottom-grid { grid-template-columns: minmax(0, 1fr) 245px; }
  .stdin-row { grid-template-columns: 92px minmax(0, 1fr); }
  .run-actions { grid-column: 2; justify-content: flex-end; }
}

@media (max-width: 760px) {
  .topbar { height: 64px; padding: 0 17px; }
  .brand-mark { width: 91px; }
  .brand { gap: 10px; }
  .brand-product { font-size: 12px; }
  .compiler-pill { display: none; }
  .topbar-meta { gap: 8px; }
  .account-button { padding: 7px 9px 7px 7px; }
  .account-button #accountLabel { max-width: 92px; }
  .main-area { padding: 30px 15px 16px; }
  .intro-row { display: block; margin-bottom: 25px; }
  .intro-row h1 { font-size: 31px; }
  .intro-copy { font-size: 13px; line-height: 1.65; }
  .intro-note { display: none; }
  .command-bar { display: block; }
  .import-form { width: 100%; }
  .command-actions { justify-content: flex-end; margin-top: 10px; }
  .workspace-grid { display: flex; flex-direction: column; height: auto; min-height: 0; gap: 12px; }
  .workspace-grid.problem-collapsed .problem-panel { display: none; }
  .problem-panel, .editor-panel { min-height: 430px; border-radius: 8px; }
  .problem-panel { max-height: 560px; }
  .resizer { display: none; }
  .bottom-grid { display: flex; flex-direction: column; gap: 12px; }
  .terminal-panel, .saved-panel { min-height: 0; }
  .terminal-panel { min-height: 360px; }
  .saved-panel { min-height: 280px; }
  .stdin-row { grid-template-columns: 1fr; gap: 9px; }
  .run-actions { grid-column: auto; justify-content: flex-end; }
  .site-footer { padding: 16px 17px 23px; flex-wrap: wrap; }
  .site-footer span:nth-child(2) { order: 3; width: 100%; }
}

@media (max-width: 620px) {
  .code-theme-control span { display: none; }
  .code-theme-control select { max-width: 92px; }
}

@media (max-width: 440px) {
  .brand-divider, #themeButton, #fullscreenButton { display: none; }
  .brand-product { letter-spacing: .06em; }
  .font-size-control { display: none; }
  .editor-footer { font-size: 9px; }
  .editor-footer span:last-child { display: none; }
  .run-actions { width: 100%; }
  .run-button, .judge-button { flex: 1; }
}

@media (max-width: 620px) {
  .editor-tools { gap: 7px; }
  .font-size-control { display: none; }
  .completion-menu { left: 12px; right: 12px; bottom: 12px; }
  .snippet-grid { grid-template-columns: 1fr; }
}

/* 原型工作台布局：工具栏、编辑器、可折叠终端占满视口，题面和个人题目按需呼出。 */
html, body { height: 100%; }
body { overflow: hidden; }
.app-shell { height: 100vh; min-height: 0; }
.topbar { height: 54px; flex: 0 0 54px; padding-left: 20px; padding-right: 20px; }
.main-area { width: 100%; max-width: none; min-height: 0; padding: 0; display: flex; flex-direction: column; }
.intro-row { display: none; }
.command-bar { flex: 0 0 54px; min-height: 54px; margin: 0; padding: 8px 18px; align-items: center; border-bottom: 1px solid var(--line); background: var(--surface); }
.import-form { width: min(500px, 50vw); display: flex; align-items: center; gap: 10px; }
.import-form label { margin: 0; white-space: nowrap; }
.import-control { height: 36px; flex: 1; }
.command-actions { gap: 7px; }
.workspace-grid { flex: 1; min-height: 0; height: auto; }
.workspace-grid.layout-right { grid-template-columns: minmax(0, 1fr) 8px minmax(270px, var(--problem-width)); }
.workspace-grid.layout-right .editor-panel { grid-column: 1; grid-row: 1; border-radius: 0; }
.workspace-grid.layout-right .resizer { grid-column: 2; grid-row: 1; }
.workspace-grid.layout-right .problem-panel { grid-column: 3; grid-row: 1; border-radius: 0; }
.workspace-grid.layout-top { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(180px, 38%) 8px minmax(0, 1fr); }
.workspace-grid.layout-top .problem-panel { grid-column: 1; grid-row: 1; border-radius: 0; }
.workspace-grid.layout-top .resizer { grid-column: 1; grid-row: 2; cursor: row-resize; }
.workspace-grid.layout-top .editor-panel { grid-column: 1; grid-row: 3; border-radius: 0; }
.workspace-grid.layout-full { position: relative; display: block; }
.workspace-grid.layout-full .problem-panel { position: absolute; inset: 0; z-index: 20; width: 100%; height: 100%; border-radius: 0; }
.workspace-grid.layout-full .editor-panel { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; border-radius: 0; }
.workspace-grid.layout-full .resizer { display: none; }
.problem-panel, .editor-panel { border-radius: 0; }
.problem-heading-actions, .saved-heading-actions { display: flex; align-items: center; gap: 4px; }
.editor-heading { height: 44px; flex-basis: 44px; }
.code-editor-shell { position: relative; }
#codeEditor { flex: 1; width: 100%; height: 100%; min-height: 0; font: 20px/1.5 "SFMono-Regular", Consolas, monospace; }
#codeEditor.ace_editor { padding: 0; color: inherit; }
#codeEditor .ace_gutter { width: 54px; color: #71809d; background: #101726; }
#codeEditor .ace_gutter-cell { padding-left: 12px; padding-right: 12px; }
#codeEditor .ace_scroller { left: 54px; background: var(--code); }
#codeEditor .ace_content, #codeEditor .ace_text-layer { line-height: 1.5; }
#codeEditor .ace_cursor { border-left-color: #ff6d79; }
.fallback-code-editor { width: 100%; height: 100%; resize: none; border: 0; outline: 0; padding: 18px 20px; color: #e7edfb; background: var(--code); font: 20px/1.5 "SFMono-Regular", Consolas, monospace; tab-size: 4; }
.symbol-menu { position: absolute; top: 16px; left: 72px; z-index: 45; width: min(260px, calc(100% - 88px)); max-height: min(430px, calc(100% - 30px)); overflow: auto; padding: 7px; border: 1px solid #506795; border-radius: 8px; color: #e7edfb; background: rgba(24, 36, 58, .97); box-shadow: 0 18px 40px rgba(0,0,0,.4); }
.symbol-menu[hidden] { display: none; }
.symbol-menu p { margin: 3px 8px 7px; color: #bdcae3; font: 800 11px "SFMono-Regular", Consolas, monospace; }
.symbol-menu p span { float: right; color: #8495b7; font-weight: 400; }
.symbol-menu button { display: block; width: 100%; border: 0; border-radius: 5px; padding: 9px 10px; color: #dce6fa; background: transparent; text-align: left; font-size: 12px; }
.symbol-menu button:hover, .symbol-menu button:focus-visible { color: #fff; background: #2d4374; outline: 0; }
.editor-footer { min-height: 29px; }
.bottom-grid { flex: 0 0 auto; display: block; margin: 0; }
.terminal-panel { height: 48px; min-height: 48px; border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; transition: height .22s ease; }
.terminal-panel.terminal-collapsed { height: 48px; min-height: 48px; }
.terminal-panel:not(.terminal-collapsed) { height: min(34vh, 310px); }
.terminal-collapsed .terminal-body, .terminal-collapsed .stdin-row { display: none; }
.terminal-heading { flex-basis: 48px; height: 48px; }
.terminal-heading-actions { display: flex; align-items: center; gap: 10px; }
.terminal-toggle-button { width: 27px; height: 27px; border: 1px solid var(--line); border-radius: 5px; color: var(--blue); background: var(--surface); font-weight: 800; }
.terminal-toggle-button:hover { border-color: var(--blue); }
.saved-panel { position: fixed; top: 63px; right: 16px; bottom: 16px; z-index: 42; width: min(340px, calc(100vw - 32px)); min-height: 0; transform: translateX(calc(100% + 30px)); transition: transform .2s ease; box-shadow: 0 18px 45px rgba(18, 26, 43, .22); }
.saved-panel.drawer-open { transform: translateX(0); }
.saved-panel .saved-list { min-height: 0; }
.site-footer { display: none; }
.drawing-board[hidden] { display: none; }
.drawing-board { position: fixed; inset: 0; z-index: 80; }
#drawingCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; background: rgba(255,255,255,.02); cursor: crosshair; }
.drawing-toolbar { position: absolute; top: 14px; left: 50%; display: flex; align-items: center; gap: 8px; transform: translateX(-50%); padding: 8px 10px; border: 1px solid rgba(255,255,255,.2); border-radius: 8px; color: #fff; background: rgba(24,36,58,.94); box-shadow: 0 12px 32px rgba(0,0,0,.3); font-size: 12px; }
.drawing-toolbar button { border: 1px solid #506795; border-radius: 4px; padding: 5px 9px; color: #eaf0ff; background: transparent; font-size: 11px; }
.drawing-toolbar button:hover { background: #2d4374; }
.memory-list { overflow: auto; border: 1px solid var(--line); border-radius: 5px; }
.memory-row { display: grid; grid-template-columns: 72px minmax(72px, 1fr) minmax(0, 1.5fr); gap: 8px; padding: 9px 10px; border-bottom: 1px solid var(--line); font: 11px "SFMono-Regular", Consolas, monospace; }
.memory-row:last-child { border-bottom: 0; }
.memory-address { color: var(--muted); }
.memory-name { color: var(--red); font-weight: 800; }
.memory-value { overflow: hidden; color: var(--blue); text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 760px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
  .topbar { flex-basis: 54px; }
  .main-area { min-height: calc(100vh - 54px); }
  .command-bar { display: flex; overflow-x: auto; }
  .import-form { width: min(430px, 75vw); flex: 0 0 auto; }
  .command-actions { flex: 0 0 auto; }
  .workspace-grid { flex: 0 0 auto; }
  .editor-panel { min-height: 520px; }
  .terminal-panel:not(.terminal-collapsed) { height: 360px; }
  .saved-panel { top: 62px; bottom: 12px; }
}

/* Final theme and hit-area overrides must come after the prototype workbench rules. */
.editor-panel,
.code-editor-shell { background: var(--code); border-color: var(--code-line); }
.editor-heading { color: var(--code-ink); border-bottom-color: var(--code-line); }
.editor-tools { color: var(--code-muted); }
.editor-tool-button { border-color: var(--code-line); color: var(--code-ink); background: var(--surface); }
.editor-language { border-color: var(--code-line); color: var(--code-muted); }
.code-theme-control { display: inline-flex; align-items: center; gap: 6px; color: var(--code-muted); font: 10px "SFMono-Regular", Consolas, monospace; }
.code-theme-control select { max-width: 112px; border: 1px solid var(--code-line); border-radius: 4px; padding: 4px 5px; color: var(--code-ink); background: var(--surface); font: 10px "SFMono-Regular", Consolas, monospace; }
.editor-footer { color: var(--code-muted); background: var(--code-gutter); border-top-color: var(--code-line); }
#codeEditor,
#codeEditor.ace_editor { position: relative; z-index: 2; pointer-events: auto; }
#codeEditor .ace_text-input { z-index: 5; pointer-events: auto !important; }
#codeEditor .ace_gutter { color: var(--code-muted); background: var(--code-gutter); }
#codeEditor .ace_scroller { background: var(--code); }
.fallback-code-editor { color: var(--code-ink); background: var(--code); }
.terminal-body { color: var(--ink); background: var(--surface); }
#consoleOutput { color: var(--ink); }
.output-metrics, .judge-summary { color: var(--muted); }
.judge-panel th { color: var(--muted); }
.judge-panel th, .judge-panel td { border-bottom-color: var(--line); }
.judge-panel td { color: var(--ink); }
.judge-panel td.output-cell { color: var(--muted); }

@media (max-width: 620px) {
  .code-theme-control > span { display: none; }
  .code-theme-control select { max-width: 92px; }
}
