/* UniJudge — dùng biến màu của home.css + apps.css. */

/* ---------- Kho bài ---------- */
.uj-progress { display: grid; gap: 8px; min-width: 260px; }
.uj-progress-top { display: flex; align-items: baseline; gap: 8px; }
.uj-progress-top strong { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1; color: var(--fg-deep); }
.uj-progress-top span { color: var(--fg-muted); font-size: .85rem; }
.uj-meter { height: 3px; background: var(--border); overflow: hidden; }
.uj-meter span { display: block; height: 100%; background: var(--fg-deep); transition: width .4s var(--ease); }
.uj-progress-split { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--font-mono); font-size: .75rem; color: var(--fg-muted); }
.uj-filters { display: grid; grid-template-columns: minmax(180px, 2fr) repeat(4, minmax(120px, 1fr)) auto; gap: 12px; align-items: end; margin-bottom: 10px; }
.uj-reset { align-self: end; }
.uj-table td { padding-top: 11px; padding-bottom: 11px; }
.uj-table .num { color: var(--fg-muted); }
.prose .uj-title { border-bottom: 0; font-weight: 500; color: var(--fg-deep); }
.prose .uj-title:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.uj-topics { color: var(--fg-muted); font-size: .82rem; }
.uj-cf { color: var(--fg-muted); font-size: .76rem; font-family: var(--font-mono); white-space: nowrap; }
.uj-diff { font-size: .8rem; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.uj-diff-de { color: var(--ok); } .uj-diff-trung-binh { color: var(--warn); } .uj-diff-kho { color: var(--bad); }
.uj-solved { color: var(--ok); font-size: .8rem; display: inline-flex; align-items: center; gap: 6px; }
.uj-tried { color: var(--warn); font-size: .8rem; display: inline-flex; align-items: center; gap: 6px; }
.uj-note { margin-top: 16px; }

/* ---------- Không gian làm bài ---------- */
body.uj-ws-mode { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
body.uj-ws-mode .app-footer { display: none; }
body.uj-ws-mode main.app-main { flex: 1; min-height: 0; max-width: none; width: 100%; padding: 0 16px 12px; display: flex; }
body.uj-ws-mode .appbar-inner { max-width: none; padding: 0 16px; height: 48px; }
body.uj-ws-mode main.app-main { padding-top: 12px; }
.uj-workspace { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; width: 100%; }
.uj-topbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.app-body main .uj-ws-title { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
.uj-ws-title .muted-sm { font-family: var(--font-mono); font-size: .8rem; margin-right: 4px; }
.uj-topic-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.prose a.uj-back { border-bottom: 1px solid transparent; }
.prose a.uj-source { border-bottom: 1px solid var(--border); }

.uj-split { --uj-left: 46%; flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, var(--uj-left)) 12px minmax(0, 1fr); }
.uj-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg); overflow: hidden; }
.uj-left .uj-tabs { padding: 0 18px; flex: none; }
.uj-panel { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 22px 28px; max-width: none; font-size: .95rem; }
.app-body main .uj-panel h2 { margin: 28px 0 8px; font-family: var(--font-ui); font-size: .7rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-muted); }
.uj-md p:last-child { margin-bottom: 8px; }
.uj-md ul, .uj-md ol { padding-left: 1.3em; margin: 0 0 14px; }
.uj-md code, .uj-panel code { font-family: var(--font-mono); font-size: .84em; background: var(--surface-2); border: 1px solid var(--border); padding: 0 4px; border-radius: 3px; }
.uj-md pre, .uj-panel pre { margin: 0 0 14px; padding: 12px 14px; overflow-x: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); line-height: 1.55; font-size: .82rem; font-family: var(--font-mono); }
.uj-md pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.uj-md h3 { margin: 22px 0 6px; font-size: .95rem; color: var(--fg-deep); }
.uj-md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.uj-limits { margin: 0 0 8px; padding: 0; list-style: none; display: flex; gap: 24px; font-size: .88rem; }
.uj-limits strong { font-family: var(--font-mono); font-weight: 500; }
.uj-sample { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.uj-sample-head { display: flex; justify-content: space-between; align-items: center; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-muted); }
.uj-sample pre { margin: 4px 0 0; white-space: pre; }
.uj-spoiler { border: 1px dashed var(--border); border-radius: var(--radius-lg); padding: 18px; margin-top: 16px; }
.uj-code-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.uj-code-head .tabs { border-bottom: 0; }
pre.uj-code { white-space: pre; max-height: 60vh; overflow: auto; }

