/* 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; padding: 12px 12px 12px 14px; }
.page-home .phase-body { gap: 2px; }
.page-home .phase-text { font-size: 14px; color: var(--muted); }
.page-home .phase-meta { display: flex; align-items: center; gap: 12px; padding-top: 0; }
.page-home .phase-meta .i { color: var(--faint); opacity: 0; transition: opacity .15s; }
.page-home .phase:hover .phase-meta .i { opacity: 1; }

/* 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; }
.vz-frame.is-r { stroke: var(--vz-bad); stroke-dasharray: 3 3; }
.vz-water { fill: color-mix(in srgb, var(--t-n) 55%, transparent); stroke: none; }
.vz-graph { cursor: grab; touch-action: none; user-select: none; }
.vz-graph:active { cursor: grabbing; }
.vz-edge { stroke-width: 1.6; }
.vz-wt { font: 12px var(--mono); fill: var(--muted); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.vz-ntag { font: 600 12px var(--mono); fill: var(--accent-ink); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.vz-ahead { fill: var(--line-strong); }
.vz-ln.is-r { stroke: var(--vz-bad); stroke-width: 2.4; }
.vz-wall { fill: var(--text); opacity: .75; }
.vz-ln.is-faint { stroke: var(--line); opacity: .7; }
.vz-node.vz-k0 { fill: color-mix(in srgb, #2f6587 30%, var(--surface)); }
.vz-node.vz-k1 { fill: color-mix(in srgb, #4d7337 32%, var(--surface)); }
.vz-node.vz-k2 { fill: color-mix(in srgb, #c2603e 30%, var(--surface)); }
.vz-node.vz-k3 { fill: color-mix(in srgb, #a87a22 32%, var(--surface)); }
.vz-node.vz-k4 { fill: color-mix(in srgb, #7a4f9a 30%, var(--surface)); }
.vz-node.vz-k5 { fill: color-mix(in srgb, #3d8a86 30%, var(--surface)); }
.vz-node.vz-ring2 { stroke: var(--accent); stroke-width: 3; }
.vz-iv.vz-k0 { fill: color-mix(in srgb, #2f6587 45%, var(--surface)); stroke: #2f6587; }
.vz-iv.vz-k1 { fill: color-mix(in srgb, #4d7337 45%, var(--surface)); stroke: #4d7337; }
.vz-iv.vz-k2 { fill: color-mix(in srgb, #c2603e 45%, var(--surface)); stroke: #c2603e; }
.vz-iv.vz-k3 { fill: color-mix(in srgb, #a87a22 45%, var(--surface)); stroke: #a87a22; }
.vz-iv.vz-k4 { fill: color-mix(in srgb, #7a4f9a 45%, var(--surface)); stroke: #7a4f9a; }
.vz-iv.vz-k5 { fill: color-mix(in srgb, #3d8a86 45%, var(--surface)); stroke: #3d8a86; }
.vz-pt.is-g { fill: var(--t-s); stroke: var(--t-s); }
.vz-pt.is-r { fill: var(--vz-bad); stroke: var(--vz-bad); }
.vz-dot.is-faint { fill: var(--line-strong); }
.vz-arc.vz-thick { stroke-width: 3; }
.vz-c.is-faded, .vz-v.is-faded { opacity: .38; }
.vz-ln.vz-k0-s { stroke: #2f6587; stroke-width: 2; } .vz-svg .vz-k0-t, .vz-v.vz-k0-t { fill: #2f6587; }
.vz-ln.vz-k1-s { stroke: #4d7337; stroke-width: 2; } .vz-svg .vz-k1-t, .vz-v.vz-k1-t { fill: #4d7337; }
.vz-ln.vz-k2-s { stroke: #c2603e; stroke-width: 2; } .vz-svg .vz-k2-t, .vz-v.vz-k2-t { fill: #c2603e; }
.vz-ln.vz-k3-s { stroke: #a87a22; stroke-width: 2; } .vz-svg .vz-k3-t, .vz-v.vz-k3-t { fill: #a87a22; }
.vz-ln.vz-k4-s { stroke: #7a4f9a; stroke-width: 2; } .vz-svg .vz-k4-t, .vz-v.vz-k4-t { fill: #7a4f9a; }
.vz-ln.vz-k5-s { stroke: #3d8a86; stroke-width: 2; } .vz-svg .vz-k5-t, .vz-v.vz-k5-t { fill: #3d8a86; }
.vz-trace { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; text-align: left; width: 100%; }
.vz-src { flex: 1 1 300px; min-width: 0; margin: 0; padding: 6px 0; border: 1px solid var(--line); border-radius: 8px; background: var(--code-head); font: 12.5px/1.6 var(--mono); overflow-x: auto; }
.vz-cl { display: flex; white-space: pre; padding-right: 12px; }
.vz-cl i { flex: none; width: 2.6em; padding-right: .9em; text-align: right; font-style: normal; color: var(--faint); user-select: none; }
.vz-cl code { font: inherit; background: none; padding: 0; }
.vz-cl.is-on { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.vz-side { flex: 0 1 210px; min-width: 170px; display: flex; flex-direction: column; gap: 8px; }
.vz-scope { padding: 6px 10px 8px; border: 1px solid var(--line); border-radius: 8px; font: 13px/1.5 var(--mono); }
.vz-scope.is-top { border-color: var(--t-n); }
.vz-sn { margin-bottom: 3px; font: 500 12px/1.4 var(--sans); color: var(--muted); }
.vz-scope table { width: 100%; border-collapse: collapse; }
.vz-scope th { width: 1%; padding: 1px 12px 1px 0; text-align: left; font-weight: 600; white-space: nowrap; vertical-align: top; }
.vz-scope td { padding: 1px 0; }
.vz-scope tr.is-ch td { color: var(--accent-ink); font-weight: 700; }
.vz-scope.vz-screen pre { margin: 0; padding: 0; background: none; border: 0; font: 13px/1.5 var(--mono); white-space: pre-wrap; min-height: 1.5em; }
.vz-empty { font: 12px var(--sans); color: var(--faint); }
.vz-arr { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.vz-ai { display: inline-flex; flex-direction: column; align-items: center; min-width: 2em; padding: 0 3px 1px; border: 1px solid var(--line); border-radius: 4px; }
.vz-ai i { font-style: normal; font-size: 9px; line-height: 1.3; color: var(--faint); }
.vz-ai.is-on { border-color: var(--accent); background: var(--accent-soft); }
.vz-leap { fill: color-mix(in srgb, var(--t-s) 20%, var(--surface)); stroke: var(--t-s); stroke-width: 1.5; }
.vz-scope th, .vz-scope td { background: none; border: 0; min-width: 0; }
.vz-scope th { width: auto; padding-right: 14px; }
.vz-scope td { width: 100%; }

/* Đọc thêm: tên tài liệu, nguồn nhỏ bên cạnh, một dòng mô tả bên dưới */
.theory .t-sec.is-read ul { margin: 1em 0 0; padding: 0; list-style: none; }
.theory li.ref { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; row-gap: 3px; margin: 0; padding: 14px 4px; border-top: 1px solid var(--line); }
.theory li.ref:last-child { border-bottom: 1px solid var(--line); }
.theory li.ref::marker { content: none; }
.theory .ref-link { color: var(--text); font: 500 16.5px/1.45 var(--serif); text-decoration: none; }
.theory .ref-link:hover { color: var(--accent-ink); text-decoration: underline; text-decoration-color: currentColor; text-underline-offset: 3px; }
.theory .ref-src { align-self: center; padding: 1px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font: 500 12px/1.5 var(--sans); white-space: nowrap; }
.theory .ref-desc { grid-column: 1 / -1; color: var(--muted); font: 14.5px/1.55 var(--sans); text-wrap: pretty; }
@media (max-width: 640px) { .theory li.ref { grid-template-columns: 1fr; } .theory .ref-src { justify-self: start; } }

