/* ==========================================================================
   Kylie's Kitchen — design tokens & base styles
   A calm, practical, warm household food-management interface.
   ========================================================================== */

:root {
    color-scheme: light;

    /* ---- Color: neutral ramp (warm-biased) ---- */
    --kk-bg: #faf7f2;
    --kk-bg-sunken: #f2eee6;
    --kk-surface: #ffffff;
    --kk-surface-tinted: #fbf9f5;
    --kk-surface-raised: #ffffff;
    --kk-overlay: rgba(38, 36, 31, 0.42);

    /* Every text colour below clears 4.5:1 against --kk-bg, so none of them
       depend on being "decorative" to be readable. */
    --kk-text: #26241f; /* 15.1:1 */
    --kk-text-strong: #14130f; /* 17.6:1 */
    --kk-text-muted: #6b665c; /* 5.3:1  */
    --kk-text-subtle: #736d61; /* 4.8:1  */
    --kk-text-on-accent: #ffffff;

    --kk-border: #e3ddd1;
    --kk-border-strong: #cec6b5;
    --kk-border-subtle: #ece7dd;

    /* ---- Color: primary (deep olive / forest) ---- */
    --kk-primary: #3d5a3a;
    --kk-primary-hover: #334c31;
    --kk-primary-active: #2a3f28;
    --kk-primary-soft: #eaf0e7;
    --kk-primary-soft-hover: #dfe8db;
    --kk-primary-border: #c3d4bd;
    --kk-primary-text: #2f4a2d;

    /* ---- Color: secondary accent (muted terracotta) — use sparingly ---- */
    --kk-accent: #b35f42;
    --kk-accent-hover: #9d5239;
    --kk-accent-soft: #fbeee8;
    --kk-accent-border: #eccdbe;
    --kk-accent-text: #8f4a34;

    /* ---- Color: status ---- */
    --kk-success: #2f6b46;
    --kk-success-soft: #e7f2ea;
    --kk-success-border: #bcd9c6;

    --kk-warning: #8a5d12;
    --kk-warning-soft: #fbf1de;
    --kk-warning-border: #ecd7ac;

    --kk-danger: #a33327;
    --kk-danger-soft: #fbeae7;
    --kk-danger-border: #eec4bc;

    --kk-info: #2b5470;
    --kk-info-soft: #e8f0f6;
    --kk-info-border: #bed4e3;

    /* ---- Spacing scale (4px base) ---- */
    --kk-space-0: 0;
    --kk-space-1: 0.25rem;
    --kk-space-2: 0.5rem;
    --kk-space-3: 0.75rem;
    --kk-space-4: 1rem;
    --kk-space-5: 1.25rem;
    --kk-space-6: 1.5rem;
    --kk-space-8: 2rem;
    --kk-space-10: 2.5rem;
    --kk-space-12: 3rem;
    --kk-space-16: 4rem;

    /* ---- Typography ---- */
    --kk-font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --kk-font-numeric: ui-sans-serif, system-ui, "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;

    /* Nothing smaller than 12px: below that, labels stop being readable. */
    --kk-text-xs: 0.75rem; /* 12px — badges and meta only */
    --kk-text-sm: 0.8125rem; /* 13px */
    --kk-text-base: 0.9375rem; /* 15px — body */
    --kk-text-md: 1rem; /* 16px — inputs (prevents iOS zoom) */
    --kk-text-lg: 1.125rem;
    --kk-text-xl: 1.3125rem;
    --kk-text-2xl: 1.5rem;
    --kk-text-3xl: 1.875rem;

    --kk-leading-tight: 1.25;
    --kk-leading-snug: 1.4;
    --kk-leading-normal: 1.55;
    --kk-leading-relaxed: 1.7;

    --kk-weight-normal: 400;
    --kk-weight-medium: 500;
    --kk-weight-semibold: 600;
    --kk-weight-bold: 700;

    --kk-tracking-tight: -0.011em;
    --kk-tracking-wide: 0.02em;

    /* ---- Radii ---- */
    --kk-radius-xs: 6px;
    --kk-radius-sm: 8px;
    --kk-radius-md: 10px;
    --kk-radius-lg: 12px;
    --kk-radius-xl: 14px;
    --kk-radius-pill: 999px;

    /* ---- Shadows (restrained) ---- */
    --kk-shadow-xs: 0 1px 2px rgba(38, 36, 31, 0.05);
    --kk-shadow-sm: 0 1px 3px rgba(38, 36, 31, 0.07), 0 1px 2px rgba(38, 36, 31, 0.04);
    --kk-shadow-md: 0 4px 12px rgba(38, 36, 31, 0.08), 0 1px 3px rgba(38, 36, 31, 0.05);
    --kk-shadow-lg: 0 12px 32px rgba(38, 36, 31, 0.13), 0 2px 8px rgba(38, 36, 31, 0.06);

    /* ---- Borders ---- */
    --kk-border-width: 1px;
    --kk-border-hairline: 1px solid var(--kk-border);
    --kk-border-subtle-line: 1px solid var(--kk-border-subtle);

    /* ---- Transitions ---- */
    --kk-duration-fast: 110ms;
    --kk-duration-base: 170ms;
    --kk-duration-slow: 260ms;
    --kk-ease: cubic-bezier(0.2, 0, 0.15, 1);
    --kk-transition-colors: color var(--kk-duration-fast) var(--kk-ease), background-color var(--kk-duration-fast) var(--kk-ease), border-color var(--kk-duration-fast) var(--kk-ease);

    /* ---- Focus ring ---- */
    --kk-focus-ring-color: #3d5a3a;
    --kk-focus-ring-width: 2px;
    --kk-focus-ring-offset: 2px;
    --kk-focus-ring: var(--kk-focus-ring-width) solid var(--kk-focus-ring-color);

    /* ---- Layout ---- */
    --kk-nav-rail-width: 232px;
    --kk-nav-rail-width-compact: 76px;
    --kk-topbar-height: 60px;
    --kk-bottom-nav-height: 60px;
    --kk-touch-target: 44px;

    /* Height a sticky footer reserves, before its safe-area inset. */
    --kk-sticky-action-height: 68px;

    /* ---- Safe areas ----
       Named once so a new sticky element does not have to rediscover env(). Every
       inset falls back to zero, which is what a desktop browser reports anyway. */
    --kk-safe-top: env(safe-area-inset-top, 0px);
    --kk-safe-bottom: env(safe-area-inset-bottom, 0px);
    --kk-safe-left: env(safe-area-inset-left, 0px);
    --kk-safe-right: env(safe-area-inset-right, 0px);

    /* Everything a fixed bottom element has to clear: the nav bar plus the inset. */
    --kk-bottom-nav-clearance: calc(var(--kk-bottom-nav-height) + var(--kk-safe-bottom));

    /* ---- Page padding ----
       Overridden at each breakpoint below rather than restated per page. */
    --kk-page-padding: var(--kk-space-4);

    /* ---- Content widths ----

       Three, not one. A meal-plan grid and a paragraph of prose want opposite things,
       and giving both the same 1180 px was leaving a seven-day calendar squeezed into
       the middle of a 1728 px display. */
    --kk-content-prose: 68ch;
    --kk-content-max: 1180px;
    --kk-content-wide: 1520px;

    /* ---- Breakpoints ----

       Four values, used everywhere. A media query cannot read a custom property, so
       these are the documented source and the numbers are written out inline — but
       only these four numbers, rather than the twenty that had accumulated.

         sm   480px   large phone
         md   768px   tablet; the desktop rail appears here
         lg  1024px   laptop
         xl  1280px   large desktop and landscape smart displays */
    --kk-bp-sm: 480px;
    --kk-bp-md: 768px;
    --kk-bp-lg: 1024px;
    --kk-bp-xl: 1280px;

    /* ---- Z-index ---- */
    --kk-z-sticky: 20;
    --kk-z-nav: 40;
    --kk-z-overlay: 60;
    --kk-z-dialog: 70;
    --kk-z-toast: 90;
}

