/* TokenEcon. Themes and colors are tokens on :root; nothing below hard-codes a color. */

:root {
  --bg: #0f1218; --panel: #171b24; --panel2: #1d2230; --text: #e9ecf3; --muted: #8d97ab; --line: #2a3142; --danger: #ff9a8a;
  --accent: #5b9bff; --accent-ink: #07101f; --shadow: 0 1px 2px rgba(0,0,0,.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --col: 780px;
 --c1: #3987e5; --c2: #d95926; --c3: #199e70; --grid: #262c3b; --warn: #fab219;
  --m-burn: #86b6ef; --m-burn-ink: #07101f; --m-cruise: #2a78d6; --m-cruise-ink: #ffffff; --m-slow: #184f95; --m-slow-ink: #ffffff; --m-pause: #232a39; --m-pause-ink: #8d97ab; --band: rgba(250,178,25,.10);
  color-scheme: dark;
}
:root[data-theme="light"] { --bg: #f3f4f7; --panel: #ffffff; --panel2: #e9ecf2; --text: #161a22; --muted: #5d667a; --line: #d5dae4; --danger: #c2392b; --accent: #2f6fdd; --accent-ink: #ffffff; --shadow: 0 1px 2px rgba(20,30,50,.12); --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --grid: #e3e7ef; --warn: #fab219;
  --m-burn: #184f95; --m-burn-ink: #ffffff; --m-cruise: #3987e5; --m-cruise-ink: #ffffff; --m-slow: #9ec5f4; --m-slow-ink: #0d366b; --m-pause: #e4e8f0; --m-pause-ink: #5d667a; --band: rgba(250,178,25,.16); color-scheme: light; }
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] { --bg: #f3f4f7; --panel: #ffffff; --panel2: #e9ecf2; --text: #161a22; --muted: #5d667a; --line: #d5dae4; --danger: #c2392b; --accent: #2f6fdd; --accent-ink: #ffffff; --shadow: 0 1px 2px rgba(20,30,50,.12); --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --grid: #e3e7ef; --warn: #fab219;
  --m-burn: #184f95; --m-burn-ink: #ffffff; --m-cruise: #3987e5; --m-cruise-ink: #ffffff; --m-slow: #9ec5f4; --m-slow-ink: #0d366b; --m-pause: #e4e8f0; --m-pause-ink: #5d667a; --band: rgba(250,178,25,.16); color-scheme: light; }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-boot { padding: 2rem; color: var(--muted); }
.app-icon { flex: none; }

/* page frame: a centered column that works from a phone up */
.app-page { max-width: var(--col); margin: 0 auto; padding: 0 16px 48px; padding-bottom: max(48px, env(safe-area-inset-bottom)); }
.app-bar { display: flex; align-items: center; gap: .75rem; min-height: 3.25rem; padding-top: max(.5rem, env(safe-area-inset-top)); }
.app-bar h1 { flex: 1; margin: 0; font-size: 1.15rem; }
.app-bar .app-back { display: inline-flex; align-items: center; gap: .3em; color: var(--muted); text-decoration: none; }
.app-bar .app-back:hover { color: var(--text); }

/* buttons */
.app-btn { display: inline-flex; align-items: center; gap: .4em; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: .45em .8em; cursor: pointer; min-height: 2.4rem; }
.app-btn:hover { background: var(--panel2); }
.app-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.app-btn.primary:hover { filter: brightness(1.08); }
.app-btn.danger { color: var(--danger); }
.app-btn:disabled { opacity: .4; cursor: default; }
.app-btn.icon-only { padding: .4em; width: 2.4rem; justify-content: center; }

/* forms */
.app-form { display: flex; gap: .5rem; margin: .5rem 0 1rem; }
.app-form input[type=text] { flex: 1; min-width: 0; padding: .55em .75em; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.field { margin: .9rem 0; }
.field-label { display: block; font-weight: 600; margin-bottom: .25rem; }
.field select { padding: .45em .6em; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.hint { margin: .3rem 0 0; color: var(--muted); font-size: .85rem; }

/* the list */
.app-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.app-row { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.app-row input[type=checkbox] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.app-row .app-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.app-row.done .app-text { color: var(--muted); text-decoration: line-through; }
.app-empty { color: var(--muted); text-align: center; padding: 2rem 1rem; border: 1px dashed var(--line); border-radius: 10px; }

/* settings */
.app-section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .25rem 1rem 1rem; margin: 1rem 0; }
.app-section h2 { font-size: 1rem; margin: .9rem 0 .25rem; }
.app-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.app-version { color: var(--muted); font-size: .8rem; text-align: center; margin-top: 1.5rem; }

/* toast: one line at the bottom, with an optional action (Undo) */
#app-toast { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translate(-50%, 140%); display: flex; align-items: center; gap: .75rem; max-width: calc(100% - 32px); padding: .6rem .9rem; background: var(--text); color: var(--bg); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.35); transition: transform .2s; z-index: 10; }
#app-toast.show { transform: translate(-50%, 0); }
#app-toast button { border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }


/* ---- TokenEcon ---- */
.app-foot { color: var(--muted); font-size: .8rem; text-align: center; margin: 1.5rem 0 0; }
.notice { padding: 1rem; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); }

/* tab bar: scrolls sideways on a phone, so the page itself never does */
.tabs { display: flex; gap: .25rem; overflow-x: auto; margin: 0 -16px .75rem; padding: 0 16px .35rem; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: .5em .85em; border-radius: 8px 8px 0 0; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* cards and forms */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .25rem 1rem 1rem; margin: 1rem 0; box-shadow: var(--shadow); }
.card h2 { font-size: 1rem; margin: .9rem 0 .35rem; }
.card h3 { font-size: .9rem; margin: 1rem 0 .3rem; }
.card > p { margin: .5rem 0; }
.field input[type=text], .field input[type=number], .field input[type=datetime-local], .field select, textarea { width: 100%; max-width: 26rem; padding: .5em .65em; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
textarea { max-width: none; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; }
.field-row { display: flex; align-items: center; gap: .5rem; }
.field-row input { max-width: 9rem; }
.unit { color: var(--muted); font-size: .85rem; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.toggle-row { display: flex; align-items: center; gap: .6rem; cursor: pointer; }
.toggle-row input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.toggle-label { font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0 1rem; }
.cal-grid input { max-width: 9rem; }

/* verdict */
.verdict { border: 1px solid var(--line); border-left: 6px solid var(--m-pause); background: var(--panel); border-radius: 12px; padding: .8rem 1rem; margin: .5rem 0 1rem; }
.verdict.m-burn { border-left-color: var(--m-burn); } .verdict.m-cruise { border-left-color: var(--m-cruise); } .verdict.m-slow { border-left-color: var(--m-slow); }
.verdict-top { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.verdict-allow { font-weight: 600; }
.mode-badge { font-size: 1.5rem; font-weight: 800; letter-spacing: .06em; padding: .15em .6em; border-radius: 8px; background: var(--m-pause); color: var(--m-pause-ink); }
.mode-badge.m-burn { background: var(--m-burn); color: var(--m-burn-ink); } .mode-badge.m-cruise { background: var(--m-cruise); color: var(--m-cruise-ink); } .mode-badge.m-slow { background: var(--m-slow); color: var(--m-slow-ink); }
.reasons { margin: .6rem 0 0; padding-left: 1.2rem; color: var(--text); } .reasons li { margin: .25rem 0; }

/* meters, slots, tiles */
.meters { display: grid; gap: .9rem; margin: 1rem 0; }
.meter-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: .25rem; }
.meter-track { position: relative; height: 14px; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--c1); border-radius: 7px 0 0 7px; } .meter-fill.over { background: var(--warn); }
.meter-mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); }
.meter-sub { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.slots { margin: 1rem 0; }
.slot-row { display: flex; gap: 3px; flex-wrap: wrap; }
.slot { width: 16px; height: 22px; border-radius: 3px; background: var(--panel2); border: 1px solid var(--line); }
.slot.past { opacity: .4; } .slot.now { background: var(--m-cruise); border-color: var(--text); } .slot.afford { background: var(--c1); border-color: transparent; } .slot.spare { background: transparent; border-style: dashed; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: .6rem; margin: 1rem 0; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .75rem; }
.tile-label { color: var(--muted); font-size: .8rem; } .tile-value { font-size: 1.35rem; font-weight: 700; } .tile-sub { color: var(--muted); font-size: .78rem; }

/* tables, code, details */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .7rem .8rem; overflow-x: auto; font-size: .8rem; margin: .5rem 0; }
.code.small { font-size: .78rem; }
summary { cursor: pointer; font-weight: 600; }
.glossary dl, .spec { margin: .5rem 0; } dt { font-weight: 700; margin-top: .5rem; } dd { margin: 0 0 0 0; color: var(--muted); }
.agent summary { display: flex; align-items: center; gap: .6rem; padding: .6rem 0; } .agent-name { font-weight: 700; flex: 1; }
.agent-state { font-size: .75rem; font-weight: 600; padding: .1em .55em; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); white-space: nowrap; }
.agent-state.on, .agent-state.status-supported { color: var(--text); border-color: var(--c3); }
.agent-state.status-testing { border-color: var(--warn); color: var(--text); }
.loop { margin: .3rem 0 0; padding-left: 1.2rem; }
.model.current { border-color: var(--accent); } .model-head, .phase-head, .theory-head, .est-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.tagline { color: var(--muted); margin-top: 0; }
.theories, .links { list-style: none; padding: 0; margin: 0; } .theory { padding: .6rem 0; border-bottom: 1px solid var(--line); } .theory p { margin: .3rem 0; } .links li { margin: .3rem 0; }
.est { padding: .5rem 0; } .est-value { font-size: 1.3rem; font-weight: 700; margin: .2rem 0; }
.phase-now { border-color: var(--accent); }

