/* ==========================================================================
   Timzo Town — "stepping into a new world"
   --------------------------------------------------------------------------
   The tool's own look, taken over from its design (Fredoka titles, Nunito UI,
   cream ground, blue actions, orange for what's overdue). Everything is scoped
   under .ks-world, which only StadLayout renders, so none of it leaks into the
   rest of Timzo. MudBlazor still does the dialogs and inputs; their palette is
   re-pointed at these tokens below.

   Dark mode follows Timzo's switch (html.tz-dark). The city itself stays
   colourful in the dark; only the chrome changes.
   ========================================================================== */

@font-face {
    font-family: "Fredoka";
    font-style: normal;
    font-weight: 500 600;
    font-display: swap;
    src: url("../fonts/fredoka-latin.woff2") format("woff2");
}

@font-face {
    font-family: "Nunito";
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url("../fonts/nunito-latin.woff2") format("woff2");
}

.ks-world,
.ks-drag-ghost,
.ks-drop-mark {
    --ks-bg: #F4F1EA;
    --ks-surface: #FFFFFF;
    --ks-surface-2: #FAF8F3;
    --ks-ink: #26231F;
    --ks-muted: #6A6158;
    --ks-soft: #4A433C;
    --ks-line: #E3DCCF;
    --ks-line-strong: #CFC6B8;
    --ks-seg: #EAE4D8;
    --ks-primary: #1F5F8B;
    --ks-primary-deep: #174A6C;
    --ks-on-primary: #FFFFFF;
    --ks-primary-soft: #DCEAF5;
    --ks-primary-soft-ink: #174A6C;
    --ks-chip: #F4F1EA;
    --ks-chip-ink: #4A433C;
    --ks-alt-bg: #EDE6F6;
    --ks-alt-ink: #4E3C6E;
    --ks-over: #9A430C;
    --ks-over-bg: #FCE7D6;
    --ks-over-line: #F0C9A8;
    --ks-over-badge: #B4500F;
    --ks-ruin: #7A2414;
    --ks-today: #6B4E00;
    --ks-today-bg: #FFF1C7;
    --ks-ring: #BDB3A4;
    --ks-ok: #2F6B3A;
    --ks-toast-bg: #26231F;
    --ks-toast-ink: #FFFFFF;
    --ks-shadow: rgba(38, 35, 31, 0.16);

    --ks-font-title: Fredoka, "Trebuchet MS", sans-serif;
    --ks-font: Nunito, "Segoe UI", system-ui, sans-serif;

    /* MudBlazor reads its palette from these; inside the city they're the city's. */
    --mud-palette-primary: var(--ks-primary);
    --mud-palette-primary-rgb: 31, 95, 139;
    --mud-palette-primary-text: var(--ks-on-primary);
    --mud-palette-primary-darken: var(--ks-primary-deep);
    --mud-palette-primary-lighten: #2E78AB;
    --mud-palette-primary-hover: rgba(31, 95, 139, 0.06);
    --mud-typography-default-family: var(--ks-font);
    --mud-typography-body1-family: var(--ks-font);
    --mud-typography-body2-family: var(--ks-font);
    --mud-typography-button-family: var(--ks-font);
    --mud-typography-h6-family: var(--ks-font-title);
    --mud-palette-surface: var(--ks-surface);
    --mud-palette-background: var(--ks-bg);
    --mud-palette-text-primary: var(--ks-ink);
    --mud-palette-text-secondary: var(--ks-muted);
    --mud-palette-lines-inputs: var(--ks-line-strong);
    --mud-palette-drawer-background: var(--ks-surface);
}

.ks-world {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--ks-bg);
    color: var(--ks-ink);
    font-family: var(--ks-font);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

html.tz-dark .ks-world,
html.tz-dark .ks-drag-ghost,
html.tz-dark .ks-drop-mark {
    --ks-bg: #17191D;
    --ks-surface: #23262C;
    --ks-surface-2: #1E2126;
    --ks-ink: #F1ECE3;
    --ks-muted: #A9A297;
    --ks-soft: #CFC8BC;
    --ks-line: #363A42;
    --ks-line-strong: #4A4F58;
    --ks-seg: #2C3037;
    --ks-primary: #7FB8E8;
    --ks-primary-deep: #4C86B6;
    --ks-on-primary: #10212F;
    --ks-primary-soft: #1F3346;
    --ks-primary-soft-ink: #BFDDF5;
    --ks-chip: #2C3037;
    --ks-chip-ink: #CFC8BC;
    --ks-alt-bg: #2E2640;
    --ks-alt-ink: #D9CCF0;
    --ks-over: #F4A167;
    --ks-over-bg: #3A2618;
    --ks-over-line: #5A3A22;
    --ks-ruin: #F08A72;
    --ks-today: #F2D27A;
    --ks-today-bg: #3A3018;
    --ks-ring: #6E685F;
    --ks-ok: #8FD19B;
    --ks-toast-bg: #F1ECE3;
    --ks-toast-ink: #17191D;
    --ks-shadow: rgba(0, 0, 0, 0.45);

    --mud-palette-primary-rgb: 127, 184, 232;
    --mud-palette-primary-lighten: #A3CDF0;
    --mud-palette-primary-hover: rgba(127, 184, 232, 0.08);
}

/* Inside the Timzo shell: Town keeps its accents, its illustrations and its title font, but stands on Timzo's own
   surfaces, ink and lines, and reads in Timzo's text font — playful, and still one family with Clock and Swing. */
.ks-world--embedded,
.ks-drag-ghost {
    --ks-bg: var(--tz-canvas);
    --ks-surface: var(--tz-surface-1);
    --ks-surface-2: var(--tz-surface-2);
    --ks-ink: var(--tz-ink-1);
    --ks-muted: var(--tz-ink-2);
    --ks-soft: var(--tz-ink-2);
    --ks-line: var(--tz-line);
    --ks-line-strong: var(--tz-line-strong);
    --ks-seg: var(--tz-surface-2);
    --ks-chip: var(--tz-surface-2);
    --ks-chip-ink: var(--tz-ink-2);
    --ks-font: var(--tz-font);
}

.ks-world.ks-world--embedded {
    min-height: 0;
    display: block;
    background: transparent;
    font-size: inherit;
}

.ks-world h1,
.ks-world h2,
.ks-world h3 {
    font-family: var(--ks-font-title);
    font-weight: 600;
    margin: 0;
}

.ks-world a {
    color: var(--ks-primary);
}

.ks-world :focus-visible {
    outline: 3px solid var(--ks-primary);
    outline-offset: 2px;
}

/* Blazor focuses the page title after a navigation, for screen readers; it isn't something to click. */
.ks-world h1:focus,
.ks-world h1:focus-visible {
    outline: none;
}

.ks-icon {
    display: block;
    flex: none;
}

/* ─── Buttons and chips ───────────────────────────────────────────────── */

.ks-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: 14px;
    background: var(--ks-primary);
    color: var(--ks-on-primary);
    font: 800 15px var(--ks-font);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.ks-btn:hover {
    background: var(--ks-primary-deep);
}

.ks-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.ks-btn--big {
    width: 100%;
    height: 56px;
    border-radius: 18px;
    font-size: 17px;
    box-shadow: 0 5px 0 var(--ks-primary-deep);
}

.ks-btn--big:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 var(--ks-primary-deep);
}

.ks-btn--soft {
    background: var(--ks-primary-soft);
    color: var(--ks-primary-soft-ink);
}

.ks-btn--soft:hover {
    background: var(--ks-primary-soft);
    filter: brightness(0.97);
}

.ks-btn--outline {
    background: var(--ks-surface);
    color: var(--ks-ink);
    border: 1.5px solid var(--ks-line-strong);
}

.ks-btn--outline:hover {
    background: var(--ks-chip);
}

.ks-btn--danger {
    background: transparent;
    color: var(--ks-over);
    padding: 0 8px;
}