/* Page padding grows with the viewport. Declared once so no page recomputes it. */
@media (min-width: 600px) {
    :root {
        --kk-page-padding: var(--kk-space-5);
    }
}

@media (min-width: 1024px) {
    :root {
        --kk-page-padding: var(--kk-space-6);
    }
}

@media (min-width: 1280px) {
    :root {
        --kk-page-padding: var(--kk-space-8);
    }
}

/* An exceptionally narrow phone gets a little of its width back. */
@media (max-width: 359px) {
    :root {
        --kk-page-padding: var(--kk-space-3);
    }
}

/* ==========================================================================
   Reset & base
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    background-color: var(--kk-bg);
    color: var(--kk-text);
    font-family: var(--kk-font-sans);
    font-size: var(--kk-text-base);
    line-height: var(--kk-leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100dvh;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    color: var(--kk-text-strong);
    font-weight: var(--kk-weight-semibold);
    line-height: var(--kk-leading-tight);
    letter-spacing: var(--kk-tracking-tight);
}

h1 { font-size: var(--kk-text-2xl); }
h2 { font-size: var(--kk-text-xl); }
h3 { font-size: var(--kk-text-lg); }
h4 { font-size: var(--kk-text-md); }

p {
    margin: 0 0 var(--kk-space-3);
}

    p:last-child {
        margin-bottom: 0;
    }

ul, ol {
    margin: 0;
    padding-left: 1.25rem;
}

a {
    color: var(--kk-primary-text);
    text-decoration-color: color-mix(in srgb, var(--kk-primary-text) 40%, transparent);
    text-underline-offset: 2px;
    transition: var(--kk-transition-colors);
}

    a:hover {
        color: var(--kk-primary-hover);
        text-decoration-color: currentColor;
    }

hr {
    border: 0;
    border-top: var(--kk-border-hairline);
    margin: var(--kk-space-6) 0;
}

img, svg, video {
    max-width: 100%;
    height: auto;
    display: block;
}

small {
    font-size: var(--kk-text-sm);
}

code, kbd, samp {
    font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
    font-size: 0.9em;
}

/* Focus: visible, consistent, never removed */
:focus-visible {
    outline: var(--kk-focus-ring);
    outline-offset: var(--kk-focus-ring-offset);
    border-radius: var(--kk-radius-xs);
}

