/* P5/P6: shared interface roles, adapted from Scale (22 October 2026).
   The mathematical space and its DNA colours remain owned by Line. */
:root {
    color-scheme: light;
    --page:#f5f6f8; --surface:#fff; --ink:#202630; --muted:#68717d;
    --line:#e1e5eb; --accent:#2563eb; --target:#c73535; --soft:#edf3ff;
    --topic-selected:#f1e0fa; --table-head:#f0f3f8;
    --border:var(--line); --bg-dark:var(--page); --panel-bg:var(--surface);
    --input-bg:var(--surface); --text:var(--ink); --text-muted:var(--muted);
    --active-orange:var(--target); --designer-green:#218244; --tester-blue:#2563eb;
    --ui-font:system-ui,-apple-system,sans-serif;
    --frame-gap:20px;
}
:root[data-theme=dark] {
    color-scheme:dark;
    --page:#151a21; --surface:#1e2530; --ink:#edf0f5; --muted:#a5afbd;
    --line:#35404f; --accent:#8aacff; --target:#ff928d; --soft:#26334c;
    --topic-selected:#44304f; --table-head:#29323f; --designer-green:#82d69c;
}
body { background:var(--page); color:var(--ink); font:400 14px/1.5 var(--ui-font); }
#main-view { background:var(--page); }
#top-guidance {
    display:flex; flex-wrap:wrap; align-content:center; height:auto; min-height:124px;
    padding:12px var(--frame-gap); box-sizing:border-box; gap:10px 12px;
    background:var(--page); border-color:var(--line);
}
.line-brand-header { display:flex; align-items:center; justify-content:space-between; gap:16px; flex-basis:100%; min-width:0; padding-bottom:8px; }
.line-wordmark { display:flex; align-items:baseline; gap:16px; min-width:0; }
.line-wordmark h1 { font:600 30px/1.2 var(--ui-font); margin:0; color:var(--ink); }
.line-wordmark span { color:var(--muted); font-size:13px; }
.line-brand-actions { display:flex; align-items:center; gap:8px; flex-shrink:0; }
button, select, input { font-family:var(--ui-font); }
button, select, input[type=number], input[type=text] { border-radius:7px; }
button { font-weight:500; letter-spacing:normal; text-transform:none; }
#hub-link { display:inline-flex; align-items:center; min-height:34px; padding:0 12px; box-sizing:border-box; border:1px solid var(--line); border-radius:7px; background:var(--surface); color:var(--ink); font:500 13px/1.5 var(--ui-font); text-decoration:none; white-space:nowrap; }
#hub-link:hover { color:var(--accent); border-color:var(--accent); }
#line-theme { width:auto; min-height:34px; margin:0; padding:4px 8px; background:var(--surface); border:1px solid var(--line); color:var(--ink); font-size:13px; }
#header-actions { gap:8px; min-width:0; }
#student-level-select { background:var(--topic-selected); border-color:var(--line); color:var(--ink); font-size:13px; font-weight:400; width:230px; min-width:0; border-radius:7px; }
#student-task-number { color:var(--muted); font-family:var(--ui-font); font-weight:500; }
#kos-formula-display { color:var(--target); min-width:0; font-weight:400; }
/* These navigation buttons receive inline styles from UserShell. */
[data-user-shell-task-nav] button { background:var(--surface)!important; color:var(--ink)!important; border-color:var(--line)!important; font-weight:500!important; }
#btn-student-finish { border-radius:7px; font-size:13px; font-weight:600; text-transform:none; min-width:90px; }
#stage { background:var(--page); min-height:0; }
/* No padding, CSS scaling, or fixed dimensions on the mathematical container. */
#container { box-shadow:0 0 0 1px var(--line); border-radius:12px; }
#student-skill-info { letter-spacing:normal; text-transform:none; font-family:var(--ui-font); font-weight:600; }
#student-controls { height:auto; min-height:70px; flex-wrap:wrap; gap:10px 16px; padding:12px var(--frame-gap); box-sizing:border-box; background:var(--page); border-color:var(--line); }
#footer-left { flex:0 0 auto; }
#footer-mid { min-width:80px; }
#footer-right-wrap { flex-wrap:wrap; gap:10px; }
.lvl-circle { color:var(--muted); border-color:var(--line); font-weight:400; }
.lvl-circle.active { color:var(--ink); background:var(--topic-selected); border-color:var(--line); box-shadow:none; }
#skill-label { color:var(--muted); font-size:11px; font-weight:400; text-transform:none; letter-spacing:normal; }
#skill-progress-container { background:var(--line); }
#btn-learner-overview, #btn-student-hint, #btn-student-rule-info, #btn-student-rule-info-close {
    background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:7px;
    min-width:0; font-size:12px; font-weight:500; text-transform:none; letter-spacing:normal;
}
#btn-learner-overview:hover { background:var(--soft); }
#rule-info-card, #learner-overview-panel, #local-server-notice-card { background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:12px; box-shadow:0 16px 48px #0002; }
#rule-info-title, #learner-overview-title, #local-server-notice-card h1 { color:var(--ink); font-weight:600; text-transform:none; letter-spacing:normal; }
#rule-info-text, #learner-overview-subtitle, #learner-overview-note, #local-server-notice-card p { color:var(--muted); font-weight:400; }
#btn-learner-overview-close { background:var(--surface); color:var(--ink); border-color:var(--line); }
#learner-overview-table-wrap { border-color:var(--line); }
#learner-overview-table th { background:var(--table-head); color:var(--accent); font-size:12px; font-weight:600; text-transform:none; letter-spacing:normal; }
#learner-overview-table th, #learner-overview-table td { border-color:var(--line); }
#learner-overview-table td, #learner-overview-table td:first-child strong { color:var(--ink); }
#learner-overview-table td:first-child span { color:var(--muted); }
.overview-mastered { color:var(--accent)!important; font-weight:600; }
#sidebar { background:var(--surface); border-color:var(--line); box-shadow:none; flex-shrink:0; }
#cockpit-header { background:var(--surface); color:var(--accent); text-align:left; font-size:12px; font-weight:700; letter-spacing:.1em; padding:20px; }
#navigation-panel, #action-panel { background:var(--surface); border-color:var(--line); }
#scroll-area { min-height:0; }
#sidebar .acc-header, #sidebar .accordion-header { background:var(--surface); color:var(--muted); font-weight:600; border-color:var(--line); }
#sidebar .acc-header.active, #sidebar .accordion-header.active { background:var(--topic-selected); color:var(--ink); border-color:var(--line); }
#sidebar .acc-content, #sidebar .accordion-content { background:var(--page); }
#sidebar label { color:var(--muted); }
#sidebar select, #sidebar input[type=number], #sidebar input[type=text] { background:var(--surface)!important; color:var(--ink)!important; border:1px solid var(--line)!important; }
#sidebar .btn-mode { background:var(--surface); color:var(--muted); border-color:var(--line); font-size:11px; font-weight:500; }
#sidebar .btn-mode.active { background:var(--topic-selected); color:var(--ink); border-color:var(--line); }
#sidebar .btn-ghost { color:var(--ink); border-color:var(--line); }
#sidebar .graph-entry { background:var(--surface); }
.brand-credit { display:flex; align-items:center; justify-content:center; gap:8px; flex:none; color:var(--muted); font:400 11px/1.4 var(--ui-font); }
.brand-credit img { display:block; width:42px; height:28px; object-fit:contain; flex:none; }
#sidebar>.brand-credit { padding:14px 20px; border-top:1px solid var(--line); }
:where(button, select, input, a):focus-visible { outline:2px solid var(--accent)!important; outline-offset:3px; }
@media print and (max-width:1000px) {
    .line-wordmark span { max-width:24ch; font-size:12px; }
    #footer-right-wrap { justify-content:flex-end; }
    #footer-right-wrap .brand-credit { flex-basis:100%; }
}
@media print and (max-width:720px) {
    :root { --frame-gap:12px; }
    .line-wordmark h1 { font-size:25px; }
    .line-wordmark span { display:none; }
    .line-brand-header { gap:8px; }
    #hub-link { font-size:11px; padding:0 8px; }
    #line-theme { font-size:11px; }
    #top-guidance { min-height:150px; }
    #header-actions { flex-basis:100%; margin:0; justify-content:space-between; }
    #student-level-select { flex:1; width:auto; max-width:320px; font-size:12px; }
    #footer-right-wrap { flex:1; }
    #student-controls { gap:8px; }
}
@media(prefers-reduced-motion:reduce) {
    #skill-progress, #learner-progress-meter { transition:none; }
}
/* The frame fitter sets a legacy black surround inline; only its colour changes. */
#app-wrapper { background:var(--page)!important; }
#container { box-shadow:0 0 0 1px var(--line)!important; }
#btn-student-hint, #btn-student-rule-info { color:#fff; }
.line-cockpit-toggle { display:none; }
@media print and (max-width:720px) {
    #student-controls { display:grid; grid-template-columns:auto minmax(0,1fr); }
    #footer-mid { align-items:flex-end; }
    #footer-right-wrap { grid-column:1/-1; display:flex; justify-content:flex-end; }
    #footer-right-wrap .brand-credit { flex-basis:auto; margin-left:auto; white-space:nowrap; }
    .line-cockpit-toggle { display:inline-flex; align-items:center; min-height:34px; border:1px solid var(--line); background:var(--surface); color:var(--ink); padding:4px 8px; font-size:11px; }
    #sidebar { display:none; }
    html[data-cockpit-open] #sidebar { display:flex; position:fixed; inset:0 0 0 auto; width:min(360px,100vw); height:100dvh; z-index:2000; box-shadow:-12px 0 48px #0003; }
    #sidebar>.line-cockpit-toggle { align-self:flex-end; margin:12px 12px 0; flex:none; }
}
#sidebar .btn-stepper { background:var(--surface); border-color:var(--line); color:var(--ink); }
#sidebar .stepper-arrow, #sidebar .stepper-label { color:var(--ink)!important; }
#sidebar .btn-mode.active { background:var(--topic-selected)!important; color:var(--ink)!important; }
#sidebar .acc-item { border-color:var(--line); }
#sidebar #status-display { background:var(--page)!important; color:var(--muted)!important; border-color:var(--line)!important; }
.brand-credit.mobile-credit { display:none; }
@media print and (max-width:720px) { .brand-credit.mobile-credit { display:flex; } }

/* Shared desktop layout; keep browser zoom and print layout available. */
@media screen { html { min-width: 1280px; overflow-x: auto; } body, #app-wrapper { min-width: 1280px; } }