.ks-btn--danger:hover {
    background: var(--ks-over-bg);
}

.ks-btn--text {
    background: transparent;
    color: var(--ks-primary);
    padding: 0 8px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ks-btn--text:hover {
    background: transparent;
    color: var(--ks-primary-deep);
}

.ks-round {
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 50%;
    border: 1px solid var(--ks-line);
    background: var(--ks-surface);
    color: var(--ks-ink) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-sizing: border-box;
    text-decoration: none;
}

.ks-round:hover {
    background: var(--ks-chip);
}

.ks-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px 3px 6px;
    border-radius: 999px;
    background: var(--ks-chip);
    color: var(--ks-chip-ink);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ks-chip--over {
    background: var(--ks-over-bg);
    color: var(--ks-over);
    font-weight: 800;
}

.ks-chip--today {
    background: var(--ks-today-bg);
    color: var(--ks-today);
    font-weight: 800;
}

.ks-chip--date {
    background: transparent;
}

.ks-chip--kids {
    background: var(--ks-primary-soft);
    color: var(--ks-primary-soft-ink);
    font-weight: 800;
}

.ks-chip--alt {
    background: var(--ks-alt-bg);
    color: var(--ks-alt-ink);
    font-weight: 800;
}

.ks-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 800;
    color: var(--ks-ok);
}

.ks-status::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
}

.ks-status--neglected {
    color: var(--ks-over);
}

.ks-status--ruined {
    color: var(--ks-ruin);
}

.ks-status--ruined::before {
    border-radius: 2px;
    transform: rotate(45deg);
}

.ks-tile {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: #26231F;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.ks-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    background: var(--ks-surface);
    border-radius: 24px;
    border: 1px solid var(--ks-line);
}

.ks-hint {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ks-muted);
}

/* ─── The board ───────────────────────────────────────────────────────── */

.ks-board__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.ks-board__name {
    font-size: 30px;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.ks-board__title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.ks-bld.ks-board__building {
    width: 72px;
    flex: none;
    margin: -6px 0;
}

.ks-tabs {
    display: none;
}

.ks-columns {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(260px, 1fr);
    gap: 16px;
    align-items: start;
    overflow-x: auto;
    padding-bottom: 8px;
}

.ks-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 120px;
    padding: 14px;
    border-radius: 24px;
    background: var(--ks-seg);
}

html.tz-dark .ks-col {
    background: #1E2126;
}

.ks-col__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0 4px 2px;
}

.ks-col__title {
    font-size: 19px;
}

.ks-col__count {
    font-size: 14px;
    font-weight: 800;
    color: var(--ks-muted);
    font-variant-numeric: tabular-nums;
}

.ks-col__empty {
    min-height: 64px;
    border-radius: 18px;
    border: 2px dashed var(--ks-line-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--ks-muted);
}

.ks-card {
    position: relative;
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 6px 10px 6px 4px;
    background: var(--ks-surface);
    border: 1px solid var(--ks-line);
    border-radius: 18px;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    cursor: grab;
}

.ks-card--over {
    border-color: var(--ks-over-line);
}

.ks-card--done {
    background: var(--ks-surface-2);
}

.ks-card[data-ks-dragging] {
    opacity: 0.35;
}

.ks-card__body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    flex: 1;
    padding: 6px 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    align-items: flex-start;
    justify-content: center;
    cursor: inherit;
}

.ks-card__title {
    font-size: 16px;
    font-weight: 800;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.ks-card--done .ks-card__title {
    font-size: 15px;
    color: var(--ks-muted);
    text-decoration: line-through;
}

.ks-card__sub {
    font-size: 13px;
    font-weight: 700;
    color: var(--ks-muted);
}

.ks-card__chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.ks-tick {
    width: 44px;
    height: 44px;
    flex: none;
    border: 0;
    background: transparent;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ks-tick__ring {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2.5px solid var(--ks-ring);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    transition: background 160ms ease-out, border-color 160ms ease-out;
}

.ks-tick:hover .ks-tick__ring {
    border-color: var(--ks-ok);
}

.ks-card--over .ks-tick__ring {
    border-color: var(--ks-over-badge);
}

.ks-tick--done .ks-tick__ring {
    width: 28px;
    height: 28px;
    border: 0;
    background: var(--ks-ok);
}

html.tz-dark .ks-tick--done .ks-tick__ring {
    color: #17191D;
}

.ks-drag-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--ks-muted);
}

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

.ks-addbar__input {
    flex: 1;
    min-width: 0;
    height: 52px;
    padding: 0 16px;
    border-radius: 16px;
    border: 1.5px solid var(--ks-line-strong);
    background: var(--ks-surface);
    color: var(--ks-ink);
    font: 700 16px var(--ks-font);
}

.ks-addbar__input:focus {
    outline: none;
    border-color: var(--ks-primary);
}

/* The dragged card's stand-in, drawn by board-drag.js on top of everything. */
.ks-drag-ghost {
    font-family: var(--ks-font);
    color: var(--ks-ink);
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    margin: 0;
    transform: rotate(2deg) scale(1.03);
    box-shadow: 0 18px 32px var(--ks-shadow);
    cursor: grabbing;
}

.ks-drop-mark {
    position: fixed;
    z-index: 999;
    pointer-events: none;
    height: 4px;
    border-radius: 2px;
    background: var(--ks-primary);
    box-shadow: 0 0 0 3px rgba(31, 95, 139, 0.18);
}

.ks-col[data-ks-over] {
    outline: 2px dashed var(--ks-primary);
    outline-offset: -2px;
}

@media (max-width: 720px) {
    .ks-board__name {
        font-size: 26px;
    }

    .ks-tabs {
        display: grid;
        grid-auto-columns: minmax(0, 1fr);
        grid-auto-flow: column;
        gap: 4px;
        margin: 0 0 10px;
        padding: 4px;
        border-radius: 16px;
        background: var(--ks-seg);
    }

    .ks-tabs__tab {
        height: 44px;
        border: 0;
        border-radius: 12px;
        background: transparent;
        color: var(--ks-soft);
        font: 700 14px var(--ks-font);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        cursor: pointer;
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .ks-tabs__tab[aria-selected="true"] {
        background: var(--ks-surface);
        color: var(--ks-ink);
        font-weight: 800;
        box-shadow: 0 1px 2px var(--ks-shadow);
    }

    .ks-columns {
        grid-auto-columns: min(300px, calc(100vw - 64px));
        scroll-snap-type: x mandatory;
        margin: 0 -16px;
        padding: 0 16px 8px;
        scroll-padding: 0 16px;
        scrollbar-width: none;
        gap: 12px;
    }

    .ks-col {
        scroll-snap-align: start;
        padding: 0;
        background: transparent;
    }

    html.tz-dark .ks-col {
        background: transparent;
    }

    .ks-col__head {
        display: none;
    }

    .ks-addbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        z-index: 15;
        margin: 0;
        padding: 12px 16px;
        background: linear-gradient(to top, var(--ks-bg) 70%, transparent);
    }
}

/* ─── Toast ───────────────────────────────────────────────────────────── */

.ks-toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    z-index: 30;
    transform: translateX(-50%);
    width: min(520px, calc(100vw - 32px));
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 16px;
    border-radius: 16px;
    background: var(--ks-toast-bg);
    color: var(--ks-toast-ink);
    font-size: 15px;
    font-weight: 800;
    box-shadow: 0 8px 24px var(--ks-shadow);
    animation: ks-toast-in 220ms cubic-bezier(.2, .8, .2, 1);
}

.ks-toast__text {
    flex: 1;
    min-width: 0;
}

.ks-toast__undo {
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.14);
    color: inherit;
    font: 800 14px var(--ks-font);
    cursor: pointer;
}

html.tz-dark .ks-toast__undo {
    background: rgba(0, 0, 0, 0.08);
}