/* Only suppress the default ring where we draw our own */
:focus:not(:focus-visible) {
    outline: none;
}

::selection {
    background: var(--kk-primary-soft);
    color: var(--kk-primary-active);
}

/* Scrollbars — subtle, not decorative */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--kk-border-strong) transparent;
}

/* ==========================================================================
   Utility primitives (small, deliberate set)
   ========================================================================== */

.kk-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.kk-skip-link {
    position: absolute;
    top: var(--kk-space-2);
    left: var(--kk-space-2);
    z-index: 200;
    transform: translateY(-200%);
    background: var(--kk-surface);
    color: var(--kk-primary-text);
    border: 1px solid var(--kk-primary-border);
    border-radius: var(--kk-radius-sm);
    padding: var(--kk-space-2) var(--kk-space-4);
    font-weight: var(--kk-weight-semibold);
    text-decoration: none;
    box-shadow: var(--kk-shadow-md);
}

    .kk-skip-link:focus {
        transform: translateY(0);
    }

.kk-stack {
    display: flex;
    flex-direction: column;
    gap: var(--kk-space-4);
}

.kk-row {
    display: flex;
    align-items: center;
    gap: var(--kk-space-3);
}

.kk-spacer {
    flex: 1 1 auto;
}

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

.kk-subtle {
    color: var(--kk-text-subtle);
}

.kk-numeric {
    font-variant-numeric: tabular-nums;
}

.kk-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kk-section-heading {
    font-size: var(--kk-text-xs);
    font-weight: var(--kk-weight-semibold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--kk-text-subtle);
    margin: 0;
}

/* ==========================================================================
   Page container
   ========================================================================== */

/*
    Settings pages read as a column of prose and rows rather than as a dense working
    surface, so they get a narrower measure than the pantry or a recipe list. 1000px keeps
    two setting cards comfortably side by side without letting a description stretch to an
    unreadable line length.

    Applied as a custom-property override rather than a width, so the page header inherits
    it too. PageHeader and .kk-page both size themselves from --kk-content-max, which means
    one declaration keeps the header and the content on the same left edge. Setting a width
    on the content alone is what makes a header look subtly misaligned.
*/
.kk-settings-scope {
    --kk-content-max: 1000px;
}

.kk-page {
    max-width: var(--kk-content-max);
    margin-inline: auto;

    /* One token, scaled by breakpoint in :root. No page recomputes its own padding. */
    padding-inline: var(--kk-page-padding);
    padding-block: var(--kk-page-padding) var(--kk-space-10);

    /* Landscape phones and notched devices put content under the rounded corner. */
    padding-left: max(var(--kk-page-padding), var(--kk-safe-left));
    padding-right: max(var(--kk-page-padding), var(--kk-safe-right));

    display: flex;
    flex-direction: column;
    gap: var(--kk-space-5);
}

@media (min-width: 768px) {
    .kk-page {
        gap: var(--kk-space-6);
    }
}

/* Long prose only. A readable measure is wrong for a calendar and right for a paragraph. */
.kk-page--prose {
    max-width: var(--kk-content-prose);
}

/* Operational screens: meal plan, pantry management, recipe grids, grocery review.
   These earn the extra width — a seven-day calendar centred in 1180 px on a 1728 px
   display is 270 px of margin either side of columns that are too narrow to read. */
.kk-page--wide {
    max-width: var(--kk-content-wide);
}