/* charts: classes only, colors are tokens */
.chart { position: relative; margin: .5rem 0; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; } .chart-svg .grid.v { stroke-dasharray: 2 4; }
.chart-svg .axis { stroke: var(--line); stroke-width: 1; }
.chart-svg .tick { fill: var(--muted); font-size: 10px; } .chart-svg .lbl { fill: var(--text); font-size: 11px; font-weight: 600; }
.chart-svg .band { fill: var(--band); } .chart-svg .now { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .ln { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; } .chart-svg .ln.dash { stroke-dasharray: 5 4; }
.chart-svg .cross-line { stroke: var(--muted); stroke-width: 1; } .chart-svg .dot { stroke: var(--panel); stroke-width: 2; }
.ln.c1 { stroke: var(--c1); } .ln.c2 { stroke: var(--c2); } .ln.c3 { stroke: var(--c3); } .ln.c-target { stroke: var(--muted); }
.seg.c1, .swatch-mark.c1, .dot.c1 { fill: var(--c1); } .seg.c2, .swatch-mark.c2, .dot.c2 { fill: var(--c2); } .seg.c3, .swatch-mark.c3, .dot.c3 { fill: var(--c3); } .swatch-mark.c-target, .dot.c-target { fill: var(--muted); }
.seg { stroke: var(--panel); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; list-style: none; padding: 0; margin: .4rem 0 0; font-size: .85rem; } .legend li { display: flex; align-items: center; gap: .4rem; }
.swatch { display: inline-block; width: 14px; height: 4px; border-radius: 2px; background: var(--muted); }
.swatch.c1 { background: var(--c1); } .swatch.c2 { background: var(--c2); } .swatch.c3 { background: var(--c3); } .swatch.dash { background: repeating-linear-gradient(90deg, var(--muted) 0 5px, transparent 5px 8px); }
.tip { position: absolute; top: 8px; z-index: 2; background: var(--text); color: var(--bg); border-radius: 8px; padding: .4rem .6rem; font-size: .8rem; pointer-events: none; box-shadow: 0 4px 16px rgba(0,0,0,.3); } .tip-row { display: flex; align-items: center; gap: .4rem; }
.tip .swatch { background: var(--bg); } .tip .swatch.c1 { background: var(--c1); } .tip .swatch.c2 { background: var(--c2); } .tip .swatch.c3 { background: var(--c3); }
.table-view { margin-top: .4rem; } .table-view summary { font-size: .85rem; font-weight: 500; color: var(--muted); }
.cell { stroke: none; } .cell.m-burn { fill: var(--m-burn); } .cell.m-cruise { fill: var(--m-cruise); } .cell.m-slow { fill: var(--m-slow); } .cell.m-pause { fill: var(--m-pause); } .cell.m-none { fill: transparent; stroke: var(--grid); }
.cell-letter { font-size: 10px; font-weight: 700; fill: var(--m-pause-ink); pointer-events: none; }
.peak-tick { fill: var(--warn); }
.swatch.cellkey { width: 18px; height: 18px; border-radius: 4px; text-align: center; font-size: 10px; font-weight: 700; line-height: 18px; }
.swatch.cellkey.m-burn { background: var(--m-burn); color: var(--m-burn-ink); } .swatch.cellkey.m-cruise { background: var(--m-cruise); color: var(--m-cruise-ink); } .swatch.cellkey.m-slow { background: var(--m-slow); color: var(--m-slow-ink); } .swatch.cellkey.m-pause { background: var(--m-pause); color: var(--m-pause-ink); }
.swatch.peak-key { background: var(--warn); height: 3px; }
@media (max-width: 480px) { .chart-svg .lbl { font-size: 13px; } .chart-svg .tick { font-size: 12px; } .mode-badge { font-size: 1.25rem; } }

/* ---- Providers ---- */
.providers .prov { margin-top: .9rem; } .prov h3 { font-size: .95rem; margin: .8rem 0 .3rem; }
.prov .verdict, .prov .meters, .prov .tiles { margin-top: .6rem; }
.prov-notes, .prov-calc { margin-top: .7rem; } .prov-notes summary, .prov-calc summary { font-size: .85rem; font-weight: 500; color: var(--muted); cursor: pointer; }
.sources { padding-left: 1.1rem; font-size: .85rem; } .sources a { color: var(--accent); overflow-wrap: anywhere; }
.route-list { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .35rem; }
.route-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .4rem; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 10px; }
.route-row .mode-badge { font-size: .8rem; padding: .05em .5em; } .route-row.blocked { opacity: .7; }
.calc-out { margin-top: .5rem; }

/* my week editor */
.my-week { margin: .5rem 0 1rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); }
.hour-bars { display: flex; align-items: flex-end; gap: 2px; height: 3rem; margin: .5rem 0; }
.hour-bars span { flex: 1; background: var(--c1); border-radius: 2px 2px 0 0; min-height: 2px; }
.hour-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr)); gap: .4rem; margin: .6rem 0; }
.hour-cell { display: grid; gap: .15rem; font-size: .75rem; color: var(--muted); }
.hour-cell input { width: 100%; max-width: none; padding: .3em .4em; }
