/* Solve workspace (live) and the replay stage. */
body.is-bare { padding-bottom: 0; overflow: hidden; }
.ws { position: relative; display: grid; grid-template-rows: 56px minmax(0, 1fr); height: 100vh; height: 100dvh; background: var(--bg); overflow: hidden; }
.ws-top { display: flex; align-items: center; gap: 12px; padding: 0 12px; min-width: 0; background: var(--bg); }
.ws-top__lead { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 0; }
.ws-top__title { min-width: 0; line-height: 1.25; }
.ws-top__title b { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.02em; }
.ws-top__title small { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ws-top__end { display: flex; align-items: center; gap: 8px; flex: 1 1 0; justify-content: flex-end; }

.tools { display: flex; align-items: center; gap: 6px; flex: none; }
.tools .seg { padding: 3px; }
.tools .seg__pill { top: 3px; height: calc(100% - 6px); }
.tools .seg__item { width: 34px; height: 30px; padding: 0; justify-content: center; font-size: 16px; }
.tools__colors, .tools__sizes { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface); }
.swatch { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; transition: background var(--m) var(--ease); }
.swatch:hover { background: var(--hover); }
.swatch span { width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.swatch.is-active { background: var(--surface-3); }
.size-dot { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; transition: background var(--m) var(--ease); }
.size-dot:hover { background: var(--hover); }
.size-dot span { border-radius: 50%; background: var(--ink-2); }
.size-dot.is-active { background: var(--surface-3); }
.tools .btn--icon { width: 32px; height: 32px; }
@media (max-width: 1180px) { .tools__sizes { display: none; } }
@media (max-width: 1020px) { .tools__colors { display: none; } .ws-top__title small { display: none; } }

.ws-clock { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); transition: color var(--m) var(--ease); height: 36px; padding: 0 12px; border-radius: 10px; background: var(--surface); font: 500 15px/1 var(--mono); font-variant-numeric: tabular-nums; }

.ws-body { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); min-height: 0; }
.ws-left { overflow: auto; padding: 28px 32px 64px; background: var(--surface); border-radius: 16px 0 0 0; }
.ws-right { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.ws-ink { position: absolute; inset: 0; z-index: 5; width: 100%; height: 100%; pointer-events: none; touch-action: none; }
.ws-ink.is-drawing { pointer-events: auto; cursor: crosshair; }
.ws-ink.is-erasing { pointer-events: auto; cursor: cell; }
@media (max-width: 900px) {
  .ws-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 0.9fr) minmax(0, 1.1fr); }
  .ws-left { border-radius: 0; padding: 20px; }
  .tools { display: none; }
}