/* Full-bleed, for a workflow that manages its own width. */
.kk-page--flush {
    max-width: none;
}

/* Reserves room for a fixed StickyActions bar so the last item in the content is not
   permanently underneath it. Only needed on a phone, where the bar is fixed. */
.kk-has-sticky-actions {
    padding-bottom: calc(var(--kk-sticky-action-height) + var(--kk-space-6));
}

@media (min-width: 768px) {
    .kk-has-sticky-actions {
        padding-bottom: var(--kk-space-10);
    }
}

.kk-page__section {
    display: flex;
    flex-direction: column;
    gap: var(--kk-space-3);
}

/* ==========================================================================
   Surfaces
   ========================================================================== */

.kk-panel {
    background: var(--kk-surface);
    border: var(--kk-border-hairline);
    border-radius: var(--kk-radius-lg);
}

.kk-panel--flush {
    overflow: hidden;
}

.kk-panel__header {
    display: flex;
    align-items: center;
    gap: var(--kk-space-3);
    padding: var(--kk-space-4) var(--kk-space-5);
    border-bottom: var(--kk-border-subtle-line);
}

.kk-panel__body {
    padding: var(--kk-space-5);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.kk-btn {
    --_bg: var(--kk-surface);
    --_fg: var(--kk-text);
    --_bd: var(--kk-border-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--kk-space-2);
    min-height: 38px;
    padding: 0 var(--kk-space-4);
    border: 1px solid var(--_bd);
    border-radius: var(--kk-radius-md);
    background: var(--_bg);
    color: var(--_fg);
    font-family: inherit;
    font-size: var(--kk-text-base);
    font-weight: var(--kk-weight-medium);
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--kk-transition-colors), box-shadow var(--kk-duration-fast) var(--kk-ease);
}

    .kk-btn:hover:not(:disabled) {
        background: var(--kk-bg-sunken);
        color: var(--_fg);
        text-decoration: none;
    }

    .kk-btn:active:not(:disabled) {
        transform: translateY(0.5px);
    }

    .kk-btn:disabled,
    .kk-btn[aria-disabled="true"] {
        opacity: 0.5;
        cursor: not-allowed;
    }

.kk-btn--primary {
    --_bg: var(--kk-primary);
    --_fg: var(--kk-text-on-accent);
    --_bd: var(--kk-primary);
    box-shadow: var(--kk-shadow-xs);
}

    .kk-btn--primary:hover:not(:disabled) {
        background: var(--kk-primary-hover);
        border-color: var(--kk-primary-hover);
        color: var(--kk-text-on-accent);
    }

.kk-btn--accent {
    --_bg: var(--kk-accent);
    --_fg: var(--kk-text-on-accent);
    --_bd: var(--kk-accent);
}

    .kk-btn--accent:hover:not(:disabled) {
        background: var(--kk-accent-hover);
        border-color: var(--kk-accent-hover);
        color: var(--kk-text-on-accent);
    }

.kk-btn--soft {
    --_bg: var(--kk-primary-soft);
    --_fg: var(--kk-primary-text);
    --_bd: var(--kk-primary-border);
}

    .kk-btn--soft:hover:not(:disabled) {
        background: var(--kk-primary-soft-hover);
        color: var(--kk-primary-active);
    }

.kk-btn--ghost {
    --_bg: transparent;
    --_fg: var(--kk-text-muted);
    --_bd: transparent;
}

    .kk-btn--ghost:hover:not(:disabled) {
        background: var(--kk-bg-sunken);
        color: var(--kk-text);
    }

.kk-btn--danger {
    --_bg: var(--kk-surface);
    --_fg: var(--kk-danger);
    --_bd: var(--kk-danger-border);
}

    .kk-btn--danger:hover:not(:disabled) {
        background: var(--kk-danger-soft);
        color: var(--kk-danger);
    }

.kk-btn--danger-solid {
    --_bg: var(--kk-danger);
    --_fg: var(--kk-text-on-accent);
    --_bd: var(--kk-danger);
}

    .kk-btn--danger-solid:hover:not(:disabled) {
        background: #8d2b21;
        border-color: #8d2b21;
        color: var(--kk-text-on-accent);
    }

.kk-btn--sm {
    min-height: 32px;
    padding: 0 var(--kk-space-3);
    font-size: var(--kk-text-sm);
    border-radius: var(--kk-radius-sm);
}

.kk-btn--lg {
    min-height: var(--kk-touch-target);
    padding: 0 var(--kk-space-5);
    font-size: var(--kk-text-md);
}

.kk-btn--block {
    width: 100%;
}

