/* Pavilion palette + Cotton geometry. Loaded before page slices, not over them.
   Native forms remain authoritative; these aliases let old pages migrate safely. */
html[data-pavilion-ui] {
    color-scheme: light;
    --p-navy: #252a37;
    --p-gold: #e3cf5b;
    --p-silver: #c7d0d8;
    --p-ground: #eef1f4;
    --p-surface: #ffffff;
    --p-tint: #f5f7f9;
    --p-ink: #252a37;
    --p-muted: #586074;
    --p-line: #cbd2dc;
    --p-success: #246c4d;
    --p-danger: #a9323c;
    --p-blue: #285a8f;
    --p-focus: #927a14;
    --p-selection: #f6f0ce;
    --p-radius: 8px;
    --p-radius-panel: 12px;
    --p-shadow: 0 8px 28px #10172212;
    --p-ease-out: cubic-bezier(.23, 1, .32, 1);
    --bg: var(--p-ground);
    --panel: var(--p-surface);
    --panel-strong: var(--p-surface);
    --ink: var(--p-ink);
    --muted: var(--p-muted);
    --line: var(--p-line);
    --danger: var(--p-danger);
    --success: var(--p-success);
    --shadow: var(--p-shadow);
    --accent: var(--p-gold);
    --accent-deep: var(--p-focus);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}
