/* R4 visual components around TONEX's existing questions and interactions. */
:root {
  --white: #fffaf2;
  --sub: #6d7869;
  --line: #dcded1;
  --acid: #f0d98a;
  --acid-dark: #294d40;
  --font: var(--ui);
}
html, body {background:var(--paper);color:var(--ink);font-family:var(--ui)}
body {font-weight:400}
.site-shell {background:radial-gradient(ellipse at 55% 38%,#fffff84f,transparent 74%),var(--paper)}
.site-shell .site-header {
  height:88px;padding:0 clamp(24px,4.2vw,66px);gap:22px;
  background:transparent;backdrop-filter:none;position:relative;border:0;
}
.site-header .brand {
  font:500 23px/1 Arial,sans-serif;letter-spacing:5px;color:var(--ink);
}
.site-header .header-line {display:none}
.site-header .header-caption {margin-left:auto;font-size:11px;font-weight:400;letter-spacing:1.2px;color:var(--muted)}
.site-header .header-right {margin-left:0;font-size:10px;font-weight:400;color:var(--muted);letter-spacing:.4px}
#stage .stage-wrap[data-step] {max-width:1040px;padding:18px 40px 148px}
#stage .progress-row {max-width:840px;margin:0 auto 24px;padding:0;border:0;gap:20px}
#stage .progress-no {font:11px/1.5 var(--ui);letter-spacing:1px;color:var(--muted);white-space:nowrap}
#stage .progress-label {display:none}
#stage .progress-track {width:120px;height:3px;background:#dce2d5}
#stage .progress-fill {background:var(--sage)}
#stage .question-head {max-width:840px;margin:0 auto;text-align:center}
#stage .question-head .eyebrow {font-size:10px;font-weight:400;letter-spacing:1.7px;color:var(--muted);margin:0 0 12px}
#stage .question-title {font-family:var(--ui);font-size:clamp(26px,2.5vw,35px);font-weight:500;line-height:1.45;letter-spacing:.1px;color:var(--ink);margin:12px 0 9px;max-width:none}
#stage .intro-line {font-size:12px;line-height:1.8;color:var(--muted);margin:0}
#stage .question-content {max-width:840px;margin:26px auto 0}
#stage .choice-grid {gap:14px}
#stage .choice {
  min-height:116px;padding:18px 21px;border-radius:19px;background:var(--white);
  box-shadow:0 4px 14px #50534209,inset 0 1px #fff;
}
#stage .choice .letter {width:26px;height:26px;font-size:11px;font-weight:500;background:#e9ecdf;color:var(--forest)}
#stage .choice .answer {font-size:16px;font-weight:400;line-height:1.7;color:var(--ink)}
#stage .choice:hover {transform:translateY(-1px);box-shadow:0 7px 18px #294d4011}
#stage .choice.selected {background:#eee8d0;box-shadow:0 0 0 1.5px #42664f,0 7px 18px #294d4011}
#stage .choice.selected .letter {background:var(--forest);color:var(--cream)}
#stage .skip-choice {font-size:12px;font-weight:400;min-height:44px;margin:9px 0 0;padding:10px 0;color:var(--muted)}
#stage .skip-choice.selected {color:var(--forest)}
#stage .pattern-grid {max-width:840px;grid-template-columns:repeat(3,minmax(0,1fr));gap:19px}
.r4-option {min-width:0;position:relative}
#stage .pattern-grid .visual-card {width:100%;border-radius:19px;padding:7px 7px 0;background:var(--white);overflow:hidden;box-shadow:0 4px 14px #50534209,inset 0 1px #fff}
#stage .pattern-grid .visual-card img {aspect-ratio:4/3;object-fit:contain;background:#fffaf2;border-radius:12px}
#stage .pattern-grid .visual-label {min-height:40px;padding:9px 32px 9px 8px;gap:8px}
#stage .pattern-grid .visual-label b {font:11px/1 Arial,sans-serif;font-weight:400;letter-spacing:1px;color:var(--muted)}
#stage .pattern-grid .visual-label small {font-size:10px;line-height:1.45;color:var(--muted)}
#stage .visual-card.selected {background:var(--white);box-shadow:0 0 0 1.5px #42664f,0 7px 18px #294d4011}
#stage .visual-card.selected:after,#stage .palette-card.selected:after {background:var(--butter);color:var(--ink);font-weight:500;border:2px solid var(--paper)}
.r4-zoom {position:absolute;bottom:1px;right:5px;width:36px;height:40px;border:0;border-radius:9px;background:transparent;color:var(--forest);font-size:21px;cursor:pointer}
.r4-zoom:hover {background:#294d4007}
#stage .palette-grid,#stage .material-grid {gap:16px}
#stage .palette-card,#stage .material-card {border-radius:19px;background:var(--white);box-shadow:0 4px 14px #50534209}
#stage .palette-bars {height:155px}
#stage .palette-card b,#stage .material-card .visual-label b {font-size:13px;font-weight:400;color:var(--ink)}
#stage .material-card img {aspect-ratio:1.4;object-fit:cover}
#stage .acceptance {border-color:#d9dccd;padding-top:18px}
#stage .acceptance p {font-size:14px;font-weight:400;color:var(--ink)}
#stage .accept-options button {font-size:12px;font-weight:400;background:#ede9de;border-radius:12px;min-height:44px}
#stage .accept-options button.selected {background:var(--butter)}
#stage .bottom-nav {
  position:fixed;z-index:25;left:50%;right:auto;bottom:max(25px,env(safe-area-inset-bottom));
  transform:translateX(-50%);width:min(850px,calc(100% - 54px));max-width:none;
  margin:0;padding:12px 14px;gap:14px;border:1px solid #ffffffb5;
  border-radius:26px;background:linear-gradient(135deg,#e5eadfcc,#d6e0cf99);
  box-shadow:inset 0 1px #ffffffa0,0 14px 31px #233e3317;backdrop-filter:blur(22px);
  -webkit-backdrop-filter:blur(22px);
}
#stage .nav-btn {min-height:48px;padding:0 20px;border-radius:16px;font-size:12px;font-weight:400;background:#ffffff47;color:var(--ink);border:0;transition:transform .17s var(--spring),box-shadow .17s var(--ease)}
#stage .nav-btn.primary,#stage .nav-btn.primary:not(:disabled):hover {
  min-width:190px;min-height:56px;padding:0 26px;border-radius:19px;
  background:linear-gradient(158deg,#f8e6a9 1%,#f0d98a 65%,#e9cd7d);color:#294536;
  box-shadow:inset 0 1px 1px #fff5cf,0 3px 0 #c5a75b70,0 9px 20px #20352322;
  font-size:14px;font-weight:500;border:1px solid #ffeec080;
}
#stage .nav-btn.primary:not(:disabled):hover {transform:translateY(-1px);filter:brightness(1.025)}
#stage .nav-btn.primary:not(:disabled):active {transform:translateY(3px);box-shadow:inset 0 2px 3px #af934c35,0 1px 0 #b3995655,0 3px 7px #2035231a}
#stage .nav-note {font-size:10px;font-weight:400;letter-spacing:0;color:var(--muted)}
#stage :is(.n2-route-control,.p2-control) h2 {font-size:24px;font-weight:500;color:var(--ink)}
#stage :is(.n2-choice,.p2-action) {background:#e9ecdf;border-radius:14px}
#stage .p2-action.selected {background:#eee8d0;box-shadow:0 0 0 1.5px #42664f}
#stage :is(.p2-action strong,.n2-choice strong) {font-weight:500;color:var(--ink)}
#stage :is(.n2-choice-index,.p2-action-no) {background:#dde4d4;color:var(--forest)}
#stage .p2-action.selected .p2-action-no {background:var(--forest);color:var(--cream)}
/* N2 retains its map while the step panel uses the original R4 transition. */
#stage .n2-route-grid {align-items:start;gap:24px}
#stage .n2-route-control {min-height:360px}
#stage .n2-route-control h2 {text-wrap:balance}
#stage .n2-route-grid.r4-route-switching :is(.n2-route-hit,.n2-choice,.n2-route-back,.n2-route-skip,.n2-control-top button) {pointer-events:none}
#stage .n2-route-summary {grid-template-columns:72px minmax(0,1fr);gap:16px 12px;background:#e9ecdf}
#stage .n2-route-summary strong {font-weight:500;line-height:1.55}
#stage .n2-route-grid[data-phase="3"] .n2-route-choices {grid-template-columns:minmax(0,1fr)}
/* Book widths, heights, type and joinery all follow the scene's width. */
#stage .p2-workbench {align-items:start;gap:24px}
#stage .p2-scene {min-height:0;aspect-ratio:900/565;container-type:inline-size;border-radius:12px}
#stage .p2-bookcase {border-width:clamp(5px,1.33cqw,12px);border-bottom-width:clamp(6px,1.55cqw,14px)}
#stage .p2-case-top {left:-2cqw;right:-2cqw;top:-1.77cqw;height:1.11cqw}
#stage .p2-case-base {left:-2cqw;right:-2cqw;bottom:-2.22cqw;height:1.22cqw}
#stage .p2-shelf-row {min-width:0;min-height:0;border-bottom-width:clamp(4px,1.22cqw,11px)}
#stage .p2-books {width:100%;min-width:0;gap:clamp(1px,.33cqw,3px);padding:clamp(3px,1cqw,9px) clamp(4px,1.33cqw,12px) 0}
#stage .p2-book {flex:var(--spine-weight) 1 0;min-width:0;width:auto;height:var(--book-height);max-height:100%;transform:none}
#stage .p2-book .p2-book-title {font-size:1.22cqw;line-height:1.05;margin-top:1.66cqw;letter-spacing:.04em}
#stage .p2-book .p2-book-mark {font-size:.67cqw;bottom:.89cqw;left:.22cqw;right:.22cqw}
#stage .p2-book .p2-book-rule {left:.78cqw;right:.78cqw;top:.78cqw;margin:0}
#stage .p2-book i {left:.67cqw;right:.67cqw;bottom:1.89cqw}
#stage .p2-finish-frame .p2-book-rule {top:.56cqw;bottom:.56cqw;left:.56cqw;right:.56cqw}
#stage .p2-finish-stripe .p2-book-rule {left:0;right:0;top:.89cqw;height:.67cqw}
#stage :is(.p2-finish-stripe,.p2-finish-label) .p2-book-title {margin-top:2.22cqw}
#stage .p2-finish-label .p2-book-title {padding:.56cqw .22cqw}
#stage .p2-finish-plain .p2-book-title {margin-top:2.56cqw;letter-spacing:.1em}
#stage .p2-shelf-board {bottom:calc(-1 * clamp(4px,1.22cqw,11px));height:clamp(4px,1.22cqw,11px);left:-.56cqw;right:-.56cqw}
#stage .p2-desk {bottom:0;border-top-width:clamp(3px,.67cqw,6px)}
#stage .p2-desk-paper {top:-2.78cqw;height:2.89cqw}
#stage .p2-desk-book {top:-1.33cqw;height:1.33cqw}
#stage .p2-scene-top {top:3%;left:3%;right:3%;font-size:clamp(7px,1.11cqw,10px)}
.r4-zoom-dialog {width:min(640px,calc(100vw - 32px));max-height:calc(100dvh - 32px);overflow:auto;padding:24px;border:1px solid #fff9ee;border-radius:24px;background:var(--paper);color:var(--ink);box-shadow:0 25px 70px #19392f33}
.r4-zoom-dialog::backdrop {background:#19392f88;backdrop-filter:blur(6px)}
.r4-dialog-head {display:flex;justify-content:space-between;align-items:center;gap:20px;margin-bottom:16px}
.r4-dialog-head h2 {font-size:17px;font-weight:500;margin:0}
.r4-dialog-head button,.r4-dialog-actions button {min-width:44px;min-height:44px;background:#e7eadd;border:0;border-radius:12px;color:var(--ink);cursor:pointer}
.r4-dialog-head button {font-size:24px}
.r4-zoom-dialog img {width:100%;max-height:55dvh;object-fit:contain;border-radius:14px}
.r4-dialog-actions {display:flex;gap:10px;align-items:center;margin-top:16px}
.r4-dialog-actions span {font-size:11px;color:var(--muted)}
.r4-dialog-actions #zoomChoose {margin-left:auto;padding:0 16px;background:var(--butter)}
.r4-zoom-dialog p {font-size:12px;line-height:1.6;color:var(--muted);margin-bottom:0}
/* Long interactive questions reserve a real row for their confirmation tray. */
#stage .stage-wrap:not(.text-question) {padding-bottom:32px}
#stage .stage-wrap:not(.text-question) .bottom-nav {position:relative;left:auto;right:auto;bottom:auto;transform:none;width:min(850px,100%);margin:24px auto 0}
#stage .stage-wrap:not(.text-question) .mobile-options-hint {display:none}
.r4-flow-hint {font-size:11px;line-height:1.6;color:var(--forest);margin:10px 0 0}
.r4-flow-hint[hidden] {display:none}
/* Keep the whole phone and its confirmation controls in one content flow. */
#stage .stage-wrap[data-step="E2"] {--r4-phone-width:clamp(220px,calc((100svh - 240px) * .489),264px);padding-bottom:32px}
#stage .stage-wrap[data-step="E2"] .e2-phone-layout {min-height:0;padding:0;display:flex;justify-content:center;align-items:flex-start}
#stage .stage-wrap[data-step="E2"] .e2-phone {width:var(--r4-phone-width);height:calc(var(--r4-phone-width) * 540 / 264);flex:none;margin:0}
#stage .stage-wrap[data-step="E2"] .bottom-nav {position:static;left:auto;right:auto;bottom:auto;transform:none;width:min(560px,100%);margin:24px auto 0}
#stage .stage-wrap[data-step="E2"] .nav-note {display:none}
#stage .stage-wrap[data-step="E2"] .mobile-options-hint {display:none}
#stage .e2-screen-home {background:radial-gradient(ellipse at 85% 3%,#f0d98a45,transparent 40%),linear-gradient(160deg,#e6eadd,#f5f0e7 65%)}
#stage .e2-screen-finish {background:radial-gradient(ellipse at top right,#f0d98a45,transparent 40%),#f5f3eb}
#stage :is(.e2-screen-home,.e2-screen-detail,.e2-screen-finish) {overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin}
#stage .e2-setting-arrow {width:16px;height:16px;border-color:#294d4040;font-size:0;color:var(--forest);transition:border-color .16s ease}
#stage .e2-setting-arrow::after {content:"";width:4px;height:4px;border-radius:50%;background:currentColor;opacity:0;transform:scale(.7);transition:opacity .16s ease,transform .16s ease}
#stage .e2-settings button:is(:hover,:focus-visible,:active) .e2-setting-arrow {border-color:#294d4080}
#stage .e2-settings button:is(:hover,:focus-visible,:active) .e2-setting-arrow::after {opacity:1;transform:scale(1)}
button:focus-visible,a:focus-visible {outline:3px solid #aa603e;outline-offset:4px}
@media(max-width:900px) {
  #stage .n2-route-control {min-height:0}
}
@media(max-width:700px) {
  .site-shell .site-header {height:48px;padding:0 18px;gap:12px}
  .site-header .brand {font-size:21px;letter-spacing:3px}
  .site-header .header-caption {font-size:10px;letter-spacing:.4px}
  .site-header .header-right {display:none}
  #stage .stage-wrap[data-step] {padding:12px 18px calc(140px + env(safe-area-inset-bottom))}
  #stage .progress-row {margin-bottom:12px}
  #stage .question-head .eyebrow {font-size:10px;margin:0 0 6px}
  #stage .question-title {font-size:24px;line-height:1.35;margin:0 0 8px}
  #stage .intro-line {font-size:12px;line-height:1.6}
  #stage .question-content {margin-top:18px}
  #stage .text-question .question-title {font-size:22px}
  #stage .text-question .question-context {font-family:var(--ui);color:var(--muted)}
  #stage .text-question .choice-grid {gap:8px}
  #stage .text-question .choice {min-height:62px;padding:10px 14px;gap:12px;border-radius:16px}
  #stage .text-question .choice .answer {font-size:16px;line-height:1.4}
  #stage .text-question .choice.selected {background:#eee8d0;box-shadow:0 0 0 1.5px #42664f}
  #stage .pattern-grid {grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
  #stage .pattern-grid .visual-label {padding:8px 28px 8px 4px;min-height:38px}
  #stage .pattern-grid .visual-label small {font-size:9px}
  #stage .pattern-grid .visual-card img {aspect-ratio:1.45}
  #stage .palette-grid,#stage .material-grid {grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
  #stage .palette-bars {height:100px}
  #stage .material-card img {aspect-ratio:1.45}
  #stage .bottom-nav {width:calc(100% - 24px);bottom:max(12px,env(safe-area-inset-bottom));padding:10px;gap:10px;border-radius:21px}
  #stage .nav-note {display:none}
  #stage .bottom-nav .nav-btn {min-height:44px;padding:0 14px;white-space:nowrap}
  #stage .bottom-nav .nav-btn.primary {min-width:0;flex:1;min-height:48px;max-width:210px;font-size:13px;border-radius:15px}
  #stage .mobile-options-hint {left:8px;right:8px;bottom:calc(100% + 6px);min-height:32px;padding:7px 12px;border-radius:12px;background:#f0e4bb;color:var(--ink);font-size:11px;box-shadow:0 3px 12px #294d4014}
  #stage .stage-wrap:not(.text-question) {padding-bottom:24px}
  #stage .stage-wrap:not(.text-question) .bottom-nav {width:100%;margin-top:20px}
  #stage .stage-wrap[data-step="E2"] {--r4-phone-width:clamp(220px,calc((100svh - 206px) * .489),264px);padding-bottom:24px}
  #stage .stage-wrap[data-step="E2"] .bottom-nav {width:100%;margin-top:20px}
  #stage .e2-apps strong {font-size:12px;line-height:1.4;text-wrap:balance}
  #stage .e2-personal-head strong {text-wrap:balance}
  #stage .e2-screen-home {padding-inline:14px}
  #stage .e2-apps small {font-size:10px;line-height:1.4}
  #stage .e2-apps button {min-height:102px}
  #stage .e2-settings strong {font-size:13px;line-height:1.4}
  #stage .e2-settings small {font-size:10px;line-height:1.4}
  #stage .e2-finished-step strong {font-size:13px;line-height:1.4}
  #stage .e2-screen-home .e2-apps-label {margin-top:16px}
  .r4-zoom-dialog {padding:18px}
  .r4-dialog-actions {gap:6px}
  .r4-dialog-actions #zoomChoose {font-size:12px;padding:0 10px}
}
@media(max-width:700px) and (max-height:680px) {
  .site-shell .site-header {height:44px}
  #stage .stage-wrap[data-step] {padding-top:10px}
  #stage .progress-row {margin-bottom:8px}
  #stage .text-question .question-title {font-size:20px;margin-bottom:6px}
  #stage .text-question .choice {min-height:54px;padding:8px 12px;gap:10px}
  #stage .text-question .choice .answer {font-size:15px;line-height:1.4}
}
@media(prefers-reduced-motion:reduce) {
  *,*:before,*:after {animation:none!important;transition:none!important;scroll-behavior:auto!important}
}

/* The restored abstract compositions retain their complete square format. */
#stage .pattern-grid .visual-card img{width:100%;height:auto;aspect-ratio:1;object-fit:contain}
