#editor-root { --c: #7fe8ff; --gold: #ffd27a; --red: #ff5a7a; --grn: #7dffb2; --bg: #0b0f24; --tx: #e6ecff; --dim: #8fa0d0;
  --mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --code-fs: 13px; --code-lh: 20px; --code-pad-t: 8px; --code-pad-r: 40px; --code-pad-b: 40px; --code-pad-l: 10px;
  color: var(--tx); font-size: 15px; line-height: 1.45; overflow: hidden; overscroll-behavior: none; touch-action: manipulation;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
#editor-root * { box-sizing: border-box; }
.ed { position: absolute; inset: 0; display: flex; flex-direction: column; background: linear-gradient(160deg, #0b0f24 0%, #17103a 60%, #0b0f24 100%); animation: ed-pop .2s ease-out; }
.ed.wide { --code-fs: 14px; }
@media (pointer: coarse) { .ed, .ed.wide { --code-fs: 16px; --code-lh: 22px; } }
.ed::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 50; background: repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px); }
@keyframes ed-pop { 0% { transform: scale(.94); opacity: 0; } 70% { transform: scale(1.015); opacity: 1; } 100% { transform: scale(1); } }
.ed-bar { display: none; align-items: center; gap: 6px; padding: 4px 64px 4px 64px; min-height: 54px; }
.narrow .ed-bar { display: flex; }
.ed-tabs { display: flex; gap: 4px; flex: 1; min-width: 0; }
.ed-actions { display: flex; gap: 6px; flex: none; }
.ed-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 42% 1fr; gap: 8px; padding: 8px; }
.narrow .ed-body { display: flex; flex-direction: column; padding: 0 6px 6px; }
.ed-right { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }
.narrow .ed-right { display: contents; }
.pane { border: 3px solid var(--c); background: rgba(11,15,36,.88); box-shadow: 0 0 0 2px #0b0f24, 0 0 14px rgba(127,232,255,.25); min-height: 0; min-width: 0; display: flex; flex-direction: column; position: relative; }
.pane-code { flex: 1; }
.pane-console { flex: 0 0 36%; }
.narrow .pane { flex: 1; }
.narrow[data-tab=problem] .pane-code, .narrow[data-tab=problem] .pane-console,
.narrow[data-tab=code] .pane-problem, .narrow[data-tab=code] .pane-console,
.narrow[data-tab=result] .pane-problem, .narrow[data-tab=result] .pane-code { display: none; }
/* buttons */
.eb { font: inherit; font-weight: 700; color: var(--tx); min-height: 44px; min-width: 44px; padding: 0 12px; background: #1a2350; border: 3px solid var(--c);
  box-shadow: 0 4px 0 #05122a; cursor: pointer; transition: transform .08s, filter .12s, box-shadow .12s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.eb:hover, .eb:focus-visible { filter: brightness(1.25); box-shadow: 0 4px 0 #05122a, 0 0 12px var(--c); outline: none; }
.eb:active { transform: translateY(3px) scaleY(.94); box-shadow: 0 1px 0 #05122a; }
.eb[disabled] { opacity: .45; pointer-events: none; }
.eb.gold { background: var(--gold); color: #2a1a00; border-color: #fff1c0; box-shadow: 0 4px 0 #8a5a10; }
.eb.gold:hover, .eb.gold:focus-visible { box-shadow: 0 4px 0 #8a5a10, 0 0 14px var(--gold); }
.eb.tab { background: #121936; border-color: #3a4a8a; color: var(--dim); flex: 1; padding: 0 6px; }
.eb.tab.on { background: #1f2c66; border-color: var(--c); color: #fff; }
.eb.big { min-height: 54px; font-size: 1.2em; padding: 0 22px; }
.eb.glow { animation: ed-glow 1.2s ease-in-out infinite alternate; }
@keyframes ed-glow { from { box-shadow: 0 4px 0 #8a5a10, 0 0 6px var(--gold); } to { box-shadow: 0 4px 0 #8a5a10, 0 0 22px var(--gold); } }
.eb img { width: 22px; height: 22px; image-rendering: pixelated; }
/* problem */
.ed-head { padding: 8px 10px 6px 60px; border-bottom: 2px solid #26336e; min-height: 48px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.narrow .ed-head { padding-left: 10px; }
.badge { background: #2a1d5c; border: 2px solid #c792ea; color: #e5c9ff; padding: 1px 8px; font-size: .85em; }
.ed-title { font-size: 1.15em; color: var(--gold); font-weight: 700; text-shadow: 2px 2px 0 #000; }
.scroll { overflow: auto; flex: 1; min-height: 0; padding: 10px 12px 24px; -webkit-overflow-scrolling: touch; }
.scroll p { margin: 0 0 10px; }
.chip, .ed-mono { font-family: var(--mono); }
.chip { background: #1b2550; border: 1px solid #3a4a8a; padding: 0 5px; color: var(--c); font-size: .92em; }
.ed-h { margin: 14px 0 6px; font-size: 1em; color: var(--c); font-weight: 700; }
.ex { border: 2px solid #26336e; background: #0f1534; padding: 6px 10px; margin-bottom: 8px; font-size: .92em; }
.ex .lb { color: var(--dim); font-size: max(13px, .85em); }
.ex .v { font-family: var(--mono); color: var(--grn); white-space: pre-wrap; word-break: break-all; margin-bottom: 4px; }
.ex .n { color: var(--tx); }
.cons { margin: 0; padding-left: 20px; font-family: var(--mono); font-size: .9em; color: #c9d4ff; }
.hint-card { border: 2px solid #c792ea; background: radial-gradient(circle at 10% 20%, #2a1d5c, #121936 70%); padding: 8px 10px; margin-bottom: 8px; box-shadow: 0 0 10px rgba(199,146,234,.3); }
.hint-card .st { color: var(--gold); font-weight: 700; margin-right: 4px; }
.hint-pre { margin: 6px 0 0; font-family: var(--mono); font-size: .9em; white-space: pre-wrap; color: var(--grn); }
.hint-note { font-size: .85em; color: var(--dim); margin-top: 6px; }
/* toolbar + editor */
.ed-tool { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 2px solid #26336e; }
.wide .ed-tool { padding-right: 80px; }
.ed-tool .sp { flex: 1; }
.ed-scroll { flex: 1; min-height: 0; overflow: auto; background: #0a0d20; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.ed-inner { display: flex; min-height: 100%; min-width: 100%; width: max-content; }
/* gutter, highlight layer and textarea share ONE rule so metrics can never diverge */
.ed-gut, .ed-pre, .ed-ta {
  font-family: var(--mono); font-size: var(--code-fs); line-height: var(--code-lh); font-weight: 400; font-style: normal; font-variant-ligatures: none;
  letter-spacing: 0; word-spacing: 0; tab-size: 4; -moz-tab-size: 4; margin: 0; border: 0; border-width: 0;
  white-space: pre; word-wrap: normal; overflow-wrap: normal; word-break: normal; text-transform: none; text-indent: 0;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.ed-pre, .ed-ta { padding: var(--code-pad-t) var(--code-pad-r) var(--code-pad-b) var(--code-pad-l); }
.ed-gut { position: sticky; left: 0; z-index: 2; background: #0e1330; color: #4c5a96; text-align: right; padding: var(--code-pad-t) 8px var(--code-pad-b) 8px; min-width: 40px; border-right: 2px solid #26336e; user-select: none; -webkit-user-select: none; }
.ed-gut span { display: block; position: relative; height: var(--code-lh); }
.ed-gut span.err { color: var(--red); }
.ed-gut span.err::before { content: ""; position: absolute; left: -2px; top: calc(var(--code-lh) / 2 - 3px); width: 6px; height: 6px; background: var(--red); }
.ed-box { position: relative; flex: 1; min-width: 300px; }
.ed-pre { color: #d6defa; min-height: 100%; pointer-events: none; }
.ed-ta { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; outline: 0; resize: none; overflow: hidden; -webkit-appearance: none; appearance: none; border-radius: 0;
  background: transparent; color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--gold); }
.ed-ta::selection { background: rgba(127,232,255,.3); }
.ed-mark { position: absolute; left: 0; right: 0; height: var(--code-lh); border-bottom: 2px solid var(--red); background: rgba(255,90,122,.1); pointer-events: none; }
.tk-k { color: #c792ea; } .tk-t { color: #7fe8ff; } .tk-s { color: #c3e88d; } .tk-n { color: #f78c6c; }
.tk-c { color: #6a7aa6; font-style: italic; } .tk-f { color: #ffd27a; } .tk-m { color: #ffd27a; font-weight: 700; } .tk-p { color: #ff9ad5; }
/* console */
.ed-chead { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-bottom: 2px solid #26336e; }
.ed-chead .eb.tab { flex: none; padding: 0 12px; }
.ed-chead .sp { flex: 1; }
.cview { flex: 1; min-height: 0; overflow: auto; padding: 8px 12px; }
.verdict { font-size: 1.5em; font-weight: 700; text-shadow: 2px 2px 0 #000; }
.verdict.ok { color: var(--grn); } .verdict.bad { color: var(--red); } .verdict.warn { color: var(--gold); } .verdict.info { color: var(--c); }
.stats { display: flex; gap: 6px 16px; flex-wrap: wrap; color: #c9d4ff; font-size: .92em; margin: 2px 0 6px; }
.msg, .out { font-family: var(--mono); font-size: .9em; white-space: pre-wrap; word-break: break-all; background: #0f1534; border: 2px solid #26336e; padding: 4px 8px; margin: 4px 0; }
.msg { color: #ffb3c3; border-color: var(--red); }
.out.bad { border-color: var(--red); } .out.good { border-color: var(--grn); }
.lab { color: var(--dim); font-size: .85em; margin-top: 4px; }
.ctabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.ctabs .eb { min-height: 44px; font-size: .9em; padding: 0 10px; border-width: 2px; }
.ctabs .eb.okc { border-color: var(--grn); } .ctabs .eb.badc { border-color: var(--red); }
.spin-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; font-size: 1.15em; color: var(--c); }
.spin { width: 28px; height: 28px; border: 5px solid #26336e; border-top-color: var(--gold); animation: ed-spin .8s steps(8) infinite; }
@keyframes ed-spin { to { transform: rotate(360deg); } }
.idle { color: var(--dim); padding: 10px 0; }
.warnb { color: var(--red); font-weight: 700; margin: 4px 0; }
.rank { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border: 3px solid var(--gold); background: linear-gradient(135deg, #2a1d5c, #121936); padding: 8px 12px; margin-top: 8px; box-shadow: 0 0 16px rgba(255,210,122,.35); animation: ed-pop .3s ease-out; }
.rank .letter { font-size: 3.2em; font-weight: 900; line-height: 1; width: 64px; text-align: center; text-shadow: 3px 3px 0 #000; }
.rank .letter.S { color: #ffd27a; } .rank .letter.A { color: #dfe8ff; } .rank .letter.B { color: #e08a50; }
.rank .info { flex: 1; min-width: 160px; font-size: .92em; }
.rank .info .rule { font-size: .8em; color: var(--dim); margin-top: 2px; }
.rank .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.clab { display: block; margin-bottom: 4px; color: var(--c); font-family: var(--mono); font-size: .9em; }
.cta { width: 100%; font: 16px/24px var(--mono); color: var(--grn); background: #0a0d20; border: 2px solid #3a4a8a; padding: 6px 8px; resize: none; outline: none; white-space: pre; display: block; margin-top: 4px; border-radius: 0; -webkit-text-size-adjust: 100%; }
@media (pointer: fine) { .cta { font-size: 13px; } }
.cta:focus { border-color: var(--c); }
.cerr { color: var(--red); font-size: .9em; margin: 4px 0; white-space: pre-wrap; }
.modal { position: absolute; inset: 0; z-index: 60; background: rgba(5,6,16,.75); display: flex; align-items: center; justify-content: center; }
.modal .box { border: 3px solid var(--gold); background: #121936; padding: 16px 20px; max-width: 80%; text-align: center; animation: ed-pop .2s ease-out; }
.modal .row { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
