.me-gain.positive { color: var(--pos); }
.me-gain.negative { color: var(--neg); }

.tk-back-row { margin-bottom: -14px; }
.tk-back { display: inline-flex; align-items: center; gap: 4px; padding: 8px 14px 8px 10px; font-size: 13.5px; }
.tk-back .i { font-size: 16px; }
.tk-head { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.tk-logo { width: 56px; height: 56px; border-radius: var(--r-md); }
.tk-id { display: grid; gap: 4px; min-width: 0; }
.tk-sub { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.flag { width: 20px; height: 14px; border-radius: var(--r-xs); object-fit: cover; }
.tk-quote { display: grid; justify-items: end; gap: 2px; }
.tk-price { font-size: 28px; line-height: 1.2; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.tk-change { font-size: 14px; font-weight: 600; color: var(--muted); }
.performance-value { font-variant-numeric: tabular-nums; }
.source-line { font-size: 12.5px; font-weight: 600; color: var(--faint); }

.explanation-content { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.vd-risk-dots { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: middle; }
.vd-risk-dots i { width: 7px; height: 7px; border-radius: var(--r-xs); background: var(--surface-3); }
.vd-risk-dots i.on { background: var(--text-2); }
.vd-summary-table { margin: 2px 0; }
.vd-summary-table th { width: 40%; font-weight: 600; color: var(--muted); }
.vd-summary-table td { font-weight: 600; color: var(--text); }
.vd-head { display: grid; gap: 4px; margin: 2px 0 6px; text-align: center; }
.vd-signal { margin: 0; font-size: 28px; font-weight: 600; line-height: 1.15; letter-spacing: -.01em; }
.vd-summary { margin: 0; font-size: 15px; }
.vd-scale-track { position: relative; height: 10px; border-radius: var(--r-bar); background: linear-gradient(90deg, var(--neg-fill), var(--warn-fill), var(--pos-fill)); }
.vd-scale-marker { position: absolute; top: 50%; width: 18px; height: 18px; border: 3px solid var(--surface); border-radius: var(--r-circle); background: var(--text); transform: translate(-50%, -50%); }
.vd-scale-labels, .risk-scale-labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--faint); }
.vd-reasons { display: grid; gap: 8px; padding: 0; list-style: none; font-size: 14px; }
.vd-reasons li { display: flex; gap: 10px; }
.vd-dot { flex: none; width: 8px; height: 8px; margin-top: 7px; border-radius: var(--r-circle); background: var(--faint); }
.is-pos > .vd-dot { background: var(--pos-fill); }
.is-neg > .vd-dot { background: var(--neg-fill); }
.vd-table td.positive { color: var(--pos); }
.vd-table td.negative { color: var(--neg); }
.vd-hint { font-size: 12.5px; color: var(--muted); }
.vd-bar { position: relative; display: block; width: 90px; height: 6px; border-radius: var(--r-bar); background: var(--surface-3); }
.vd-bar-fill { position: absolute; top: 0; bottom: 0; border-radius: inherit; }
.vd-bar-fill.is-pos { background: var(--pos-fill); }
.vd-bar-fill.is-neg { background: var(--neg-fill); }

.aio-hero { display: grid; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.aio-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.aio-stance { font: 600 30px/1 var(--font); letter-spacing: -.01em; color: var(--text); }
.aio-stance.positive { color: var(--pos); }
.aio-stance.negative { color: var(--neg); }
.aio-stance.neutral { color: var(--warn); }
.aio-num { display: flex; align-items: baseline; gap: 8px; padding-left: 20px; border-left: 1px solid var(--line-2); }
.aio-pct { font: 600 30px/1 var(--font); font-variant-numeric: tabular-nums; color: var(--text); }
.aio-pct.positive { color: var(--pos); }
.aio-pct.negative { color: var(--neg); }
.aio-num-label { font-size: 14px; color: var(--muted); }
.aio-conf { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--muted); }
.aio-conf.is-low { color: var(--warn); }
.aio-meter { position: relative; height: 6px; margin-top: 8px; border-radius: var(--r-bar); background: var(--surface-3); }
.aio-meter-fill { position: absolute; top: 0; bottom: 0; border-radius: inherit; }
.aio-meter-fill.positive { background: var(--pos-fill); }
.aio-meter-fill.negative { background: var(--neg-fill); }
.aio-meter-mid { position: absolute; top: -4px; bottom: -4px; left: 50%; width: 2px; background: var(--muted); }
.aio-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); }
.aio-why { display: grid; gap: 6px; }
.aio-thesis { font-size: 16px; font-weight: 600; line-height: 1.5; color: var(--text); }
.aio-reading { font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.aio-you { font-size: 14px; line-height: 1.5; color: var(--text-2); }
.aio-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.aio-col { display: grid; align-content: start; gap: 8px; padding: 14px 16px 16px; color: var(--text-2); font-size: 14px; }
.aio-col + .aio-col { border-left: 1px solid var(--line); }
.aio-col:first-child { padding-left: 0; }
.aio-col-title { font: 600 12px var(--font); letter-spacing: .06em; text-transform: uppercase; }
.aio-col.positive .aio-col-title, .aio-col.positive .aio-mark { color: var(--pos); }
.aio-col.negative .aio-col-title, .aio-col.negative .aio-mark { color: var(--neg); }
.aio-col.neutral .aio-col-title, .aio-col.neutral .aio-mark { color: var(--warn); }
.aio-col ul, .calls { display: grid; gap: 6px; padding-left: 0; list-style: none; }
.aio-col li { display: grid; grid-template-columns: 14px 1fr; gap: 4px; line-height: 1.45; }
.aio-mark { font: 600 14px/1.45 var(--mono); }
.aio-inval { font-size: 14px; color: var(--text-2); }
.aio-inval strong { font-weight: 600; color: var(--text); }
.gaps { display: grid; gap: 6px; padding-left: 18px; font-family: var(--body); font-size: 14px; color: var(--text-2); }
.opinion-thesis { color: var(--text-2); }
@media (max-width: 700px) {
    .aio-col { padding-left: 0; }
    .aio-col + .aio-col { border-left: 0; border-top: 1px solid var(--line); }
    .aio-num { padding-left: 0; border-left: 0; }
}
.aio-foot { padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.calls { padding: 0; list-style: none; }
.calls li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; }
.call-verdict { padding: 2px 8px; border-radius: var(--r-ctl); font-size: 12px; font-weight: 600; }
.call-verdict.positive { background: var(--pos-soft); }
.call-verdict.negative { background: var(--neg-soft); }
.event-list { display: grid; gap: 10px; padding: 0; list-style: none; }
.event { display: grid; gap: 2px; }
.event-title { font-size: 14px; font-weight: 600; color: var(--text-2); }
.event-tone { font-size: 12px; font-weight: 600; }

.rng-track { position: relative; height: 10px; margin: 10px 0 12px; border-radius: var(--r-bar); background: var(--surface-3); }
.rng-fill { position: absolute; top: 0; bottom: 0; border-radius: inherit; }
.rng-fill.positive { background: var(--pos-fill); }
.rng-fill.negative { background: var(--neg-fill); }
.rng-open { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: var(--r-xs); background: var(--faint); transform: translateX(-1px); }
.rng-now { position: absolute; top: 50%; width: 18px; height: 18px; border: 3px solid var(--surface); border-radius: var(--r-circle); transform: translate(-50%, -50%); }
.rng-now.positive { background: var(--pos-fill); }
.rng-now.negative { background: var(--neg-fill); }
.rng-labels { display: grid; grid-template-columns: repeat(3, 1fr); font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.rng-labels span { display: grid; gap: 2px; }
.rng-labels span:nth-child(2) { text-align: center; }
.rng-labels span:nth-child(3) { text-align: right; }
.rng-labels small { font-size: 12px; font-weight: 600; color: var(--muted); }

.trade-form { display: grid; gap: 14px; padding: 16px; border-radius: var(--r-md); background: var(--surface-2); }
.trade-form input:not([type="radio"]) { background-color: var(--surface); }
.trade-fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.form-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.sim-form { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); align-items: end; }
.sim-form .pills { min-height: 46px; align-items: center; }
.sim-out { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.scenarios { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }

.scenarios:has(> :nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.scenarios:has(> :only-child) { grid-template-columns: minmax(0, 1fr); }
.scenario { display: grid; align-content: start; gap: 4px; padding: 16px; border-radius: var(--r-md); background: var(--surface-2); color: var(--text-2); }
.scenario-label { font-size: 13px; font-weight: 600; }
.scenario-value { font-size: 24px; line-height: 1.2; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.scenario-delta { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.scenario.negative { background: var(--neg-soft); }
.scenario.positive { background: var(--pos-soft); }
.scenario.negative :is(.scenario-label, .scenario-delta) { color: var(--neg); }
.scenario.positive :is(.scenario-label, .scenario-delta) { color: var(--pos); }
.loss-meter { display: grid; gap: 8px; }
.loss-label strong { color: var(--neg); }
.loss-track { height: 10px; overflow: hidden; border-radius: var(--r-bar); background: var(--surface-3); }
.loss-fill { display: block; height: 100%; border-radius: inherit; background: var(--neg-fill); transform-origin: left; }
.sim-chart { position: relative; height: 280px; }

.analysis-plain, .ai-lab { display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; }
.comfort-key { color: var(--pos); }
.risk-scale { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.risk-scale span { height: 14px; border-radius: var(--r-sm); background: var(--surface-3); }
.risk-scale span.on { background: var(--accent); }
.risk-scale span.comfort { outline: 2px solid var(--pos); outline-offset: 2px; }
.risk-verdict { font-size: 15px; font-weight: 600; }
.risk-level { font-size: 15px; font-weight: 600; color: var(--muted); }
.risk-level strong { font-size: 22px; margin-right: 4px; }
.analysis-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.analysis-grid { display: flex; flex-wrap: wrap; gap: 20px; }
.analysis-grid > * { flex: 1 1 340px; min-width: 0; }
.analysis-grid > .panel-wide { flex-basis: 100%; }
.risk-contrib-name { font-weight: 600; color: var(--text-2); }
.risk-contrib-sym { color: var(--muted); }
.risk-contrib-delta { margin-left: 6px; font-size: 11.5px; font-weight: 600; }
.risk-contrib-delta.over { color: var(--neg); }
.risk-contrib-delta.under { color: var(--pos); }
.risk-contrib-delta.neutral { color: var(--faint); }
.risk-contrib-bar { position: relative; min-width: 96px; height: 20px; overflow: hidden; border-radius: var(--r-sm); background: var(--surface-3); }
.risk-contrib-bar-fill { height: 100%; background: color-mix(in srgb, var(--text) 22%, transparent); }
.risk-contrib-bar-fill.negative { background: color-mix(in srgb, var(--neg-fill) 55%, transparent); }
.risk-contrib-bar-label { position: absolute; inset: 0; display: flex; align-items: center; padding-left: 8px; font-size: 11.5px; font-weight: 600; color: var(--text); }
.correlation-matrix { display: grid; gap: 3px; min-width: max-content; }
.matrix-cell { display: grid; place-items: center; min-height: 36px; padding: 6px 4px; border-radius: var(--r-sm); color: var(--text); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.matrix-header { gap: 2px; background: none; text-align: center; }
.matrix-header .row-logo { width: 24px; height: 24px; border-radius: var(--r-sm); }
.matrix-header-name { max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--text-2); }
.matrix-header-ticker { font-size: 10px; color: var(--faint); }

.checkup-progress { display: grid; gap: 8px; }
.opinions { display: flex; flex-wrap: wrap; gap: 18px; }
.opinions > * { flex: 1 1 300px; min-width: 0; }
.opinion {
    display: grid;
    align-content: start;
    gap: 10px;
    padding: 16px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color .15s;
}
.opinion:hover { border-color: var(--line-2); }
.opinion-head { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.opinion-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opinion-chance { font-size: 14px; }
.opinion-thesis { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.steps { display: grid; gap: 4px; padding: 0; list-style: none; }
.step { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.step-dot { flex: none; width: 8px; height: 8px; border-radius: var(--r-circle); background: var(--faint); }
.step.is-done .step-dot { background: var(--pos-fill); }
.step.is-active .step-dot { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.step.is-failed .step-dot { background: var(--neg-fill); }
.step-name { min-width: 70px; font-weight: 600; color: var(--text-2); }
.run-list, .run-notes { display: grid; gap: 12px; padding: 0; list-style: none; }
.run-notes { gap: 2px; }
.run-item { display: grid; gap: 6px; }
.run-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
@keyframes pulse { 50% { opacity: .35; } }

.me-edit { display: grid; grid-template-columns: 88px minmax(0, 420px); gap: 18px; align-items: center; }
.pfp-upload { position: relative; width: 88px; height: 88px; border-radius: var(--r-circle); cursor: pointer; }
.pfp-upload img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; background: var(--surface-2); }
.pfp-badge { position: absolute; right: -4px; bottom: -4px; display: grid; place-items: center; width: 32px; height: 32px; border: 3px solid var(--surface); border-radius: var(--r-circle); background: var(--surface-3); color: var(--text); font-size: 14px; }
.investor-form { gap: 20px; }
.question { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
.question legend { margin-bottom: 10px; padding: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.comfort { font-size: 14px; }
.saved-note { color: var(--pos); }

.ai-settings { display: grid; gap: 20px; }
.ais-list { display: grid; gap: 8px; }
.ais-row { display: grid; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); }
.ais-row > .notice { background: var(--surface); }
.ais-task { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
/* The buttons sit beside the name when there is room, and wrap under it when there is not. */
.ais-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.ais-row > .ais-main { flex: 1 1 220px; }
.ais-row > .ais-side { flex: 0 1 auto; }
.ais-row > :is(.notice, .ais-edit) { flex: 1 1 100%; }
.ais-task .ais-side { justify-content: flex-end; }
.ais-main { display: grid; gap: 2px; min-width: 0; }
.ais-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.ais-side { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 10px; }
.dot { width: 9px; height: 9px; border-radius: var(--r-circle); background: var(--faint); }
.dot.is-ok { background: var(--pos-fill); }
.dot.is-busy { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.dot.is-bad { background: var(--neg-fill); }
.ais-add { display: flex; flex-wrap: wrap; gap: 10px; }
.ais-add > :is(input, select) { flex: 1 1 170px; min-width: 0; }
.ais-add > input[data-keep="url"] { flex: 2 1 260px; }
.ais-edit > input:nth-child(2) { flex: 2 1 260px; }
.ais-add > .btn { flex: none; }
.ais-add > .ais-task-error { flex-basis: 100%; }
.ais-unnamed { color: var(--warn); }
.ais-title input { width: min(240px, 100%); padding: 6px 10px; }
.ais-task { display: grid; gap: 8px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ais-task:last-child { border-bottom: 0; }
.ais-task select { width: min(320px, 100%); }
.ais-task-error { grid-column: 1 / -1; color: var(--neg); font-size: 13px; font-weight: 600; }
.voice-kind { display: grid; gap: 4px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.voice-kind:last-child { border-bottom: 0; padding-bottom: 0; }
.voice-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.voice-controls select { width: 220px; max-width: 100%; }
.voice-controls input { width: 150px; max-width: 100%; }
.rules-input { min-height: 120px; }

.explorer-filters { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
.explorer-ai-status.negative { color: var(--neg); }
.explorer-limit { display: grid; gap: 10px; }
.explorer-limit label:first-child { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; }
.explorer-limit output { color: var(--text); font-weight: 600; }
.explorer-limit-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.explorer-list { display: grid; gap: 8px; }
.explorer-item {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto 150px;
    gap: 14px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.explorer-item:hover { border-color: var(--line-2); background: var(--surface-2); }
.explorer-item.is-off { opacity: .6; }
.explorer-item-logo { width: 40px; height: 40px; border-radius: var(--r-sm); }
.explorer-item .stance { justify-self: end; font-size: 13px; }
.explorer-market-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.market-grid-btn { display: grid; place-items: center; aspect-ratio: 16 / 10; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); transition: border-color .15s, background .15s; }
.market-grid-btn:hover { border-color: var(--line-2); background: var(--surface-2); }
.market-grid-btn img { max-height: 44px; object-fit: contain; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; }

.news-bar { display: grid; gap: 12px; }
.news-list { display: grid; gap: 10px; }
.news-item {
    display: grid;
    gap: 6px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    color: inherit;
    transition: border-color .15s, background .15s;
}
a.news-item { text-decoration: none; }
a.news-item:hover { border-color: var(--line-2); background: var(--surface-2); }
.news-title { font-size: 16px; line-height: 1.4; font-weight: 600; }
.news-summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; color: var(--muted); }
.news-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; font-weight: 600; color: var(--faint); }
.news-source { font-weight: 600; color: var(--muted); }
.news-badge { padding: 2px 8px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.news-badge.positive { background: var(--pos-soft); }
.news-badge.negative { background: var(--neg-soft); }

.card.terminal-card.active { gap: 16px; }
.terminal-body {
    --term-fg: var(--text-2);
    --term-bright: var(--text);
    --term-dim: var(--muted);
    --term-line: var(--line);
    display: grid; gap: 10px; padding: 0; border: 0; border-radius: 0; background: transparent;
    color: var(--term-fg); font: 400 14px/1.5 'Cascadia Mono', Consolas, 'SF Mono', Menlo, 'DejaVu Sans Mono', 'Liberation Mono', var(--mono);
    font-variant-ligatures: none; letter-spacing: 0;
}
.terminal-output { display: flex; flex-direction: column; max-height: 65vh; overflow-y: auto; white-space: pre-wrap; word-break: break-word; scrollbar-width: none; }
.terminal-output::-webkit-scrollbar { display: none; }
.terminal-log { padding: 1px 0; }
.terminal-banner { margin-block: 16px; color: var(--term-bright); font-size: clamp(8px, 2.5vw, 14px); font-weight: 600; line-height: 1.25; white-space: pre; }
.terminal-cmd, .terminal-command { color: var(--term-bright); }
.terminal-panel { margin: 8px 0; padding-top: 10px; border-top: 1px solid var(--term-line); }
.terminal-mini-table, .terminal-data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.terminal-mini-table :is(th, td), .terminal-data-table :is(th, td) { padding: 4px 6px; border-bottom: 1px solid var(--term-line); text-align: left; vertical-align: top; }
.terminal-mini-table th, .terminal-data-table th { color: var(--term-bright); font-weight: 600; }
.terminal-mini-table tr:last-child > *, .terminal-data-table tr:last-child > * { border-bottom: 0; }
.terminal-help-table :is(td, th):first-child { width: 48%; }
.terminal-muted { color: var(--term-dim); }
.terminal-pos { color: var(--pos); }
.terminal-neg, .terminal-warning { color: var(--neg); }
.terminal-input-row { display: flex; align-items: center; gap: 1ch; }
.terminal-input-row::before { content: 'USER>'; color: var(--term-bright); }
input.terminal-input { flex: 1; width: auto; min-width: 0; padding: 2px 0; border: 0; border-radius: 0; background: none; color: var(--term-bright); caret-color: var(--term-bright); font: inherit; transition: none; }
input.terminal-input::placeholder { color: var(--term-dim); }

/* Home: the coach. Three levels per card: the headline, one sentence, then the rest on demand. */
.card.home-card.active { max-width: 720px; }
.coach { display: grid; gap: 24px; }
.coach-hello { margin: 0; font-size: 30px; font-weight: 600; line-height: 1.15; letter-spacing: -.02em; color: var(--text); }
.coach-status { margin: -8px 0 4px; color: var(--muted); }
.coach-cards, .coach-hero { display: grid; gap: 24px; }
.coach-hero:empty { display: none; }
.coach-card { --pad: 28px; display: grid; gap: 18px; padding: var(--pad); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.coach-card p { margin: 0; }
.coach-head { display: grid; }
/* The kind's word already says what a card is about: no badge beside it. */
.coach-icon { display: none; }
.coach-text { display: grid; gap: 4px; }
/* One color per kind of situation: fall red, rise green, risk amber, to set up blue, tip purple, calm grey. */
.coach-card { --kind: var(--muted); --kind-soft: var(--surface-2); }
.is-down { --kind: var(--neg); --kind-soft: var(--neg-soft); }
.is-up { --kind: var(--pos); --kind-soft: var(--pos-soft); }
.is-warn { --kind: var(--warn); --kind-soft: var(--warn-soft); }
.is-setup { --kind: var(--info); --kind-soft: var(--info-soft); }
.is-tip { --kind: var(--accent); --kind-soft: var(--accent-soft); }
.coach-kind { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--kind); }
.coach-photo { position: relative; height: clamp(140px, 30vw, 220px); margin: calc(-1 * var(--pad)) calc(-1 * var(--pad)) 0; overflow: hidden; border-radius: calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px) 0 0; background: var(--surface-2); }
.coach-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.coach-photo-credit { position: absolute; right: 8px; bottom: 8px; max-width: calc(100% - 16px); overflow: hidden; padding: 2px 8px; border-radius: var(--r-pill); background: rgb(0 0 0 / .55); color: #fff; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; text-decoration: none; }
.coach-what { font-size: 19px; line-height: 1.3; color: var(--text); }
.coach-lead { color: var(--text-2); }
.coach-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.coach-toggle .i { transition: transform .2s; }
.coach-toggle[aria-expanded="true"] .i { transform: rotate(180deg); }
.coach-idea-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; text-decoration: none; }
.coach-idea-btn:hover, .coach-idea-btn[aria-expanded="true"] { color: var(--text); }
.coach-more, .coach-lesson { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.coach-why { font-size: 14px; color: var(--muted); }
.coach-options { display: grid; margin: 0; padding: 0; list-style: none; }
.coach-options li { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.coach-options li + li { border-top: 1px solid var(--line); }
.coach-options li > div { display: grid; flex: 1; gap: 2px; min-width: 0; }
.coach-option { color: var(--text); font-weight: 500; }
.coach-options .btn { flex: none; }
.coach-more > .btn { justify-self: start; }
.coach-idea { font-size: 16px; font-weight: 600; color: var(--text); }

@media (max-width: 640px) {
    .coach-card { --pad: 20px; }
    .coach-options li { flex-wrap: wrap; }
}

/* Academy: a world's path beside what you know, then a level one step at a time. The world's colour tints the page. */
body:has(#card-learn.active) .container { background: var(--world-bg); }
:root[data-theme="dark"] body:has(#card-learn.active) .container { background: color-mix(in srgb, var(--world) 34%, #0d0d12); }
.learn-card.active { max-width: 1040px; animation-fill-mode: backwards; }
.learn-card[data-view="play"].active { max-width: 640px; }
.coach-learn { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 16px; padding: 20px; border: 1px solid color-mix(in srgb, var(--world) 35%, transparent); border-radius: var(--r-lg); background: color-mix(in srgb, var(--world) 10%, var(--surface)); }
.coach-learn .coach-kind { color: var(--world); }
.coach-learn .coach-actions { grid-column: 1 / -1; margin: 0; }
.learn-split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; align-items: start; }
.learn-world { display: grid; gap: 24px; }
.learn-grades { position: sticky; top: 24px; display: grid; gap: 6px; }
.learn-grades > summary { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; cursor: pointer; list-style: none; }
.learn-grades > summary::-webkit-details-marker { display: none; }
.learn-grades > summary { gap: 10px; }
.learn-grades > summary .panel-title, .learn-grades > summary { font-weight: 700; }
.learn-ring, .learn-close { display: none; }
.learn-average { margin-left: auto; color: var(--world); font-variant-numeric: tabular-nums; font-weight: 700; }
.learn-mini { width: 44px; height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.learn-mini i { display: block; height: 100%; background: var(--world); }
.learn-grades > summary .i { flex: none; transform: rotate(-90deg); transition: transform .2s; }
.learn-grades[open] > summary .i { transform: rotate(90deg); }
.learn-grades .pbar-fill { background: var(--world); }
.learn-title { display: flex; align-items: center; gap: 12px; font-family: var(--font); font-size: 40px; color: var(--world); }
.learn-title .i { flex: none; width: 1em; height: 1em; }
.world-select { width: auto; padding: 0 40px 0 0; border: 0; background-color: transparent; background-position: right center; background-size: 28px; color: inherit; font: inherit; letter-spacing: inherit; }
.learn-talk { display: flex; align-items: center; gap: 14px; }
.learn-talk { align-items: flex-end; margin-bottom: 28px; }
.learn-bubble { position: relative; flex: 1; padding: 14px 18px; border-radius: 6px 22px 22px 22px; background: var(--surface); color: var(--text); font-size: 17px; line-height: 1.5; transform-origin: left bottom; animation: bubbleIn .4s cubic-bezier(.2, .9, .3, 1.3) both; }
.learn-bubble .word { display: inline-block; white-space: nowrap; }
.learn-bubble .w { animation: wordIn .08s both; animation-delay: calc(350ms + var(--i) * 48ms); }
.skip .w { animation: none; }
@keyframes bubbleIn { from { opacity: 0; transform: scale(.7); } }
@keyframes wordIn { from { opacity: 0; } }
.learn-bubble > :is(p, ul) { margin: 0; }
.learn-bubble > * + * { margin-top: 10px; }
.learn-list { display: grid; gap: 6px; padding-left: 22px; }
.learn-path { display: grid; justify-items: center; gap: 30px; margin: 0; padding: 24px 0 40px; list-style: none; }
.learn-node:nth-child(4n + 2) { translate: 90px; }
.learn-node:nth-child(4n) { translate: -90px; }
.learn-node button { font-family: var(--font); display: grid; justify-items: center; gap: 10px; max-width: 220px; padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 16px; font-weight: 700; text-align: center; cursor: pointer; }
.learn-node button:disabled { opacity: 1; color: var(--muted); cursor: default; }
.learn-dot { display: grid; place-items: center; width: 92px; height: 92px; border-radius: var(--r-circle); background: var(--world); color: #fff; font-size: 40px; box-shadow: 0 8px 0 color-mix(in srgb, var(--world) 55%, #000); transition: transform .15s; }
.learn-node button:not(:disabled):hover .learn-dot { transform: translateY(-3px) scale(1.04); }
.learn-node.is-boss .learn-dot { width: 120px; height: 120px; font-size: 54px; }
.learn-node.is-next .learn-dot { outline: 6px solid color-mix(in srgb, var(--world) 38%, transparent); outline-offset: 7px; animation: pulse 2.2s ease-in-out infinite; }
.learn-node button:disabled .learn-dot { background: color-mix(in srgb, var(--world) 22%, var(--surface)); color: color-mix(in srgb, var(--world) 55%, var(--surface)); box-shadow: none; }
@keyframes pulse { 50% { outline-offset: 12px; outline-color: color-mix(in srgb, var(--world) 12%, transparent); } }
.learn-stars, .learn-hearts { display: inline-flex; gap: 3px; color: var(--warn); }
.learn-hearts { color: var(--neg); font-size: 22px; }
.learn-stars .is-lost, .learn-hearts .is-lost { opacity: .25; }
.learn-play { display: grid; gap: 18px; }
.learn-top { display: flex; align-items: center; gap: 14px; }
.learn-top .pbar-track { flex: 1; }
.learn-top .pbar-fill { background: var(--world); }
.learn-phase { margin: 0; color: var(--muted); }
.learn-phase strong { color: var(--world); }
.learn-phase[data-phase="practice"] strong { color: var(--warn); }
.learn-phase[data-phase="apply"] strong, .learn-phase[data-phase="boss"] strong { color: var(--neg); }
.learn-stage { display: grid; gap: 16px; padding-top: 14vh; padding-bottom: 6vh; }
.learn-photo { height: clamp(160px, 40vw, 240px); margin: 0; overflow: hidden; border-radius: var(--r-md); background: var(--surface-2); }
.learn-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.learn-photo .coach-photo-credit { display: none; }
.learn-start { position: sticky; bottom: 48px; z-index: 6; justify-self: center; display: inline-flex; align-items: center; gap: 10px; min-width: min(360px, 100%); min-height: 60px; padding: 0 32px; border: 0; border-radius: var(--r-pill); background: var(--world); color: #fff; font: inherit; font-size: 19px; font-weight: 700; box-shadow: 0 8px 24px color-mix(in srgb, var(--world) 45%, transparent); cursor: pointer; justify-content: center; }
.learn-start:active { transform: scale(.98); }
.learn-nav { position: sticky; bottom: 16px; display: flex; align-items: center; gap: 10px; }
.learn-next, .learn-back { flex: none; min-width: 140px; min-height: 52px; padding: 0 28px; font-size: 16px; }
.learn-next { margin-left: auto; }
.learn-back { border: 2px solid var(--accent); background: transparent; color: var(--accent); }
.learn-result { display: grid; justify-items: center; align-content: center; gap: 24px; min-height: 70vh; text-align: center; }
.learn-result h1 { font-family: var(--font); font-weight: 700; font-size: clamp(44px, 12vw, 84px); line-height: 1; letter-spacing: -.03em; color: var(--world); }
.learn-result .teacher { width: 140px; }
.learn-result .btn { background: var(--world); color: #fff; }
.learn-result .learn-stars, .learn-result .learn-hearts { font-size: 44px; }
.learn-result .learn-bubble { flex: none; max-width: 460px; text-align: left; }
.learn-actions { display: grid; gap: 10px; width: min(100%, 380px); }
.learn-actions .btn { min-height: 52px; font-size: 16px; }
/* The start of a level, from the map or from Home: the Academy's screen turns violet and the level's name fills it. */
.learn-splash { position: fixed; inset: 0 0 0 var(--sidebar-w); z-index: 60; display: grid; justify-items: center; align-content: center; gap: 14px; padding: 24px; background: var(--world); color: #fff; text-align: center; animation: fade .25s ease both; cursor: pointer; }
.learn-splash-kind { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; animation: fade .7s .3s ease both; }
.learn-splash h1 { max-width: 14ch; font-family: var(--font); font-weight: 700; font-size: clamp(38px, 10vw, 68px); line-height: 1.08; letter-spacing: -.03em; color: #fff; }
.learn-splash h1 span { display: inline-block; animation: slideUp .6s calc(1.1s + var(--i) * .18s) cubic-bezier(.2, .9, .3, 1.2) both; }
.learn-splash.is-out { animation: fade .4s ease reverse both; pointer-events: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(60px); } }
/* Nemeris the teacher: the voice orb's soft shape, flat. Two uneven layers wave and turn against each other, and two big eyes blink and look around. */
.teacher { position: relative; display: inline-flex; flex: none; align-items: center; justify-content: center; gap: 14%; width: 64px; aspect-ratio: 1; }
.teacher::before, .teacher::after { content: ''; position: absolute; inset: 0; }
.teacher::after { z-index: 1; background: var(--world, var(--accent)); border-radius: 38% 62% 55% 45% / 55% 36% 64% 45%; animation: turn 14s linear infinite, wave 4.5s ease-in-out infinite; }
.teacher::before { background: color-mix(in srgb, var(--world, var(--accent)) 25%, transparent); border-radius: 60% 40% 38% 62% / 42% 60% 40% 58%; animation: turn 9s linear infinite reverse, wave2 3.4s ease-in-out infinite; }
.teacher i { position: relative; z-index: 2; width: 17%; height: 26%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0 18%, #15121E 21%); animation: blink 5s infinite, look 9s ease-in-out infinite; }
.teacher.is-happy { animation: hop .55s ease; }
.teacher.is-oops { animation: shake .4s ease; }
.teacher.is-joy { animation: hop .7s ease infinite; }
@keyframes turn { to { rotate: 360deg; } }
@keyframes wave { 50% { border-radius: 64% 36% 42% 58% / 40% 62% 38% 60%; } }
@keyframes wave2 { 50% { border-radius: 40% 60% 62% 38% / 60% 38% 62% 40%; } }
@keyframes blink { 0%, 92%, 100% { scale: 1; } 95% { scale: 1 .1; } }
@keyframes look { 0%, 30%, 100% { translate: 0; } 38%, 55% { translate: 30% -10%; } 63%, 85% { translate: -30% 8%; } }
@keyframes hop { 40% { transform: translateY(-22%) scale(.94, 1.08); } 70% { transform: translateY(0) scale(1.08, .92); } }
@keyframes shake { 25% { transform: translateX(-8%); } 75% { transform: translateX(8%); } }
@media (prefers-reduced-motion: reduce) { .teacher, .teacher::before, .teacher::after, .teacher i { animation: none; } }
@media (max-width: 899px) {
    .learn-split { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    /* What you know: closed, just the score in its ring, floating at the top right; open, a panel with a clear close button. */
    .panel.learn-grades { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); right: 16px; z-index: 65; max-height: calc(100dvh - 160px); padding: 0; border: 0; background: none; box-shadow: none; }
    .panel.learn-grades > summary { margin: 0; }
    .panel.learn-grades > summary > :not(.learn-ring, .learn-label, .learn-average, .learn-close) { display: none; }
    .panel.learn-grades:not([open]) > summary > :is(.learn-label, .learn-average, .learn-close),
    .panel.learn-grades[open] > summary > .learn-ring { display: none; }
    .panel.learn-grades[open] { width: min(340px, calc(100vw - 32px)); padding: 6px 8px 16px 18px; overflow-y: auto; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); }
    .learn-ring { position: relative; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: conic-gradient(var(--world) var(--p), var(--surface-3) 0); box-shadow: var(--shadow); }
    .learn-ring::before { content: ''; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
    .learn-ring b { position: relative; font-size: 13px; font-variant-numeric: tabular-nums; }
    .learn-close { display: grid; place-items: center; width: 44px; height: 44px; margin-left: 4px; border-radius: 50%; background: var(--surface-2); color: var(--text); font-size: 20px; }
    .learn-splash { left: 0; }
    .learn-title { font-size: 30px; }
    .learn-node:nth-child(4n + 2) { translate: 56px; }
    .learn-node:nth-child(4n) { translate: -56px; }
    .learn-nav { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
    .learn-start { bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }
    /* Centred, and narrow enough to leave the assistant's button free on the right. */
    .learn-start { min-width: 0; width: calc(100% - 144px); padding: 0 12px; font-size: 16px; white-space: nowrap; }
}
/* About you, asked the Academy's way, always in the app's own violet. */
.survey { --world: var(--accent); --world-bg: var(--surface-2); }
.survey .learn-stage { padding: 8px 0 0; }
.survey .learn-bubble { background: var(--surface-2); }
.survey .learn-nav { position: static; }
.survey-intro { --world: var(--accent); display: flex; flex-wrap: wrap; align-items: center; gap: 14px 16px; }
.survey-intro .teacher { width: 56px; }
.survey-blurb { flex: 1; min-width: 200px; margin: 0; color: var(--text-2); }
.survey-intro[hidden], .survey[hidden] { display: none; }