@media (max-width: 720px) {
    .ks-toast {
        bottom: calc(160px + env(safe-area-inset-bottom));
    }
}

@keyframes ks-toast-in {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Refurbished: a short, springy pop (design: "Beweging"). */
@keyframes ks-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.07); }
    70% { transform: scale(0.98); }
    100% { transform: scale(1); }
}

.ks-pop {
    animation: ks-pop 700ms cubic-bezier(.34, 1.56, .64, 1);
    transform-origin: 50% 90%;
}

/* ─── The city's front door (until the map arrives) ───────────────────── */

.ks-home {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    max-width: 720px;
}

.ks-home__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.ks-home__title {
    font-size: 30px;
}

.ks-home__today {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ks-muted);
}

.ks-building-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 6px 8px;
    border-radius: 14px;
    color: var(--ks-ink) !important;
    text-decoration: none;
}

.ks-building-row:hover {
    background: var(--ks-chip);
}

.ks-building-row__name {
    flex: 1;
    font-size: 16px;
    font-weight: 800;
    min-width: 0;
    overflow-wrap: anywhere;
}

.ks-found {
    max-width: 480px;
    margin: 8vh auto 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
}

.ks-found__tile {
    align-self: center;
    width: 88px;
    height: 88px;
    border-radius: 28px;
    background: #F6EBD9;
    color: #26231F;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ks-found__title {
    font-size: 34px;
}

/* ─── Dialog content ──────────────────────────────────────────────────── */

.ks-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-family: var(--ks-font);
}

.ks-form__label {
    font-size: 13px;
    font-weight: 800;
    color: var(--ks-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 6px;
}

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

.ks-choice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1.5px solid var(--ks-line);
    background: var(--ks-surface);
    color: var(--ks-soft);
    font: 700 14px var(--ks-font);
    cursor: pointer;
}

.ks-choice[aria-pressed="true"] {
    background: var(--ks-primary);
    border-color: var(--ks-primary);
    color: var(--ks-on-primary);
    font-weight: 800;
}

.ks-swatch {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 2px solid rgba(38, 35, 31, 0.12);
    cursor: pointer;
    padding: 0;
}

.ks-swatch[aria-pressed="true"] {
    border-color: var(--ks-ink);
    box-shadow: 0 0 0 2px var(--ks-surface), 0 0 0 4px var(--ks-ink);
}

.ks-column-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ks-column-row .mud-input-control {
    flex: 1;
}

.ks-dialog-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
    width: 100%;
}

.ks-dialog-actions__spacer {
    flex: 1;
}

@media (prefers-reduced-motion: reduce) {
    .ks-pop,
    .ks-toast {
        animation: none;
    }

    .ks-tick__ring {
        transition: none;
    }

    .ks-drag-ghost {
        transform: none;
    }
}

.ks-dialog-title {
    font-family: var(--ks-font-title);
    font-weight: 600;
    font-size: 24px;
    margin: 0;
}

/* On a phone the add bar sits above the tab bar when there is one, and on the bottom edge when there isn't. */
@media (max-width: 720px) {
    /* Above the Timzo shell's tab bar. */
    .ks-world--embedded .ks-addbar {
        bottom: calc(var(--tz-tabbar-height, 0px) + env(safe-area-inset-bottom));
        padding-bottom: 12px;
    }

    .ks-world--embedded .ks-board {
        padding-bottom: 72px;
    }
}

/* ─── A building (StadBuilding) ───────────────────────────────────────── */
/* Layers are shown by the root's state and season classes; every change is a transition, so swapping
   last visit's state for today's plays the decay (design: "Beweging"). */

.ks-bld {
    width: 100%;
    line-height: 0;
}

.ks-bld svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    transition: filter 1200ms ease-in-out;
}

.ks-bld--neglected svg {
    filter: saturate(0.55) brightness(0.97);
}

.ks-bld--ruined svg {
    filter: saturate(0.32) brightness(0.88);
}

.ks-bld__body {
    transform-box: view-box;
    transform-origin: 80px 136px;
    transition: transform 900ms cubic-bezier(.34, 1.56, .64, 1);
}

.ks-bld--ruined .ks-bld__body {
    transform: rotate(-1.6deg);
}

/* Windows go out last. */
.ks-bld__window {
    fill: #FFE08A;
    transition: fill 900ms ease-in-out 600ms;
}

.ks-bld__skylight {
    stroke: #FFE08A;
    transition: stroke 900ms ease-in-out 600ms;
}