.uj-gutter { position: relative; touch-action: none; user-select: none; }
.uj-gutter::after { content: ""; position: absolute; border-radius: 2px; background: var(--border); transition: background-color .15s; }
.uj-gutter-v { cursor: col-resize; }
.uj-gutter-v::after { left: 5px; right: 5px; top: 42%; bottom: 42%; }
.uj-gutter-h { cursor: row-resize; flex: none; height: 9px; }
.uj-gutter-h::after { top: 3px; bottom: 4px; left: 44%; right: 44%; }
.uj-gutter:hover::after, .uj-gutter.dragging::after, .uj-gutter:focus-visible::after { background: var(--fg-deep); }

/* Thanh công cụ: nhập file + bảng trình biên dịch */
.uj-right { --uj-console: 40%; }
.uj-toolbar { display: grid; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.uj-file-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .82rem; }
.uj-file-hint { color: var(--fg); }
.uj-file-name { font-family: var(--font-mono); font-size: .75rem; }
.uj-lang-row { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 6px; }
.uj-lang-grid { display: flex; flex-wrap: wrap; gap: 2px 14px; }
.uj-lang-grid.is-locked { opacity: .5; pointer-events: none; }
.uj-lang-opt { background: none; border: 0; padding: 2px 0; font-family: var(--font-ui); font-size: .84rem; color: var(--fg-muted); cursor: pointer; border-bottom: 1px solid transparent; transition: color .15s, border-color .15s; }
.uj-lang-opt:hover { color: var(--fg-deep); }
.uj-lang-opt[aria-checked="true"] { color: var(--fg-deep); font-weight: 600; border-bottom-color: var(--fg-deep); }
.uj-compiler { font-size: .74rem; color: var(--fg-muted); white-space: nowrap; }
.uj-spacer { flex: 1; }
.uj-statusbar { flex: none; padding: 3px 12px; border-top: 1px solid var(--border); font-size: .74rem; }
.uj-status { margin: 0; font-family: var(--font-mono); font-size: .74rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uj-editor { flex: 1; min-height: 120px; overflow: hidden; }
.uj-editor-loading { padding: 12px; }
.uj-console { flex: 0 0 var(--uj-console); min-height: 90px; display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.uj-console-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.uj-console-head .tabs { border-bottom: 0; }
.uj-actions { display: flex; gap: 8px; padding: 6px 0; }
.uj-console-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; }
.uj-console-body .textarea { min-height: 140px; }

/* Kết quả: phẳng, chỉ một đường màu bên trái mang trạng thái */
.uj-results { display: grid; gap: 12px; }
.uj-results p { margin: 0; }
.uj-running { display: flex; align-items: center; gap: 10px; color: var(--fg-muted); font-size: .88rem; }
.uj-spinner { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--border); border-top-color: var(--fg-deep); animation: uj-spin .8s linear infinite; }
@keyframes uj-spin { to { transform: rotate(360deg); } }
.uj-verdict { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 18px; padding: 8px 0 8px 14px; border-left: 3px solid currentColor; }
.uj-verdict-main { display: flex; align-items: baseline; gap: 12px; }
.uj-verdict-code { font-family: var(--font-mono); font-size: 1.35rem; font-weight: 600; letter-spacing: .02em; }
.uj-verdict-main span { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; color: var(--fg-deep); }
.uj-verdict-stats { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: .8rem; color: var(--fg-muted); }
.uj-verdict-stats strong { font-family: var(--font-mono); font-weight: 500; color: var(--fg-deep); }
.uj-tone-ok { color: var(--ok); } .uj-tone-bad { color: var(--bad); } .uj-tone-warn { color: var(--warn); } .uj-tone-muted { color: var(--fg-muted); }
.uj-diag { margin: 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); font-size: .78rem; line-height: 1.55; overflow-x: auto; white-space: pre-wrap; font-family: var(--font-mono); color: var(--fg-deep); }
.uj-warn-box summary, .uj-case summary { cursor: pointer; font-size: .88rem; }
.uj-case { border-bottom: 1px solid var(--border); padding: 6px 0 10px; }
.uj-case[open] summary { margin-bottom: 8px; }
.uj-case-detail { color: var(--bad); font-size: .85rem; }
.uj-case-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.uj-case-grid .muted-sm { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.uj-case-grid pre { margin: 3px 0 0; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); font-size: .78rem; max-height: 180px; overflow: auto; font-family: var(--font-mono); }
.uj-test-table td, .uj-test-table th { padding: 6px 10px; }