.kk-btn--icon {
    padding: 0;
    width: 38px;
    min-height: 38px;
}

.kk-btn--sm.kk-btn--icon {
    width: 32px;
}

.kk-btn__icon {
    flex: 0 0 auto;
    width: 1.05em;
    height: 1.05em;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.kk-field {
    display: flex;
    flex-direction: column;
    gap: var(--kk-space-2);
}

.kk-label {
    font-size: var(--kk-text-sm);
    font-weight: var(--kk-weight-semibold);
    color: var(--kk-text);
}

.kk-label__optional {
    font-weight: var(--kk-weight-normal);
    color: var(--kk-text-subtle);
}

.kk-hint {
    font-size: var(--kk-text-sm);
    color: var(--kk-text-muted);
}

.kk-input,
.kk-select,
.kk-textarea {
    width: 100%;
    min-height: 40px;
    padding: var(--kk-space-2) var(--kk-space-3);
    border: 1px solid var(--kk-border-strong);
    border-radius: var(--kk-radius-md);
    background: var(--kk-surface);
    color: var(--kk-text);
    font-family: inherit;
    font-size: var(--kk-text-md);
    line-height: 1.4;
    transition: var(--kk-transition-colors), box-shadow var(--kk-duration-fast) var(--kk-ease);
}

.kk-textarea {
    min-height: 84px;
    resize: vertical;
}

.kk-select {
    appearance: none;
    padding-right: var(--kk-space-8);
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b665c' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--kk-space-3) center;
}

.kk-input::placeholder,
.kk-textarea::placeholder {
    color: var(--kk-text-subtle);
}

.kk-input:hover:not(:disabled),
.kk-select:hover:not(:disabled),
.kk-textarea:hover:not(:disabled) {
    border-color: var(--kk-text-subtle);
}

.kk-input:focus-visible,
.kk-select:focus-visible,
.kk-textarea:focus-visible {
    outline: none;
    border-color: var(--kk-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--kk-primary) 18%, transparent);
}

.kk-input:disabled,
.kk-select:disabled,
.kk-textarea:disabled {
    background: var(--kk-bg-sunken);
    color: var(--kk-text-muted);
    cursor: not-allowed;
}

.kk-input[aria-invalid="true"],
.kk-select[aria-invalid="true"],
.kk-textarea[aria-invalid="true"],
.kk-input.invalid,
.kk-select.invalid,
.kk-textarea.invalid {
    border-color: var(--kk-danger);
}

    .kk-input[aria-invalid="true"]:focus-visible,
    .kk-input.invalid:focus-visible {
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--kk-danger) 16%, transparent);
    }

.kk-input--number {
    font-variant-numeric: tabular-nums;
}

.kk-checkbox,
.kk-radio {
    width: 18px;
    height: 18px;
    accent-color: var(--kk-primary);
    cursor: pointer;
    flex: 0 0 auto;
}

.kk-check-row {
    display: flex;
    align-items: flex-start;
    gap: var(--kk-space-3);
    min-height: var(--kk-touch-target);
    padding: var(--kk-space-2) 0;
    cursor: pointer;
}

.kk-check-row__label {
    font-size: var(--kk-text-base);
    line-height: var(--kk-leading-snug);
}

.kk-fieldset {
    border: 0;
    padding: 0;
    margin: 0;
    min-width: 0;
}

.kk-legend {
    padding: 0;
    margin-bottom: var(--kk-space-2);
    font-size: var(--kk-text-sm);
    font-weight: var(--kk-weight-semibold);
    color: var(--kk-text);
}

.kk-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--kk-space-4);
}

/* Validation */
.validation-message,
.kk-validation-message {
    display: block;
    color: var(--kk-danger);
    font-size: var(--kk-text-sm);
    font-weight: var(--kk-weight-medium);
}

.kk-validation-summary {
    display: flex;
    gap: var(--kk-space-3);
    padding: var(--kk-space-3) var(--kk-space-4);
    background: var(--kk-danger-soft);
    border: 1px solid var(--kk-danger-border);
    border-radius: var(--kk-radius-md);
    color: var(--kk-danger);
    font-size: var(--kk-text-sm);
}

    .kk-validation-summary ul {
        margin: var(--kk-space-1) 0 0;
    }

.valid.modified:not([type=checkbox]) {
    border-color: var(--kk-success-border);
}

.invalid {
    border-color: var(--kk-danger);
}

/* Progressive disclosure */
.kk-disclosure {
    border-top: var(--kk-border-subtle-line);
    padding-top: var(--kk-space-4);
}

