/* Thuật toán Canuc80k: phần riêng thêm trên ui/portal.css của lõi chung (tools/site-kit). */
.tag-adv { background: var(--accent-soft); color: var(--accent-ink); }
.row-end .tag { margin-top: 1px; }

/* bài tập */
.pr-head { margin-bottom: 18px; }
.pr-hint { margin: -1px 0 6px; font-size: 13.5px; line-height: 1.5; color: var(--text-2); text-wrap: pretty; }
.pr-hint code { font-size: 12.5px; }
.theory .plist-box { margin: 1.2em 0 1.6em; font-family: var(--sans); }
.theory .plist-box a { text-decoration: none; }
.theory .plist-box .pr-name { font-size: 15px; }
.theory .t-sec.is-problems .pr-list { border-top: 1px solid var(--line); }

/* trang đề */
.problem-head h1 { font-size: 34px; }
.problem-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.problem-actions .mark { margin-top: 0; justify-self: auto; }
.problem-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.problem-meta a { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); }
.problem-meta a:hover { color: var(--accent-ink); }
.problem-meta .i { width: 13px; height: 13px; }
.statement { max-width: 760px; }
.statement h3 { margin: 1.8em 0 .5em; font: 600 13px/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.statement > h3:first-child { margin-top: 0; }
.statement pre { white-space: pre-wrap; }
.sample { margin: 1.2em 0 1.8em; }
.sample-title { margin: 0 0 -.6em !important; font: 500 14px var(--sans); color: var(--text-2); }
.sample .hw-io { margin-bottom: .8em; }
.sample .hw-io pre { padding: 12px 14px; font: 13.5px/1.55 var(--mono); }
.sample-note { font-size: 15.5px; color: var(--text-2); }
.sample-note > :first-child::before { content: "Giải thích. "; font-weight: 600; color: var(--muted); }
.solution { max-width: 760px; margin-top: 28px; }
.solution summary .i { width: 16px; height: 16px; }
.solution .prose { margin-top: 12px; font-size: 16px; }
.solution .prose ul { padding-left: 1.1em; }

@media (max-width: 720px) {
  .problem-head h1 { font-size: 28px; }
}

.page-home .phase { grid-template-columns: 1fr auto 16px; padding-left: 8px; }

/* code dài: thu gọn, bấm để xem toàn bộ */
.theory figure.code.is-fold:not(.is-open) .code-body { max-height: 23.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 62%, transparent); mask-image: linear-gradient(#000 62%, transparent); }
.code-more { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; height: 34px; margin: 0; padding: 0; border: 0; border-top: 1px solid var(--line); background: var(--code-head); color: var(--accent-ink); font: 500 13px/1 var(--sans); cursor: pointer; }
.code-more:hover { background: var(--hover); }
.code-more .i { width: 14px; height: 14px; transform: rotate(90deg); transition: transform .15s; }
figure.code.is-open .code-more .i { transform: rotate(-90deg); }
figure.code.is-fold:not(.is-open) .code-more { margin-top: -1px; }
@media print { .code-more { display: none; } .theory figure.code.is-fold .code-body { max-height: none; -webkit-mask-image: none; mask-image: none; } }

/* hình tương tác (ui/viz.js) */
.fig.viz { outline: none; }
.viz-box { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.vz-ctl { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 18px; font: 13px/1.4 var(--sans); color: var(--muted); }
.vz-f { display: inline-flex; align-items: center; gap: 7px; }
.vz-f input[type=text], .vz-f input[type=number] { padding: 5px 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--text); font: 13px var(--mono); }
.vz-f input[type=number] { width: 5.6em; }
.vz-f input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.vz-f input[type=range] { width: 120px; accent-color: var(--accent); }
.vz-f output { min-width: 1.4em; font: 13px var(--mono); color: var(--text); }
.vz-btn { height: 28px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--text-2); font: 500 13px/1 var(--sans); cursor: pointer; }
.vz-btn:hover { background: var(--hover); }
.vz-btn.is-on { border-color: var(--accent); color: var(--accent-ink); }
.vz-stage { max-width: 100%; overflow-x: auto; touch-action: pan-y; }
.vz-svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.vz-grab { cursor: crosshair; touch-action: none; user-select: none; }
.vz-bar { width: min(100%, 640px); max-width: none !important; margin-top: 0; }
.vz-bar .vz-step svg { width: 14px; height: 14px; }
.vz-note { text-wrap: pretty; }
.vz-foot { max-width: 62ch; margin: 0; font: 14.5px/1.55 var(--sans); color: var(--text-2); text-align: center; text-wrap: pretty; }
.vz-foot b { color: var(--text); }
.vz-eq { color: var(--muted); }
.vz-err { font: 13px var(--sans); color: var(--muted); }
.vz-svg text { font-family: var(--mono); }
.vz-v { font-size: 15px; fill: var(--text); }
.vz-v.is-dim { fill: var(--faint); }
.vz-i { font-size: 11px; fill: var(--faint); }
.vz-lab { font: 13px var(--sans) !important; fill: var(--muted); }
.vz-strong { fill: var(--text); font-weight: 600; }
.vz-c { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.2; transition: fill .2s, stroke .2s; }
.vz-c.is-a { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.6; }
.vz-c.is-b { fill: color-mix(in srgb, var(--t-n) 16%, var(--surface)); stroke: var(--t-n); stroke-width: 1.6; }
.vz-c.is-g { fill: color-mix(in srgb, var(--t-s) 16%, var(--surface)); stroke: var(--t-s); stroke-width: 1.6; }
.vz-c.is-dim { fill: transparent; stroke-dasharray: 3 3; }
rect.vz-span.is-b { fill: var(--t-n); stroke: none; opacity: .85; }
rect.vz-span.is-g { fill: var(--t-s); stroke: none; opacity: .85; }
.vz-lab.is-b, .vz-foot .is-b { fill: var(--t-n); color: var(--t-n); }
.vz-lab.is-g, .vz-foot .is-g { fill: var(--t-s); color: var(--t-s); }
.vz-lab.is-a { fill: var(--accent-ink); }
.vz-foot .is-k { color: var(--t-k); }
.vz-ln { stroke: var(--line-strong); stroke-width: 1.4; fill: none; }
.vz-br { stroke: var(--muted); stroke-width: 1.4; fill: none; }
path.vz-br.is-a { stroke: var(--accent); }
.vz-arc { fill: none; stroke-width: 1.8; }
.vz-arc.is-b, .vz-arrow.is-b { stroke: var(--t-n); }
.vz-arrow { fill: none; stroke-width: 1.8; marker-end: none; }
.vz-frame { fill: none; stroke-width: 2.2; }
.vz-frame.is-b { stroke: var(--t-n); }
.vz-frame.is-g { stroke: var(--t-s); stroke-dasharray: 6 4; }
.vz-frame.is-k { stroke: var(--t-k); stroke-dasharray: 2 4; }
@media print { .vz-ctl, .vz-bar { display: none !important; } }
.vz-svg { --vz-warn: #a87a22; --vz-bad: #b23c2c; }
:root[data-theme="dark"] .vz-svg { --vz-warn: #d4a548; --vz-bad: #e0705e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .vz-svg { --vz-warn: #d4a548; --vz-bad: #e0705e; } }
rect.vz-track { fill: var(--hover); stroke: none; }
rect.vz-span.is-a { fill: var(--vz-warn); stroke: none; }
rect.vz-span.is-r { fill: var(--vz-bad); stroke: none; }
.vz-lab.is-r { fill: var(--vz-bad); }
.vz-lab.is-a { fill: var(--vz-warn); }
.vz-dash { stroke-dasharray: 4 4; }
.vz-bulb { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.4; }
.vz-bulb.is-on { fill: #e9b949; stroke: #b98a1e; }
.vz-bulb.is-sq { stroke: var(--accent); stroke-width: 3; }
.vz-i.vz-even { fill: var(--muted); }
.vz-arc.is-a { stroke: var(--accent); } .vz-arc.is-g { stroke: var(--t-s); }
.vz-arc.is-faint { stroke: var(--line-strong); stroke-width: 1.2; }
.vz-dot { fill: var(--text); } .vz-dot.is-r { fill: var(--vz-bad); }
.vz-click { cursor: pointer; user-select: none; }
.vz-sq { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.vz-sq.is-dk { fill: color-mix(in srgb, var(--t-n) 22%, var(--surface)); }
.vz-hole { fill: none; stroke: var(--line-strong); stroke-width: 1.2; stroke-dasharray: 3 3; }
.vz-domino { fill: color-mix(in srgb, var(--accent) 20%, transparent); stroke: var(--accent); stroke-width: 1.8; }
.vz-paint { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.vz-paint.is-r { fill: color-mix(in srgb, #c0453a 70%, var(--surface)); }
.vz-paint.is-bl { fill: color-mix(in srgb, var(--t-n) 70%, var(--surface)); }
.vz-paint.is-last { stroke: var(--text); stroke-width: 2.2; }
path.vz-arrow { stroke-width: 1.6; }
.vz-v.vz-sm { font-size: 11px; }
.vz-iv { fill: color-mix(in srgb, var(--muted) 18%, var(--surface)); stroke: var(--line-strong); stroke-width: 1.2; }
.vz-iv.is-a { fill: color-mix(in srgb, var(--accent) 30%, var(--surface)); stroke: var(--accent); }
.vz-iv.is-b { fill: color-mix(in srgb, var(--t-n) 28%, var(--surface)); stroke: var(--t-n); }
.vz-iv.is-g { fill: color-mix(in srgb, var(--t-s) 30%, var(--surface)); stroke: var(--t-s); }
.vz-iv.is-k { fill: color-mix(in srgb, var(--vz-warn) 30%, var(--surface)); stroke: var(--vz-warn); }
.vz-iv.is-r { fill: color-mix(in srgb, var(--vz-bad) 28%, var(--surface)); stroke: var(--vz-bad); }
.vz-iv.is-dim { fill: transparent; stroke-dasharray: 3 3; }
.vz-grid { stroke: var(--line); stroke-width: 1; }
.vz-node { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
.vz-node.is-a { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.vz-node.is-b { fill: color-mix(in srgb, var(--t-n) 16%, var(--surface)); stroke: var(--t-n); }
.vz-node.is-g { fill: color-mix(in srgb, var(--t-s) 16%, var(--surface)); stroke: var(--t-s); }
.vz-node.is-dim { fill: transparent; stroke-dasharray: 3 3; }
.vz-ln.is-a { stroke: var(--accent); stroke-width: 2; }
.vz-ln.is-b { stroke: var(--t-n); stroke-width: 2; }
.vz-ln.is-g { stroke: var(--t-s); stroke-width: 2; }
.vz-iv.is-faded { opacity: .35; }
.vz-sq.is-hit { fill: color-mix(in srgb, var(--vz-warn) 13%, var(--surface)); }
.vz-sq.is-dk.is-hit { fill: color-mix(in srgb, var(--vz-warn) 22%, color-mix(in srgb, var(--t-n) 22%, var(--surface))); }
.vz-sq.is-dead { fill: color-mix(in srgb, var(--vz-bad) 22%, var(--surface)); }
.vz-sq.is-first { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.vz-queen { fill: var(--accent); stroke: none; }
.vz-queen.is-win { fill: var(--t-s); }
.vz-qt { font: 600 14px var(--sans) !important; fill: #fff; }
.vz-domino.is-win { fill: color-mix(in srgb, var(--t-s) 26%, transparent); stroke: var(--t-s); }
.vz-c.is-r { fill: color-mix(in srgb, var(--vz-bad) 18%, var(--surface)); stroke: var(--vz-bad); stroke-width: 1.6; }
.vz-strike { stroke: var(--faint); stroke-width: 1.3; }
.vz-band { fill: color-mix(in srgb, var(--t-n) 10%, transparent); stroke: none; }
.vz-pt { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; }
.vz-pt.is-in { fill: var(--muted); }
.vz-pt.is-a { fill: var(--accent); stroke: var(--accent); }
.vz-pt.is-b { fill: var(--t-n); stroke: var(--t-n); }
.vz-ln.vz-thick { stroke-width: 3; }
.vz-sq.is-hole { fill: var(--text); }
.vz-frame.is-a { stroke: var(--accent); }
.vz-c.is-k { fill: color-mix(in srgb, var(--vz-warn) 16%, var(--surface)); stroke: var(--vz-warn); stroke-width: 1.6; }
.vz-node.is-end { fill: color-mix(in srgb, var(--t-s) 22%, var(--surface)); }
.vz-ring { fill: none; stroke: var(--t-s); stroke-width: 1.6; }