/* đoạn code của từng bước trong lời giải: gọn hơn khối code đầy đủ */
.theory figure.t-code.is-part { margin: 1em 0 1.3em; background: transparent; }
.theory figure.t-code.is-part .code-head { display: none; }
.theory figure.t-code.is-part .code-body { padding: 12px 18px; font-size: 13.5px; }
.theory figure.t-code.is-full .code-name { font: 500 13px var(--sans); color: var(--text-2); }

/* tiêu đề một ví dụ trong bài: nhãn nhỏ, tên bài bằng chữ có chân */
.theory h3.ex-head { margin: 2.8em 0 .9em; font: 500 20px/1.35 var(--serif); }
.theory h3.ex-head .ex-kicker { display: block; margin-bottom: 4px; font: 600 11.5px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
.theory h3.ex-head a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-decoration-thickness: 1px; text-underline-offset: 4px; }
.theory h3.ex-head a:hover { color: var(--accent-ink); text-decoration-color: currentColor; }
.vz-expr { padding: 18px 8px 10px; font: 500 22px/1.6 var(--mono); color: var(--text); text-align: center; white-space: pre-wrap; }
.vz-expr.is-done { color: var(--t-s); }
.vz-xh { padding: 2px 6px; border-radius: 6px; background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.vz-xn { color: var(--accent-ink); font-weight: 700; }
.vz-xs { opacity: .4; text-decoration: line-through; text-decoration-thickness: 1.5px; }
.viz, .viz * { font-variant-ligatures: none !important; font-feature-settings: "liga" 0, "calt" 0 !important; }
.pr-go.is-off, .btn.is-off { color: var(--faint); cursor: default; pointer-events: none; }
.vz-trace.is-stack .vz-src { flex-basis: 100%; }
.vz-trace.is-stack .vz-side { flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; }
.vz-trace.is-stack .vz-side > .vz-scope { flex: 1 1 200px; }
.row-body:has(.row-vi) { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; }
.row-vi { font-size: 14px; color: var(--muted); font-weight: 400; }