.kk-disclosure > summary {
    display: inline-flex;
    align-items: center;
    gap: var(--kk-space-2);
    min-height: 36px;
    list-style: none;
    cursor: pointer;
    color: var(--kk-primary-text);
    font-size: var(--kk-text-base);
    font-weight: var(--kk-weight-semibold);
    border-radius: var(--kk-radius-sm);
}

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

    .kk-disclosure > summary::before {
        content: "";
        width: 1rem;
        height: 1rem;
        background: currentColor;
        mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat;
        transition: transform var(--kk-duration-base) var(--kk-ease);
    }

.kk-disclosure[open] > summary::before {
    transform: rotate(90deg);
}

.kk-disclosure__content {
    padding-top: var(--kk-space-4);
}

/* ==========================================================================
   Badges & chips
   ========================================================================== */

.kk-badge {
    --_bg: var(--kk-bg-sunken);
    --_fg: var(--kk-text-muted);
    --_bd: var(--kk-border);
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    padding: 0.2em 0.6em;
    border: 1px solid var(--_bd);
    border-radius: var(--kk-radius-pill);
    background: var(--_bg);
    color: var(--_fg);
    font-size: var(--kk-text-xs);
    font-weight: var(--kk-weight-semibold);
    line-height: 1.45;
    white-space: nowrap;
}

.kk-badge--success { --_bg: var(--kk-success-soft); --_fg: var(--kk-success); --_bd: var(--kk-success-border); }
.kk-badge--warning { --_bg: var(--kk-warning-soft); --_fg: var(--kk-warning); --_bd: var(--kk-warning-border); }
.kk-badge--danger  { --_bg: var(--kk-danger-soft);  --_fg: var(--kk-danger);  --_bd: var(--kk-danger-border); }
.kk-badge--info    { --_bg: var(--kk-info-soft);    --_fg: var(--kk-info);    --_bd: var(--kk-info-border); }
.kk-badge--accent  { --_bg: var(--kk-accent-soft);  --_fg: var(--kk-accent-text); --_bd: var(--kk-accent-border); }
.kk-badge--primary { --_bg: var(--kk-primary-soft); --_fg: var(--kk-primary-text); --_bd: var(--kk-primary-border); }

.kk-badge__glyph {
    width: 0.9em;
    height: 0.9em;
    flex: 0 0 auto;
}

/* ==========================================================================
   Tables (list/table hybrids)
   ========================================================================== */

.kk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--kk-text-base);
}

    .kk-table th {
        text-align: left;
        font-size: var(--kk-text-xs);
        font-weight: var(--kk-weight-semibold);
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: var(--kk-text-subtle);
        padding: var(--kk-space-2) var(--kk-space-3);
        border-bottom: var(--kk-border-hairline);
    }

    .kk-table td {
        padding: var(--kk-space-3);
        border-bottom: var(--kk-border-subtle-line);
        vertical-align: middle;
    }

    .kk-table tbody tr:last-child td {
        border-bottom: 0;
    }

/* ==========================================================================
   Motion preferences
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (prefers-contrast: more) {
    :root {
        --kk-border: #a89f8c;
        --kk-border-strong: #8b8578;
        --kk-text-muted: #4f4a41;
        --kk-text-subtle: #5c574d;
    }
}

/* ==========================================================================
   Blazor framework UI
   ========================================================================== */

#blazor-error-ui {
    color-scheme: light only;
    background: var(--kk-warning-soft);
    border-top: 1px solid var(--kk-warning-border);
    color: var(--kk-warning);
    bottom: 0;
    box-shadow: 0 -2px 12px rgba(38, 36, 31, 0.12);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: var(--kk-space-3) var(--kk-space-5);
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: var(--kk-text-base);
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: var(--kk-space-3);
        top: var(--kk-space-2);
    }

.blazor-error-boundary {
    display: flex;
    flex-direction: column;
    gap: var(--kk-space-2);
    background: var(--kk-danger-soft);
    border: 1px solid var(--kk-danger-border);
    border-radius: var(--kk-radius-lg);
    padding: var(--kk-space-5);
    color: var(--kk-danger);
}

    .blazor-error-boundary::after {
        content: "Something went wrong while rendering this section.";
        font-weight: var(--kk-weight-semibold);
    }

/* ==========================================================================
   Identity / Account pages
   Generated Identity components use Bootstrap-style class names. Rather than
   rewrite that generated markup, map those names onto the design system.
   ========================================================================== */

.kk-auth {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--kk-space-8) var(--kk-space-4) var(--kk-space-12);
    background: var(--kk-bg);
}

.kk-auth__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--kk-space-3);
    margin-bottom: var(--kk-space-6);
    text-decoration: none;
    color: var(--kk-text-strong);
}