.stmt__head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.stmt__title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.3; }
.stmt__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 22px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 8px; background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.stmt__h { margin: 26px 0 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.ex { margin-bottom: 10px; padding: 12px 14px; border-radius: 12px; background: var(--bg-2); font: 13px/1.6 var(--mono); overflow-x: auto; white-space: pre; }
.ex b { color: var(--muted); font-weight: 500; }
.schema { padding: 14px 16px; border-radius: 12px; background: var(--bg-2); font: 13px/1.75 var(--mono); white-space: pre; overflow-x: auto; color: var(--ink-2); }

/* editor */
.ed { position: relative; flex: 1 1 60%; min-height: 0; background: var(--bg); }
.ed__scroll { position: absolute; inset: 0; overflow: auto; display: flex; align-items: flex-start; }
.ed__gutter { position: sticky; left: 0; z-index: 2; flex: none; min-width: 48px; min-height: 100%; padding: 14px 12px 14px 0; text-align: right; background: var(--bg); color: var(--muted-2); font: 13px/22px var(--mono); user-select: none; white-space: pre; }
.ed__code { position: relative; flex: 1; min-width: max-content; min-height: 100%; }
.ed__hl, .ed__ta { margin: 0; padding: 14px 24px 14px 8px; font: 14px/22px var(--mono); letter-spacing: 0; tab-size: 2; white-space: pre; word-wrap: normal; }
.ed__hl { color: var(--ink); pointer-events: none; min-height: 100%; }
.ed__ta { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; border: 0; overflow: hidden; background: transparent; color: transparent; caret-color: var(--ink); -webkit-text-fill-color: transparent; }
.ed__ta::selection { background: rgba(106, 166, 255, .3); -webkit-text-fill-color: transparent; }
.tk-c { color: var(--muted-2); font-style: italic; }
.tk-s { color: #9fd98b; }
.tk-n { color: #f5b971; }
.tk-k { color: #8fb8ff; }
:root[data-theme="light"] .tk-s { color: #2f7d1e; }
:root[data-theme="light"] .tk-n { color: #a65a00; }
:root[data-theme="light"] .tk-k { color: #2456d6; }

/* console */
.con { flex: 0 0 38%; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.con__bar { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px; flex: none; font-size: 13px; font-weight: 600; color: var(--muted); }
.con__body { flex: 1; min-height: 0; overflow: auto; padding: 0 16px 16px; }
.case { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); margin-bottom: 8px; font-size: 13px; }
.case__head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 6px; }
.case__head small { margin-left: auto; color: var(--muted); font-weight: 400; font-family: var(--mono); }
.case pre { margin: 2px 0; font: 12.5px/1.6 var(--mono); white-space: pre-wrap; word-break: break-all; color: var(--ink-2); }
.case pre b { color: var(--muted); font-weight: 500; }
.ok { color: var(--green); }
.bad { color: var(--red); }
.logs { margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: var(--bg-2); }
.rtable { border-collapse: collapse; font: 12.5px/1.5 var(--mono); }
.rtable th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 14px 6px 0; position: sticky; top: 0; background: var(--surface); }
.rtable td { padding: 3px 14px 3px 0; white-space: nowrap; color: var(--ink-2); }
.rtable tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.con__hint { color: var(--muted); font-size: 13px; padding-top: 4px; }

/* answers for non-code types */
.ans { flex: 1; min-height: 0; overflow: auto; padding: 28px 32px; }
.ans__label { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.opt { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 12px 16px; margin-bottom: 8px; border-radius: 14px; background: var(--surface); text-align: left; font-size: 15px;
  transition: background var(--m) var(--ease), transform 120ms var(--ease); }
.opt:hover { background: var(--surface-2); }
.opt:active { transform: scale(.99); }
.opt__key { width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); font-weight: 700; font-size: 13px; color: var(--muted); transition: background var(--m) var(--ease), color var(--m) var(--ease); }
.opt.is-active { background: var(--surface-3); }
.opt.is-active .opt__key { background: var(--action); color: var(--action-ink); }
.field { width: 100%; height: 56px; padding: 0 18px; border: 0; border-radius: 14px; background: var(--surface); font: 500 20px var(--mono); caret-color: var(--accent); transition: background var(--m) var(--ease); }
.field:focus { background: var(--surface-2); }

/* verdict */
.verdict { margin: 0 0 12px; padding: 16px 18px; border-radius: 14px; background: var(--surface-2); overflow: hidden; }
.verdict__top { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.verdict__detail { margin-top: 6px; font-size: 13.5px; color: var(--ink-2); word-break: break-all; }
.verdict__acts { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.verdict--ok { background: var(--green-soft); }
.verdict--ok .verdict__top { color: var(--green); }
.verdict--bad { background: var(--red-soft); }
.verdict--bad .verdict__top { color: var(--red); }
.ans .verdict { margin-top: 20px; }

/* submit button swaps its label in place */
.swap { display: inline-grid; overflow: hidden; }
.swap > span { grid-area: 1 / 1; transition: transform var(--m) var(--ease), opacity 200ms var(--ease), filter 200ms var(--ease); }
.swap > span.is-out { transform: translateY(-110%); opacity: 0; filter: blur(4px); }
.swap > span.is-in { transform: translateY(110%); opacity: 0; filter: blur(4px); }

/* replay */
.rp { display: grid; grid-template-rows: minmax(0, 1fr) auto; height: 100vh; height: 100dvh; background: var(--bg-2); }
.rp__stage { position: relative; overflow: hidden; }
.rp__frame { position: absolute; left: 0; top: 0; transform-origin: 0 0; border-radius: 14px; overflow: hidden; box-shadow: 0 24px 64px rgba(0, 0, 0, .5); }
.rp__frame .ws { height: 100%; }
.rp__frame .ws * { pointer-events: none !important; }
.rp__bar { display: flex; align-items: center; gap: 12px; padding: 12px var(--gut) 16px; background: var(--bg-2); }
.rp__time { font: 500 14px var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.scrub { position: relative; flex: 1; height: 32px; cursor: pointer; touch-action: none; }
.scrub__track { position: absolute; left: 0; right: 0; top: 14px; height: 4px; border-radius: 2px; background: var(--surface-3); }
.scrub__fill { position: absolute; left: 0; top: 14px; height: 4px; border-radius: 2px; background: var(--ink); }
.scrub__knob { position: absolute; top: 9px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--ink); transition: transform 200ms var(--spring); }
.scrub__mark { position: absolute; top: 8px; width: 3px; height: 16px; margin-left: -1.5px; border-radius: 2px; background: var(--c); }
.ws-cursor { position: absolute; left: 0; top: 0; z-index: 9; pointer-events: none; transition: transform 60ms linear; }
.ws-cursor svg { display: block; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); }
.ws-cursor__pen { width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--c); }
.rp__who { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); white-space: nowrap; }

/* anti-cheat */
.ws-left { -webkit-user-select: none; user-select: none; }
.ws-guard { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 10px; background: var(--surface); font-size: 13px; font-weight: 500; color: var(--green); white-space: nowrap; transition: color var(--m) var(--ease), background var(--m) var(--ease); }
.ws-guard.is-warn { color: var(--yellow); background: var(--yellow-soft); }
.ws-guard.is-bad { color: var(--red); background: var(--red-soft); }
@media (max-width: 1180px) { .ws-guard span { display: none; } }
.verdict--flag { background: var(--yellow-soft); }
.verdict--flag .verdict__top { color: var(--yellow); }
.btn--primary.is-ok { background: var(--green); color: #0b0b0b; }
.btn--primary.is-flag { background: var(--yellow); color: #0b0b0b; }
.btn--primary.is-bad { background: var(--red); color: #fff; }
.btn--primary { transition: background 360ms var(--ease), color 360ms var(--ease), transform 120ms var(--ease), opacity var(--m) var(--ease); }
.btn[disabled].is-ok, .btn[disabled].is-flag { opacity: 1; }
.ws-msg { min-height: 100vh; display: grid; place-items: center; text-align: center; color: var(--ink-2); padding: 24px; }
.ws-msg p { margin: 0 0 16px; font-size: 16px; }
.rp__flags { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 12px; border-radius: 10px; background: var(--yellow-soft); color: var(--yellow); font-size: 13px; font-weight: 600; white-space: nowrap; }
.ws-clock .ph-duotone { color: var(--muted); }
.ws-clock.is-done { color: var(--green); }
.ws-clock.is-flag { color: var(--yellow); }