.ks-bld--neglected .ks-bld__window { fill: #C9CDC6; }
.ks-bld--neglected .ks-bld__skylight { stroke: #C9CDC6; }
.ks-bld--ruined .ks-bld__window { fill: #3E434B; }
.ks-bld--ruined .ks-bld__skylight { stroke: #3E434B; }

/* Every optional layer starts hidden and fades. */
.ks-bld__snow,
.ks-bld__ruin,
.ks-bld__decay,
.ks-bld__healthy,
.ks-bld__flowerbox,
.ks-bld__pumpkin,
.ks-bld__leaves,
.ks-bld__blossom,
.ks-bld__smoke,
.ks-bld__sparkles {
    opacity: 0;
    transition: opacity 600ms ease-in-out;
}

.ks-bld__not-ruin,
.ks-bld__column {
    opacity: 0.7;
    transition: opacity 600ms ease-in-out;
}

.ks-bld__not-ruin { opacity: 1; }

.ks-bld--ruined .ks-bld__not-ruin,
.ks-bld--ruined .ks-bld__column {
    opacity: 0;
}

.ks-bld--healthy .ks-bld__healthy,
.ks-bld--neglected .ks-bld__decay,
.ks-bld--ruined .ks-bld__decay,
.ks-bld--ruined .ks-bld__ruin,
.ks-bld--winter .ks-bld__snow,
.ks-bld--autumn .ks-bld__leaves,
.ks-bld--spring.ks-bld--healthy .ks-bld__blossom,
.ks-bld--spring.ks-bld--healthy .ks-bld__flowerbox,
.ks-bld--summer.ks-bld--healthy .ks-bld__flowerbox,
.ks-bld--autumn:not(.ks-bld--ruined) .ks-bld__pumpkin,
.ks-bld--healthy .ks-bld__smoke,
.ks-bld--shine .ks-bld__sparkles {
    opacity: 1;
}

/* Smoke dies out quickly. */
.ks-bld__smoke {
    transition-duration: 400ms;
}

/* Weeds grow from the ground, one tuft after another. */
.ks-bld__weed {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    transform: scaleY(0);
    transition: transform 600ms ease-out;
}

.ks-bld--neglected .ks-bld__decay .ks-bld__weed,
.ks-bld--ruined .ks-bld__weed {
    transform: scaleY(1);
}

.ks-bld__weed:nth-child(2) { transition-delay: 80ms; }
.ks-bld__weed:nth-child(3) { transition-delay: 160ms; }
.ks-bld__ruin .ks-bld__weed:nth-child(1) { transition-delay: 240ms; }
.ks-bld__ruin .ks-bld__weed:nth-child(2) { transition-delay: 320ms; }
.ks-bld__ruin .ks-bld__weed:nth-child(3) { transition-delay: 400ms; }

/* The shutter swings loose to 20° with a small overshoot; the barn door hangs. */
.ks-bld__shutter {
    transform-box: view-box;
    transform-origin: 38px 90px;
    transition: transform 700ms cubic-bezier(.34, 1.56, .64, 1), opacity 300ms;
}

.ks-bld--ruined .ks-bld__shutter {
    transform: rotate(20deg);
}

.ks-bld__door {
    transform-box: view-box;
    transform-origin: 60px 102px;
    transition: transform 700ms cubic-bezier(.34, 1.56, .64, 1);
}

.ks-bld--ruined .ks-bld__door {
    transform: rotate(7deg);
}

/* Ambient loops: smoke, the cat's tail, sparkles. CSS rather than SMIL, so reduced motion can stop them. */
.ks-bld__smoke circle {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
    animation: ks-smoke 3.6s ease-out infinite;
}

.ks-bld__smoke circle:nth-child(2) { animation-delay: 1.2s; }
.ks-bld__smoke circle:nth-child(3) { animation-delay: 2.4s; }

@keyframes ks-smoke {
    0% { transform: translate(0, 0) scale(1); opacity: 0; }
    25% { opacity: 0.85; }
    100% { transform: translate(7px, -26px) scale(2.6); opacity: 0; }
}

.ks-bld__tail {
    transform-box: fill-box;
    transform-origin: 100% 100%;
    animation: ks-tail 2.6s ease-in-out infinite;
}

@keyframes ks-tail {
    0%, 100% { transform: rotate(-8deg); }
    50% { transform: rotate(10deg); }
}

.ks-bld__sparkles path {
    transform-box: fill-box;
    transform-origin: center;
    animation: ks-sparkle 1.1s ease-in-out infinite;
}

.ks-bld__sparkles g:nth-child(2) path { animation-delay: -0.55s; }
.ks-bld__sparkles g:nth-child(3) path { animation-duration: 0.9s; }

@keyframes ks-sparkle {
    0%, 100% { transform: scale(0.3); }
    50% { transform: scale(1.15); }
}

/* Refurbished: a springy pop of 420 ms. */
.ks-bld--pop {
    animation: ks-pop 420ms cubic-bezier(.34, 1.56, .64, 1);
    transform-origin: 50% 90%;
}

@media (prefers-reduced-motion: reduce) {
    .ks-bld svg,
    .ks-bld__body,
    .ks-bld__window,
    .ks-bld__skylight,
    .ks-bld__weed,
    .ks-bld__shutter,
    .ks-bld__door,
    .ks-bld [class*="ks-bld__"] {
        transition-duration: 150ms !important;
        transition-delay: 0s !important;
    }

    .ks-bld__smoke circle,
    .ks-bld__tail,
    .ks-bld__sparkles path,
    .ks-bld--pop {
        animation: none;
    }

    .ks-bld__smoke circle:first-child {
        opacity: 0.6;
        transform: translate(3px, -10px) scale(1.6);
    }
}

/* ─── The town map (StadMap) ──────────────────────────────────────────── */

.ks-map {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: var(--ks-map-grass);
    color: #26231F;
    transition: background-color 1500ms ease-in-out;
}

.ks-map__ground {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* The season's palette: fills follow the variables and fade (1.5 s); decorations fade in after 300 ms. */
.ks-map__ground * {
    transition: fill 1500ms ease-in-out, stroke 1500ms ease-in-out, opacity 900ms ease-in-out 300ms;
}

.ks-map__grass { fill: var(--ks-map-grass); }
.ks-map__tufts { stroke: var(--ks-map-grass-dark); }
.ks-map__path { stroke: var(--ks-map-path); }
.ks-map__path-edge { stroke: var(--ks-map-path-edge); }
.ks-map__path-fill { fill: var(--ks-map-path); }
.ks-map__path-edge-fill { fill: var(--ks-map-path-edge); }
.ks-map__water { fill: var(--ks-map-water); }
.ks-map__tree1 { fill: var(--ks-map-tree1); }
.ks-map__tree2 { fill: var(--ks-map-tree2); }

.ks-map__spring,
.ks-map__summer,
.ks-map__autumn,
.ks-map__winter {
    opacity: 0;
}

.ks-map--spring .ks-map__spring,
.ks-map--summer .ks-map__summer,
.ks-map--autumn .ks-map__autumn,
.ks-map--winter .ks-map__winter {
    opacity: 1;
}

.ks-map--winter .ks-map__not-winter {
    opacity: 0;
}

.ks-map__duck {
    transform: translate(392px, 104px);
    animation: ks-duck 9s ease-in-out infinite;
}

@keyframes ks-duck {
    0%, 100% { transform: translate(392px, 104px); }
    50% { transform: translate(378px, 108px); }
}

.ks-map__spot {
    position: absolute;
    min-width: 48px;
    transform: translate(-50%, -60%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ks-map__link {
    position: relative;
    display: block;
    width: 100%;
    color: inherit;
    text-decoration: none;
    border-radius: 18px;
}

.ks-map__link .ks-bld svg {
    transition: filter 1200ms ease-in-out, transform 160ms ease-out;
}

.ks-map__link:hover .ks-bld svg {
    transform: translateY(-3px);
}

.ks-map__link:focus-visible {
    outline: 3px solid #FFFFFF;
    outline-offset: 2px;
}

.ks-map__label {
    margin-top: -6%;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    color: #26231F;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(38, 35, 31, 0.18);
    max-width: 160%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ks-badge {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    animation: ks-badge-in 420ms cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes ks-badge-in {
    from { transform: scale(0.4); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.ks-badge--neglected {
    top: 4%;
    right: 0;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    border-radius: 13px;
    background: #B4500F;
    border: 2.5px solid #FFFFFF;
    box-shadow: 0 2px 4px rgba(38, 35, 31, 0.2);
}

.ks-badge--ruined {
    top: 2%;
    right: 2%;
    width: 28px;
    height: 28px;
}

.ks-badge--ruined::before {
    content: "";
    position: absolute;
    inset: 3px;
    background: #7A2414;
    border: 2.5px solid #FFFFFF;
    border-radius: 5px;
    transform: rotate(45deg);
    box-shadow: 0 2px 4px rgba(38, 35, 31, 0.25);
}

.ks-badge--ruined span {
    position: relative;
}

.ks-badge--healthy {
    top: 6%;
    right: 4%;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #2F6B3A;
    border: 2px solid #FFFFFF;
}

.ks-map__flag {
    position: absolute;
    left: 50%;
    top: -14%;
    transform: translateX(-10%);
    display: flex;
    align-items: flex-end;
    pointer-events: none;
}

.ks-map__flag-pole {
    width: 3px;
    height: 40px;
    background: #5B4636;
    border-radius: 2px;
}

.ks-map__flag-cloth {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 14px;
    padding: 4px 9px 4px 7px;
    border-radius: 4px 999px 999px 4px;
    background: #1F5F8B;
    color: #FFFFFF;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(38, 35, 31, 0.2);
    transform-origin: 0 50%;
    animation: ks-flag 3s ease-in-out infinite;
}

@keyframes ks-flag {
    0%, 100% { transform: skewY(0deg); }
    50% { transform: skewY(-3deg); }
}

.ks-map__plot {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px dashed rgba(38, 35, 31, 0.45);
    background: rgba(255, 255, 255, 0.45);
    color: #26231F;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.ks-map__plot:hover {
    background: rgba(255, 255, 255, 0.75);
}

/* "De winter is er": once per season, the first time the town is opened. */
.ks-map__sign {
    position: absolute;
    left: 50%;
    top: 30%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 14px;
    background: #7A4E33;
    color: #FFF6E5;
    border: 3px solid #5B3A26;
    box-shadow: 0 6px 16px rgba(38, 35, 31, 0.3);
    font-family: var(--ks-font-title);
    font-weight: 600;
    font-size: 22px;
    white-space: nowrap;
    pointer-events: none;
    animation: ks-sign 3.4s ease-in-out both;
}

@keyframes ks-sign {
    0% { opacity: 0; transform: translate(-50%, -80%) rotate(-4deg); }
    12%, 82% { opacity: 1; transform: translate(-50%, -50%) rotate(-2deg); }
    100% { opacity: 0; transform: translate(-50%, -50%) rotate(-2deg); }
}

@keyframes ks-sign-still {
    0%, 85% { opacity: 1; }
    100% { opacity: 0; }
}

/* ─── The front door: map and the side panels ─────────────────────────── */

.ks-town {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
}

.ks-town__map {
    flex: 999 1 560px;
    min-width: 0;
    position: relative;
    border-radius: 28px;
    overflow: hidden;
    transition: background-color 1500ms ease-in-out;
}

.ks-town__scroll {
    overflow: auto;
    max-height: min(900px, calc(100dvh - 180px));
    scrollbar-width: thin;
}

.ks-town__canvas {
    margin: 0 auto;
    max-width: 720px;
}

.ks-town__zoom {
    position: absolute;
    right: 16px;
    top: 16px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    background: var(--ks-surface);
    box-shadow: 0 2px 8px var(--ks-shadow);
    overflow: hidden;
}

.ks-town__zoom button {
    width: 48px;
    height: 48px;
    border: 0;
    background: transparent;
    color: var(--ks-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ks-town__zoom button:disabled {
    opacity: 0.35;
    cursor: default;
}

.ks-town__zoom span {
    height: 1px;
    background: var(--ks-line);
}

.ks-town__legend {
    position: absolute;
    left: 16px;
    bottom: 16px;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    padding: 8px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    color: #26231F;
    font-size: 13px;
    font-weight: 800;
}

.ks-town__legend > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ks-town__dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
}

.ks-town__diamond {
    width: 13px;
    height: 13px;
    margin: 0 2px;
    border-radius: 2px;
    background: #7A2414;
    transform: rotate(45deg);
}

.ks-town__aside {
    flex: 1 1 340px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ks-town__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.ks-late-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px;
    margin-bottom: 16px;
    border-radius: 14px;
    background: var(--ks-over-bg);
    color: var(--ks-over) !important;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
}

.ks-today-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
}

.ks-today-row__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    color: inherit !important;
    text-decoration: none;
}

.ks-today-row__title {
    font-size: 15px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.ks-today-row--done .ks-today-row__title {
    text-decoration: line-through;
    color: var(--ks-muted);
}

.ks-today-row__sub {
    font-size: 13px;
    font-weight: 700;
    color: var(--ks-muted);
}

.ks-tile--small {
    width: 36px;
    height: 36px;
    border-radius: 11px;
}

.ks-next-context {
    display: flex;
    text-decoration: none;
    gap: 12px;
    align-items: flex-start;
    padding: 18px 20px;
    border-radius: 24px;
    background: var(--ks-alt-bg);
    color: var(--ks-alt-ink);
}

.ks-next-context strong {
    font-size: 15px;
}

.ks-next-context p {
    margin: 2px 0 0;
    font-size: 14px;
    line-height: 1.45;
}

@media (max-width: 720px) {
    .ks-town__map {
        margin: 0 -16px;
        border-radius: 0;
        flex-basis: 100%;
    }

    .ks-town__scroll {
        max-height: none;
    }

    .ks-town__legend {
        display: none;
    }

    .ks-map__label {
        font-size: 11px;
        padding: 2px 8px;
    }

    .ks-badge--neglected {
        min-width: 22px;
        height: 22px;
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ks-map,
    .ks-map__ground * {
        transition-duration: 150ms !important;
        transition-delay: 0s !important;
    }

    .ks-map__duck,
    .ks-map__flag-cloth,
    .ks-badge {
        animation: none;
    }

    .ks-map__sign {
        animation-name: ks-sign-still;
    }
}

/* ─── The town hall (StadTownHall) ─────────────────────────────────────── */

.ks-hall {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
}

.ks-hall__filters {
    flex: 1 1 250px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    background: var(--ks-surface);
    border-radius: 24px;
    border: 1px solid var(--ks-line);
}

.ks-filter {
    border: 0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ks-filter__option {
    height: 44px;
    border: 0;
    border-radius: 12px;
    padding: 0 12px;
    background: transparent;
    color: var(--ks-ink);
    font: 800 15px var(--ks-font);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    text-align: left;
}

.ks-filter__option:hover {
    background: var(--ks-chip);
}

.ks-filter__option[aria-checked="true"] {
    background: var(--ks-primary-soft);
    color: var(--ks-primary-soft-ink);
}

.ks-filter__count {
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.ks-filter__check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 6px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
}

.ks-filter__check input {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--ks-primary);
}

.ks-filter__name {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.ks-filter__late {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    box-sizing: border-box;
    border-radius: 11px;
    background: var(--ks-over-badge);
    color: #FFFFFF;
    font-size: 12px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ks-tile--tiny {
    width: 30px;
    height: 30px;
    border-radius: 9px;
}

.ks-hall__main {
    flex: 999 1 560px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ks-hall__head {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ks-bld.ks-hall__building {
    width: 84px;
    flex: none;
}

.ks-hall__title {
    font-size: 40px;
    line-height: 1.05;
}

.ks-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 16px;
}

.ks-tile-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 16px 20px;
    border-radius: 20px;
    background: var(--ks-surface);
    border: 1px solid var(--ks-line);
    font-size: 13px;
    font-weight: 700;
    color: var(--ks-muted);
}

.ks-tile-stat > span:first-child {
    font-size: 14px;
    font-weight: 800;
    color: var(--ks-soft);
}

.ks-tile-stat strong {
    font-size: 40px;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--ks-ink);
}

.ks-tile-stat--late {
    background: var(--ks-over-bg);
    border-color: transparent;
}

.ks-tile-stat--late,
.ks-tile-stat--late > span:first-child,
.ks-tile-stat--late strong {
    color: var(--ks-over);
}

.ks-tile-stat--today {
    background: var(--ks-today-bg);
    border-color: transparent;
}

.ks-tile-stat--today,
.ks-tile-stat--today > span:first-child,
.ks-tile-stat--today strong {
    color: var(--ks-today);
}

.ks-hall__list {
    background: var(--ks-surface);
    border-radius: 24px;
    border: 1px solid var(--ks-line);
    padding-bottom: 8px;
    overflow: hidden;
}

.ks-hall__row {
    display: grid;
    grid-template-columns: 52px minmax(180px, 2fr) minmax(130px, 1fr) minmax(140px, 1fr) minmax(120px, 1fr) 110px;
    align-items: center;
    gap: 0 8px;
    padding: 0 16px 0 8px;
    min-height: 56px;
    border-top: 1px solid var(--ks-line);
    font-size: 14px;
    font-weight: 700;
}

.ks-hall__row--head {
    min-height: 44px;
    border-top: 0;
    font-size: 13px;
    font-weight: 800;
    color: var(--ks-muted);
}

.ks-hall__title-cell {
    font-size: 15px;
    font-weight: 800;
    color: var(--ks-ink) !important;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.ks-hall__title-cell:hover {
    text-decoration: underline;
}

.ks-hall__building-cell,
.ks-hall__rhythm-cell {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: var(--ks-soft);
}

.ks-hall__when {
    text-align: right;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--ks-muted);
}

.ks-hall__when--overdue { color: var(--ks-over); }
.ks-hall__when--today { color: var(--ks-today); }

.ks-hall__group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 14px 16px 6px 24px;
    font-family: var(--ks-font);
    font-size: 15px;
    font-weight: 800;
}

.ks-hall__group--late {
    color: var(--ks-over);
}

.ks-hall__empty {
    margin: 0;
    padding: 40px;
    text-align: center;
    color: var(--ks-muted);
    font-size: 15px;
    font-weight: 700;
}

@media (max-width: 900px) {
    .ks-hall__row {
        grid-template-columns: 48px minmax(0, 1fr) auto;
        grid-template-areas:
            "tick title when"
            "tick meta meta";
        padding: 6px 12px 8px 4px;
        gap: 2px 8px;
    }

    .ks-hall__row--head {
        display: none;
    }

    .ks-hall__row > .ks-tick { grid-area: tick; }
    .ks-hall__row > .ks-hall__title-cell { grid-area: title; }
    .ks-hall__row > .ks-hall__when { grid-area: when; }

    .ks-hall__row > .ks-hall__building-cell,
    .ks-hall__row > .ks-hall__rhythm-cell,
    .ks-hall__row > span:nth-child(5) {
        grid-area: meta;
        font-size: 13px;
    }

    /* On a phone the building, rhythm and context share one line under the title. */
    .ks-hall__row > .ks-hall__rhythm-cell,
    .ks-hall__row > span:nth-child(5) {
        display: none;
    }

    .ks-hall__filters {
        flex-basis: 100%;
    }

    .ks-hall__title {
        font-size: 32px;
    }
}

/* ─── The notification centre (StadNotifications) ─────────────────────── */

.ks-notices {
    max-width: 720px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ks-notices__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.ks-pill-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--ks-line);
    background: var(--ks-surface);
    color: var(--ks-ink);
    font: 800 13px var(--ks-font);
    cursor: pointer;
}

.ks-paper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px 14px 10px;
    border-radius: 22px;
    background: #E1EDD5;
    color: #1F3A1A;
}

html.tz-dark .ks-paper {
    background: #2B3A2E;
    color: #E8F2E4;
}

.ks-bld.ks-paper__building {
    width: 84px;
    flex: none;
}

.ks-paper__text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    line-height: 1.45;
}

.ks-paper__kicker {
    font-size: 13px;
    font-weight: 800;
    opacity: 0.85;
}

.ks-paper__title {
    font-family: var(--ks-font-title);
    font-weight: 600;
    font-size: 22px;
    line-height: 1.15;
}

.ks-notices__section {
    margin: 4px 0 0;
    font-family: var(--ks-font);
    font-size: 15px;
    font-weight: 800;
    color: var(--ks-muted);
}

.ks-notice {
    display: flex;
    gap: 12px;
    padding: 12px 14px 12px 10px;
    border-radius: 20px;
    background: var(--ks-surface);
    border: 1px solid var(--ks-line);
}

.ks-notice__picture {
    width: 56px;
    flex: none;
    display: flex;
    justify-content: center;
}

.ks-notice__tile {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ks-notice__tile--context {
    background: var(--ks-primary-soft);
    color: var(--ks-primary-soft-ink);
}

.ks-notice__tile--season {
    background: #E2ECF3;
    color: #274B66;
}

.ks-notice__body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.ks-notice__top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
}

.ks-notice__title {
    font-size: 16px;
    line-height: 1.25;
}

.ks-notice__when {
    font-size: 12px;
    font-weight: 700;
    color: var(--ks-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ks-notice__text {
    font-size: 14px;
    line-height: 1.45;
    color: var(--ks-soft);
}

.ks-notice__actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.ks-snoozed {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 6px 6px 14px;
    border-radius: 14px;
    background: var(--ks-seg);
    font-size: 14px;
    font-weight: 700;
}

.ks-calendar {
    margin-top: 12px;
}

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

.ks-calendar__link .ks-addbar__input {
    height: 44px;
    font-size: 13px;
    font-weight: 600;
}

.ks-calendar__how {
    margin: 6px 0 0;
    font-family: var(--ks-font);
    font-size: 15px;
    font-weight: 800;
}

/* ─── First run (StadWelcome, design M6) ──────────────────────────────── */

.ks-welcome {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 1fr);
    grid-template-areas:
        "head head"
        "map sheet";
    gap: 16px 24px;
    align-items: start;
}

.ks-welcome__head {
    grid-area: head;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ks-welcome__map {
    grid-area: map;
    border-radius: 28px;
    overflow: hidden;
    max-width: 640px;
    width: 100%;
    justify-self: center;
}

.ks-welcome__sheet {
    grid-area: sheet;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 20px 22px;
    background: var(--ks-surface);
    border-radius: 26px;
    border: 1px solid var(--ks-line);
    box-shadow: 0 6px 20px var(--ks-shadow);
}

.ks-welcome__grip {
    display: none;
}

.ks-welcome__title {
    font-size: 23px;
    line-height: 1.15;
    margin-bottom: 4px;
}

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

.ks-welcome__choice {
    min-height: 56px;
    border-radius: 16px;
    border: 1.5px solid var(--ks-line);
    background: var(--ks-surface);
    color: var(--ks-ink);
    font: 800 15px var(--ks-font);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    cursor: pointer;
    text-align: left;
}

.ks-welcome__choice--own {
    border-style: dashed;
    border-color: var(--ks-ring);
    background: transparent;
}

.ks-welcome__choice[aria-checked="true"] {
    border: 2px solid var(--ks-primary);
    background: var(--ks-primary-soft);
    color: var(--ks-primary-soft-ink);
}

@media (max-width: 860px) {
    .ks-welcome {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "head"
            "map"
            "sheet";
        gap: 0;
    }

    .ks-welcome__head {
        margin-bottom: 12px;
    }

    .ks-welcome__map {
        margin: 0 -16px;
        width: auto;
        justify-self: stretch;
        border-radius: 0;
    }

    .ks-welcome__sheet {
        margin: -26px -16px 0;
        position: relative;
        z-index: 3;
        border-radius: 26px 26px 0 0;
        border: 0;
    }

    .ks-welcome__grip {
        display: block;
        align-self: center;
        width: 40px;
        height: 5px;
        border-radius: 3px;
        background: var(--ks-line);
    }
}

/* ─── The rhythm editor (StadRhythm, design M4) ───────────────────────── */

.ks-rhythm {
    max-width: 960px;
}

.ks-rhythm__title {
    font-size: 24px;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.ks-rhythm__body {
    display: flex;
    flex-wrap: wrap;
    gap: 24px 40px;
    align-items: flex-start;
}

.ks-rhythm__controls {
    flex: 1 1 340px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.ks-rhythm__subtitle {
    display: block;
    font-size: 14px;
    margin-bottom: 8px;
}

.ks-ring {
    position: relative;
    flex: none;
    width: 358px;
    max-width: 100%;
    height: 290px;
    margin: 0 auto;
}

.ks-ring__corner {
    position: absolute;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 800;
    color: var(--ks-soft);
}

.ks-ring__dial {
    position: absolute;
    left: 50%;
    top: 5px;
    width: 280px;
    height: 280px;
    margin-left: -140px;
}

.ks-ring__dial svg {
    display: block;
    overflow: visible;
}

.ks-ring__quadrant {
    opacity: 0.62;
    stroke: none;
    stroke-width: 3;
    stroke-linejoin: round;
    transition: opacity 200ms ease-out, transform 220ms cubic-bezier(.34, 1.56, .64, 1);
}

.ks-ring__quadrant--on {
    opacity: 1;
    stroke: var(--ks-ink);
}

.ks-ring__button {
    position: absolute;
    width: 56px;
    height: 56px;
    margin: -28px 0 0 -28px;
    border: 0;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: left 220ms cubic-bezier(.34, 1.56, .64, 1), top 220ms cubic-bezier(.34, 1.56, .64, 1);
}

.ks-ring__disc {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #FFFFFF;
    color: #26231F;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(38, 35, 31, 0.2);
    transition: width 220ms ease-out, height 220ms ease-out;
}

.ks-ring__button--on .ks-ring__disc {
    width: 44px;
    height: 44px;
}

.ks-ring__centre {
    position: absolute;
    left: 62px;
    top: 62px;
    width: 156px;
    height: 156px;
    border-radius: 50%;
    background: var(--ks-surface);
    box-shadow: inset 0 0 0 1px var(--ks-line);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
    pointer-events: none;
}

.ks-ring__season {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    font-weight: 800;
    color: var(--ks-muted);
}

.ks-ring__label {
    font-family: var(--ks-font-title);
    font-weight: 600;
    font-size: 22px;
    line-height: 1.1;
    max-width: 120px;
}

.ks-tempo {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ks-tempo__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 14px;
}

.ks-tempo__name {
    font-weight: 800;
    color: var(--ks-primary-soft-ink);
}

.ks-tempo__scale {
    position: relative;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
}

.ks-tempo__track {
    position: absolute;
    left: 30px;
    right: 30px;
    top: 26px;
    height: 4px;
    border-radius: 2px;
    background: var(--ks-line);
}

.ks-tempo__stop {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    color: var(--ks-ink);
    font-family: inherit;
}

.ks-tempo__disc {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ks-surface);
    color: var(--ks-ink);
    border: 2px solid var(--ks-line);
    transition: transform 220ms cubic-bezier(.34, 1.56, .64, 1);
}

.ks-tempo__stop--on .ks-tempo__disc {
    background: var(--ks-primary);
    color: var(--ks-on-primary);
    border-color: var(--ks-primary);
    transform: scale(1.08);
}

.ks-tempo__short {
    font-size: 12px;
    font-weight: 800;
    color: var(--ks-muted);
    font-variant-numeric: tabular-nums;
}

.ks-tempo__stop--on .ks-tempo__short {
    color: var(--ks-primary-soft-ink);
}

.ks-segments {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border-radius: 16px;
    background: var(--ks-seg);
}

.ks-segments__option {
    flex: 1 1 auto;
    min-height: 44px;
    padding: 0 12px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--ks-soft);
    font: 800 13px var(--ks-font);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    white-space: nowrap;
}

.ks-segments__option[aria-checked="true"] {
    background: var(--ks-surface);
    color: var(--ks-ink);
    box-shadow: 0 1px 2px var(--ks-shadow);
}

.ks-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 18px;
    background: var(--ks-surface);
    border: 1px solid var(--ks-line);
}

.ks-preview__tile {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--ks-primary-soft);
    color: var(--ks-primary-soft-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.ks-preview__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ks-preview__kicker,
.ks-preview__then {
    font-size: 13px;
    font-weight: 800;
    color: var(--ks-muted);
}

.ks-preview__then {
    font-weight: 700;
}

.ks-preview__date {
    font-family: var(--ks-font-title);
    font-weight: 600;
    font-size: 21px;
    line-height: 1.15;
}

@media (max-width: 400px) {
    .ks-ring {
        transform: scale(0.92);
        transform-origin: 50% 0;
        height: 270px;
    }

    .ks-tempo__disc {
        width: 46px;
        height: 46px;
    }

    .ks-tempo__track {
        top: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ks-ring__quadrant,
    .ks-ring__button,
    .ks-ring__disc,
    .ks-tempo__disc {
        transition-duration: 0s;
    }
}

/* A text button with a sentence in it may wrap. */
.ks-btn--wrap {
    white-space: normal;
    height: auto;
    min-height: 44px;
    padding-top: 8px;
    padding-bottom: 8px;
    text-align: center;
    line-height: 1.35;
}

/* In a narrow side panel the status drops under the name rather than squeezing it letter by letter. */
.ks-building-row {
    flex-wrap: wrap;
    row-gap: 2px;
}

.ks-building-row__name {
    flex: 1 1 8rem;
}

.ks-building-row .ks-status {
    margin-left: 52px;
    flex: 1 1 100%;
}

/* ─── The town's calendar (TownCalendar, TownContextDialog) ─────────────── */

.ks-cal {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.ks-cal-empty {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--ks-soft);
}

.ks-cal-empty p {
    margin: 0;
}

.ks-cal-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 12px;
}

.ks-cal-item {
    appearance: none;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--ks-line);
    border-left: 5px solid var(--ks-cal-colour);
    border-radius: 18px;
    background: var(--ks-surface);
    color: var(--ks-ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.ks-cal-item:hover {
    border-color: var(--ks-cal-colour);
}

.ks-cal-item__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ks-cal-item__name {
    font-weight: 700;
    font-size: 16px;
}

.ks-cal-item__sub {
    color: var(--ks-soft);
    font-size: 13px;
}

.ks-cal-item__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.ks-cal-months__title {
    margin: 8px 0 0;
    font-size: 17px;
}

.ks-cal-months {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 12px;
}

.ks-cal-month h3 {
    margin: 0 0 10px;
    font-size: 15px;
}

.ks-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.ks-cal-grid__dow {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--ks-soft);
    text-transform: uppercase;
}

.ks-cal-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 5px 0 4px;
    border-radius: 9px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.ks-cal-day--today {
    background: var(--ks-chip);
    font-weight: 800;
}

.ks-cal-day--paused {
    background-image: repeating-linear-gradient(135deg, transparent 0 4px, rgba(0, 0, 0, 0.06) 4px 6px);
}

.ks-cal-day__marks {
    display: flex;
    gap: 2px;
    min-height: 5px;
}

.ks-cal-day__mark {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.ks-cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 13px;
    color: var(--ks-soft);
}

.ks-cal-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ks-cal-legend__paused {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    background-image: repeating-linear-gradient(135deg, transparent 0 4px, rgba(0, 0, 0, 0.18) 4px 6px);
}

.ks-cal-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ks-cal-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    gap: 8px;
    align-items: center;
}

.ks-cal-switches {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

@media (max-width: 720px) {
    .ks-cal-pair,
    .ks-cal-row {
        grid-template-columns: 1fr 1fr;
    }
}

/* ─── The map scales as one picture ────────────────────────────────────── */
/* Zoomed out on a phone the map is a few hundred pixels wide; labels, plot buttons and flags in fixed pixels then
   pile on top of each other. Everything on the map is sized in container units (cqw: a percent of the map's own
   width) between a floor and the size it has at full width, and the names of buildings give way when the map is too
   small to hold them — zoom in to read them. */
.ks-map {
    container-type: inline-size;
}

.ks-map__spot {
    min-width: 0;
}

.ks-map__plot {
    width: clamp(20px, 10cqw, 72px);
    height: clamp(20px, 10cqw, 72px);
    border-width: clamp(1.5px, 0.4cqw, 3px);
}

.ks-map--large .ks-map__plot {
    width: clamp(18px, 6.2cqw, 72px);
    height: clamp(18px, 6.2cqw, 72px);
}

.ks-map__plot .ks-icon {
    width: 45%;
    height: 45%;
}

.ks-map__label,
.ks-map__flag-cloth {
    font-size: clamp(9px, 1.7cqw, 12px);
}

.ks-map--large .ks-map__label,
.ks-map--large .ks-map__flag-cloth {
    font-size: clamp(8px, 1.05cqw, 12px);
}

.ks-map__flag-pole {
    height: clamp(16px, 5.5cqw, 40px);
}

@container (max-width: 480px) {
    .ks-map--large .ks-map__spot:not(.ks-map__spot--hall) .ks-map__label,
    .ks-map--large .ks-map__flag {
        display: none;
    }

    .ks-map--large .ks-badge {
        zoom: 0.7;
    }
}

@container (max-width: 300px) {
    .ks-map__spot:not(.ks-map__spot--hall) .ks-map__label,
    .ks-map__flag {
        display: none;
    }

    .ks-badge {
        zoom: 0.7;
    }
}

/* Zooming out never squeezes the town below a width it can still be read at. */
.ks-town__canvas {
    min-width: min(100%, 320px);
}

/* ─── The town hall's tabs: its tasks and the town's calendar (TownHallTabs) ── */

.ks-hall-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: var(--ks-chip);
    margin-bottom: 14px;
    align-self: flex-start;
}

.ks-hall-tabs__tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    color: var(--ks-soft);
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
}

.ks-hall-tabs__tab[aria-current="page"] {
    background: var(--ks-surface);
    color: var(--ks-ink);
    box-shadow: 0 1px 3px rgba(38, 35, 31, 0.12);
}

.ks-filter__manage {
    align-self: flex-start;
    margin-top: 4px;
}

/* ─── Life in town: hovering a building (TownBuilding) ──────────────────── */
/* Point at a building on the map — or tab to it — and someone is home: the door opens with a person in it (the barn
   door slides, the workshop's shutter rolls up), a shadow walks past a window, and at the holiday home the parasol
   sways and someone waves from the lounger. A ruined building stays empty; reduced motion keeps it all still. */
.ks-bld__door-leaf,
.ks-bld__slide,
.ks-bld__roller,
.ks-bld__parasol,
.ks-bld__wave {
    transform-box: fill-box;
    transition: transform 520ms cubic-bezier(.3, .8, .3, 1);
}

.ks-bld__door-leaf {
    transform-origin: left center;
}

.ks-bld__parasol {
    transform-origin: 50% 100%;
}

.ks-bld__wave {
    transform-origin: 0% 100%;
}

.ks-bld__person,
.ks-bld__walker {
    opacity: 0;
    transition: opacity 260ms ease-out 140ms;
}

.ks-bld__person--resting {
    opacity: 1;
}

.ks-map__link:is(:hover, :focus-visible) .ks-bld__door-leaf {
    transform: scaleX(0.14);
}

.ks-map__link:is(:hover, :focus-visible) .ks-bld__slide {
    transform: translateX(34px);
}

.ks-map__link:is(:hover, :focus-visible) .ks-bld__roller {
    transform: translateY(-30px);
}

.ks-map__link:is(:hover, :focus-visible) .ks-bld__person {
    opacity: 1;
}

.ks-map__link:is(:hover, :focus-visible) .ks-bld__walker {
    opacity: 1;
    animation: ks-walk 2.8s linear infinite;
}

.ks-map__link:is(:hover, :focus-visible) .ks-bld__parasol {
    animation: ks-sway 2.4s ease-in-out infinite;
}

.ks-map__link:is(:hover, :focus-visible) .ks-bld__wave {
    animation: ks-wave 0.9s ease-in-out infinite;
}

@keyframes ks-walk {
    from { transform: translateX(-14px); }
    to { transform: translateX(var(--walk, 26px)); }
}

@keyframes ks-sway {
    0%, 100% { transform: rotate(-4deg); }
    50% { transform: rotate(4deg); }
}

@keyframes ks-wave {
    0%, 100% { transform: rotate(-20deg); }
    50% { transform: rotate(25deg); }
}

/* Nobody lives in a ruin. */
.ks-bld--ruined .ks-bld__person,
.ks-bld--ruined .ks-bld__walker {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .ks-bld__door-leaf,
    .ks-bld__slide,
    .ks-bld__roller,
    .ks-bld__parasol,
    .ks-bld__wave,
    .ks-bld__person,
    .ks-bld__walker {
        transition: none;
        animation: none !important;
    }
}

/* ─── Arranging the town (town hall → Layout) ──────────────────────────── */
.ks-arrange {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.ks-arrange__map {
    width: 100%;
    max-width: 760px;
    border-radius: 24px;
    overflow: hidden;
}

.ks-map__pick {
    border: 0;
    padding: 0;
    background: none;
    cursor: grab;
    font: inherit;
}

.ks-map__spot--picked .ks-bld svg {
    transform: translateY(-10px) rotate(-3deg);
    filter: drop-shadow(0 14px 10px rgba(38, 35, 31, 0.35));
}

.ks-map__spot--picked .ks-map__label {
    background: var(--ks-primary);
    color: var(--ks-on-primary);
}

.ks-map__plot--target {
    border-style: solid;
    background: rgba(255, 255, 255, 0.7);
    animation: ks-plot-beckon 1.4s ease-in-out infinite;
}

@keyframes ks-plot-beckon {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.08); }
}

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

/* ─── The shopping list: the town hall's fourth tab and the market stall ───────────────────── */

.ks-shopping {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 760px;
}

.ks-shop {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ks-shop__add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px 90px auto;
    gap: 8px;
}

.ks-shop__add input {
    height: 44px;
    min-width: 0;
    padding: 0 12px;
    border: 1px solid var(--ks-line-strong);
    border-radius: 12px;
    background: var(--ks-surface);
    color: var(--ks-ink);
    font: 600 15px var(--ks-font);
}

.ks-shop__add input:focus-visible {
    outline: 2px solid var(--ks-primary);
    outline-offset: 1px;
}

.ks-shop__empty {
    margin: 4px 0;
    color: var(--ks-muted);
}

.ks-shop__lines {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.ks-shop__line {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid var(--ks-line);
    animation: ks-shop-in 260ms ease-out both;
}

.ks-shop__line:first-child {
    border-top: 0;
}

.ks-shop__what {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.ks-shop__item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.ks-shop__item strong {
    font-size: 16px;
    overflow-wrap: anywhere;
}

.ks-shop__total {
    font-weight: 800;
    color: var(--ks-primary-deep);
    font-variant-numeric: tabular-nums;
}

.ks-shop__sources {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
    font-size: 13px;
    color: var(--ks-muted);
}

.ks-shop__source {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 4px 1px 8px;
    border-radius: 999px;
    background: var(--ks-chip);
}

.ks-shop__drop {
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font: 700 15px/1 var(--ks-font);
    cursor: pointer;
}

.ks-shop__drop:hover {
    background: var(--ks-line);
}

.ks-shop__line--done .ks-shop__what {
    opacity: 0.55;
}

.ks-shop__line--done .ks-shop__item strong,
.ks-shop__line--done .ks-shop__total {
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

.ks-shop__foot {
    display: flex;
    justify-content: flex-end;
}

.ks-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--ks-muted);
    cursor: pointer;
}

.ks-icon-btn:hover {
    background: var(--ks-chip);
    color: var(--ks-ink);
}

@keyframes ks-shop-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 560px) {
    .ks-shop__add {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .ks-shop__name {
        grid-column: 1 / -1;
    }

    .ks-shop__add .ks-btn {
        grid-column: 1 / -1;
    }
}

/* The stall on the map: a spot like a building's, but a button, never a link. */
.ks-map__spot--stall {
    z-index: 1;
}

button.ks-map__link {
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

.ks-stall {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    transition: transform 160ms ease-out;
}

.ks-map__link:hover .ks-stall {
    transform: translateY(-3px) rotate(-1deg);
}

/* What's still to get, in a bubble like a building's — quiet grey, never the orange of what's overdue: the list
   doesn't ask for attention. */
.ks-badge--stall {
    top: -6%;
    right: -8%;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 11px;
    background: #6E685F;
    border: 2px solid #FFFFFF;
    box-shadow: 0 2px 4px rgba(38, 35, 31, 0.2);
    font-size: 12px;
}

/* The panel the stall opens: a sheet from the right on a desktop, from the bottom on a phone. */
.ks-sheet__backdrop {
    position: fixed;
    inset: 0;
    z-index: 1300;
    background: rgba(30, 27, 38, 0.32);
    animation: ks-fade-in 180ms ease-out both;
}

.ks-sheet {
    position: fixed;
    top: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 1301;
    width: min(440px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px 18px 22px;
    overflow-y: auto;
    background: var(--ks-surface);
    color: var(--ks-ink);
    border: 1px solid var(--ks-line);
    border-radius: 24px;
    box-shadow: 0 24px 60px -18px rgba(30, 27, 38, 0.45);
    animation: ks-sheet-in 260ms cubic-bezier(.2, .8, .2, 1) both;
}

.ks-sheet__head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ks-sheet__head h2 {
    flex: 1;
    margin: 0;
    font-size: 22px;
}

@keyframes ks-sheet-in {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: none; }
}

@keyframes ks-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 640px) {
    .ks-sheet {
        top: auto;
        left: 8px;
        right: 8px;
        bottom: 8px;
        width: auto;
        max-height: 82dvh;
        animation-name: ks-sheet-up;
    }

    @keyframes ks-sheet-up {
        from { opacity: 0; transform: translateY(32px); }
        to { opacity: 1; transform: none; }
    }
}

@media (prefers-reduced-motion: reduce) {
    .ks-shop__line,
    .ks-sheet,
    .ks-sheet__backdrop {
        animation: none;
    }
}

.ks-map__spot--stall .ks-map__label {
    max-width: none;
}
