:root {
    color-scheme: light;
    --bg: #f5f3ee;
    --surface: #fcfcfb;
    --surface-2: #f0efec;
    --border: #e4e2dc;
    --text: #0b0b0b;
    --text-2: #52514e;
    --text-3: #7a7974;
    --accent: #2a78d6;
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-4: #eda100;
    --pos: #008300;
    --neg: #2a78d6;
    --up: #0b7a0b;
    --down: #c0392f;
    --grid: #e4e2dc;
    --zero: #b9b7b0;
    --seg-crisis: #2a78d6;
    --seg-downturn: #86b6ef;
    --seg-stable: #d9d8d4;
    --seg-expansion: #8fd18f;
    --seg-boom: #008300;
    --hero-boom: linear-gradient(135deg, #fff1c9, #ffd9a8);
    --hero-expansion: linear-gradient(135deg, #e3f5e9, #d5ebff);
    --hero-stable: linear-gradient(135deg, #f1f2f4, #e2e7ee);
    --hero-downturn: linear-gradient(135deg, #e2e9f3, #c9d4e4);
    --hero-crisis: linear-gradient(135deg, #3a3e57, #5b2d3b);
    --hero-text: #0b0b0b;
    --hero-crisis-text: #f7f4ef;
    --radius: 18px;
    --shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 6px 20px rgb(0 0 0 / 5%);
    /* A thin pixel outline around Kibba's pictures, so her light wool shows on a light page. */
    --kibba-outline: rgb(0 0 0 / 55%);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        /* …and a light one in dark mode, so her black face shows. */
        --kibba-outline: rgb(255 255 255 / 70%);
        --bg: #121211;
        --surface: #1a1a19;
        --surface-2: #242422;
        --border: #2e2e2b;
        --text: #f0efec;
        --text-2: #c3c2b7;
        --text-3: #94938b;
        --accent: #3987e5;
        --series-1: #3987e5;
        --series-2: #d95926;
        --series-3: #199e70;
        --series-4: #c98500;
        --pos: #0ca30c;
        --neg: #3987e5;
        --up: #4fc34f;
        --down: #f07a70;
        --grid: #2e2e2b;
        --zero: #55554f;
        --seg-crisis: #3987e5;
        --seg-downturn: #2b5b95;
        --seg-stable: #4a4a46;
        --seg-expansion: #2e6b2e;
        --seg-boom: #0ca30c;
        --hero-boom: linear-gradient(135deg, #4a3812, #5a3417);
        --hero-expansion: linear-gradient(135deg, #17382a, #173353);
        --hero-stable: linear-gradient(135deg, #24262b, #2b3038);
        --hero-downturn: linear-gradient(135deg, #1f2a3a, #2a3346);
        --hero-crisis: linear-gradient(135deg, #22243a, #3e1a26);
        --hero-text: #f0efec;
        --shadow: none;
    }
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

h1, h2 {
    line-height: 1.15;
    margin: 0;
}

h2 {
    font-size: 1.15rem;
    margin-bottom: 12px;
}

a {
    color: var(--accent);
}

.muted {
    color: var(--text-3);
}

.small {
    font-size: .85rem;
    margin: 8px 0 0;
}

/* Header */

.site-header {
    padding: 20px 16px 8px;
}

.site-header__inner,
.content,
.site-footer {
    max-width: 1040px;
    margin: 0 auto;
}

.site-header__inner {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: ". switches";
    align-items: center;
    gap: 4px 16px;
}

.switches {
    grid-area: switches;
    justify-self: end;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.switch {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px;
}

.switch a {
    padding: 6px 12px;
    border-radius: 999px;
    color: var(--text-2);
    text-decoration: none;
    font-size: .9rem;
    white-space: nowrap;
}

.switch a[aria-current] {
    background: var(--text);
    color: var(--surface);
}

/* Layout */

.content {
    padding: 8px 16px 24px;
    display: grid;
    /* minmax(0, …) so a wide table inside a card scrolls instead of widening the page. */
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

.panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

.panel[hidden] {
    display: none;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.cards-3 {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.cards-2 {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* Time machine */

.time-machine {
    padding: 14px 20px 30px;
}

/* On screens with room for it the time machine stays in view while scrolling. */
@media (min-width: 700px) and (min-height: 460px) {
    .time-machine {
        position: sticky;
        top: 8px;
        z-index: 5;
    }
}

/* On low screens (laptops with a bookmarks bar) it is made compact, so it does not take too
   much of the page while it follows: less padding and no hint text. */
@media (min-width: 700px) and (min-height: 460px) and (max-height: 800px) {
    .time-machine {
        padding: 8px 16px 18px;
    }

    .time-machine__label .muted {
        display: none;
    }
}

.time-machine__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 6px;
}

.view-switch {
    flex: none;
}

.time-machine__head {
    flex-wrap: wrap;
}

.time-machine__label {
    font-weight: 700;
}

.time-machine__label .muted {
    font-weight: 400;
    font-size: .85rem;
    margin-left: 6px;
}

.time-machine__year {
    margin-left: auto;
    font-size: 1.6rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.time-machine input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    height: 28px;
    margin: 0;
    cursor: pointer;
}

.time-machine__ticks {
    position: relative;
    margin: 0 10px;
    font-size: .75rem;
    color: var(--text-3);
}

.time-machine__ticks span {
    position: absolute;
    transform: translateX(-50%);
}

/* Hero */

.hero {
    border-radius: var(--radius);
    padding: 24px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px 20px;
    align-items: center;
    color: var(--hero-text);
    box-shadow: var(--shadow);
}

.hero--boom { background: var(--hero-boom); }
.hero--expansion { background: var(--hero-expansion); }
.hero--stable { background: var(--hero-stable); }
.hero--downturn { background: var(--hero-downturn); }
.hero--crisis { background: var(--hero-crisis); color: var(--hero-crisis-text); }

.hero__mascot {
    position: relative;
    animation: float 4s ease-in-out infinite;
}

.hero__mascot .mascot {
    display: block;
}

/* Kibba's face and legs are black, so a thin light outline keeps her whole on dark backgrounds. */
.mascot {
    filter:
        drop-shadow(1px 0 0 rgb(255 255 255 / 75%))
        drop-shadow(-1px 0 0 rgb(255 255 255 / 75%))
        drop-shadow(0 1px 0 rgb(255 255 255 / 75%))
        drop-shadow(0 -1px 0 rgb(255 255 255 / 75%))
        drop-shadow(0 4px 6px rgb(0 0 0 / 25%));
}

.hero__weather {
    position: absolute;
    top: -14px;
    right: -14px;
    font-size: 2.2rem;
    line-height: 1;
}

.hero__mascot[data-bleat] {
    cursor: pointer;
}

.hero__mascot[data-bleat]:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 6px;
    border-radius: 8px;
}

/* A little hop while bleating; it replaces the gentle float for a moment. */
.hero__mascot.is-bleating {
    animation: hop .5s ease-out;
}

@keyframes hop {
    30% { transform: translateY(-14px) rotate(-4deg); }
    60% { transform: translateY(0) rotate(2deg); }
}

.bleat {
    position: absolute;
    left: 55%;
    top: -34px;
    padding: 4px 10px;
    border-radius: 12px;
    background: #fff;
    color: #0b0b0b;
    font-weight: 800;
    font-size: .95rem;
    white-space: nowrap;
    box-shadow: 0 3px 10px rgb(0 0 0 / 25%);
    animation: bleat-pop 2.2s ease-out forwards;
    pointer-events: none;
    z-index: 3;
}

.bleat::after {
    content: "";
    position: absolute;
    left: 14px;
    bottom: -7px;
    border: 7px solid transparent;
    border-bottom: 0;
    border-top-color: #fff;
}

@keyframes bleat-pop {
    0% { opacity: 0; transform: translateY(6px) scale(.8); }
    12% { opacity: 1; transform: translateY(0) scale(1.05); }
    20% { transform: scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-8px); }
}

@media (prefers-reduced-motion: reduce) {
    .bleat { animation: none; }
}

@keyframes float {
    50% { transform: translateY(-6px) rotate(-3deg); }
}

@media (prefers-reduced-motion: reduce) {
    .hero__mascot { animation: none; }
}

.hero__bubble {
    position: relative;
    display: inline-block;
    margin: 10px 0 0;
    padding: 8px 14px;
    border-radius: 14px;
    background: rgb(255 255 255 / 75%);
    color: #0b0b0b;
    font-size: 1rem;
    max-width: 52ch;
}

.hero__bubble::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 14px;
    border: 8px solid transparent;
    border-left: 0;
    border-right-color: rgb(255 255 255 / 75%);
}

.hero__when {
    margin: 0;
    font-weight: 600;
    opacity: .8;
}

.hero__band {
    font-size: clamp(2.2rem, 7vw, 3.4rem);
    font-weight: 900;
    letter-spacing: -.02em;
}

.hero__score {
    text-align: right;
}

.hero__number {
    display: block;
    font-size: clamp(2.4rem, 8vw, 3.6rem);
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.hero__of {
    font-size: .8rem;
    opacity: .75;
}

.hero__question {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-2);
}

.hero__note {
    grid-column: 1 / -1;
    margin: 4px 0 0;
    font-size: .85rem;
    opacity: .8;
}

.gauge {
    grid-column: 1 / -1;
    margin-top: 12px;
}

.gauge__track {
    position: relative;
    display: flex;
    gap: 2px;
    height: 14px;
}

.gauge__seg {
    flex: 1;
}

.gauge__seg:first-child { border-radius: 7px 0 0 7px; }
.gauge__seg:last-of-type { border-radius: 0 7px 7px 0; }
.gauge__seg--crisis { flex: 50; background: var(--seg-crisis); }
.gauge__seg--downturn { flex: 35; background: var(--seg-downturn); }
.gauge__seg--stable { flex: 30; background: var(--seg-stable); }
.gauge__seg--expansion { flex: 35; background: var(--seg-expansion); }
.gauge__seg--boom { flex: 50; background: var(--seg-boom); }

.gauge__marker {
    position: absolute;
    top: -6px;
    width: 26px;
    height: 26px;
    margin-left: -13px;
    border-radius: 50%;
    background: var(--surface);
    border: 4px solid var(--text);
    box-shadow: 0 2px 6px rgb(0 0 0 / 25%);
    transition: left .3s ease;
}

.hero--crisis .gauge__marker {
    border-color: var(--hero-crisis-text);
    background: #22243a;
}

.gauge__legend {
    display: flex;
    gap: 2px;
    margin-top: 10px;
    font-size: .8rem;
    line-height: 1.25;
}

.gauge__legend-item {
    text-align: center;
    opacity: .7;
    min-width: 0;
}

.gauge__legend-item--crisis,
.gauge__legend-item--boom { flex: 50; }
.gauge__legend-item--downturn,
.gauge__legend-item--expansion { flex: 35; }
.gauge__legend-item--stable { flex: 30; }

.gauge__legend-item.is-current {
    opacity: 1;
    font-weight: 800;
}

.gauge__legend-name,
.gauge__legend-range {
    display: block;
}

.gauge__legend-range {
    font-variant-numeric: tabular-nums;
    font-size: .75rem;
}

.gauge__explain {
    margin: 12px 0 0;
    font-size: .9rem;
    opacity: .85;
}

/* Score breakdown */

.breakdown__intro {
    margin: -4px 0 12px;
}

.breakdown__head {
    display: grid;
    grid-template-columns: minmax(120px, 200px) 1fr 64px;
    gap: 12px;
    font-size: .75rem;
    color: var(--text-3);
}

.breakdown__dirs {
    display: flex;
    justify-content: space-between;
}

.breakdown__rounded {
    display: block;
    font-size: .75rem;
    font-weight: 400;
    color: var(--text-3);
}

.breakdown__list {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
}

.breakdown__row {
    display: grid;
    grid-template-columns: minmax(120px, 200px) 1fr 64px;
    align-items: center;
    gap: 12px;
    padding: 5px 0;
}

.breakdown__name {
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breakdown__track {
    position: relative;
    height: 16px;
}

.breakdown__track::after {
    content: "";
    position: absolute;
    left: 50%;
    top: -5px;
    bottom: -5px;
    width: 2px;
    margin-left: -1px;
    background: var(--zero);
}

.breakdown__bar {
    position: absolute;
    top: 0;
    bottom: 0;
}

.breakdown__bar.is-pos {
    background: var(--pos);
    border-radius: 0 4px 4px 0;
}

.breakdown__bar.is-neg {
    background: var(--neg);
    border-radius: 4px 0 0 4px;
}

.breakdown__value {
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.breakdown__row.is-missing {
    display: none;
}

/* In the fixed order, indicators without data keep their place as a faint row. */
[data-breakdown="fixed"] .breakdown__row.is-missing {
    display: grid;
    opacity: .45;
}

.breakdown__total {
    border-top: 2px solid var(--border);
    margin-top: 6px;
    padding-top: 10px;
    font-weight: 800;
}

.breakdown__total .breakdown__track::after {
    display: none;
}

.breakdown__total .breakdown__value {
    font-size: 1.2rem;
}

/* Indicator tiles */

.tiles {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.tile {
    background: var(--surface-2);
    border-radius: 14px;
    padding: 14px;
}

.tile__label {
    font-weight: 700;
}

.tile__value {
    font-size: 1.7rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.tile__hint {
    color: var(--text-3);
    font-size: .8rem;
    min-height: 2.4em;
}

/* Mock home loan */

.loan__intro {
    margin: -4px 0 16px;
}

.loan__grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    align-items: center;
}

.loan__big {
    background: var(--surface-2);
    border-radius: 14px;
    padding: 16px;
}

.loan__label {
    display: block;
    color: var(--text-2);
    font-weight: 600;
}

.loan__payment {
    display: block;
    font-size: clamp(1.8rem, 6vw, 2.4rem);
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.loan__burden {
    display: block;
    color: var(--text-2);
    font-size: .9rem;
}

.loan__burden strong {
    color: var(--text);
    font-size: 1.1rem;
}

.loan__bar {
    height: 10px;
    margin-top: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg, var(--seg-expansion) 0 33%, var(--seg-stable) 33% 50%, var(--seg-downturn) 50% 100%);
    position: relative;
    overflow: hidden;
}

.loan__bar span {
    position: absolute;
    inset: 0 auto 0 0;
    border-right: 3px solid var(--text);
    background: rgb(0 0 0 / 8%);
    transition: width .2s ease;
}

.loan__note {
    margin: 16px 0 0;
    font-size: .85rem;
    color: var(--text-2);
}

.loan__slider {
    display: block;
    margin-top: 16px;
    font-size: .9rem;
    color: var(--text-2);
}

.loan__slider input {
    width: 100%;
    accent-color: var(--accent);
    margin-top: 6px;
}

/* Rows in the small cards */

.rows {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.rows li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 12px;
}

.rows__label {
    color: var(--text-2);
}

.rows__value {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.rows__delta {
    grid-column: 1 / -1;
    font-size: .8rem;
    color: var(--text-2);
}

.rows__delta.is-up::first-letter { color: var(--up); }
.rows__delta.is-down::first-letter { color: var(--down); }

/* Line charts (shared by the two-panel charts) */

.lines__toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
}

.lines__toggle[aria-pressed="false"] {
    background: transparent;
    color: var(--text-3);
    text-decoration: line-through;
}

.lines__toggle[aria-pressed="false"] .lines__key {
    opacity: .3;
}

.lines__key {
    display: inline-block;
    width: 14px;
    height: 3px;
    border-radius: 2px;
    background: var(--series);
    flex: none;
}

.lines__plot {
    position: relative;
}

.lines__plot svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.lines__grid {
    stroke: var(--grid);
    stroke-width: 1;
}

.lines__grid.is-zero {
    stroke: var(--zero);
}

.lines__axis {
    fill: var(--text-3);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.lines__path {
    fill: none;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.lines__path--dashed {
    stroke-dasharray: 6 4;
}

.lines__key--dashed {
    background: repeating-linear-gradient(90deg, var(--series) 0 5px, transparent 5px 8px);
}

.lines__toggle:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.sr__ma-toggle[aria-pressed="false"] {
    text-decoration: none;
}

.lines__hair {
    stroke: var(--text-3);
    stroke-width: 1;
}

.lines__dot {
    stroke: var(--surface);
    stroke-width: 2;
}

.lines__tooltip {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    pointer-events: none;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 4px 14px rgb(0 0 0 / 20%);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: .8rem;
    white-space: nowrap;
    z-index: 2;
}

.lines__tooltip-title {
    color: var(--text-2);
    margin-bottom: 4px;
}

.lines__tooltip-row {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-2);
}

.lines__tooltip-row strong {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* Compare anything */

.compare__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin: 12px 0;
}

.compare__select {
    display: grid;
    gap: 4px;
    font-size: .85rem;
    color: var(--text-2);
}

.sr__about {
    margin-top: 4px;
}

.compare__select select {
    font: inherit;
    font-size: .95rem;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 10px;
    min-width: 240px;
    max-width: 100%;
}

/* Stocks and rates */

.sr__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 12px 0 4px;
}

.sr__compare-label {
    color: var(--text-2);
    font-size: .9rem;
    margin-right: 4px;
}

.sr__controls .lines__toggle[aria-pressed="false"] {
    text-decoration: none;
}

.sr__controls .lines__toggle[aria-pressed="true"] {
    background: var(--text);
    color: var(--surface);
    border-color: var(--text);
}

.sr__summary {
    margin: 8px 0 12px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    font-weight: 600;
}

.sr__shade {
    fill: var(--series-2);
    opacity: .12;
}

.sr__shade-key {
    display: inline-block;
    width: 14px;
    height: 10px;
    vertical-align: -1px;
    background: var(--series-2);
    opacity: .3;
}

.sr__panel-title {
    fill: var(--text-2);
    font-size: 12px;
    font-weight: 700;
}

/* Warnings */

.warnings__summary {
    margin: 0 0 12px;
    font-weight: 700;
}

.warnings__message {
    grid-column: 1 / -1;
    color: var(--text-2);
    font-size: 0.9em;
}

.warnings > p.small {
    margin: 12px 0 0;
}

/* History chart */

.chart {
    position: relative;
    margin-top: 12px;
}

.chart svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.chart__grid {
    stroke: var(--grid);
    stroke-width: 1;
    stroke-dasharray: 3 4;
}

.chart__grid.is-zero {
    stroke: var(--zero);
    stroke-dasharray: none;
}

.chart__axis,
.chart__band {
    fill: var(--text-3);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.chart__divider {
    stroke: var(--zero);
    stroke-dasharray: 4 4;
}

.chart__hatch {
    fill: currentColor;
}

.chart__bar.is-forecast .chart__mark {
    fill-opacity: .45;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-dasharray: 3 2;
}

.chart__bar.is-forecast .chart__mark.is-pos { color: var(--pos); }
.chart__bar.is-forecast .chart__mark.is-neg { color: var(--neg); }

.hero__note--forecast {
    font-weight: 700;
    opacity: 1;
}

.time-machine__forecast {
    color: var(--text-2);
}

.fishfood__basket {
    margin: 14px 0 0;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    font-size: .9rem;
}

.chart__label {
    fill: var(--text);
    font-size: 12px;
    font-weight: 700;
}

.chart__bar {
    cursor: pointer;
}

.chart__hit {
    fill: transparent;
}

.chart__bar:hover .chart__hit {
    fill: var(--surface-2);
}

.chart__mark.is-pos { fill: var(--pos); }
.chart__mark.is-neg { fill: var(--neg); }

.chart__bar.is-selected .chart__hit {
    fill: var(--surface-2);
}

.chart__bar.is-selected .chart__mark {
    stroke: var(--text);
    stroke-width: 2;
}

.chart__divider {
    stroke: var(--zero);
    stroke-dasharray: 4 4;
}

.chart__hatch {
    fill: currentColor;
}

.chart__bar.is-forecast .chart__mark {
    fill-opacity: .45;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-dasharray: 3 2;
}

.chart__bar.is-forecast .chart__mark.is-pos { color: var(--pos); }
.chart__bar.is-forecast .chart__mark.is-neg { color: var(--neg); }

.hero__note--forecast {
    font-weight: 700;
    opacity: 1;
}

.time-machine__forecast {
    color: var(--text-2);
}

.fishfood__basket {
    margin: 14px 0 0;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    font-size: .9rem;
}

.chart__tooltip {
    position: absolute;
    transform: translateX(-50%);
    pointer-events: none;
    background: var(--text);
    color: var(--surface);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: .85rem;
    white-space: nowrap;
}

.history__table {
    margin-top: 12px;
}

summary {
    cursor: pointer;
    color: var(--text-2);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: .9rem;
}

th, td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}

td.num {
    font-variant-numeric: tabular-nums;
}

.method summary {
    list-style: none;
    cursor: pointer;
}

.method summary h2 {
    display: inline;
    color: var(--text);
}

.method__steps {
    margin: 12px 0 0;
    padding-left: 22px;
    display: grid;
    gap: 6px;
    color: var(--text-2);
}

.method p {
    margin: 12px 0 0;
    color: var(--text-2);
}

/* Disclaimer & footer */

.site-footer {
    padding: 0 16px 32px;
    color: var(--text-3);
    font-size: .8rem;
}

.site-footer__stale {
    color: var(--text-2);
    font-weight: 700;
}

.site-footer p {
    margin: 4px 0;
}

.unavailable h1 {
    margin-bottom: 8px;
}

/* Phones */

@media (max-width: 640px) {
    .site-header__inner {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "switches";
    }

    .switches {
        justify-self: start;
        max-width: 100%;
    }

    /* Same pills, but each scrolls sideways inside itself rather than widening the page. */
    .switch {
        max-width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .switch::-webkit-scrollbar {
        display: none;
    }

    .hero {
        grid-template-columns: auto 1fr;
        padding: 20px;
    }

    .hero__mascot .mascot {
        width: 120px;
        height: auto;
    }

    .hero__weather {
        font-size: 1.6rem;
        top: -10px;
        right: -10px;
    }

    .hero__score {
        grid-column: 1 / -1;
        text-align: left;
        display: flex;
        align-items: baseline;
        gap: 8px;
    }

    .time-machine__label .muted {
        display: none;
    }

    .gauge__legend-range {
        display: none;
    }

    .breakdown__row,
    .breakdown__head {
        grid-template-columns: 110px 1fr 44px;
        gap: 8px;
    }

    .breakdown__name {
        font-size: .8rem;
        white-space: normal;
        line-height: 1.2;
    }

    .gauge__legend-item:not(.is-current) .gauge__legend-text {
        display: none;
    }

    .gauge__legend {
        font-size: .75rem;
    }

    .tiles {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .tile {
        padding: 12px;
    }

    .tile__value {
        font-size: 1.35rem;
    }

    /* The bar charts are drawn server-side at a fixed width; let them scroll sideways instead of shrinking. */
    .history .chart {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .history .chart svg {
        min-width: 620px;
    }
}

.text-center {
    text-align: center;
}

/* Section navigation, grouped sections */

.dca__inputs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 2fr) auto;
    align-items: end;
    gap: 12px 16px;
    margin: 12px 0;
}

.dca__field {
    display: grid;
    gap: 6px;
    min-width: 0;
    font-size: .9rem;
    color: var(--text-2);
}

.dca__field output {
    color: var(--text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.dca__field input[type="number"] {
    font: inherit;
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
}

.dca__range input {
    width: 100%;
    accent-color: var(--accent);
}

.dca__play,
.dca__play[aria-pressed="false"] {
    justify-self: start;
    color: var(--text);
    text-decoration: none;
}

.dca__rows {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 12px;
}

.dca__legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 0 0 4px;
}

.dca__area {
    fill: var(--series-1);
    opacity: .12;
}

/* Months the savings tool buys in, when it buys only below a moving average. */
.dca__shade {
    fill: var(--series-1);
    opacity: .07;
}

.dca__shade-key {
    display: inline-block;
    width: 14px;
    height: 10px;
    margin-left: 8px;
    vertical-align: -1px;
    background: var(--series-1);
    opacity: .2;
}

.dca__subtitle {
    margin: 16px 0 6px;
    font-size: 1rem;
}

.dca__legend [hidden],
.dca__rows li[hidden] {
    display: none;
}

/* One slider only, so it takes the full width. */
.currencies__inputs {
    grid-template-columns: 1fr;
}

/* The yardstick is flat at 100 by definition, so its row is quieter. */
.currencies__rank li.is-yardstick {
    opacity: .6;
}

@media (max-width: 640px) {
    .dca__inputs {
        grid-template-columns: 1fr;
    }
}

.cycles__table-wrap {
    overflow-x: auto;
    margin: 12px 0;
}

.cycles__table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
    font-size: .9rem;
}

.cycles__table caption {
    text-align: left;
    padding-bottom: 6px;
}

.cycles__table th,
.cycles__table td {
    padding: 6px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.cycles__table th:first-child {
    text-align: left;
}

.cycles__table thead th {
    color: var(--text-2);
    font-weight: 600;
}

.cycles__table td.is-up { color: var(--up); font-weight: 700; }
.cycles__table td.is-down { color: var(--down); font-weight: 700; }

.cycles__table tr.is-current th {
    color: var(--accent);
}

.breakdown__aside {
    display: block;
    color: var(--text-3);
    font-size: .8rem;
    font-weight: 400;
}

.group-title {
    margin: 28px 4px 4px;
    font-size: 1.15rem;
    scroll-margin-top: 16px;
}

.group-note {
    margin: 0 4px 4px;
}

#overview,
#risks,
#breakdown,
#method {
    scroll-margin-top: 16px;
}

/* Hero: what the score is, coverage and comparison */

.hero__facts {
    grid-column: 1 / -1;
    margin: 4px 0 0;
    padding-left: 20px;
    display: grid;
    gap: 4px;
    font-size: 0.9rem;
}

.hero__facts .is-caution {
    font-weight: 600;
}

.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    vertical-align: middle;
}

.badge--forecast {
    background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 4px, var(--surface) 4px, var(--surface) 8px);
    border: 1px dashed var(--text-3);
    color: var(--text);
}

/* Warning lights: status in words, not only colour */

.warnings__status {
    font-weight: 700;
}

.warnings__item.is-above .warnings__status {
    color: var(--down);
}

.warnings__item.is-unknown .rows__value {
    color: var(--text-3);
    font-weight: 600;
}

.warnings__more {
    margin-top: 10px;
}

.warnings__all[open] summary {
    margin-bottom: 12px;
}

.warnings__more summary,
.breakdown__details summary,
.history__table summary {
    cursor: pointer;
    font-weight: 600;
}

/* Calculation table */

.table-scroll {
    overflow-x: auto;
    max-width: 100%;
}

.breakdown__details {
    margin-top: 14px;
}

.breakdown__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.breakdown__table th,
.breakdown__table td {
    padding: 8px 6px;
    border-top: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.breakdown__table td.num {
    text-align: right;
    white-space: nowrap;
}

.breakdown__table tbody th {
    font-weight: 700;
    min-width: 220px;
}

.breakdown__meta {
    display: block;
    font-weight: 400;
    color: var(--text-2);
    margin-top: 2px;
}

.breakdown__table tr.is-missing {
    color: var(--text-3);
}

/* Loan inputs */

.loan__inputs {
    display: flex;
    gap: 12px;
    align-items: center;
}

.loan__inputs input[type="range"] {
    flex: 1;
    min-width: 0;
}

.loan__number {
    display: flex;
    align-items: center;
    gap: 4px;
}

.loan__number input {
    width: 5.5em;
    padding: 4px 6px;
    font: inherit;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

/* History chart: links, partial coverage, risk dots */

.chart__bar:focus-visible {
    outline: none;
}

.chart__bar:focus-visible .chart__hit {
    fill: var(--surface-2);
    stroke: var(--accent);
    stroke-width: 2;
}

.chart__bar.is-partial .chart__mark {
    stroke: var(--text);
    stroke-width: 1.5;
    stroke-dasharray: 3 2;
}

.chart__risk {
    fill: var(--down);
}

.time-machine__steps {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    /* Below the absolutely positioned year ticks. */
    margin-top: 30px;
    font-size: 0.9rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

[aria-busy="true"] {
    opacity: 0.6;
    transition: opacity 0.2s;
}

@media (prefers-reduced-motion: reduce) {
    [aria-busy="true"] {
        transition: none;
    }
}

@media (max-width: 640px) {
    .breakdown__table tbody th {
        min-width: 160px;
    }
}

.sr__controls[hidden] {
    display: none;
}

/* When each figure was measured */

.rows__period {
    display: block;
    font-size: .78rem;
    color: var(--text-3);
    font-weight: 400;
}

.badge--older {
    background: var(--surface-2);
    border: 1px solid var(--text-3);
    color: var(--text);
    margin-left: 4px;
}

/* Loan example: payment and amount first, the assumptions behind a disclosure */

.loan__grid .loan__slider {
    margin-top: 0;
}

.loan__grid .loan__slider .rows {
    margin-top: 12px;
}

.loan__assumptions {
    margin-top: 16px;
}

.loan__assumptions summary {
    cursor: pointer;
    font-weight: 600;
}

.loan__assumptions .rows {
    margin-top: 12px;
}

/* Tabs (markets tools) */

.tabs__list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 12px;
}

.tabs__tab {
    font: inherit;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
}

.tabs__tab[aria-selected="true"] {
    background: var(--text);
    color: var(--surface);
    border-color: var(--text);
}

.tabs__tab:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.tabs__panel {
    display: grid;
    gap: 16px;
}

.tabs__panel[hidden] {
    display: none;
}

[data-show-for][hidden] {
    display: none;
}

.cycles__explain {
    margin: 12px 0 4px;
}

.cycles__notes {
    padding-left: 18px;
    color: var(--text-2);
}

/* Mix: compare anything */

.compare__presets {
    margin-top: 12px;
}

.compare__meta {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 4px;
    color: var(--text-2);
}

.compare__causation {
    margin: 12px 0 0;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--surface-2);
    font-size: .9rem;
}

.source-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 0;
    list-style: none;
}

/* Kibba on her patch of grass */

.pasture {
    position: relative;
    display: grid;
    justify-items: center;
    padding-bottom: 4px;
}

.pasture__grass {
    list-style: none;
    margin: -10px 0 0;
    padding: 14px 8px 8px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    max-width: 230px;
    border-radius: 50% 50% 14px 14px / 22px 22px 14px 14px;
    background:
        repeating-linear-gradient(100deg, transparent 0 6px, rgb(0 0 0 / 6%) 6px 8px),
        #6dbb4c;
    box-shadow: inset 0 6px 0 #8fd16a;
}

.pasture__grass a {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgb(255 255 255 / 85%);
    color: #14361a;
    font-size: .72rem;
    font-weight: 700;
    text-decoration: none;
}

.pasture__grass a:hover,
.pasture__grass a:focus-visible {
    background: #fff;
    text-decoration: underline;
    outline: 2px solid #14361a;
    outline-offset: 1px;
}

.hero__mascot.is-grazing {
    animation: graze 1.6s ease-in-out;
}

@keyframes graze {
    20%, 70% { transform: translateY(10px) rotate(9deg); }
    35%, 55% { transform: translateY(12px) rotate(11deg); }
}

.pasture__say {
    position: absolute;
    left: 50%;
    top: -30px;
    transform: translateX(-50%);
    width: max-content;
    max-width: 220px;
    padding: 6px 10px;
    border-radius: 12px;
    background: #fff;
    color: #0b0b0b;
    font-weight: 700;
    font-size: .85rem;
    box-shadow: 0 3px 10px rgb(0 0 0 / 25%);
    pointer-events: none;
    z-index: 3;
    animation: say-fade 4s ease-out forwards;
}

@keyframes say-fade {
    0% { opacity: 0; }
    10%, 85% { opacity: 1; }
    100% { opacity: 0; }
}

.pasture__fart {
    position: absolute;
    left: -8px;
    top: 50px;
    padding: 6px 12px;
    border-radius: 50%;
    background: #f3f1e8;
    color: #555;
    border: 2px solid #c9c4b0;
    font-size: .75rem;
    font-weight: 800;
    pointer-events: none;
    z-index: 2;
    animation: fart-drift 2.6s ease-out forwards;
}

@keyframes fart-drift {
    0% { opacity: 0; transform: translate(20px, 0) scale(.4); }
    20% { opacity: 1; transform: translate(0, -6px) scale(1); }
    100% { opacity: 0; transform: translate(-30px, -40px) scale(1.3); }
}

@media (prefers-reduced-motion: reduce) {
    .hero__mascot.is-grazing,
    .pasture__say,
    .pasture__fart { animation: none; }
}

/* Kibba while data is on its way */

.kibba-loader {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    background: rgb(0 0 0 / 25%);
    animation: loader-in .2s ease-out;
}

.kibba-loader[hidden] {
    display: none;
}

.kibba-loader__card {
    display: grid;
    justify-items: center;
    gap: 8px;
    max-width: 300px;
    margin: 16px;
    padding: 20px 24px;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    text-align: center;
    font-weight: 700;
}

.kibba-loader__card p {
    margin: 0;
}

.kibba-loader .mascot {
    animation: munch .5s ease-in-out infinite alternate;
}

.kibba-loader.is-done .mascot {
    animation: cheer .45s ease-out 2;
}

@keyframes munch {
    to { transform: rotate(-4deg) translateY(2px); }
}

@keyframes cheer {
    40% { transform: translateY(-18px) rotate(-6deg); }
}

@keyframes loader-in {
    from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .kibba-loader,
    .kibba-loader .mascot,
    .kibba-loader.is-done .mascot { animation: none; }
}

.loan__assumptions + .rows,
.loan__assumptions ~ .rows {
    margin-top: 16px;
}

.method__more {
    margin-top: 12px;
}

.method__more > summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text);
}

.method__section {
    margin-top: 16px;
}

.method__more > summary::after {
    content: " ▸";
    color: var(--text-3);
}

.method__more[open] > summary::after {
    content: " ▾";
}

/* A warning light reading data more than a year old */

.warnings__item.is-stale > .rows__label,
.warnings__item.is-stale > .rows__value {
    opacity: .6;
}

/* The grass comes after the heading in reading order but is shown on the left, like Kibba elsewhere. */
.hero--pasture .pasture {
    order: -1;
}

/* Mix: a shared scale for two percentages */

.compare__options {
    display: flex;
    flex-wrap: wrap;
    gap: 0 18px;
}

.compare__shared {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin-top: 10px;
    font-size: .9rem;
}

.compare__shared[hidden] {
    display: none;
}

/* Footer: Kibba in a suit with the "not financial advice" note */

.footer-kibba {
    display: flex;
    align-items: center;
    gap: 18px;
    margin: 8px 0 16px;
}

.footer-kibba .mascot {
    flex: none;
}

.footer-kibba__bubble {
    position: relative;
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: .85rem;
    max-width: 62ch;
}

.footer-kibba__bubble::before {
    content: "";
    position: absolute;
    left: -9px;
    top: 50%;
    margin-top: -8px;
    border: 8px solid transparent;
    border-left: 0;
    border-right-color: var(--border);
}

.footer-kibba__bubble strong {
    color: var(--text);
}

.footer-kibba__bubble p {
    margin: 4px 0 0;
}

@media (max-width: 640px) {
    .footer-kibba {
        flex-direction: column;
        align-items: flex-start;
    }

    .footer-kibba__bubble::before {
        left: 24px;
        top: -9px;
        margin-top: 0;
        border: 8px solid transparent;
        border-top: 0;
        border-bottom-color: var(--border);
    }
}

/* Story time in the time machine (story.js): Kibba tells each year's story while the slider follows */

.story {
    margin-top: 12px;
}

.story__start {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 0;
}

/* The way into the story is the most inviting button on the page. */
.story__play {
    font-size: 1.1rem;
    font-weight: 700;
    padding: 10px 20px;
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.story__play:hover,
.story__play:focus-visible {
    filter: brightness(1.1);
}

.story__ask {
    margin-top: 10px;
    padding: 10px 14px;
    border: 2px dashed var(--accent);
    border-radius: 14px;
}

.story__ask[hidden] {
    display: none;
}

.story__question {
    margin: 0 0 8px;
    font-size: 1.05rem;
}

.story__answers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.story__answer {
    font-size: .95rem;
    padding: 6px 14px;
}

.story__answer:disabled {
    cursor: default;
    opacity: .6;
}

.story__answer.is-right {
    opacity: 1;
    border-color: var(--up);
    background: color-mix(in srgb, var(--up) 20%, transparent);
}

.story__answer.is-wrong {
    opacity: 1;
    border-color: var(--down);
    text-decoration: line-through;
}

.story__player {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: box-shadow .3s;
}

.story__player.is-alarm {
    box-shadow: 0 0 0 3px var(--down) inset;
}

.story__stage {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-start;
}

.story__scene {
    flex: 0 1 440px;
    width: 100%;
    max-width: 440px;
    height: auto;
    border-radius: 10px;
    image-rendering: pixelated;
}

.story__text {
    flex: 1 1 260px;
    min-width: 0;
}

.story__when .muted {
    color: var(--text-2);
}

.story__when {
    font-size: 1.15rem;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    margin: 0;
    font-weight: 600;
}

.story__year {
    font-size: 1.8rem;
    font-variant-numeric: tabular-nums;
}

.story__bubble {
    display: block;
    flex: 1;
    min-width: 0;
    min-height: 4.5em;
    margin-top: 0;
    max-width: none;
    font-size: 1.12rem;
    line-height: 1.5;
    background: var(--surface-2);
    color: var(--text);
}

/* Kibba stands next to her speech bubble and bobs while she talks. */
.story__narrator {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 8px;
}

.story__kibba {
    position: relative;
    flex: 0 0 auto;
    cursor: pointer;
}

.story__kibba svg {
    display: block;
    width: 160px;
    height: auto;
}

.story__kibba.is-talking {
    animation: kibba-talk .45s ease-in-out infinite alternate;
}

.story__kibba.is-bleating {
    animation: hop .5s ease-out;
}

@keyframes kibba-talk {
    from { transform: translateY(0) rotate(0deg); }
    to { transform: translateY(-5px) rotate(-3deg); }
}

@media (prefers-reduced-motion: reduce) {
    .story__kibba.is-talking { animation: none; }
}

/* On a phone Kibba stands above her bubble, so the words get the full width. */
@media (max-width: 640px) {
    .story__narrator {
        flex-direction: column;
        align-items: stretch;
    }

    .story__kibba svg {
        width: 120px;
    }

    .story__narrator .story__bubble::before {
        display: none;
    }
}

.story__bubble::before {
    border-right-color: var(--surface-2);
}

.story__start[hidden] {
    display: none;
}

.story__figures {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    font-size: .95rem;
    font-variant-numeric: tabular-nums;
}

.story__figure-name {
    color: var(--text-2);
    margin-right: 4px;
}

.story__timeline {
    position: relative;
    margin: 22px 0 10px;
    padding-top: 30px;
}

.story__bar {
    height: 8px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--text-3) 35%, transparent);
    overflow: hidden;
}

.story__fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
}

.story__marks {
    position: absolute;
    inset: 0;
}

/* Every year is a dot on the bar; a big event is a round badge with its emoji just above it. */
.story__mark {
    position: absolute;
    bottom: -5px;
    width: 18px;
    height: 18px;
    margin-left: -9px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.story__mark::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-2);
}

.story__mark.is-event {
    bottom: 12px;
    width: 30px;
    height: 30px;
    margin-left: -15px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface-2);
    font-size: 16px;
    line-height: 28px;
    text-align: center;
}

.story__mark.is-event::after {
    display: none;
}

.story__mark.is-current::after {
    background: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}

.story__mark.is-event.is-current {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

.story__mark:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 50%;
}

/* On a narrow screen there is no room for a badge per event: they become larger coloured dots instead. */
@media (max-width: 640px) {
    .story__timeline {
        padding-top: 8px;
    }

    .story__mark.is-event {
        bottom: -5px;
        width: 18px;
        height: 18px;
        margin-left: -9px;
        border: 0;
        background: transparent;
        font-size: 0;
    }

    .story__mark.is-event::after {
        display: block;
        left: 3px;
        top: 3px;
        width: 12px;
        height: 12px;
        background: var(--down);
    }

    .story__mark.is-event.is-current {
        box-shadow: none;
    }
}

.story__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.story__range {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .85rem;
    color: var(--text-2);
}

.story__range select {
    font: inherit;
    padding: 2px 4px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

/* "Your home in the time machine" on the Life page (household.js) */

.home__form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px 16px;
    margin-top: 12px;
}

.home__form small {
    display: block;
    margin-top: 2px;
    font-size: .75rem;
}

.home__housing {
    margin: 0;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.home__housing legend {
    padding: 0 4px;
    font-size: .85rem;
    color: var(--text-2);
}

.home__housing label {
    display: block;
    font-size: .9rem;
}

.home__go {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 14px 0 0;
}

/* The ready-made households: three big cards, the chosen one clearly framed. */
.home__presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.home__preset {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: .9rem;
    text-align: left;
    cursor: pointer;
}

.home__preset strong {
    font-size: 1rem;
}

.home__preset span:not(.home__preset-emoji) {
    color: var(--text-2);
}

.home__preset-emoji {
    font-size: 1.8rem;
    line-height: 1.2;
}

.home__preset[aria-pressed="true"] {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

.home__guess {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin-top: 10px;
}

.home__guess-choice[aria-pressed="false"] {
    text-decoration: none;
    color: var(--text-2);
}

.home__guess-choice[aria-pressed="true"] {
    border-color: var(--accent);
}

.home__form {
    padding-top: 6px;
}

.home [hidden] {
    display: none;
}

.home__year {
    margin: 0 0 4px;
    font-size: 1.3rem;
}

.home__player .story__bubble p:last-of-type {
    margin: 0;
}


.home__housing small {
    display: block;
    margin-top: 4px;
    font-size: .75rem;
}

.home__speed {
    min-width: 2.6em;
    justify-content: center;
}

.home__speed[aria-pressed="false"] {
    text-decoration: none;
    color: var(--text-2);
}

.home__speed[aria-pressed="true"] {
    border-color: var(--accent);
    color: var(--text);
}

/* One bar each for pay, food, housing and what is left (household.js). */
.home__rows {
    display: grid;
    gap: 8px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.home__rows li {
    display: grid;
    grid-template-columns: minmax(90px, 160px) 1fr minmax(110px, auto);
    align-items: center;
    gap: 10px;
    font-variant-numeric: tabular-nums;
}

.home__label {
    color: var(--text-2);
    font-size: .9rem;
}

.home__bar {
    height: 14px;
    border-radius: 7px;
    background: color-mix(in srgb, var(--text-3) 25%, transparent);
    overflow: hidden;
}

.home__fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 7px;
    transition: width .5s ease-out;
}

.home__fill--income { background: var(--accent); }
.home__fill--food { background: #e8a33d; }
.home__fill--housing { background: #9b6bd6; }
.home__fill--left { background: var(--up); }
.home__fill--left.is-negative { background: var(--down); }

.home__value {
    text-align: right;
}

.home__value.is-short {
    color: var(--down);
}

/* "Left after the costs" is the one big number of the trip. */
.home__left {
    margin: 12px 0 0;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    font-weight: 800;
    font-size: clamp(1.2rem, 3.2vw, 1.6rem);
    text-align: center;
}

.home__summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.home__after {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 0;
}

@media (prefers-reduced-motion: reduce) {
    .home__fill { transition: none; }
}

.home__fill--car { background: #e0564f; }
.home__fill--energy { background: #f2c94c; }
.home__fill--other { background: #4fb3bf; }

/* The household settings: fields keep their natural height and line up at the top. */
.home__form {
    align-items: start;
}

.home__form select {
    font: inherit;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

/* On a phone each bar gets its own line under its name, so it has room to show. */
@media (max-width: 640px) {
    .home__rows li {
        grid-template-columns: 1fr auto;
        gap: 2px 10px;
    }

    .home__rows .home__bar {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}

/* Loan or rent: the same household three ways (household.js). */
.home__compare h3 {
    margin: 14px 0 4px;
}

.home__chart svg {
    width: 100%;
    height: auto;
}

.home__grid {
    stroke: var(--grid);
    stroke-width: 1;
}

.home__zero {
    stroke: var(--zero);
    stroke-width: 1.5;
}

.home__axis {
    fill: var(--text-2);
    font-size: 12px;
}

.home__line {
    fill: none;
    stroke-width: 3;
    stroke-linejoin: round;
}

.home__line--rent, .home__dot--rent { stroke: var(--accent); background: var(--accent); }
.home__line--indexed, .home__dot--indexed { stroke: #9b6bd6; background: #9b6bd6; }
.home__line--variable, .home__dot--variable { stroke: #e8a33d; background: #e8a33d; }

.home__compare-rows {
    display: grid;
    gap: 4px;
    margin: 8px 0;
    padding: 0;
    list-style: none;
    font-size: .9rem;
    font-variant-numeric: tabular-nums;
}

.home__dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dca__end-label {
    fill: var(--text);
    font-size: 13px;
    font-weight: 700;
    paint-order: stroke;
    stroke: var(--surface);
    stroke-width: 4px;
}

/* Hræringur: the ready-made pairs as picture cards, the full lists under "Choose your own". */
.compare__pick {
    margin: 12px 0 6px;
    font-weight: 700;
}

.compare__pairs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}



/* Compact cards: the icons beside the name, so the chosen pair and its chart fit on one screen. */
.compare__pair {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: .9rem;
    text-align: left;
    cursor: pointer;
}

/* Long names wrap between words (or at a proper hyphen) inside the card, never in the middle of a word. */
.compare__pair > span:last-child {
    min-width: 0;
    hyphens: auto;
    line-height: 1.3;
}

.compare__pair-icons {
    flex: 0 0 auto;
    font-size: 1.3rem;
    line-height: 1.2;
    white-space: nowrap;
}

.compare__pair[aria-pressed="true"] {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

.compare__pair--own {
    border-style: dashed;
    border-color: var(--accent);
    background: transparent;
}

.compare__own {
    margin-top: 12px;
}

/* "Choose your own" is a clear button, not a small disclosure line. */
.compare__own > summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 2px solid var(--accent);
    border-radius: 999px;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.compare__own > summary::-webkit-details-marker {
    display: none;
}

.compare__own > summary::after {
    content: "▾";
    font-size: .8em;
}

.compare__own[open] > summary::after {
    content: "▴";
}

.compare__own[open] > summary {
    margin-bottom: 10px;
}

/* The time machine inside the household card: in place at first, floating at the top once scrolled past. */
.home__clock {
    margin: 12px 0;
}

.home__clock .time-machine {
    position: relative;
    top: auto;
    margin: 0;
    border: 1px solid var(--border);
    box-shadow: none;
}

.home__clock .time-machine.is-floating {
    position: fixed;
    top: 8px;
    z-index: 20;
    background: var(--surface);
    box-shadow: var(--shadow);
}

/* A smaller hero for pages where what comes next should be in view sooner (Life). */
.hero.hero--compact {
    padding: 14px 20px;
    gap: 4px 16px;
}

.hero--compact .hero__band {
    font-size: clamp(1.5rem, 4.5vw, 2.2rem);
}

.hero--compact .hero__number {
    font-size: clamp(1.8rem, 5vw, 2.6rem);
}

.hero--compact .hero__mascot .mascot {
    width: 110px;
    height: auto;
}

.hero--compact .hero__facts {
    display: none;
}

/* Household cards: a picture and a name; the chosen one's amounts show underneath. */
.home__preset {
    align-items: center;
    text-align: center;
    padding: 12px 8px;
}

.home__preset-emoji {
    font-size: 2.4rem;
}

.home__amounts {
    margin: 10px 0 0;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    font-variant-numeric: tabular-nums;
}

.home__amounts .muted {
    display: block;
    margin-top: 2px;
}

.home__go .story__play {
    font-size: 1.25rem;
    padding: 12px 26px;
}

/* On a phone the compact hero leaves Kibba's longer words out, so the trip is in view at once. */
@media (max-width: 640px) {
    .hero--compact .hero__bubble {
        display: none;
    }

    .hero--compact .hero__mascot .mascot {
        width: 80px;
    }
}

.home__chosen {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-top: 10px;
}

.home__chosen > div {
    flex: 1 1 320px;
}

.home__chosen .home__amounts {
    margin: 0;
}

.home__chosen .story__play {
    font-size: 1.25rem;
    padding: 12px 26px;
}

/* In the compact hero the pasture keeps Kibba but not the grass of source links; each chart names its sources. */
.hero--compact .pasture__grass {
    display: none;
}

/* Fjárhúsið: guess first, then Kibba's answer. */
.fh-guess {
    margin: 12px 0 6px;
    font-weight: 600;
}

.fh-answer > summary {
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid var(--accent);
    border-radius: 999px;
    font-size: .9rem;
    cursor: pointer;
}

.fh-answer > summary::-webkit-details-marker {
    display: none;
}

.fh-answer[open] > summary {
    display: none;
}

.fh-answer p {
    margin: 6px 0 0;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--surface-2);
}

.fh-soon {
    margin: 0 4px;
}

/* The savings game: the dividend note and Kibba's line stand right by the result. */
.dca__dividends {
    margin: 8px 0 0;
    padding: 6px 12px;
    border-left: 3px solid var(--series-4);
    border-radius: 6px;
    background: var(--surface-2);
    font-size: .9rem;
}

.dca__kibba {
    margin: 8px 0 0;
    font-size: .95rem;
}

.dca__kibba:empty {
    display: none;
}

/* Shortcuts in the savings game: Kibba with each asset; one click plays a ready-made trip. */
.dca__shortcuts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    margin: 10px 0 6px;
}

.dca__shortcut {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 6px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: .88rem;
    text-align: left;
    cursor: pointer;
}

.dca__shortcut img {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    image-rendering: pixelated;
}

.dca__shortcut span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.dca__shortcut:hover,
.dca__shortcut.is-chosen {
    border-color: var(--accent);
}

.dca__shortcut.is-chosen {
    box-shadow: 0 0 0 2px var(--accent);
}

.dca__quip {
    margin: 4px 0 8px;
    font-weight: 600;
}

.dca__quip:empty {
    display: none;
}

/* Markets: the tools as questions with Kibba; only the chosen one is shown. */
.markets__questions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.markets__question {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 6px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.markets__question img {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    image-rendering: pixelated;
}

/* Words wrap between words (or at a proper hyphen), never in the middle. */
.markets__question span {
    min-width: 0;
    hyphens: auto;
    line-height: 1.3;
}

.markets__question[aria-selected="true"] {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
    background: var(--surface);
}

/* Kibba's pictures stand straight on the card with a one-pixel outline, like an old game sprite, so both her
   cream wool and her black face show in light and dark mode. */
.dca__shortcut img,
.markets__question img {
    filter:
        drop-shadow(1px 0 0 var(--kibba-outline))
        drop-shadow(-1px 0 0 var(--kibba-outline))
        drop-shadow(0 1px 0 var(--kibba-outline))
        drop-shadow(0 -1px 0 var(--kibba-outline));
}

/* Fjárhúsið: the levels as pictures of Kibba growing up, and shortcuts to the test and the cards. */
.fh-levels {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.fh-levels .markets__question img {
    width: 72px;
    height: 72px;
    padding: 2px;
    border-radius: 12px;
    background: linear-gradient(180deg, #a9d3f5, #d9ecfb);
    image-rendering: pixelated;
}

.fh-levels .markets__question span {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.fh-levels small {
    font-weight: 400;
    color: var(--text-2);
}

.fh-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
}

.fh-shortcut {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 2px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: .95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.fh-shortcut:hover {
    border-color: var(--accent);
}

/* Fjárhúsið: Kibba's quick question on each card, and each level's progress. */
.fh-quick {
    margin-top: 12px;
    padding: 10px 12px;
    border: 2px dashed var(--accent);
    border-radius: 14px;
}

.fh-quick:empty {
    display: none;
}

.fh-quick__question {
    margin: 0 0 8px;
}

.fh-quick__feedback {
    margin: 8px 0 0;
}

.fh-quick__feedback:empty {
    display: none;
}

.fh-quick .story__answers {
    flex-direction: column;
    align-items: stretch;
}

.fh-quick .story__answer {
    justify-content: flex-start;
    text-align: left;
    white-space: normal;
}

.fh-progress {
    margin: 0 4px 10px;
}

.fh-progress__bar {
    height: 10px;
    border-radius: 5px;
    background: color-mix(in srgb, var(--text-3) 30%, transparent);
    overflow: hidden;
}

.fh-progress__bar span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--up);
    transition: width .5s ease-out;
}

.fh-progress p {
    margin: 4px 0 0;
    color: var(--text-2);
}

.fh-progress.is-complete p {
    color: var(--up);
    font-weight: 700;
}

.compare__moments {
    margin: 10px 0 4px;
    padding: 8px 12px;
    border-left: 3px solid var(--series-4);
    border-radius: 6px;
    background: var(--surface-2);
    font-size: .95rem;
}

.compare__moments:empty {
    display: none;
}

/* Kibba's reaction when the score moves a lot in the time machine: a longer bubble than a bleat. */
.bleat.bleat--long {
    white-space: normal;
    width: max-content;
    max-width: 240px;
    animation-duration: 4.5s;
}

/* The result line when Play reaches today. */
.dca__done {
    margin: 8px 0 0;
    padding: 10px 14px;
    border: 2px solid var(--up);
    border-radius: 12px;
    font-weight: 700;
    animation: talk-in .4s ease-out;
}

.dca__done[hidden] {
    display: none;
}

.dca__done.is-loss {
    border-color: var(--down);
}