.kk-auth__brand-mark {
    width: 34px;
    height: 34px;
    border-radius: var(--kk-radius-md);
    background: var(--kk-primary);
    color: #fff;
    display: grid;
    place-items: center;
}

.kk-auth__brand-name {
    font-size: var(--kk-text-lg);
    font-weight: var(--kk-weight-bold);
    letter-spacing: var(--kk-tracking-tight);
}

.kk-auth__card {
    width: 100%;
    max-width: 460px;
    background: var(--kk-surface);
    border: var(--kk-border-hairline);
    border-radius: var(--kk-radius-xl);
    box-shadow: var(--kk-shadow-sm);
    padding: var(--kk-space-8);
}

.kk-auth--wide .kk-auth__card {
    max-width: 920px;
}

.kk-auth__card h1 {
    font-size: var(--kk-text-2xl);
    margin-bottom: var(--kk-space-2);
}

.kk-auth__card h2 {
    font-size: var(--kk-text-lg);
    margin-bottom: var(--kk-space-1);
}

.kk-auth__card h3 {
    font-size: var(--kk-text-base);
    color: var(--kk-text-muted);
    font-weight: var(--kk-weight-semibold);
}

.kk-auth__card hr {
    margin: var(--kk-space-4) 0;
}

.kk-auth__card > .row {
    margin-top: var(--kk-space-5);
}

/* Bootstrap-name shims — scoped to Identity surfaces only */
.kk-auth .row,
.kk-manage .row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--kk-space-8);
}

@media (min-width: 768px) {
    .kk-auth--wide .row {
        grid-template-columns: 1.3fr 1fr;
    }
}

.kk-auth [class^="col-"],
.kk-auth [class*=" col-"],
.kk-manage [class^="col-"],
.kk-manage [class*=" col-"] {
    min-width: 0;
}

.kk-auth .form-floating,
.kk-manage .form-floating {
    display: flex;
    flex-direction: column-reverse;
    gap: var(--kk-space-2);
    margin-bottom: var(--kk-space-4);
}

    .kk-auth .form-floating > label,
    .kk-manage .form-floating > label {
        font-size: var(--kk-text-sm);
        font-weight: var(--kk-weight-semibold);
        color: var(--kk-text);
    }

.kk-auth .form-control,
.kk-manage .form-control {
    width: 100%;
    min-height: 42px;
    padding: var(--kk-space-2) var(--kk-space-3);
    border: 1px solid var(--kk-border-strong);
    border-radius: var(--kk-radius-md);
    background: var(--kk-surface);
    color: var(--kk-text);
    font-family: inherit;
    font-size: var(--kk-text-md);
    transition: var(--kk-transition-colors), box-shadow var(--kk-duration-fast) var(--kk-ease);
}

    .kk-auth .form-control:focus-visible,
    .kk-manage .form-control:focus-visible {
        outline: none;
        border-color: var(--kk-primary);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--kk-primary) 18%, transparent);
    }

/* The template relies on a placeholder to drive floating labels; we use real
   labels instead, so hide the redundant placeholder text. */
.kk-auth .form-floating > .form-control::placeholder,
.kk-manage .form-floating > .form-control::placeholder {
    color: transparent;
}

.kk-auth .form-label,
.kk-manage .form-label {
    font-size: var(--kk-text-sm);
    font-weight: var(--kk-weight-semibold);
    color: var(--kk-text);
}

/* The Login page renders a wrapping <label class="form-label"> around a checkbox. */
.kk-auth .checkbox,
.kk-manage .checkbox {
    margin-bottom: var(--kk-space-4);
}

    .kk-auth .checkbox > .form-label,
    .kk-manage .checkbox > .form-label {
        display: flex;
        align-items: center;
        gap: var(--kk-space-2);
        min-height: var(--kk-touch-target);
        font-weight: var(--kk-weight-normal);
        font-size: var(--kk-text-base);
        cursor: pointer;
    }

.kk-auth .btn,
.kk-manage .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--kk-space-2);
    min-height: 42px;
    padding: 0 var(--kk-space-4);
    border: 1px solid var(--kk-border-strong);
    border-radius: var(--kk-radius-md);
    background: var(--kk-surface);
    color: var(--kk-text);
    font-family: inherit;
    font-size: var(--kk-text-base);
    font-weight: var(--kk-weight-semibold);
    text-decoration: none;
    cursor: pointer;
    transition: var(--kk-transition-colors);
}