html[data-pavilion-ui][data-theme="dark"] {
    color-scheme: dark;
    --p-ground: #1b202b;
    --p-surface: #252a37;
    --p-tint: #303746;
    --p-ink: #f0f3f6;
    --p-muted: #bcc7d5;
    --p-line: #465164;
    --p-success: #8ed3ac;
    --p-danger: #ffabb1;
    --p-blue: #9bc4ee;
    --p-focus: #e3cf5b;
    --p-selection: #45422f;
    --p-shadow: 0 8px 28px #00000026;
}
body.pavilion-ui { background: var(--p-ground); color: var(--p-ink); letter-spacing: 0; font-weight: 400; line-height: 1.45; }
.pavilion-ui :where(h1, h2, h3, h4, h5, h6) { color: var(--p-ink); }
.pavilion-ui :where(.hero, .panel, .profile-card, .cotton-panel) {
    background: var(--p-surface);
    color: var(--p-ink);
    border: 1px solid var(--p-line);
    border-radius: var(--p-radius-panel);
    box-shadow: none;
}
.pavilion-ui :where(.button, .chip, button) {
    font-family: var(--font-ui);
    border-radius: var(--p-radius);
    min-height: 42px;
    font-weight: 600;
    letter-spacing: 0;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
.pavilion-ui :where(.button, button:not(.app-nav-icon-button)) {
    background: var(--p-surface);
    color: var(--p-ink);
    border: 1px solid var(--p-line);
    box-shadow: none;
}
.pavilion-ui :where(.button.primary, button.primary) {
    background: var(--p-gold);
    color: var(--p-navy);
    border-color: var(--p-gold);
}
.pavilion-ui :where(.button.ghost) { background: transparent; }
.pavilion-ui :where(.button.danger, button.danger) {
    color: var(--p-danger);
    border-color: var(--p-danger);
    background: var(--p-surface);
}
.pavilion-ui :where(.button.active, .chip.active) {
    background: var(--p-selection);
    color: var(--p-ink);
    border-color: var(--p-focus);
}
.pavilion-ui :where(button, .button):disabled { opacity: .55; cursor: not-allowed; }
.pavilion-ui :where(input, textarea, select) {
    background: var(--p-surface);
    color: var(--p-ink);
    border: 1px solid var(--p-line);
    border-radius: var(--p-radius);
    box-shadow: none;
    min-height: 42px;
    font: inherit;
}
.pavilion-ui :where(input[type="checkbox"], input[type="radio"]) {
    min-height: auto;
    accent-color: var(--p-focus);
}
.pavilion-ui :where(input, textarea)::placeholder { color: var(--p-muted); opacity: 1; }
.pavilion-ui :where(input, textarea, select)[aria-invalid="true"] { border-color: var(--p-danger); }
.pavilion-ui :where(th) { background: var(--p-tint); color: var(--p-muted); }
.pavilion-ui :where(th, td) { border-color: var(--p-line); font-variant-numeric: tabular-nums; }
.pavilion-ui .table-wrap { background: var(--p-surface); border-color: var(--p-line); border-radius: var(--p-radius); box-shadow: none; }
.pavilion-ui .pill { background: var(--p-selection); color: var(--p-ink); border-color: var(--p-line); }
.pavilion-ui :where(.eyebrow) { color: var(--p-muted); }
.pavilion-ui .profile-card { border-radius: var(--p-radius-panel); box-shadow: none; }
.pavilion-ui .profile-card-status, .pavilion-ui .home-card-status { background: var(--p-selection); color: var(--p-ink); }
.pavilion-ui .profile-card-result strong, .pavilion-ui .home-card-result strong { color: var(--p-ink); }
.pavilion-ui :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--p-focus);
    outline-offset: 3px;
}
.pavilion-ui .shell:focus { outline: none; }
.pavilion-skip-link { position: fixed; left: 16px; top: -80px; z-index: 1000; padding: 12px 18px; border-radius: 8px; background: var(--p-gold); color: var(--p-navy); }
.pavilion-skip-link:focus { top: 12px; }
.pavilion-ui .message { background: var(--p-surface); border-color: var(--p-line); color: var(--p-ink); border-radius: 8px; }
.pavilion-ui .message.error { border-color: var(--p-danger); }
.pavilion-ui .message.success { border-color: var(--p-success); }
.cotton-appearance { min-width: 0; margin: 8px 0; padding: 8px 0; border: 0; }
.cotton-appearance legend { margin-bottom: 6px; color: inherit; font-size: .78rem; font-weight: 600; }
.cotton-segmented { display: inline-flex; width: 100%; gap: 3px; padding: 3px; background: var(--p-tint); border: 1px solid var(--p-line); border-radius: 9px; }
.cotton-segmented button { flex: 1; min-width: 0; padding: 7px 9px; border: 0; background: transparent; color: var(--p-muted); font-size: .8rem; }
.cotton-segmented [aria-pressed="true"] { background: var(--p-surface); color: var(--p-ink); box-shadow: 0 1px 3px #00000012; }

/* Searchable Cotton-style control; a native select remains the form field. */
.cotton-select { position: relative; min-width: 0; }
.cotton-select__trigger { width: 100%; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; text-align: left; }
.cotton-select__trigger span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cotton-select__trigger::after { content: ""; width: 7px; height: 7px; flex: 0 0 auto; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); margin: -4px 2px 0 0; }
.cotton-select__popover { position: fixed; z-index: 300; display: flex; flex-direction: column; max-width: calc(100vw - 24px); padding: 6px; border: 1px solid var(--p-line); border-radius: 9px; background: var(--p-surface); box-shadow: var(--p-shadow); color: var(--p-ink); }
.cotton-select__popover[hidden] { display: none; }
.cotton-select__search { width: 100%; min-height: 42px; padding: 9px 10px; margin-bottom: 5px; }
.cotton-select__options { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.cotton-select__option { display: block; width: 100%; min-height: 42px; padding: 9px 10px; border: 0 !important; text-align: left; background: transparent !important; border-radius: 5px; font-weight: 500; overflow-wrap: anywhere; }
.cotton-select__option[aria-selected="true"] { background: var(--p-selection) !important; color: var(--p-ink); font-weight: 700; }
.cotton-select__option.is-highlighted { outline: 2px solid var(--p-focus); outline-offset: -2px; }
.cotton-select__option:disabled {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 3px 8px;
    color: var(--p-muted);
    opacity: 1;
    cursor: default;
}
.cotton-select__option-reason { font-size: var(--text-meta); }
.cotton-select__empty { padding: 12px; color: var(--p-muted); }
.cotton-select select[data-cotton-enhanced] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
dialog.cotton-dialog { width: min(520px, calc(100% - 24px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 24px; color: var(--p-ink); background: var(--p-surface); border: 1px solid var(--p-line); border-radius: 12px; box-shadow: var(--p-shadow); }
dialog.cotton-dialog::backdrop { background: #111724a6; }
.cotton-dialog__actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
body.cotton-dialog-open { overflow: hidden; }

/* Soft rail changes paint only; preserve native scrolling, touch and forced colours. */
@media (hover: hover) and (pointer: fine) and (forced-colors: none) {
    html[data-scrollbar="rail"] { --scroll-thumb: #7b8797; --scroll-hover: #586477; --scroll-track: #edf1f5; }
    html[data-scrollbar="rail"][data-theme="dark"] { --scroll-thumb: #8895a6; --scroll-hover: #bcc7d5; --scroll-track: #303746; }
    html[data-scrollbar="rail"], html[data-scrollbar="rail"] * { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) var(--scroll-track); }
    @supports selector(::-webkit-scrollbar) {
        html[data-scrollbar="rail"], html[data-scrollbar="rail"] * { scrollbar-width: auto; scrollbar-color: auto; }
        html[data-scrollbar="rail"]::-webkit-scrollbar, html[data-scrollbar="rail"] *::-webkit-scrollbar { width: 10px; height: 10px; }
        html[data-scrollbar="rail"]::-webkit-scrollbar-track, html[data-scrollbar="rail"] *::-webkit-scrollbar-track { background: var(--scroll-track); border-radius: 99px; }
        html[data-scrollbar="rail"]::-webkit-scrollbar-thumb, html[data-scrollbar="rail"] *::-webkit-scrollbar-thumb { background: var(--scroll-thumb); background-clip: padding-box; border: 2px solid transparent; border-radius: 99px; min-height: 36px; }
        html[data-scrollbar="rail"]::-webkit-scrollbar-thumb:hover, html[data-scrollbar="rail"] *::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-hover); }
        html[data-scrollbar="rail"]::-webkit-scrollbar-button, html[data-scrollbar="rail"] *::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
        html[data-scrollbar="rail"]::-webkit-scrollbar-corner, html[data-scrollbar="rail"] *::-webkit-scrollbar-corner { background: transparent; }
    }
    .pavilion-ui :where(.button, button):not(:disabled):hover { filter: brightness(.97); }
}
@media (pointer: coarse) { .pavilion-ui :where(input, select, textarea) { font-size: 16px; } }
@media (prefers-reduced-motion: no-preference) { .pavilion-ui :where(.button, button):active:not(:disabled) { transform: scale(.98); } }