/* ---------- CodeMirror: màu theo biến của site ---------- */
.uj-editor .cm-editor { height: 100%; background: var(--bg); color: var(--fg-deep); font-size: 14px; }
.uj-editor .cm-scroller { font-family: var(--font-mono); line-height: 1.6; font-size: 13.5px; }
.uj-editor .cm-gutters { background: var(--surface-2); color: var(--fg-muted); border-right: 1px solid var(--border); }
.uj-editor .cm-activeLine { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.uj-editor .cm-activeLineGutter { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--fg-deep); }
.uj-editor .cm-cursor { border-left-color: var(--fg-deep); }
.uj-editor .cm-selectionBackground, .uj-editor .cm-focused .cm-selectionBackground { background: color-mix(in srgb, var(--accent) 25%, transparent) !important; }
.uj-editor .cm-matchingBracket { background: color-mix(in srgb, var(--accent) 22%, transparent); outline: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); }
.uj-editor .cm-focused { outline: none; }
.uj-editor .cm-tooltip { background: var(--bg); border: 1px solid var(--border); color: var(--fg-deep); }
.uj-editor .cm-tooltip-autocomplete ul li[aria-selected] { background: var(--accent); color: var(--bg); }
.uj-editor .cm-panels { background: var(--surface-2); color: var(--fg-deep); }
.tok-keyword, .tok-controlKeyword, .tok-definitionKeyword, .tok-moduleKeyword, .tok-operatorKeyword { color: #a626a4; }
.tok-string, .tok-string2 { color: #50a14f; }
.tok-number, .tok-bool, .tok-atom { color: #b76b01; }
.tok-comment { color: #8a8a8a; font-style: italic; }
.tok-typeName, .tok-className { color: #0f7f8a; }
.tok-variableName.tok-definition, .tok-function { color: #4078f2; }
.tok-meta, .tok-processingInstruction { color: #c18401; }
.tok-propertyName { color: #986801; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tok-keyword, :root:not([data-theme="light"]) .tok-controlKeyword, :root:not([data-theme="light"]) .tok-definitionKeyword, :root:not([data-theme="light"]) .tok-moduleKeyword, :root:not([data-theme="light"]) .tok-operatorKeyword { color: #c678dd; }
  :root:not([data-theme="light"]) .tok-string, :root:not([data-theme="light"]) .tok-string2 { color: #98c379; }
  :root:not([data-theme="light"]) .tok-number, :root:not([data-theme="light"]) .tok-bool, :root:not([data-theme="light"]) .tok-atom { color: #d19a66; }
  :root:not([data-theme="light"]) .tok-typeName, :root:not([data-theme="light"]) .tok-className { color: #56b6c2; }
  :root:not([data-theme="light"]) .tok-variableName.tok-definition, :root:not([data-theme="light"]) .tok-function { color: #61afef; }
  :root:not([data-theme="light"]) .tok-meta, :root:not([data-theme="light"]) .tok-processingInstruction, :root:not([data-theme="light"]) .tok-propertyName { color: #e5c07b; }
}
:root[data-theme="dark"] .tok-keyword, :root[data-theme="dark"] .tok-controlKeyword, :root[data-theme="dark"] .tok-definitionKeyword, :root[data-theme="dark"] .tok-moduleKeyword, :root[data-theme="dark"] .tok-operatorKeyword { color: #c678dd; }
:root[data-theme="dark"] .tok-string, :root[data-theme="dark"] .tok-string2 { color: #98c379; }
:root[data-theme="dark"] .tok-number, :root[data-theme="dark"] .tok-bool, :root[data-theme="dark"] .tok-atom { color: #d19a66; }
:root[data-theme="dark"] .tok-typeName, :root[data-theme="dark"] .tok-className { color: #56b6c2; }
:root[data-theme="dark"] .tok-variableName.tok-definition, :root[data-theme="dark"] .tok-function { color: #61afef; }
:root[data-theme="dark"] .tok-meta, :root[data-theme="dark"] .tok-processingInstruction, :root[data-theme="dark"] .tok-propertyName { color: #e5c07b; }

/* ---------- Màn hình hẹp: xếp chồng hai khung ---------- */
@media (max-width: 900px) {
  .uj-filters { grid-template-columns: 1fr 1fr; }
  .uj-search { grid-column: 1 / -1; }
  .uj-col-topic { display: none; }
  body.uj-ws-mode { height: auto; overflow: visible; display: block; }
  body.uj-ws-mode main.app-main { display: block; padding: 0 12px 16px; }
  .uj-split { display: flex; flex-direction: column; gap: 12px; }
  .uj-gutter { display: none; }
  .uj-left { max-height: 70vh; }
  .uj-editor { flex: none; height: 55vh; }
  .uj-console { flex: none; min-height: 260px; }
  .uj-status { text-align: left; white-space: normal; }
}
@media (max-width: 520px) {
  .uj-filters { grid-template-columns: 1fr; }
  .uj-col-status { display: none; }
  .uj-sample { grid-template-columns: 1fr; }
  .uj-lang { min-width: 0; flex: 1 1 100%; }
  .uj-panel { padding: 4px 12px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .uj-spinner { animation-duration: 2s; }
}

