:root {
    color-scheme: light;
    --paper: #f6f3ec;
    --surface: #fffefa;
    --ink: #20231f;
    --muted: #656a62;
    --accent: #a13d2f;
    --line: #d3cec2;
    --control: #ebe6db;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--paper);
    color: var(--ink);
    font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    padding: 0 32px;
    border-bottom: 1px solid var(--line);
    background: rgb(246 243 236 / 92%);
}

.brand,
.section-link {
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-decoration: none;
    text-transform: uppercase;
}

.brand-trail {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-divider {
    width: 1px;
    height: 20px;
    background: var(--line);
}

.section-link {
    font-family: inherit;
}

.brand:hover,
.section-link:hover {
    color: var(--accent);
}

.brand:focus-visible,
.section-link:focus-visible {
    outline: 3px solid rgb(161 61 47 / 28%);
    outline-offset: 4px;
}

.header-actions,
.language-switcher {
    display: flex;
    align-items: center;
}

.header-actions {
    gap: 12px;
}

.language-switcher {
    padding: 3px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.language-button,
.print-button {
    border: 0;
    cursor: pointer;
}

.language-button {
    width: 42px;
    height: 34px;
    background: transparent;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.language-button.is-active {
    background: var(--ink);
    color: white;
}

.print-button {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 18px;
    background: var(--accent);
    color: white;
    font-size: 0.82rem;
    font-weight: 700;
}

.language-button:focus-visible,
.print-button:focus-visible,
.area-number:focus-visible,
.area-range:focus-visible,
.area-note:focus-visible {
    outline: 3px solid rgb(161 61 47 / 28%);
    outline-offset: 2px;
}

.app-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    min-height: calc(100vh - 76px);
}

.control-panel {
    padding: 44px 32px;
    border-right: 1px solid var(--line);
    background: var(--surface);
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2,
p {
    letter-spacing: 0;
}

h1,
h2 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
}

h1 {
    font-size: 2.3rem;
    line-height: 1;
}

h2 {
    font-size: 2rem;
}

.instructions {
    margin: 18px 0 22px;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.55;
}

.scale-key {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) 54px;
    gap: 10px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 0.67rem;
}

.scale-key span:first-child {
    grid-column: 2;
}

.scale-key span:last-child {
    grid-column: 3;
    text-align: center;
}

.area-controls {
    display: grid;
    gap: 2px;
}

.area-control {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) 54px;
    align-items: center;
    gap: 10px;
    min-height: 82px;
    padding: 9px 0 10px;
    border-top: 1px solid var(--line);
}

.area-swatch {
    width: 10px;
    height: 32px;
    background: var(--sector-color);
}

.area-inputs {
    min-width: 0;
}

.area-name {
    display: block;
    margin-bottom: 4px;
    overflow: hidden;
    font-size: 0.78rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.area-range {
    width: 100%;
    height: 16px;
    margin: 0;
    accent-color: var(--sector-color);
    cursor: pointer;
}

.area-number {
    width: 54px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 0;
    background: var(--paper);
    color: var(--ink);
    font-weight: 700;
    text-align: center;
}

.area-note {
    grid-column: 2 / 4;
    width: 100%;
    height: 30px;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 0;
    background: var(--surface);
    color: var(--ink);
    font-size: 0.72rem;
}

.area-note::placeholder {
    color: #888b84;
}

.privacy-note {
    margin: 22px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.5;
}

.wheel-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 36px 40px 24px;
    overflow: hidden;
}

.wheel-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 32px;
}

.wheel-heading > p {
    max-width: 390px;
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
    text-align: right;
}

.wheel-heading .wheel-date {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    text-align: left;
}

.wheel-wrap {
    display: grid;
    place-items: center;
    min-height: 0;
}

.balance-wheel {
    display: block;
    width: min(100%, 920px);
    max-height: calc(100vh - 190px);
    aspect-ratio: 6 / 5;
}

.wheel-hit-area {
    cursor: crosshair;
    fill: transparent;
}

.sector-fill {
    opacity: 0.76;
}

.value-arc {
    fill: none;
    stroke: var(--ink);
    stroke-width: 4;
}

.grid-ring {
    fill: none;
    stroke: #bcb8ae;
    stroke-width: 1.5;
    stroke-dasharray: 3 7;
}

.grid-boundary,
.grid-outline {
    fill: none;
    stroke: var(--ink);
}

.grid-boundary {
    stroke-width: 3;
}

.grid-outline {
    stroke-width: 5;
}

.wheel-label-name {
    fill: var(--ink);
    font-size: 20px;
    font-weight: 700;
}

.wheel-label-description {
    fill: #565b54;
    font-size: 15px;
}

.wheel-label-value {
    fill: var(--accent);
    font-size: 18px;
    font-weight: 700;
}

.wheel-label-note {
    fill: #565b54;
    font-size: 13px;
    font-style: italic;
}

@media (max-width: 1040px) {
    .app-layout {
        grid-template-columns: 300px minmax(0, 1fr);
    }

    .control-panel {
        padding: 34px 24px;
    }

    .wheel-panel {
        padding: 30px 24px 18px;
    }

    .wheel-heading > p {
        display: none;
    }
}

@media (max-width: 760px) {
    .app-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 18px 20px;
    }

    .header-actions {
        justify-content: space-between;
        width: 100%;
    }

    .app-layout {
        display: block;
    }

    .control-panel {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 32px 20px;
    }

    .wheel-panel {
        padding: 32px 8px 16px;
    }

    .wheel-heading {
        padding: 0 12px;
    }

    .balance-wheel {
        width: 100%;
        max-height: none;
    }
}

@media print {
    @page {
        size: landscape;
        margin: 8mm;
    }

    body {
        background: white;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .app-header,
    .control-panel {
        display: none;
    }

    .app-layout,
    .wheel-panel {
        display: block;
        min-height: 0;
    }

    .wheel-panel {
        padding: 0;
        overflow: visible;
    }

    .wheel-heading {
        align-items: start;
        margin-bottom: 2mm;
    }

    .wheel-heading > p {
        display: block;
    }

    .balance-wheel {
        width: 100%;
        height: 165mm;
        max-height: none;
    }
}