.kk-auth .btn-primary,
.kk-manage .btn-primary {
    background: var(--kk-primary);
    border-color: var(--kk-primary);
    color: #fff;
}

    .kk-auth .btn-primary:hover,
    .kk-manage .btn-primary:hover {
        background: var(--kk-primary-hover);
        border-color: var(--kk-primary-hover);
        color: #fff;
    }

.kk-auth .btn-danger,
.kk-manage .btn-danger {
    background: var(--kk-danger);
    border-color: var(--kk-danger);
    color: #fff;
}

.kk-auth .btn-lg,
.kk-manage .btn-lg {
    min-height: var(--kk-touch-target);
    font-size: var(--kk-text-md);
}

.kk-auth .btn-link,
.kk-manage .btn-link {
    background: none;
    border: 0;
    min-height: 0;
    padding: 0;
    color: var(--kk-primary-text);
    text-decoration: underline;
    font-weight: var(--kk-weight-medium);
}

.kk-auth .w-100,
.kk-manage .w-100 {
    width: 100%;
}

.kk-auth .mb-3, .kk-manage .mb-3 { margin-bottom: var(--kk-space-4); }
.kk-auth .mt-3, .kk-manage .mt-3 { margin-top: var(--kk-space-4); }
.kk-auth .me-1, .kk-manage .me-1 { margin-right: var(--kk-space-1); }

.kk-auth .text-danger,
.kk-manage .text-danger {
    color: var(--kk-danger);
    font-size: var(--kk-text-sm);
}

.kk-auth .text-success,
.kk-manage .text-success {
    color: var(--kk-success);
}

.kk-auth .form-check,
.kk-manage .form-check {
    display: flex;
    align-items: center;
    gap: var(--kk-space-2);
    margin-bottom: var(--kk-space-4);
}

.kk-auth .form-check-input,
.kk-manage .form-check-input {
    width: 18px;
    height: 18px;
    accent-color: var(--kk-primary);
    margin: 0;
}

.kk-auth .form-check-label,
.kk-manage .form-check-label {
    font-size: var(--kk-text-base);
}

.kk-auth .alert,
.kk-manage .alert {
    padding: var(--kk-space-3) var(--kk-space-4);
    border-radius: var(--kk-radius-md);
    border: 1px solid var(--kk-info-border);
    background: var(--kk-info-soft);
    color: var(--kk-info);
    font-size: var(--kk-text-sm);
    margin-bottom: var(--kk-space-4);
}

.kk-auth .alert-danger,
.kk-manage .alert-danger {
    border-color: var(--kk-danger-border);
    background: var(--kk-danger-soft);
    color: var(--kk-danger);
}

.kk-auth .alert-success,
.kk-manage .alert-success {
    border-color: var(--kk-success-border);
    background: var(--kk-success-soft);
    color: var(--kk-success);
}

.kk-auth .alert-info,
.kk-manage .alert-info {
    border-color: var(--kk-info-border);
    background: var(--kk-info-soft);
    color: var(--kk-info);
}

.kk-auth .nav,
.kk-manage .nav {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--kk-space-4);
    display: flex;
    flex-direction: column;
    gap: var(--kk-space-1);
}

.kk-auth .nav-link,
.kk-manage .nav-link {
    display: block;
    padding: var(--kk-space-2) var(--kk-space-3);
    border-radius: var(--kk-radius-sm);
    color: var(--kk-text-muted);
    text-decoration: none;
    font-size: var(--kk-text-base);
}

    .kk-auth .nav-link:hover,
    .kk-manage .nav-link:hover {
        background: var(--kk-bg-sunken);
        color: var(--kk-text);
    }

    .kk-auth .nav-link.active,
    .kk-manage .nav-link.active {
        background: var(--kk-primary-soft);
        color: var(--kk-primary-text);
        font-weight: var(--kk-weight-semibold);
    }

.kk-auth .list-group,
.kk-manage .list-group {
    list-style: none;
    padding: 0;
    margin: 0;
    border: var(--kk-border-hairline);
    border-radius: var(--kk-radius-md);
    overflow: hidden;
}

.kk-auth .list-group-item,
.kk-manage .list-group-item {
    padding: var(--kk-space-3) var(--kk-space-4);
    border-bottom: var(--kk-border-subtle-line);
    background: var(--kk-surface);
}

.kk-auth table,
.kk-manage table {
    width: 100%;
    border-collapse: collapse;
}

.kk-auth td, .kk-auth th,
.kk-manage td, .kk-manage th {
    padding: var(--kk-space-2) var(--kk-space-3);
    border-bottom: var(--kk-border-subtle-line);
    text-align: left;
}

.darker-border-checkbox.form-check-input {
    border-color: var(--kk-border-strong);
}
