/* Ruang CAT V2 — approved Claude visual contract, system-font fallback. */
:root {
  --bg-canvas: #FFF6E0;
  --surface-paper: #FFFFFF;
  --surface-muted: #F3EBDD;
  --surface-tint: #FFF9EC;
  --pastel-lavender: #B8A1FF;
  --pastel-mint: #CCFF4D;
  --pastel-peach: #FFB74D;
  --pastel-blue: #7DD3FC;
  --pastel-butter: #FFF0A8;
  --text-primary: #14110F;
  --text-secondary: #514A43;
  --text-muted: #6B6258;
  --text-on-accent: #14110F;
  --accent: #CCFF4D;
  --accent-hover: #B8ED36;
  --accent-soft: #E8FFAC;
  --accent-ink: #14110F;
  --accent-ring: #B8A1FF;
  --border-hairline: rgba(20, 17, 15, .24);
  --border-strong: #14110F;
  --success-bg: #CFF4DD;
  --success-text: #12593A;
  --success-border: #2BB673;
  --warning-bg: #FFE2AE;
  --warning-text: #5B3900;
  --warning-border: #FFB74D;
  --danger-bg: #FFD5D9;
  --danger-text: #71131D;
  --danger-border: #FF4D5E;
  --info-bg: #D7F1FE;
  --info-text: #173F56;
  --info-border: #7DD3FC;
  --radius-sm: 14px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-pill: 99px;
  --max-width: 960px;
  --reading-width: 640px;
  --font-display: "Bricolage Grotesque", "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-sans: "Bricolage Grotesque", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --shadow-xs: 3px 3px 0 #14110F;
  --shadow-glass: 4px 4px 0 #14110F;
  --shadow-sheet: 8px 8px 0 #14110F;
}

[data-theme="dark"] {
  --bg-canvas: #17131F;
  --surface-paper: #251E33;
  --surface-muted: #302740;
  --surface-tint: #2B2339;
  --text-primary: #F6F1E6;
  --text-secondary: #D2CADB;
  --text-muted: #A79FB5;
  --border-hairline: rgba(246, 241, 230, .24);
  --border-strong: #F6F1E6;
  --accent-ink: #14110F;
  --shadow-xs: 3px 3px 0 #08060B;
  --shadow-glass: 4px 4px 0 #08060B;
  --shadow-sheet: 8px 8px 0 #08060B;
}

html { scroll-padding-top: 92px; }
body {
  line-height: 1.5;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(circle, currentColor 1.25px, transparent 1.35px);
  background-size: 22px 22px;
  background-attachment: fixed;
  background-blend-mode: soft-light;
}

body, button, input, select, textarea { font-family: var(--font-sans); }
button, input, select, textarea, .reading-surface, .soft-surface, .path-tile { min-width: 0; }
:focus-visible { outline: 3px solid #B8A1FF; outline-offset: 3px; }

.main-content { padding: 22px 18px calc(112px + env(safe-area-inset-bottom, 0px)); }
.page-title, .home-hero__title, .path-tile__title, .result-score-big, .result-reaction {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -.03em;
}
.page-title { font-size: clamp(2.125rem, 7vw, 3.5rem); line-height: .98; }
.page-subtitle { font-size: 16px; color: var(--text-secondary); }
.kicker, .st { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.st { display: inline-flex; padding: 8px 15px; border: 3px solid var(--text-primary); border-radius: 99px; background: #FFB74D; color: #14110F; transform: rotate(-3deg); }

.glass-surface, .glass-surface--strong {
  background: var(--surface-paper);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 3px solid var(--text-primary);
  box-shadow: var(--shadow-glass);
}
.reading-surface, .soft-surface, .bx {
  background: var(--surface-paper);
  border: 3px solid var(--text-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
}

.top-nav { padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 8px; }
.top-nav__inner { min-height: 58px; padding: 6px 10px 6px 16px; border-radius: 20px; flex-wrap: wrap; }
.brand { min-height: 44px; padding: 0 12px; border: 3px solid #14110F; border-radius: 12px; background: #CCFF4D; color: #14110F; box-shadow: 3px 3px 0 #14110F; }
.brand__name { font-size: 18px; font-weight: 800; }
.brand-credit { font-size: 11px; font-weight: 700; color: var(--text-secondary); text-decoration: underline; text-underline-offset: 3px; }
.desktop-nav { gap: 6px; }
.nav-pill { min-height: 44px; padding: 0 15px; border: 2px solid transparent; font-weight: 800; }
.nav-pill.is-active { background: #B8A1FF; border-color: #14110F; color: #14110F; }
.icon-btn { border: 3px solid var(--text-primary); background: var(--surface-muted); color: var(--text-primary); }

.bottom-nav { padding: 8px 14px calc(12px + env(safe-area-inset-bottom, 0px)); }
.bottom-nav__inner { border-radius: 22px; }
.bottom-nav__item { min-height: 54px; border-radius: 15px; font-weight: 800; }
.bottom-nav__item.is-active { background: #CCFF4D; color: #14110F; outline: 2px solid #14110F; }

.btn, .exam-action-btn {
  min-height: 44px;
  border: 3px solid var(--text-primary);
  border-radius: 14px;
  font-weight: 800;
  box-shadow: 3px 3px 0 var(--text-primary);
}
.btn:hover:not(:disabled), .exam-action-btn:hover:not(:disabled), .path-tile:hover { transform: translate(-1px, -1px); }
.btn:active:not(:disabled), .exam-action-btn:active:not(:disabled), .path-tile:active { transform: translate(3px, 3px); box-shadow: none; }
.btn--primary, .exam-action-btn--primary { background: #CCFF4D; color: #14110F; }
.btn--soft { background: #B8A1FF; color: #14110F; }
.btn--ghost { background: var(--surface-paper); color: var(--text-primary); }
.btn--danger { background: #FF8A96; color: #14110F; }
.btn--text { font-weight: 800; color: var(--text-primary); }
.field-line, .field-input, select {
  min-height: 44px;
  padding: 10px 13px;
  border: 3px solid var(--text-primary);
  border-radius: 14px;
  background: var(--surface-paper);
}
.field-line:focus { border-color: var(--text-primary); box-shadow: 4px 4px 0 #B8A1FF; }
.tag { padding: 6px 10px; border: 2px solid currentColor; border-radius: 99px; }
.tab-bar { gap: 8px; border: 0; }
.tab-btn { padding: 8px 13px; border: 2px solid var(--text-primary); border-radius: 99px; background: var(--surface-paper); color: var(--text-primary); }
.tab-btn.is-active { background: #CCFF4D; color: #14110F; }
.tab-btn.is-active::after { display: none; }

.home-editorial { gap: 34px; padding-top: 12px; }
.home-hero { gap: 26px; }
.home-hero__title { margin-top: 18px; font-size: clamp(3rem, 11vw, 6.5rem); line-height: .92; }
.home-hero__title mark { padding: 0 .08em; background: #FF8FD0; color: #14110F; transform: rotate(-2deg); display: inline-block; }
.home-hero__title span { position: relative; display: inline-block; }
.home-hero__title span::after { content: ""; position: absolute; left: 2%; right: 0; bottom: -.09em; height: .11em; background: #CCFF4D; border: 2px solid #14110F; transform: rotate(-2deg); z-index: -1; }
.home-hero__lead { font-size: 18px; line-height: 1.6; max-width: 50ch; }
.home-note { padding: 22px; background: #FFFFFF; color: #14110F; transform: rotate(1deg); }
.home-note__quote { margin: 12px 0 18px; font-size: 20px; line-height: 1.45; font-weight: 700; color: #14110F; }
.home-note__foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; color: #514A43; }
.home-note .kicker, .home-note .btn--text { color: #14110F; }
/* Theme foreground and background must switch together, not cross-fade through low contrast. */
body { transition: none; }
.home-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.home-stats .bx { padding: 18px; }
.home-stats strong { display: block; font-size: clamp(2rem, 8vw, 3.6rem); line-height: 1; }
.home-stats strong span { font-size: .45em; color: var(--text-muted); }
.home-stats p { margin-top: 8px; color: var(--text-secondary); }
.path-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.path-tile { min-height: 220px; padding: 22px; border: 3px solid #14110F; border-radius: 26px; box-shadow: 6px 6px 0 #14110F; color: #14110F; display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: start; text-align: left; }
.go-tile--sky { background: #7DD3FC; }
.go-tile--pink { background: #FF8FD0; }
.go-tile--lime { background: #CCFF4D; }
.path-tile__num { width: 44px; height: 44px; display: grid; place-items: center; border: 3px solid #14110F; border-radius: 99px; background: #FFF6E0; color: #14110F; font: 800 16px var(--font-sans); }
.path-tile__title { margin: 0; font-size: clamp(2rem, 8vw, 2.75rem); line-height: 1; }
.path-tile__desc { margin-top: 12px; color: #2A2521; font-size: 16px; }
.home-colophon { border-top: 3px solid var(--text-primary); }

.syllabus-list { gap: 12px; border: 0; }
.syllabus-row { padding: 17px; border: 3px solid var(--text-primary); border-radius: 18px; background: var(--surface-paper); box-shadow: 3px 3px 0 var(--text-primary); }
.syllabus-row:hover { background: var(--pastel-blue); color: #14110F; }
.syllabus-row__title { font-size: 18px; font-weight: 800; }
.module-reader { max-width: 960px; }
.lesson-section { border-top: 3px solid var(--text-primary); }
.lesson-section-title h2, .lesson-section-title h3 { font-weight: 800; }
.lesson-formula { border: 3px solid var(--text-primary); border-left-width: 8px; border-radius: 14px; background: #B8A1FF; color: #14110F; }
.lesson-preview, .lesson-feedback { border: 3px solid var(--text-primary); box-shadow: 3px 3px 0 var(--text-primary); }
.lesson-diagram { border: 3px solid #14110F; }

.option-card { padding: 18px; border: 3px solid var(--text-primary); border-radius: 18px; box-shadow: 3px 3px 0 var(--text-primary); }
.option-card.is-selected { background: #CCFF4D; border-color: #14110F; color: #14110F; }
.setup-grid { min-width: 0; }
.question-card { padding: 22px; }
.question-stem { font-size: clamp(1.25rem, 4.4vw, 2.125rem); line-height: 1.4; font-weight: 700; }
.answer-opt { min-height: 52px; padding: 13px 14px; border: 3px solid var(--text-primary); border-radius: 16px; }
.answer-opt.is-selected { background: #B8A1FF; color: #14110F; border-color: #14110F; }
.answer-opt.is-correct { background: #8EE6B5; color: #102A1B; border-color: #14110F; }
.answer-opt.is-wrong { background: #FF9AA4; color: #3A080E; border-color: #14110F; }
.answer-opt__key { border: 2px solid currentColor; background: transparent; }
.feedback-panel { border: 3px solid var(--text-primary); border-left-width: 8px; border-radius: 16px; }
.q-dot { min-height: 44px; border: 2px solid var(--text-primary); }
.q-dot.is-answered { background: #CCFF4D; color: #14110F; }
.q-dot.is-flagged { background: #FFB74D; color: #14110F; }
.q-dot.is-current { box-shadow: 0 0 0 3px #B8A1FF; }

body.exam-focus-mode { background: #17131F; color: #F6F1E6; }
body.exam-focus-mode .main-content { max-width: 1120px; }
body.exam-focus-mode .exam-topbar, body.exam-focus-mode .question-card, body.exam-focus-mode .grid-panel, body.exam-focus-mode .exam-bottom-bar__inner {
  background: #251E33; color: #F6F1E6; border-color: #F6F1E6; box-shadow: 4px 4px 0 #08060B;
}
body.exam-focus-mode .question-meta { border-color: rgba(246,241,230,.28); }
body.exam-focus-mode #exam-theme-btn { background:#2B2339; color:#F6F1E6; border-color:#F6F1E6; }
body.exam-focus-mode .question-stem, body.exam-focus-mode .answer-opt__text { color: #F6F1E6; }
body.exam-focus-mode .answer-opt { background: #2B2339; color: #F6F1E6; border-color: #6E617D; }
body.exam-focus-mode .answer-opt.is-selected { background: #B8A1FF; color: #14110F; border-color: #F6F1E6; }
body.exam-focus-mode .answer-opt.is-selected .answer-opt__text { color: #14110F; }
body.exam-focus-mode .exam-action-btn { background: #2B2339; color: #F6F1E6; border-color: #F6F1E6; box-shadow: 3px 3px 0 #08060B; }
body.exam-focus-mode .exam-action-btn--primary { background: #CCFF4D; color: #14110F; }
body.exam-focus-mode .q-dot { background: #2B2339; color: #F6F1E6; border-color: #A79FB5; }
body.exam-focus-mode .q-dot.is-answered { background: #CCFF4D; color: #14110F; }
body.exam-focus-mode .q-dot.is-flagged { background: #FFB74D; color: #14110F; }
body.exam-focus-mode .exam-timer { background: #17131F; color: #F6F1E6; border: 2px solid #F6F1E6; }

.result-editorial-hero { padding: 26px; border: 3px solid #14110F; border-radius: 26px; background: #FFF6E0; color: #14110F; box-shadow: 8px 8px 0 #14110F; }
.result-editorial-hero .result-score-big { font-size: clamp(4.2rem, 18vw, 8rem); color: #6752A3; -webkit-text-stroke: 3px #14110F; paint-order: stroke fill; text-shadow: 8px 8px 0 #14110F; }
.result-editorial-hero .kicker { color: #615746; }
.result-score-max { font-size: 18px; color: #51493D; font-weight: 700; }
.result-score-meta { margin-top: 10px; font-size: 14.5px; color: #51493D; }
.result-editorial-hero .result-reaction { color: #14110F; font-size: clamp(1.55rem, 4vw, 2.45rem); }
.result-editorial-hero .btn--ghost { background: #251E33; color: #F6F1E6; border-color: #14110F; }
.result-editorial-hero .btn--text { color: #14110F; }
.result-quote, .result-quote-meaning { color: #332A4B; }
.result-quote-meaning { margin-top: 6px; font-size: 14px; }
.subtest-strip { border: 3px solid var(--text-primary); box-shadow: 4px 4px 0 var(--text-primary); }
.subtest-cell { border-color: var(--text-primary); }
.topic-bar-track { height: 9px; border: 2px solid var(--text-primary); }
.topic-bar-fill { background: #CCFF4D; }
.review-item { border-bottom: 3px solid var(--text-primary); }

.modal-root { background: rgba(10, 8, 12, .72); }
.modal-card { max-width: 620px; border: 3px solid var(--text-primary); border-radius: 22px; box-shadow: var(--shadow-sheet); }
.toast { border: 3px solid #14110F; border-radius: 14px; background: #CCFF4D; color: #14110F; box-shadow: 4px 4px 0 #14110F; }
.share-preview-canvas { width: min(100%, 360px); border: 3px solid var(--text-primary); border-radius: 18px; box-shadow: 6px 6px 0 var(--text-primary); }
.poster-style-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.poster-style-picker button { min-height: 44px; padding: 8px 12px; border: 3px solid var(--text-primary); border-radius: 99px; background: var(--surface-paper); font-weight: 800; }
.poster-style-picker button[aria-pressed="true"] { background: #CCFF4D; color: #14110F; }

@media (min-width: 700px) {
  .path-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .path-tile { min-height: 320px; grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .setup-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home-stats { max-width: 620px; }
}

@media (min-width: 900px) {
  .desktop-nav { display: inline-flex; }
  .bottom-nav { display: none; }
  .main-content { padding: 30px 18px 70px; }
  .home-hero { grid-template-columns: 1.35fr .65fr; gap: 44px; }
  .module-reader { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px 40px; align-items: start; }
  .module-reader > * { grid-column: 2; }
  .module-reader > .lesson-outline { grid-column: 1; grid-row: 1 / span 99; position: sticky; top: 100px; margin: 0; padding: 14px; border: 3px solid var(--text-primary); border-radius: 16px; background: var(--surface-paper); box-shadow: 3px 3px 0 var(--text-primary); }
  .result-editorial-hero { grid-template-columns: 1fr 1.15fr; }
}

@media (max-width: 899px) {
  .desktop-nav { display: none; }
  .bottom-nav { display: block; }
  .brand-credit { display: none; }
}

@media (max-width: 699px) {
  .setup-grid--2, .setup-grid--3 { grid-template-columns: 1fr; }
  .home-stats { grid-template-columns: 1fr; }
  .subtest-strip { grid-template-columns: 1fr; }
  .result-editorial-hero { padding: 20px 16px 24px; }
}

@media (max-width: 390px) {
  .main-content { padding-inline: 12px; }
  .top-nav { padding-inline: 12px; }
  .top-nav__inner { padding-left: 10px; }
  .path-tile { padding: 18px; grid-template-columns: 44px 1fr; }
  .path-tile > span:last-child { display: none; }
  .q-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .exam-bottom-bar__inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exam-action-btn { white-space: normal; }
  .home-hero__title { overflow-wrap: anywhere; }
}


/* Phase 5 proposed corrections — scoped accessibility and reflow, no redesign. */
.result-rec-row { padding:12px 0; border-bottom:1px solid var(--border-hairline); display:flex; justify-content:space-between; align-items:center; gap:12px; min-width:0; }
.result-rec-body { flex:1 1 0; min-width:0; overflow-wrap:anywhere; }
.result-rec-copy { display:flex; gap:8px; align-items:center; flex-wrap:wrap; min-width:0; }
.result-rec-copy strong { min-width:0; overflow-wrap:anywhere; }
.result-rec-row [data-rec-mod] { flex:0 0 auto; min-width:44px; min-height:44px; white-space:normal; padding:8px 4px; }
.result-score-line { display:flex; flex-wrap:wrap; align-items:baseline; gap:12px; min-width:0; }
.result-editorial-hero > div { min-width:0; }
.modal-card { color:var(--text-primary); }
body.exam-focus-mode .exam-topbar, body.exam-focus-mode .question-card,
body.exam-focus-mode .grid-panel, body.exam-focus-mode .exam-bottom-bar__inner {
  --text-primary:#F6F1E6; --text-secondary:#D2CADB; --text-muted:#A79FB5;
}
.lesson-link { color:#514078; }
[data-theme="dark"] .lesson-link { color:#CCFF4D; }
.lesson-section-title:after { color:var(--text-primary); }
.option-card.is-selected { --text-primary:#14110F; --text-secondary:#514A43; --text-muted:#514A43; color:#14110F; }
.subtest-status { font-size:12px; font-weight:700; }
.subtest-status.is-pass { color:var(--success-text); }
.subtest-status.is-below { color:var(--danger-text); }
[data-theme="dark"] .subtest-status.is-pass { color:#9FE8BB; }
[data-theme="dark"] .subtest-status.is-below { color:#FFB6BE; }
.subtest-progress { position:relative; height:10px; margin-top:8px; border:2px solid var(--text-primary); background:var(--surface-muted); border-radius:8px; }
.subtest-progress__fill { display:block; height:100%; border-radius:4px; background:var(--accent); }
.subtest-progress__threshold { position:absolute; top:-3px; bottom:-3px; width:2px; background:var(--text-primary); transform:translateX(-50%); }
.skip-link { min-height:44px; }
.brand-credit { align-items:center; }
@media (min-width:900px) { .brand-credit { display:inline-flex; min-height:44px; } }
.lesson-preview > summary { min-height:44px; padding-block:10px; }
.q-grid { grid-template-columns:repeat(auto-fit,minmax(44px,1fr)); gap:4px; }
.q-dot { min-width:44px; min-height:44px; }
@media (max-width:390px) { .modal-root { padding:8px; } .modal-card { padding:12px; } }
.share-render-status { color:var(--danger-text); font-size:14px; }
[data-theme="dark"] .share-render-status { color:#FFB6BE; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
