/* ============================================================================
   Target U Runtime Theme Foundation

   DESIGN.md is the normative source. The Figma Theme Contract is a translation
   reference; its WEB syntax shares this runtime-only `--theme-` namespace.
   The namespace keeps the new contract isolated from legacy variables still
   consumed by unmigrated routes (notably `--color-border-strong`).
   ============================================================================ */

:root {
    /* Target U / Theme — DESIGN.md colors */
    --theme-color-primary: #0F2C59;
    --theme-color-primary-hover: oklch(0.245 0.082 255);
    /* Text guidance brightens on hover; deepening a high-contrast Navy reads as no change. */
    --theme-color-primary-light: oklch(0.42 0.095 255);
    --theme-color-primary-soft: oklch(0.955 0.018 255);
    /* `decision` is fill-only: 2.24:1 on the cool white surface. Text uses `decision-ink`. */
    --theme-color-decision: #C6A969;
    --theme-color-decision-ink: oklch(0.535 0.105 85.9);
    /* Deprecated v1 alias. Declared for compatibility; no canonical rule may consume it. */
    --theme-color-decision-text: #806A32;
    /* Brand identity gold: favicon lens/front corner and the wordmark U only.
     * One value on every surface, 3.66:1 on white and 3.76:1 on Navy. Not a UI
     * colour: interface gold stays `decision` (fill) / `decision-ink` (text). */
    --theme-color-brand-gold: #A18137;
    --theme-color-background: oklch(0.969 0.006 255);
    --theme-color-surface: oklch(0.997 0.002 255);
    --theme-color-surface-muted: oklch(0.982 0.005 255);
    --theme-color-surface-selected: oklch(0.955 0.018 255);
    --theme-color-foreground: oklch(0.255 0.035 255);
    --theme-color-muted: oklch(0.535 0.035 255);
    --theme-color-border: oklch(0.906 0.014 255);
    --theme-color-border-strong: oklch(0.82 0.025 255);
    /* DESIGN v2.2: brighter, lower-chroma focus ink; >= 3:1 on runtime surfaces. */
    --theme-color-focus: #708BBB;
    --theme-color-overlay-scrim: oklch(0.16 0.035 255 / 0.27);
    --theme-color-danger: oklch(0.38 0.13 27);
    --theme-color-danger-hover-ink: oklch(0.33 0.12 27);
    --theme-color-danger-active-ink: oklch(0.29 0.1 27);
    --theme-color-danger-surface: oklch(0.935 0.032 27);
    --theme-color-danger-hover: oklch(0.91 0.044 27);
    --theme-color-danger-active: oklch(0.885 0.056 27);
    --theme-color-danger-border: oklch(0.62 0.12 27);
    --theme-color-danger-soft: oklch(0.955 0.018 27);
    /* Deprecated compatibility alias. Destructive focus consumes `danger`. */
    --theme-color-danger-focus: oklch(0.38 0.13 27 / 0.22);
    /*
     * Interface-feedback statuses formally registered in DESIGN.md v2.
     * This namespace is independent from placement classification and risk.
     */
    --theme-color-status-info-text: #075985;
    --theme-color-status-info-surface: #E0F2FE;
    --theme-color-status-info-border: #0369A1;
    --theme-color-status-success-text: #047857;
    --theme-color-status-success-surface: #D1FAE5;
    --theme-color-status-success-border: #047857;
    --theme-color-status-warning-text: #92400E;
    --theme-color-status-warning-surface: #FEF3C7;
    --theme-color-status-warning-border: #B45309;
    --theme-color-safe-text: #047857;
    --theme-color-safe-bg: #D1FAE5;
    --theme-color-realistic-text: #0369A1;
    --theme-color-realistic-bg: #E0F2FE;
    --theme-color-aggressive-text: #B45309;
    --theme-color-aggressive-bg: #FEF3C7;
    --theme-color-dream-text: #BE123C;
    --theme-color-dream-bg: #FFE4E6;
    --theme-color-low-prob-text: #475569;
    --theme-color-low-prob-bg: #F1F5F9;
    --theme-color-failed-text: #4B5563;
    --theme-color-failed-bg: #E5E7EB;
    --theme-color-risk-safe-text: #047857;
    --theme-color-risk-safe-bg: #D1FAE5;
    --theme-color-risk-hard-text: #B45309;
    --theme-color-risk-hard-bg: #FEF3C7;
    --theme-color-risk-risk-text: #BE123C;
    --theme-color-risk-risk-bg: #FFE4E6;
    --theme-color-risk-excess-text: #B45309;
    --theme-color-risk-excess-bg: #FEF3C7;
    --theme-color-risk-unavailable-text: #475569;
    --theme-color-risk-unavailable-bg: #F1F5F9;
    /* DESIGN v2.18: categorical data-chart fills; one gold (slot 2), Navy ladder otherwise. */
    --theme-color-chart-categorical-1: #0F2C59;
    --theme-color-chart-categorical-2: #C6A969;
    --theme-color-chart-categorical-3: oklch(0.56 0.08 255);
    --theme-color-chart-categorical-4: oklch(0.76 0.045 255);
    --theme-color-chart-categorical-5: oklch(0.40 0.05 255);
    --theme-color-chart-categorical-6: oklch(0.66 0.03 255);
    --theme-color-chart-categorical-7: oklch(0.48 0.02 255);
    --theme-color-chart-categorical-8: oklch(0.72 0.015 255);

    /* Target U / Typography */
    --theme-font-serif: "GenYoMin TW", "Songti TC", PMingLiU, serif;
    --theme-font-sans: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
    --theme-font-mono: "IBM Plex Mono", SFMono-Regular, Consolas, monospace;
    --theme-font-data: "Source Serif 4", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
    --theme-font-brand: "Target U Display", Inter, sans-serif;
    --theme-text-page-title: 1.875rem;
    --theme-text-page-title--font-weight: 500;
    --theme-text-page-title--line-height: 1.4;
    --theme-text-section-title: 1.5rem;
    --theme-text-section-title--font-weight: 400;
    --theme-text-section-title--line-height: 1.4;
    --theme-text-entity-title: 1.125rem;
    --theme-text-entity-title--font-weight: 600;
    --theme-text-entity-title--line-height: 1.45;
    --theme-text-body: 1rem;
    --theme-text-body--font-weight: 400;
    --theme-text-body--line-height: 1.7;
    --theme-text-body-compact: 0.875rem;
    --theme-text-body-compact--font-weight: 400;
    --theme-text-body-compact--line-height: 1.7;
    --theme-text-panel-title: 1rem;
    --theme-text-panel-title--font-weight: 500;
    --theme-text-panel-title--line-height: 1.5;
    --theme-text-control: 0.875rem;
    --theme-text-control--font-weight: 550;
    --theme-text-control--line-height: 1.5;
    --theme-text-control--letter-spacing: 0.02em;
    --theme-text-dense-label: 0.875rem;
    --theme-text-dense-label--font-weight: 500;
    --theme-text-dense-label--line-height: 1.5;
    --theme-text-dense-label--letter-spacing: 0.01em;
    --theme-text-bulk-action: 0.75rem;
    --theme-text-bulk-action--font-weight: 500;
    --theme-text-bulk-action--line-height: 1.5;
    --theme-text-bulk-action--letter-spacing: 0.01em;
    --theme-text-data: 0.9375rem;
    --theme-text-data--font-weight: 500;
    --theme-text-data--line-height: 1.4;
    --theme-text-data-lead: 1.25rem;
    --theme-text-data-lead--font-weight: 600;
    --theme-text-data-lead--line-height: 1.4;
    --theme-text-supporting: 0.75rem;
    --theme-text-supporting--font-weight: 500;
    --theme-text-supporting--line-height: 1.5;
    --theme-text-supporting--letter-spacing: 0.01em;
    --theme-text-micro: 0.6875rem;
    --theme-text-micro--font-weight: 500;
    --theme-text-micro--line-height: 1.5;
    --theme-text-micro--letter-spacing: 0.02em;
    --theme-text-decision-kpi: 2.25rem;
    --theme-text-decision-kpi--font-weight: 500;
    --theme-text-decision-kpi--line-height: 1.3;

    /* Target U / Dimensions. v2.4: every corner is square; the named
       radius roles stay so components keep consuming semantic tokens. */
    --theme-radius-none: 0px;
    --theme-radius-micro: 0px;
    --theme-radius-field: 0px;
    --theme-radius-control: 0px;
    --theme-radius-entity: 0px;
    --theme-radius-popover: 0px;
    --theme-radius-dialog: 0px;
    --theme-radius-toast: 0px;
    --theme-radius-mobile-overlay: 0px;
    --theme-radius-pill: 0px;
    /* The one circular exception: non-control markers (avatar, step
       index) whose roundness carries identity, not affordance. */
    --theme-radius-marker: 9999px;
    --theme-spacing-xs: 4px;
    --theme-spacing-sm: 8px;
    --theme-spacing-filter-search-gap: 10px;
    --theme-spacing-md: 12px;
    --theme-spacing-lg: 16px;
    --theme-spacing-card: 20px;
    --theme-spacing-xl: 24px;
    --theme-spacing-2xl: 32px;
    --theme-spacing-3xl: 40px;
    --theme-spacing-4xl: 48px;
    --theme-spacing-5xl: 64px;

    /* Public shell: the single owner of the page's horizontal safe area. */
    --theme-shell-max-width: 1280px;
    --theme-shell-padding-inline: var(--theme-spacing-xl);

    /* Shared overlay elevation specified in DESIGN.md prose. */
    --theme-shadow-tooltip: 0 2px 8px oklch(0.18 0.035 255 / 0.08);
    --theme-shadow-overlay: 0 16px 42px oklch(0.18 0.035 255 / 0.18);

    /*
     * DESIGN v2.2 focus geometry: a 2px owner-shaped ring, separated from the
     * retained inner boundary by 1px. The outer edge therefore sits 3px beyond
     * the owner. v2.4 squares every corner, so the ring keeps the owner radius.
     */
    --theme-focus-ring-width: 2px;
    --theme-focus-ring-gap: 1px;
    --theme-focus-ring-outer-extent: 3px;
    --theme-focus-ring-radius-delta: 0px;
    --theme-focus-ring-halo: 0 0 4px 1px oklch(0.8 0.035 258 / 0.16);
    --theme-focus-ring-destructive-halo: 0 0 4px 1px oklch(0.8 0.035 27 / 0.16);
    /* Deprecated v2.1 name retained while route-local CSS migrates. */
    --theme-focus-ring-offset: var(--theme-focus-ring-gap);

    /* Shared interaction timing; primitives still enumerate transitioned properties. */
    --theme-motion-duration-interaction: 180ms;
    --theme-motion-duration-overlay: 200ms;
    --theme-motion-ease-overlay: ease-out;

    /*
     * Legacy compatibility layer. Unmigrated components keep their current
     * values. Only exact semantic matches alias the new foundation.
     */
    --color-brand-navy: var(--theme-color-primary);
    --color-brand-navy-light: #2A4D85;
    --color-brand-gold: var(--theme-color-decision);
    /* Stays on the deprecated value: unmigrated routes must not shift colour
     * mid-migration. Each page moves its own gold text to `decision-ink`. */
    --color-brand-gold-text: var(--theme-color-decision-text);
    --color-brand-gold-border: #B59A60;
    --color-surface-canvas: #F4F6F8;
    --color-surface-default: #FFFFFF;
    --color-surface-subtle: #F8FAFC;
    --color-text-primary: #1A202C;
    --color-text-strong: #334155;
    --color-text-secondary: #64748B;
    --color-border-default: #E2E8F0;
    --color-border-strong: #CBD5E1;
    --shadow-surface: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-control: 0 1px 2px rgba(15, 23, 42, 0.05);
}

/*
 * Public interaction baseline. `:where()` keeps this below component-specific
 * focus rules while guaranteeing a visible fallback for native controls.
 */
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) :where(
    a[href],
    button,
    input:not([type="hidden"]),
    select,
    textarea,
    summary,
    [contenteditable="true"],
    [tabindex]:not([tabindex="-1"])
):focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

/*
 * Restore the fallback only where legacy Tailwind utilities explicitly remove
 * an outline without supplying a positive-width ring of their own.
 */
[data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]) :where(
    a[href],
    button,
    input:not([type="hidden"]),
    select,
    textarea,
    summary,
    [contenteditable="true"],
    [tabindex]:not([tabindex="-1"])
):is(
    [class~="focus:outline-none"],
    [class~="focus-visible:outline-none"]
):where(:not(
    [class~="focus:ring"],
    [class~="focus:ring-1"],
    [class~="focus:ring-2"],
    [class~="focus:ring-4"],
    [class~="focus:ring-8"],
    [class~="focus-visible:ring"],
    [class~="focus-visible:ring-1"],
    [class~="focus-visible:ring-2"],
    [class~="focus-visible:ring-4"],
    [class~="focus-visible:ring-8"]
)):focus-visible,
[data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])
:where(input:not([type="hidden"])):is(
    [class~="focus:ring-0"],
    [class~="focus-visible:ring-0"]
):focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

/*
 * Browsers may match `:focus-visible` on pointer-focused text inputs. The
 * document modality controller makes the product rule deterministic and this
 * author rule also suppresses the user-agent outline in that case.
 */
:where([data-runtime-theme="target-u"][data-focus-modality="pointer"]) :where(
    a[href],
    button,
    input:not([type="hidden"]),
    select,
    textarea,
    summary,
    [contenteditable="true"],
    [tabindex]
):focus {
    outline: none;
    box-shadow: none;
}

/* Destructive owners keep the same geometry but use the canonical danger ink. */
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
:where([data-focus-tone="destructive"]):focus-visible {
    outline-color: var(--theme-color-danger);
    box-shadow: var(--theme-focus-ring-destructive-halo);
}

/*
 * Preserve state changes while making movement effectively immediate for users
 * who request reduced motion. Component geometry and visibility remain intact.
 */
@media (prefers-reduced-motion: reduce) {
    :where([data-runtime-theme="target-u"]),
    :where([data-runtime-theme="target-u"]) *,
    :where([data-runtime-theme="target-u"]) *::before,
    :where([data-runtime-theme="target-u"]) *::after {
        scroll-behavior: auto !important;
        animation-delay: 0ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-delay: 0ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* The HTML hidden state must win over display-owning canonical primitives. */
:where([data-runtime-theme="target-u"]) [hidden] {
    display: none !important;
}

/* `clip` rather than `hidden`: with `overflow-x: hidden` the used value of
   `overflow-y` becomes `auto`, so any absolutely positioned overlay reaching
   past the box bottom raises a second scrollbar and shifts the page sideways. */
html,
body {
    overflow-x: clip;
}

/* Serif Headings */
.font-serif {
    font-family: var(--theme-font-serif);
}

/* Sans-serif Body */
.font-sans {
    font-family: var(--theme-font-sans);
}

/* Monospace Data */
.font-mono {
    font-family: var(--theme-font-mono);
}

/* Standard English Serif */
.font-serif-en {
    font-family: 'Times New Roman', Times, serif;
}

/* =========================
   3. Brand Colors
   ========================= */

/* Primary: Deep Navy */
.bg-navy {
    background-color: #0F2C59;
}

.bg-navy-light {
    background-color: #2A4D85;
}

.text-navy {
    color: #0F2C59;
}

.border-navy {
    border-color: #0F2C59;
}

.hover\:bg-navy-light:hover {
    background-color: #2A4D85;
}

.hover\:text-navy:hover {
    color: #0F2C59;
}

.hover\:border-navy:hover {
    border-color: #0F2C59;
}

/* Accent: Muted Gold */
.bg-gold {
    background-color: #C6A969;
}

.text-gold {
    color: #C6A969;
}

.border-gold {
    border-color: #C6A969;
}

.text-charcoal {
    color: #1A202C;
}

.text-slate {
    color: #64748B;
}

/* =========================
   4. Card Styles
   ========================= */

/* =========================
   5. Button Styles
   ========================= */

/* =========================
   7. HTMX Indicators
   ========================= */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline;
}

.htmx-request.htmx-indicator {
    display: inline;
}

/* Loading spinner */
.spinner {
    border: 3px solid #F4F6F8;
    border-top: 3px solid #0F2C59;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Card hover effects — removed .card-hover (dead code, see Spec 022) */

/* Modal Shell Customization */
.analysis-modal-close-btn {
    border: none;
    background: transparent;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s ease;
    padding: 0;
}

.analysis-modal-close-btn:hover {
    color: #f87171;
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.analysis-modal-close-btn:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    border-radius: 0;
    box-shadow: var(--theme-focus-ring-halo);
}

/* Mobile: Full-screen modal */
@media (max-width: 767px) {
    .analysis-modal-close-btn {
        position: fixed !important;
        top: 1rem;
        right: 1rem;
        z-index: 130;
        background-color: rgba(255, 255, 255, 0.9) !important;
        border-radius: 0;
        padding: 0.35rem !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        color: #64748b !important;
        backdrop-filter: blur(4px);
    }
}

/* =========================
   15. Utility Classes
   ========================= */

.text-balance {
    text-wrap: balance;
}

.text-low_prob-text,
.text-failed-text {
    color: #64748b; /* slate-500 */
}

/* Spec 085: Insight panel gate table namespace */
.insight-gate-table {
    width: 100%;
    border-collapse: collapse;
}

.insight-gate-table th,
.insight-gate-table td {
    vertical-align: middle;
}

/* Spec 087: enforce colors for HTMX-rendered gate widgets */
.insight-stage-index-badge {
    display: inline-flex;
    width: 1.5rem;
    height: 1.5rem;
    align-items: center;
    justify-content: center;
    border-radius: var(--theme-radius-marker);
    background-color: #334155;
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1;
}

.insight-risk-unavailable {
    background-color: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
}

/* =========================
   19. HTMX Loading States
   ========================= */

.htmx-loading {
    position: relative;
    pointer-events: none;
}

.htmx-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 3px solid #F4F6F8;
    border-top-color: #0F2C59;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* =========================
   20. Print Styles
   ========================= */

@media print {
    .no-print {
        display: none !important;
    }

    .bg-navy {
        background-color: #0F2C59 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body {
        font-size: 12pt;
    }
}

/* ============================================================================
   補足：低機率 (low_prob) 與檢定未過 (failed) 的動態 class 樣式
   ============================================================================ */

/* 1. 膠囊形狀標籤背景（灰底） */
.bg-low_prob-bg {
    background-color: #F1F5F9 !important; /* 淺灰底 (slate-100) */
}

.bg-failed-bg {
    background-color: #E5E7EB !important; /* 稍深的灰底 (gray-200) */
}

/* 2. 標籤內的文字與「錄取機率」數字（深灰字） */
.text-low_prob-text {
    color: #475569 !important; /* 深灰色 (slate-600) */
}

.text-failed-text {
    color: #4B5563 !important; /* 深灰色 (gray-600) */
}

/* ============================================================================
   Target U Canonical Component Primitives

   These selectors are opt-in and public-scoped. Legacy consumers keep their
   current appearance until their route is migrated to the `ui-*` API.
   ============================================================================ */

/* Layout and typography ----------------------------------------------------- */
@media screen and (width < 48em) {
    /* Interpolate from 20rem to 24rem of available width, then hold the phone scale. */
    :root[data-runtime-theme="target-u"] {
        --theme-text-page-title: clamp(1.625rem, 1rem + 3.125vw, 1.75rem);
        --theme-text-section-title: clamp(1.25rem, 0.625rem + 3.125vw, 1.375rem);
        --theme-text-entity-title: clamp(1rem, 0.6875rem + 1.5625vw, 1.0625rem);
        --theme-text-decision-kpi: clamp(1.75rem, 0.5rem + 6.25vw, 2rem);
    }
}

:where([data-runtime-theme="target-u"]) .ui-page {
    display: flex;
    flex-direction: column;
    gap: var(--theme-spacing-xl);
    padding-block: var(--theme-spacing-2xl);
    color: var(--theme-color-foreground);
}

:where([data-runtime-theme="target-u"]) .ui-page--readable {
    max-width: 48rem;
    margin-inline: auto;
}

:where([data-runtime-theme="target-u"]) .ui-page-header {
    display: grid;
    gap: var(--theme-spacing-sm);
    padding-block: var(--theme-spacing-lg);
    border-bottom: 1px solid var(--theme-color-border);
}

/* Page header slots, top to bottom: context, title, meta, lead. Meta and lead
   take the shared type roles (ui-type-supporting, ui-type-body); actions trail
   the copy on wide screens and follow it on phones. */
:where([data-runtime-theme="target-u"]) .ui-page-header__copy {
    display: grid;
    min-width: 0;
    max-width: 52rem;
    gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .ui-page-header__context {
    margin: 0;
    color: var(--theme-color-primary);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: var(--theme-text-supporting--line-height);
    letter-spacing: 0.08em;
}

:where([data-runtime-theme="target-u"]) .ui-page-header__lead {
    max-width: 52rem;
}

/* Entity pages (school, department, offering) name the entity in Navy, so the
   context line steps down to muted and the header never stacks two blues. */
:where([data-runtime-theme="target-u"]) .ui-page-header--entity .ui-page-header__context {
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .ui-page-header--entity .ui-type-page-title {
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .ui-page-header__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .ui-page-header:has(> .ui-page-header__actions) {
    gap: var(--theme-spacing-lg) var(--theme-spacing-xl);
}

@media screen and (width < 48em) {
    :where([data-runtime-theme="target-u"]) .ui-page {
        gap: var(--theme-spacing-card);
        padding-block: var(--theme-spacing-xl);
    }

    :where([data-runtime-theme="target-u"]) .ui-page-header {
        padding-block: var(--theme-spacing-md);
    }
}

@media (min-width: 48rem) {
    :where([data-runtime-theme="target-u"]) .ui-page-header:has(> .ui-page-header__actions) {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
    }

    :where([data-runtime-theme="target-u"]) .ui-page-header__actions {
        justify-content: flex-end;
    }
}

/* Breadcrumb for pages that sit under a parent page. Phones keep only the
   parent, with a back chevron, so it never wraps to a second line. */
:where([data-runtime-theme="target-u"]) .ui-breadcrumb {
    color: var(--theme-color-muted);
    font-size: var(--theme-text-supporting);
}

:where([data-runtime-theme="target-u"]) .ui-breadcrumb ol {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--theme-spacing-sm);
    margin: 0;
    padding: 0;
    list-style: none;
}

:where([data-runtime-theme="target-u"]) .ui-breadcrumb a {
    color: var(--theme-color-primary);
    text-underline-offset: var(--theme-spacing-xs);
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .ui-breadcrumb a:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

:where([data-runtime-theme="target-u"]) .ui-breadcrumb__back {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .ui-breadcrumb a:hover {
        color: var(--theme-color-primary-light);
        text-decoration: underline;
    }
}

@media (max-width: 47.999rem) {
    :where([data-runtime-theme="target-u"]) .ui-breadcrumb:has(.ui-breadcrumb__parent) li:not(.ui-breadcrumb__parent) {
        display: none;
    }

    :where([data-runtime-theme="target-u"]) .ui-breadcrumb__back {
        display: inline-block;
        margin-inline-end: var(--theme-spacing-xs);
    }

    :where([data-runtime-theme="target-u"]) .ui-breadcrumb__parent > a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        margin-block: -13px;
    }
}

:where([data-runtime-theme="target-u"]) .ui-summary-band {
    display: grid;
    gap: var(--theme-spacing-lg);
    padding-block: var(--theme-spacing-xl);
    border-block: 1px solid var(--theme-color-border);
    background: var(--theme-color-surface-muted);
}

:where([data-runtime-theme="target-u"]) .ui-filter-panel {
    display: grid;
    gap: var(--theme-spacing-lg);
    padding: var(--theme-spacing-card);
    border: 1px solid var(--theme-color-border);
    background: var(--theme-color-surface);
}

:where([data-runtime-theme="target-u"]) .ui-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--theme-spacing-md);
    padding-block: var(--theme-spacing-md);
    border-bottom: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .ui-result-group {
    display: grid;
    gap: var(--theme-spacing-lg);
    padding-block: var(--theme-spacing-xl);
}

:where([data-runtime-theme="target-u"]) .ui-divider {
    width: 100%;
    height: 1px;
    border: 0;
    background: var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .ui-divider--strong {
    background: var(--theme-color-border-strong);
}

:where([data-runtime-theme="target-u"]) .ui-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--theme-spacing-xs);
}

:where([data-runtime-theme="target-u"]) .ui-type-page-title {
    margin: 0;
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-serif);
    font-size: var(--theme-text-page-title);
    font-weight: var(--theme-text-page-title--font-weight);
    line-height: var(--theme-text-page-title--line-height);
    text-wrap: balance;
}

:where([data-runtime-theme="target-u"]) .ui-type-section-title {
    margin: 0;
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-serif);
    font-size: var(--theme-text-section-title);
    font-weight: var(--theme-text-section-title--font-weight);
    line-height: var(--theme-text-section-title--line-height);
    text-wrap: balance;
}

/* These headings supply their preferred boundaries with <wbr>. */
:where([data-runtime-theme="target-u"]) .ui-title--phrased {
    word-break: keep-all;
    overflow-wrap: anywhere;
}

:where([data-runtime-theme="target-u"]) .ui-type-entity-title {
    margin: 0;
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-entity-title);
    font-weight: var(--theme-text-entity-title--font-weight);
    line-height: var(--theme-text-entity-title--line-height);
    text-wrap: balance;
}

/* Data-entity names outside a card (result list rows) take the card name ink. */
:where([data-runtime-theme="target-u"]) .ui-entity-name {
    color: var(--theme-color-primary);
    transition: color var(--theme-motion-duration-interaction);
}

/*
 * A school heading that groups department cards is an entity name, not
 * editorial structure: Sans 600 in Navy at the section-title size, linking to
 * the school page. The link reveals the 1px guide rule by clipping on hover.
 */
:where([data-runtime-theme="target-u"]) .ui-entity-group-title {
    margin: 0;
    color: var(--theme-color-primary);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-section-title);
    font-weight: var(--theme-text-entity-title--font-weight);
    line-height: var(--theme-text-section-title--line-height);
    text-wrap: balance;
}

:where([data-runtime-theme="target-u"]) .ui-entity-group-title__link {
    position: relative;
    display: inline-block;
    color: inherit;
    text-decoration: none;
    transition: color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-entity-group-title__link::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 0;
    border-block-start: 1px solid currentColor;
    clip-path: inset(0 100% 0 0);
    transition: clip-path var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .ui-entity-group-title__link:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) tr[data-analysis-card]:hover .ui-entity-name,
    :where([data-runtime-theme="target-u"]) .ui-entity-group-title__link:hover {
        color: var(--theme-color-primary-light);
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-group-title__link:hover::after {
        clip-path: inset(0);
    }
}

:where([data-runtime-theme="target-u"]) .ui-type-panel-title {
    margin: 0;
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-panel-title);
    font-weight: var(--theme-text-panel-title--font-weight);
    line-height: var(--theme-text-panel-title--line-height);
}

:where([data-runtime-theme="target-u"]) .ui-type-body {
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-body);
    font-weight: var(--theme-text-body--font-weight);
    line-height: var(--theme-text-body--line-height);
    text-wrap: pretty;
}

:where([data-runtime-theme="target-u"]) .ui-type-body-compact {
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-body-compact);
    font-weight: var(--theme-text-body-compact--font-weight);
    line-height: var(--theme-text-body-compact--line-height);
    text-wrap: pretty;
}

:where([data-runtime-theme="target-u"]) .ui-type-dense-label {
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-dense-label);
    font-weight: var(--theme-text-dense-label--font-weight);
    line-height: var(--theme-text-dense-label--line-height);
    letter-spacing: var(--theme-text-dense-label--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .ui-type-bulk-action {
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-bulk-action);
    font-weight: var(--theme-text-bulk-action--font-weight);
    line-height: var(--theme-text-bulk-action--line-height);
    letter-spacing: var(--theme-text-bulk-action--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .ui-type-data {
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-data);
    font-size: var(--theme-text-data);
    font-weight: var(--theme-text-data--font-weight);
    line-height: var(--theme-text-data--line-height);
    letter-spacing: normal;
    font-variant-numeric: tabular-nums;
}

:where([data-runtime-theme="target-u"]) .ui-type-data-lead {
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-data);
    font-size: var(--theme-text-data-lead);
    font-weight: var(--theme-text-data-lead--font-weight);
    line-height: var(--theme-text-data-lead--line-height);
    letter-spacing: normal;
    font-variant-numeric: tabular-nums;
}

:where([data-runtime-theme="target-u"]) .ui-type-supporting {
    color: var(--theme-color-muted);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: var(--theme-text-supporting--line-height);
    letter-spacing: var(--theme-text-supporting--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .ui-type-micro {
    color: var(--theme-color-muted);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-micro);
    font-weight: var(--theme-text-micro--font-weight);
    line-height: var(--theme-text-micro--line-height);
    letter-spacing: var(--theme-text-micro--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .ui-type-decision-kpi {
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-serif);
    font-size: var(--theme-text-decision-kpi);
    font-weight: var(--theme-text-decision-kpi--font-weight);
    line-height: var(--theme-text-decision-kpi--line-height);
    font-variant-numeric: tabular-nums;
}

/* Icons -------------------------------------------------------------------- */
/*
 * One stroke weight reads across every size: `stroke-width = 32.4 / display px`
 * on a 24 grid keeps the drawn line at ~1.35px, above the 1px hairline rules and
 * below the Inter 550 stem. Icons take their colour from the text they sit in
 * and never carry a semantic colour of their own.
 */
:where([data-runtime-theme="target-u"]) .ico {
    flex: 0 0 auto;
    color: inherit;
    fill: none;
    stroke: currentColor;
}

:where([data-runtime-theme="target-u"]) .ico :is(path, rect, circle, line, polyline, polygon) {
    stroke-width: var(--theme-icon-stroke);
}

:where([data-runtime-theme="target-u"]) .ico--12 {
    width: 12px;
    height: 12px;
    --theme-icon-stroke: 2.7;
}

:where([data-runtime-theme="target-u"]) .ico--14 {
    width: 14px;
    height: 14px;
    --theme-icon-stroke: 2.3;
}

:where([data-runtime-theme="target-u"]) .ico--16 {
    width: 16px;
    height: 16px;
    --theme-icon-stroke: 2;
}

:where([data-runtime-theme="target-u"]) .ico--20 {
    width: 20px;
    height: 20px;
    --theme-icon-stroke: 1.6;
}

/*
 * Two fills are semantic rather than decorative: the selected square and data
 * volume (chart bars). A pressed state inverting its own icon — the filled
 * heart on a saved item — is the same icon, not a third exception.
 */
:where([data-runtime-theme="target-u"]) .ico--filled :is(path, rect, circle, polygon) {
    fill: currentColor;
    stroke: none;
}

/* Buttons ------------------------------------------------------------------ */
/*
 * Ported from the confirmed component lab, then re-tiered against DESIGN.md v2.3
 * `target-u-button-port-verification.html`. Seven tiers answer one question:
 * does this change data, and where does it take you? Geometry, opacity, and
 * transition targets are the verification file's values, not re-derived prose.
 *
 * Corner marks mean guidance and nothing else. They live on the secondary tier
 * and the navbar; the v1 "primary wears marks at rest" model is retired.
 */
:where([data-runtime-theme="target-u"]) .ui-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--theme-spacing-sm);
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--theme-radius-control);
    background: transparent;
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-control);
    font-weight: var(--theme-text-control--font-weight);
    line-height: var(--theme-text-control--line-height);
    letter-spacing: var(--theme-text-control--letter-spacing);
    text-decoration: none;
    cursor: pointer;
    transition:
        background-color var(--theme-motion-duration-interaction),
        border-color var(--theme-motion-duration-interaction),
        color var(--theme-motion-duration-interaction),
        box-shadow var(--theme-motion-duration-interaction);
}

/*
 * Commit is the only solid Navy in the system: the one-off submission a page
 * exists for. It stays out of the mark language — the fill is the declaration.
 * At most one per page, and no execution-tier button beside it. v2.5: it
 * shares the standard 44px control geometry with every other tier, so paired
 * actions (儲存／取消 rows, dialog footers) can never sit at mismatched
 * heights — emphasis is carried by the fill alone.
 */
:where([data-runtime-theme="target-u"]) .ui-button--commit {
    background: var(--theme-color-primary);
    color: var(--theme-color-surface);
}

:where([data-runtime-theme="target-u"]) .ui-button--primary {
    background: var(--theme-color-primary-soft);
    color: var(--theme-color-primary);
}

/* Secondary stays surface-transparent and reads as guidance in Navy at rest. */
:where([data-runtime-theme="target-u"]) .ui-button--secondary {
    background: transparent;
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .ui-button--tertiary,
:where([data-runtime-theme="target-u"]) .ui-button--tertiary-guide {
    padding-inline: var(--theme-spacing-sm);
    border-radius: var(--theme-radius-none);
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .ui-button--bulk-action {
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-bulk-action);
    font-weight: var(--theme-text-bulk-action--font-weight);
    line-height: var(--theme-text-bulk-action--line-height);
    letter-spacing: var(--theme-text-bulk-action--letter-spacing);
}

/* Inline prose links use the shared text-action ink/underline/hover while
   inheriting the sentence metrics instead of the 44px control geometry. */
:where([data-runtime-theme="target-u"]) a.ui-button--inline {
    display: inline-block;
    min-height: 0;
    margin-inline: var(--theme-spacing-xs);
    padding: 0;
    border: 0;
    font: inherit;
    letter-spacing: inherit;
    vertical-align: baseline;
}

:where([data-runtime-theme="target-u"]) a.ui-button--inline::before,
:where([data-runtime-theme="target-u"]) a.ui-button--inline::after {
    inset-inline: 0;
    bottom: -0.1em;
}

/* In paired filter bulk actions, Clear is the quieter subtractive operation.
   It remains Tertiary: hover still resolves to the canonical operation ink and
   reveals the full 1px rule. */
:where([data-runtime-theme="target-u"]) .ui-button--tertiary.ui-button--filter-clear {
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .ui-button--destructive {
    border-color: var(--theme-color-danger-border);
    background: var(--theme-color-danger-surface);
    color: var(--theme-color-danger);
}

/*
 * Quiet is the mechanical tier — pagination, view plumbing. It never earns
 * corner marks; a plain bordered control keeps it out of the action language.
 */
:where([data-runtime-theme="target-u"]) .ui-button--quiet {
    border-color: var(--theme-color-border-strong);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
}

/*
 * Secondary is the guidance tier, and the only button tier that wears marks.
 * One pseudo-element paints all four open corner arms as background layers, so
 * `inset` alone animates them inward. They wait invisible at the surface edge
 * and fly in on interaction — "this one takes you somewhere else".
 */
:where([data-runtime-theme="target-u"]) .ui-button--secondary::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(currentColor, currentColor) left top / 11px 1px no-repeat,
        linear-gradient(currentColor, currentColor) left top / 1px 11px no-repeat,
        linear-gradient(currentColor, currentColor) right bottom / 11px 1px no-repeat,
        linear-gradient(currentColor, currentColor) right bottom / 1px 11px no-repeat;
    opacity: 0;
    color: var(--theme-color-primary);
    pointer-events: none;
    transition:
        inset var(--theme-motion-duration-interaction),
        opacity var(--theme-motion-duration-interaction),
        color var(--theme-motion-duration-interaction);
}

/* A persistent arrow is already directional, so this variant never adds marks. */
:where([data-runtime-theme="target-u"]) .ui-button--secondary.ui-button--directional::before {
    content: none;
}

/*
 * Text operations keep a faint full-width rule at rest, while their full-ink
 * rule and the guide variant reveal a statically rendered 1px line by clipping.
 * Paint the hairline as a border on a zero-height box: Chromium can rasterize
 * a 1px background box across two device rows when its block position is
 * fractional, which made otherwise identical controls appear mismatched.
 */
:where([data-runtime-theme="target-u"]) .ui-button--tertiary::after {
    content: '';
    position: absolute;
    right: var(--theme-spacing-sm);
    bottom: 7px;
    left: var(--theme-spacing-sm);
    height: 0;
    border-block-start: 1px solid color-mix(in oklch, currentColor 38%, transparent);
    background: none;
}

:where([data-runtime-theme="target-u"]) .ui-button--tertiary::before,
:where([data-runtime-theme="target-u"]) .ui-button--tertiary-guide::after {
    content: '';
    position: absolute;
    right: var(--theme-spacing-sm);
    bottom: 7px;
    left: var(--theme-spacing-sm);
    height: 0;
    border-block-start: 1px solid currentColor;
    background: none;
    clip-path: inset(0 100% 0 0);
    transition: clip-path var(--theme-motion-duration-interaction);
}

/*
 * Bulk actions use a smaller 18px text line inside the shared 44px owner.
 * They stay unlined at rest like other lightweight guides; hover reveals the
 * full-ink rule close to the text without shrinking the interactive target.
 */
:where([data-runtime-theme="target-u"])
    .ui-button--tertiary.ui-button--bulk-action::before {
    bottom: 10px;
}

:where([data-runtime-theme="target-u"])
    .ui-button--tertiary.ui-button--bulk-action::after {
    content: none;
}

/*
 * Compact text actions (DESIGN v2.26) serve a single field — 立即驗證 beside
 * an e-mail status, 變更密碼 under it. They take the Bulk-action type size so
 * they weigh the same as the field's supporting text, keep the 44px owner and
 * keep their tier's rule (operation lined at rest, guide revealed on hover),
 * moved up to the smaller 18px text line.
 */
:where([data-runtime-theme="target-u"]) .ui-button--compact {
    font-size: var(--theme-text-bulk-action);
    font-weight: var(--theme-text-bulk-action--font-weight);
    line-height: var(--theme-text-bulk-action--line-height);
    letter-spacing: var(--theme-text-bulk-action--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .ui-button--tertiary.ui-button--compact::before,
:where([data-runtime-theme="target-u"]) .ui-button--tertiary.ui-button--compact::after,
:where([data-runtime-theme="target-u"]) .ui-button--tertiary-guide.ui-button--compact::after {
    bottom: 10px;
}

:where([data-runtime-theme="target-u"]) .ui-button__arrow {
    transition: transform var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-button [data-ui-spinner] {
    display: none;
    flex: 0 0 15px;
    width: 15px;
    height: 15px;
    border: 1.5px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .ui-button--commit:hover {
        background: var(--theme-color-primary-hover);
        color: var(--theme-color-surface);
    }

    :where([data-runtime-theme="target-u"]) .ui-button--primary:hover {
        background: color-mix(
            in oklch,
            var(--theme-color-primary) 8%,
            var(--theme-color-surface)
        );
        color: var(--theme-color-primary-hover);
    }

    :where([data-runtime-theme="target-u"]) .ui-button--secondary:hover {
        background: var(--theme-color-surface-muted);
        color: var(--theme-color-primary-light);
    }

    :where([data-runtime-theme="target-u"]) .ui-button--quiet:hover {
        border-color: var(--theme-color-border-strong);
        background: var(--theme-color-surface-muted);
        color: var(--theme-color-primary);
    }

    /* Guidance lock-on: the arms fly in from the edge to a 3px frame in Navy. */
    :where([data-runtime-theme="target-u"]) .ui-button--secondary:hover::before {
        inset: 3px;
        opacity: 1;
        color: var(--theme-color-primary);
    }

    :where([data-runtime-theme="target-u"]) .ui-button--tertiary:hover {
        color: var(--theme-color-primary-hover);
    }

    :where([data-runtime-theme="target-u"]) .ui-button--tertiary:hover::before {
        clip-path: inset(0);
    }

    :where([data-runtime-theme="target-u"]) .ui-button--tertiary-guide:hover {
        color: var(--theme-color-primary-light);
    }

    :where([data-runtime-theme="target-u"]) .ui-button--tertiary-guide:hover::after {
        clip-path: inset(0);
    }

    :where([data-runtime-theme="target-u"]) .ui-button--destructive:hover {
        border-color: var(--theme-color-danger-border);
        background: var(--theme-color-danger-hover);
        color: var(--theme-color-danger-hover-ink);
    }

    :where([data-runtime-theme="target-u"]) .ui-button--directional:hover .ui-button__arrow {
        transform: translateX(5px);
    }
}

/*
 * Focus is an additive outer signal. It follows the complete button owner,
 * retains the tier's inner state, and never activates hover-only decoration.
 */
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-button:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-button--destructive:focus-visible {
    outline-color: var(--theme-color-danger);
    box-shadow: var(--theme-focus-ring-destructive-halo);
}

/*
 * Active deepens the surface a further step. On guidance, the locked 3px frame
 * snaps one step tighter as well. Surface and marks carry the feedback — no
 * inner frame, per the confirmed no-grey-frame decision.
 */
:where([data-runtime-theme="target-u"]) .ui-button--commit:active {
    background: color-mix(
        in oklch,
        var(--theme-color-primary-hover) 78%,
        var(--theme-color-foreground)
    );
    color: var(--theme-color-surface);
}

:where([data-runtime-theme="target-u"]) .ui-button--primary:active {
    background: color-mix(
        in oklch,
        var(--theme-color-primary) 14%,
        var(--theme-color-surface)
    );
    color: var(--theme-color-primary-hover);
}

:where([data-runtime-theme="target-u"]) .ui-button--secondary:active {
    background: color-mix(
        in oklch,
        var(--theme-color-primary) 10%,
        var(--theme-color-surface)
    );
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .ui-button--secondary:active::before {
    inset: 6px;
    opacity: 1;
    color: var(--theme-color-primary);
    transition-duration: 90ms;
}

:where([data-runtime-theme="target-u"]) .ui-button--quiet:active {
    background: var(--theme-color-surface-selected);
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .ui-button--destructive:active {
    border-color: var(--theme-color-danger-border);
    background: var(--theme-color-danger-active);
    color: var(--theme-color-danger-active-ink);
}

:where([data-runtime-theme="target-u"]) .ui-button[aria-busy="true"],
:where([data-runtime-theme="target-u"]) .ui-button[data-state="busy"] {
    pointer-events: none;
    cursor: progress;
}

:where([data-runtime-theme="target-u"]) .ui-button[aria-busy="true"] [data-ui-spinner],
:where([data-runtime-theme="target-u"]) .ui-button[data-state="busy"] [data-ui-spinner] {
    display: inline-block;
}

/* Disabled is last in source order so it wins the state-precedence contract. */
:where([data-runtime-theme="target-u"]) .ui-button:disabled,
:where([data-runtime-theme="target-u"]) .ui-button[aria-disabled="true"],
:where([data-runtime-theme="target-u"]) .ui-button[data-state="disabled"] {
    pointer-events: none;
    cursor: not-allowed;
    border-color: var(--theme-color-border);
    background: var(--theme-color-surface-muted);
    color: var(--theme-color-muted);
    box-shadow: none;
    opacity: 0.68;
}

/*
 * Tertiary stays an unboxed text action in every state, so it keeps the muted
 * ink and the dimming but never inherits the disabled surface or border.
 */
:where([data-runtime-theme="target-u"]) .ui-button--tertiary:disabled,
:where([data-runtime-theme="target-u"]) .ui-button--tertiary[aria-disabled="true"],
:where([data-runtime-theme="target-u"]) .ui-button--tertiary[data-state="disabled"],
:where([data-runtime-theme="target-u"]) .ui-button--tertiary-guide:disabled,
:where([data-runtime-theme="target-u"]) .ui-button--tertiary-guide[aria-disabled="true"],
:where([data-runtime-theme="target-u"]) .ui-button--tertiary-guide[data-state="disabled"] {
    border-color: transparent;
    background: transparent;
}

:where([data-runtime-theme="target-u"]) .ui-button:disabled::before,
:where([data-runtime-theme="target-u"]) .ui-button:disabled::after,
:where([data-runtime-theme="target-u"]) .ui-button[aria-disabled="true"]::before,
:where([data-runtime-theme="target-u"]) .ui-button[aria-disabled="true"]::after,
:where([data-runtime-theme="target-u"]) .ui-button[data-state="disabled"]::before,
:where([data-runtime-theme="target-u"]) .ui-button[data-state="disabled"]::after {
    display: none;
}

/* Fields, filters, and selection ------------------------------------------- */
:where([data-runtime-theme="target-u"]) .ui-field-group {
    display: grid;
    align-content: start;
    gap: var(--theme-spacing-sm);
}

/* Cloudflare 人機驗證框撐滿欄寬（data-size="flexible"）時內層最小 300px：
   不讓它把整欄表單撐寬（accounts-and-guest BR-47）。欄寬不足時由 turnstile_fit.js 給出
   --turnstile-fit，把驗證框等比縮到欄寬；沒有這個值時 scale 無效、維持原尺寸。 */
:where([data-runtime-theme="target-u"]) .cf-turnstile {
    min-width: 0;
    overflow: hidden;
}

:where([data-runtime-theme="target-u"]) .cf-turnstile > div {
    scale: var(--turnstile-fit);
    transform-origin: 0 0;
}

:where([data-runtime-theme="target-u"]) .ui-field-label {
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-control);
    font-weight: var(--theme-text-control--font-weight);
    line-height: var(--theme-text-control--line-height);
    letter-spacing: var(--theme-text-control--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .ui-field {
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid var(--theme-color-border-strong);
    border-radius: var(--theme-radius-field);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-control);
    font-weight: var(--theme-text-control--font-weight);
    line-height: var(--theme-text-control--line-height);
    letter-spacing: var(--theme-text-control--letter-spacing);
    transition:
        background-color var(--theme-motion-duration-interaction),
        border-color var(--theme-motion-duration-interaction),
        color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-field.ui-type-data {
    font-family: var(--theme-font-data);
    font-size: var(--theme-text-data);
    font-weight: var(--theme-text-data--font-weight);
    line-height: var(--theme-text-data--line-height);
    letter-spacing: normal;
    font-variant-numeric: tabular-nums;
}

:where([data-runtime-theme="target-u"]) .ui-field-help {
    color: var(--theme-color-muted);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: var(--theme-text-supporting--line-height);
}

:where([data-runtime-theme="target-u"]) .ui-field-error {
    color: var(--theme-color-danger);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: var(--theme-text-supporting--line-height);
}

@media (max-width: 47.999rem) {
    :where([data-runtime-theme="target-u"]) input.ui-field,
    :where([data-runtime-theme="target-u"]) select.ui-field,
    :where([data-runtime-theme="target-u"]) textarea.ui-field {
        font-size: 1rem;
    }

    :where([data-runtime-theme="target-u"]) input.ui-field.ui-type-data,
    :where([data-runtime-theme="target-u"]) select.ui-field.ui-type-data,
    :where([data-runtime-theme="target-u"]) textarea.ui-field.ui-type-data {
        font-size: 1rem;
    }

    /* Search keeps the canonical 14px control type inside its complete owner. */
    :where([data-runtime-theme="target-u"]) .ui-search > input.ui-field {
        font-size: var(--theme-text-control);
    }
}

:where([data-runtime-theme="target-u"]) .ui-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--theme-spacing-sm);
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid var(--theme-color-border-strong);
    border-radius: var(--theme-radius-field);
    background: var(--theme-color-surface);
    transition:
        background-color var(--theme-motion-duration-interaction),
        border-color var(--theme-motion-duration-interaction),
        color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-search__icon {
    flex: 0 0 auto;
    color: var(--theme-color-muted);
    pointer-events: none;
    transition: color var(--theme-motion-duration-interaction);
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .ui-search:hover {
        border-color: color-mix(
            in oklch,
            var(--theme-color-primary) 32%,
            var(--theme-color-border-strong)
        );
    }

    :where([data-runtime-theme="target-u"]) .ui-search:hover .ui-search__icon {
        color: var(--theme-color-primary);
    }

    :where([data-runtime-theme="target-u"]) .ui-search__clear:hover {
        background: var(--theme-color-surface-muted);
        color: var(--theme-color-primary);
    }
}

:where([data-runtime-theme="target-u"]) .ui-search > .ui-field {
    min-width: 0;
    flex: 1 1 auto;
    min-height: auto;
    padding: 0;
    border: 0;
    background: transparent;
}

/* Search owns exactly one trailing clear control. Chromium otherwise adds a
   second native cancel glyph on top of `.ui-search__clear`. */
:where([data-runtime-theme="target-u"]) .ui-search > input[type="search"]::-webkit-search-cancel-button,
:where([data-runtime-theme="target-u"]) .ui-search > input[type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

:where([data-runtime-theme="target-u"]) .ui-search > input[type="search"]::-ms-clear {
    display: none;
}

:where([data-runtime-theme="target-u"]) .ui-search > .ui-field::placeholder {
    color: var(--theme-color-muted);
    font-weight: 500;
}

/*
 * Optional inline clear is the one named Search trailing control. Explicit
 * submit/apply actions remain outside the Search owner.
 */
:where([data-runtime-theme="target-u"]) .ui-search:has(> .ui-search__clear) > .ui-field {
    padding-inline-end: 36px;
}

@media (max-width: 47.999rem) {
    :where([data-runtime-theme="target-u"]) .ui-search:has(> .ui-search__clear[hidden]) > .ui-field {
        padding-inline-end: 0;
    }
}

:where([data-runtime-theme="target-u"]) .ui-search__clear {
    position: absolute;
    inset-block: 0;
    inset-inline-end: 0;
    display: inline-grid;
    width: 44px;
    min-height: 44px;
    place-items: center;
    flex: 0 0 auto;
    padding: 0;
    border: 0;
    border-radius: var(--theme-radius-control);
    background: transparent;
    color: var(--theme-color-muted);
    text-decoration: none;
    cursor: pointer;
    transition:
        background-color var(--theme-motion-duration-interaction),
        color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-filter-trigger {
    position: relative;
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    justify-content: space-between;
    gap: var(--theme-spacing-sm);
    padding: 9px 11px;
    border: 1px solid var(--theme-color-border-strong);
    border-radius: var(--theme-radius-control);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-control);
    font-weight: var(--theme-text-control--font-weight);
    line-height: var(--theme-text-control--line-height);
    letter-spacing: var(--theme-text-control--letter-spacing);
    text-align: start;
    cursor: pointer;
    transition:
        background-color var(--theme-motion-duration-interaction),
        border-color var(--theme-motion-duration-interaction),
        color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-tooltip-label {
    display: inline-flex;
    width: fit-content;
    max-width: 100%;
    align-items: center;
    gap: var(--theme-spacing-xs);
}
:where([data-runtime-theme="target-u"]) .ui-tooltip-trigger {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    margin: -12px;
    padding: 0;
    color: var(--theme-color-muted);
}
:where([data-runtime-theme="target-u"]) .ui-tooltip-trigger:is(:hover, [aria-expanded="true"]) {
    color: var(--theme-color-primary);
}
:where([data-runtime-theme="target-u"]) .ui-tooltip {
    position: fixed;
    z-index: 80;
    inset: auto;
    box-sizing: border-box;
    width: max-content;
    max-width: min(22rem, var(--ui-tooltip-viewport-width, calc(100vw - 16px)));
    margin: 0;
    padding: 6px var(--theme-spacing-md);
    overflow: auto;
    overflow-wrap: anywhere;
    white-space: normal;
    text-align: start;
    border: 1px solid var(--theme-color-border);
    border-radius: 0;
    color: var(--theme-color-foreground);
    background: var(--theme-color-surface);
    box-shadow: var(--theme-shadow-tooltip);
}
:where([data-runtime-theme="target-u"]) .ui-tooltip > span { display: block; }
:where([data-runtime-theme="target-u"]) .ui-tooltip > span + span { margin-block-start: var(--theme-spacing-xs); }

:where([data-runtime-theme="target-u"]) .ui-popover {
    position: absolute;
    z-index: 40;
    width: max-content;
    min-width: 100%;
    max-width: min(28rem, calc(100vw - var(--theme-spacing-2xl)));
    margin-block-start: 6px;
    padding: var(--theme-spacing-md);
    border: 1px solid var(--theme-color-border-strong);
    border-radius: var(--theme-radius-popover);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
    box-shadow: var(--theme-shadow-overlay);
}

:where([data-runtime-theme="target-u"]) .ui-listbox {
    position: relative;
}

:where([data-runtime-theme="target-u"]) .ui-popover .ui-search {
    margin-block-end: var(--theme-spacing-filter-search-gap);
}

:where([data-runtime-theme="target-u"]) .ui-option-list {
    display: grid;
    gap: var(--theme-spacing-xs);
    margin: 0;
    padding: 0;
    list-style: none;
}

:where([data-runtime-theme="target-u"]) .ui-option {
    position: relative;
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: var(--theme-spacing-sm);
    padding: var(--theme-spacing-sm);
    border-radius: var(--theme-radius-control);
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-dense-label);
    font-weight: var(--theme-text-dense-label--font-weight);
    line-height: var(--theme-text-dense-label--line-height);
    letter-spacing: var(--theme-text-dense-label--letter-spacing);
    cursor: pointer;
    transition:
        background-color var(--theme-motion-duration-interaction),
        color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-chip {
    position: relative;
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border: 1px solid var(--theme-color-border-strong);
    border-radius: var(--theme-radius-control);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-control);
    font-weight: var(--theme-text-control--font-weight);
    line-height: var(--theme-text-control--line-height);
    letter-spacing: var(--theme-text-control--letter-spacing);
    cursor: pointer;
    transition:
        background-color var(--theme-motion-duration-interaction),
        border-color var(--theme-motion-duration-interaction),
        color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-chip > .ico {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    color: var(--theme-color-muted);
    transition: color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-segment {
    display: inline-flex;
    gap: var(--theme-spacing-xs);
}

:where([data-runtime-theme="target-u"]) .ui-segment__btn {
    position: relative;
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 6px;
    justify-content: center;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: var(--theme-radius-control);
    background: transparent;
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-control);
    font-weight: var(--theme-text-control--font-weight);
    line-height: var(--theme-text-control--line-height);
    letter-spacing: var(--theme-text-control--letter-spacing);
    cursor: pointer;
    transition:
        background-color var(--theme-motion-duration-interaction),
        color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-segment__btn > .ico {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .ui-field:hover {
        border-color: var(--theme-color-border-strong);
    }

    :where([data-runtime-theme="target-u"]) .ui-filter-trigger:hover {
        border-color: color-mix(
            in oklch,
            var(--theme-color-primary) 32%,
            var(--theme-color-border-strong)
        );
    }

    :where([data-runtime-theme="target-u"]) .ui-filter-trigger:hover .t-value,
    :where([data-runtime-theme="target-u"]) .ui-filter-trigger:hover > .ico {
        color: var(--theme-color-primary);
    }

    :where([data-runtime-theme="target-u"]) .ui-option:hover {
        background: var(--theme-color-surface-muted);
    }

    :where([data-runtime-theme="target-u"]) .ui-option:hover [data-ui-option-indicator] {
        border-color: color-mix(
            in oklch,
            var(--theme-color-primary) 40%,
            var(--theme-color-border-strong)
        );
    }

    :where([data-runtime-theme="target-u"]) .ui-chip:hover {
        border-color: color-mix(
            in oklch,
            var(--theme-color-primary) 32%,
            var(--theme-color-border-strong)
        );
        background: var(--theme-color-surface-muted);
        color: var(--theme-color-primary);
    }

    :where([data-runtime-theme="target-u"]) .ui-chip:hover > .ico {
        color: var(--theme-color-primary);
    }

    :where([data-runtime-theme="target-u"]) .ui-segment__btn:hover {
        background: var(--theme-color-surface-muted);
        color: var(--theme-color-primary);
    }
}

/*
 * DESIGN v2.2: keyboard focus is an independent outer owner ring. It does not
 * repaint the visible field/filter boundary, so error and selected states stay
 * legible underneath it.
 */
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-field:focus-visible,
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-filter-trigger:focus-visible,
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-option:focus-visible,
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-option:has(input:focus-visible),
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-chip:focus-visible,
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-segment__btn:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-search__clear:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

:where([data-runtime-theme="target-u"]) .ui-filter-trigger .t-label {
    flex: 0 0 auto;
    color: var(--theme-color-muted);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
}

:where([data-runtime-theme="target-u"]) .ui-filter-trigger .t-value {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--theme-color-foreground);
    text-overflow: ellipsis;
    white-space: nowrap;
}

:where([data-runtime-theme="target-u"]) .ui-filter-trigger > .ico {
    color: var(--theme-color-muted);
    transition:
        transform var(--theme-motion-duration-interaction),
        color var(--theme-motion-duration-interaction);
}

/*
 * Clicking into Search may strengthen its retained inner boundary. Keyboard
 * focus transfers the outer ring from the input to the complete Search owner.
 */
:where([data-runtime-theme="target-u"][data-focus-modality="pointer"])
.ui-search:focus-within {
    border-color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-search:has(> .ui-field:focus-visible) {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-search > .ui-field:focus-visible,
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-option input:focus-visible {
    outline: none;
    box-shadow: none;
}

/* Expanded must read louder than hover: Navy border, selected surface, turned chevron. */
:where([data-runtime-theme="target-u"]) .ui-filter-trigger[aria-expanded="true"] {
    border-color: var(--theme-color-primary);
    background: var(--theme-color-surface-selected);
    color: var(--theme-color-primary);
}

/* Any disclosure turns its chevron on expand, not just filter triggers. */
:where([data-runtime-theme="target-u"]) [data-ui-chevron] {
    transition:
        transform var(--theme-motion-duration-interaction),
        color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) [aria-expanded="true"] [data-ui-chevron] {
    transform: rotate(180deg);
}

/*
 * Persistent selection is one site-wide symbol: a pale selected surface with
 * Navy ink, plus a solid square dot inside the checkbox. No corner marks (those
 * mean guidance), no tick, no radio dot, no filled pill.
 */
:where([data-runtime-theme="target-u"]) .ui-option[aria-selected="true"] {
    background: var(--theme-color-surface-selected);
    color: var(--theme-color-primary);
}

/* The box is always drawn; selecting fills it. An empty box states the choice. */
:where([data-runtime-theme="target-u"]) .ui-option [data-ui-option-indicator] {
    flex: 0 0 16px;
    display: grid;
    place-items: center;
    width: 16px;
    height: 16px;
    border: 1px solid var(--theme-color-border-strong);
    border-radius: 0;
    background: var(--theme-color-surface);
    transition: border-color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-option [data-ui-option-indicator]::after {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--theme-color-primary);
    opacity: 0;
    transition: opacity var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-option[aria-selected="true"] [data-ui-option-indicator] {
    border-color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .ui-option[aria-selected="true"] [data-ui-option-indicator]::after {
    opacity: 1;
}

/*
 * Chips and segments share the surface, and keep a plain border while selected.
 * A segment built from links states its selection as `aria-current="page"`
 * rather than `aria-pressed`; it is the same state and gets the same language.
 */
:where([data-runtime-theme="target-u"]) .ui-chip[aria-pressed="true"],
:where([data-runtime-theme="target-u"]) .ui-chip[aria-current="page"],
:where([data-runtime-theme="target-u"]) .ui-segment__btn[aria-pressed="true"],
:where([data-runtime-theme="target-u"]) .ui-segment__btn[aria-current="page"],
:where([data-runtime-theme="target-u"]) .ui-option[aria-current="page"] {
    background: var(--theme-color-surface-selected);
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .ui-field[aria-invalid="true"],
:where([data-runtime-theme="target-u"]) .ui-field[data-state="error"] {
    border-color: var(--theme-color-danger-border);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
}

:where([data-runtime-theme="target-u"]) .ui-filter-trigger[aria-expanded="true"] .t-label,
:where([data-runtime-theme="target-u"]) .ui-filter-trigger[aria-expanded="true"] > .ico {
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .ui-chip[aria-pressed="true"] > .ico {
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .ui-filter-trigger[aria-invalid="true"],
:where([data-runtime-theme="target-u"]) .ui-filter-trigger[data-state="error"] {
    border-color: var(--theme-color-danger-border);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
}

:where([data-runtime-theme="target-u"]) .ui-search:has(> .ui-field[aria-invalid="true"]),
:where([data-runtime-theme="target-u"]) .ui-search:has(> .ui-field[data-state="error"]) {
    border-color: var(--theme-color-danger-border);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
}

:where([data-runtime-theme="target-u"]) .ui-filter-trigger[aria-busy="true"],
:where([data-runtime-theme="target-u"]) .ui-filter-trigger[data-state="busy"] {
    pointer-events: none;
    cursor: progress;
}

:where([data-runtime-theme="target-u"]) .ui-field:disabled,
:where([data-runtime-theme="target-u"]) .ui-field[aria-disabled="true"],
:where([data-runtime-theme="target-u"]) .ui-field[data-state="disabled"] {
    pointer-events: none;
    cursor: not-allowed;
    border-color: var(--theme-color-border);
    background: var(--theme-color-surface-muted);
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .ui-search:has(> .ui-field:disabled),
:where([data-runtime-theme="target-u"]) .ui-search:has(> .ui-field[aria-disabled="true"]),
:where([data-runtime-theme="target-u"]) .ui-search:has(> .ui-field[data-state="disabled"]) {
    pointer-events: none;
    border-color: var(--theme-color-border);
    background: var(--theme-color-surface-muted);
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .ui-filter-trigger:disabled,
:where([data-runtime-theme="target-u"]) .ui-filter-trigger[aria-disabled="true"],
:where([data-runtime-theme="target-u"]) .ui-filter-trigger[data-state="disabled"] {
    pointer-events: none;
    cursor: not-allowed;
    border-color: var(--theme-color-border);
    background: var(--theme-color-surface-muted);
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .ui-filter-trigger:disabled .t-label,
:where([data-runtime-theme="target-u"]) .ui-filter-trigger:disabled > .ico,
:where([data-runtime-theme="target-u"]) .ui-filter-trigger[aria-disabled="true"] .t-label,
:where([data-runtime-theme="target-u"]) .ui-filter-trigger[aria-disabled="true"] > .ico,
:where([data-runtime-theme="target-u"]) .ui-filter-trigger[data-state="disabled"] .t-label,
:where([data-runtime-theme="target-u"]) .ui-filter-trigger[data-state="disabled"] > .ico {
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .ui-option[aria-disabled="true"],
:where([data-runtime-theme="target-u"]) .ui-option[data-state="disabled"] {
    pointer-events: none;
    cursor: not-allowed;
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .ui-option[aria-disabled="true"] [data-ui-option-indicator],
:where([data-runtime-theme="target-u"]) .ui-option[data-state="disabled"] [data-ui-option-indicator] {
    border-color: var(--theme-color-border);
    background: var(--theme-color-surface-muted);
}

/* Entity surfaces ---------------------------------------------------------- */
:where([data-runtime-theme="target-u"]) .ui-entity-card {
    --liquid-x: 56%;
    --liquid-y: 40%;
    position: relative;
    isolation: isolate;
    /* The v2.2 ring lives outside the card owner and must remain unclipped. */
    overflow: visible;
    /* The card, not the viewport, decides when its columns tighten. */
    container-type: inline-size;
    border: 1px solid var(--theme-color-border);
    border-radius: var(--theme-radius-entity);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
    transition:
        border-color var(--theme-motion-duration-interaction) cubic-bezier(0.2, 0, 0, 1),
        background-color var(--theme-motion-duration-interaction) cubic-bezier(0.2, 0, 0, 1);
}

/*
 * The confirmed structural-grid hover: a faint, local, cool-white reflection
 * that follows the pointer (theme_ui.js drives --liquid-x/--liquid-y). The
 * isolated stacking context lets the layer sit on z-index -1 — behind every
 * child but above the card surface — without lifting each child like the lab.
 */
:where([data-runtime-theme="target-u"]) .ui-entity-card::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    border-radius: inherit;
    background:
        radial-gradient(
            220px 160px at var(--liquid-x) var(--liquid-y),
            color-mix(in oklch, var(--theme-color-surface) 97%, var(--theme-color-primary)) 0%,
            color-mix(in oklch, var(--theme-color-surface) 99%, var(--theme-color-primary)) 40%,
            transparent 74%
        ),
        linear-gradient(
            120deg,
            color-mix(in oklch, var(--theme-color-surface) 99%, var(--theme-color-primary)),
            transparent 52%
        );
    opacity: 0;
    transition: opacity var(--theme-motion-duration-interaction) cubic-bezier(0.2, 0, 0, 1);
}

/*
 * The status row holds a shared 60px floor even on cards with no favourite
 * control, so side-by-side cards start their content on the same pixel.
 */
:where([data-runtime-theme="target-u"]) .ui-entity-card__status {
    display: flex;
    min-height: 60px;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--theme-spacing-sm);
    padding: var(--theme-spacing-lg) var(--theme-spacing-card) 0;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__status:has(> .ui-entity-card__badges) {
    flex-wrap: nowrap;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__badges {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--theme-spacing-xs);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__identity {
    display: grid;
    gap: var(--theme-spacing-xs);
    padding: var(--theme-spacing-md) var(--theme-spacing-card) var(--theme-spacing-lg);
}

/* Canonical identity leaves: routes supply data; the shared card owns hierarchy. */
:where([data-runtime-theme="target-u"]) .ui-entity-card__school {
    min-width: 0;
    color: var(--theme-color-muted);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__name {
    min-width: 0;
    margin: 0;
    color: var(--theme-color-primary);
    font-size: var(--theme-text-entity-title);
    font-weight: var(--theme-text-entity-title--font-weight);
    line-height: var(--theme-text-entity-title--line-height);
}

:where([data-runtime-theme="target-u"]) .ui-identity-group {
    color: var(--theme-color-muted);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: var(--theme-text-supporting--line-height);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__name--preference {
    text-wrap: pretty;
    overflow-wrap: anywhere;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__name--preference:not(:has(> .ui-identity-group)) {
    text-wrap: balance;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__name--preference:not(:has(> .ui-identity-group)) > span {
    display: inline-block;
    max-inline-size: 100%;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__code {
    display: block;
    min-width: 0;
    min-height: 1.5em;
    margin: 0;
    color: var(--theme-color-muted);
    font-family: var(--theme-font-data);
    font-variant-numeric: tabular-nums;
    font-size: var(--theme-text-micro);
    font-weight: var(--theme-text-micro--font-weight);
    line-height: var(--theme-text-micro--line-height);
    letter-spacing: var(--theme-text-micro--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__tags {
    display: block;
    min-width: 0;
    min-height: 1.5em;
    margin: 0;
    color: var(--theme-color-muted);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: var(--theme-text-supporting--line-height);
    letter-spacing: var(--theme-text-micro--letter-spacing);
}

/*
 * The grid paints its own gridlines: cells sit on the card surface and the
 * 1px gaps expose the container background, so every wrap — 2×2 at the real
 * ~400px card width, single column on narrow phones — gets complete row and
 * column rules without per-cell border bookkeeping.
 */
/*
 * The old theme paired the screening basis with a hero probability number;
 * the decision zone keeps that composition on system geometry: reasons on
 * the left, the KPI on the right behind one soft vertical rule.
 */
/*
 * Column contract: the data band is a three-part grid, so the decision zone is
 * 2fr / 1fr — putting the KPI column on the same vertical band as the band's
 * third cell. The children carry the inline padding and the KPI pulls back 1px
 * so its rule lands on the same pixel as the data gridline.
 */
:where([data-runtime-theme="target-u"]) .ui-entity-card__decision {
    display: grid;
    grid-template-columns: 2fr 1fr;
    padding: var(--theme-spacing-lg) 0;
}

/*
 * Cards with no data band (personal application, distribution) frame the zone
 * with their own pair of hairlines, so all four card kinds share one rule
 * language — on a placement card those lines come from the band itself.
 */
:where([data-runtime-theme="target-u"]) .ui-entity-card__decision--banded {
    border-block: 1px solid
        color-mix(in oklch, var(--theme-color-border) 55%, var(--theme-color-surface));
    transition: border-color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__decision-main,
:where([data-runtime-theme="target-u"]) .ui-entity-card__facts {
    min-width: 0;
    display: grid;
    gap: var(--theme-spacing-xs);
    align-content: start;
    padding-inline: var(--theme-spacing-card) var(--theme-spacing-lg);
}

/* The decision owner supplies the sole 4px title-to-content gap. */
:where([data-runtime-theme="target-u"])
.ui-entity-card__decision-main > .ui-entity-card__evidence-title {
    margin-block-end: 0;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__facts {
    gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .ui-fact {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .ui-fact .ico {
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .ui-fact .fact-label {
    flex: 0 0 auto;
    color: var(--theme-color-muted);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    letter-spacing: 0.02em;
}

:where([data-runtime-theme="target-u"]) .ui-fact .fact-value {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    font-family: var(--theme-font-data);
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-overflow: ellipsis;
    white-space: nowrap;
}

:where([data-runtime-theme="target-u"]) .ui-fact .fact-value--text {
    font-family: var(--theme-font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__decision-kpi {
    display: grid;
    gap: 2px;
    align-content: start;
    min-width: 0;
    margin-inline-start: -1px;
    padding-inline: var(--theme-spacing-lg) var(--theme-spacing-card);
    border-inline-start: 1px solid
        color-mix(in oklch, var(--theme-color-border) 55%, var(--theme-color-surface));
    transition: border-color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__decision-kpi .kpi-label {
    color: var(--theme-color-muted);
    font-size: var(--theme-text-micro);
    font-weight: var(--theme-text-micro--font-weight);
    letter-spacing: var(--theme-text-micro--letter-spacing);
}

/* The longer distribution PR label can wrap. Align the values in both admission cards. */
:where([data-runtime-theme="target-u"]) .ui-entity-card__decision--banded .kpi-label {
    min-block-size: 2lh;
    text-wrap: balance;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__decision-kpi .kpi-value {
    font-family: var(--theme-font-serif);
    font-size: var(--theme-text-decision-kpi);
    font-weight: var(--theme-text-decision-kpi--font-weight);
    line-height: var(--theme-text-decision-kpi--line-height);
    font-variant-numeric: tabular-nums;
}

/*
 * The 校系 PR is the gold version of the same hero template, sharing the one
 * text-bearing gold with the change flags. Never the brand fill #C6A969 — at
 * 2.24:1 on the cool white surface it cannot even clear the 3:1 large-text bar.
 */
:where([data-runtime-theme="target-u"]) .ui-kpi--decision {
    color: var(--theme-color-decision-ink);
}

:where([data-runtime-theme="target-u"]) .ui-caac-pr {
    white-space: nowrap;
}

:where([data-runtime-theme="target-u"]) .ui-caac-pr__mark {
    font-size: clamp(.28125rem, .36em, .5625rem);
    margin-inline-start: 1px;
    line-height: 0;
    vertical-align: -.14em;
}

/* No data means "—", never a zero and never a hidden column. */
:where([data-runtime-theme="target-u"]) .kpi-value--unknown {
    color: var(--theme-color-muted);
}

/*
 * Gridlines stay quiet — a border/surface mix, not the full border token —
 * and every cell paints its own start-side rules. The container clips the
 * first row/column lines, so any wrap gets complete gridlines, an odd last
 * cell just leaves quiet surface beside it, and cells stay transparent so
 * the pointer reflection shows through.
 */
:where([data-runtime-theme="target-u"]) .ui-entity-card__data-grid {
    display: grid;
    overflow: hidden;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.5rem), 1fr));
    border-block: 1px solid
        color-mix(in oklch, var(--theme-color-border) 55%, var(--theme-color-surface));
    transition: border-color var(--theme-motion-duration-interaction) cubic-bezier(0.2, 0, 0, 1);
}

/* Triple comparison bands never auto-fit or reflow to a second row. */
:where([data-runtime-theme="target-u"]) .ui-entity-card__data-grid--triple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/*
 * Inner cells breathe on 16px; the first and last cells keep the card's
 * 20px edge inset so the strip stays aligned with the content above it.
 */
/*
 * Inner cells breathe on 16px; the first and last cells keep the card's
 * 20px edge inset so the strip stays aligned with the content around it.
 */
:where([data-runtime-theme="target-u"]) .ui-entity-card__data-grid > .ui-entity-card__data-cell {
    margin-block-start: -1px;
    margin-inline-start: -1px;
    border-inline-end: 0;
    border-inline-start: 1px solid
        color-mix(in oklch, var(--theme-color-border) 55%, var(--theme-color-surface));
    border-block-start: 1px solid
        color-mix(in oklch, var(--theme-color-border) 55%, var(--theme-color-surface));
    transition: border-color var(--theme-motion-duration-interaction) cubic-bezier(0.2, 0, 0, 1);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__data-grid > .ui-entity-card__data-cell:first-child {
    padding-inline-start: var(--theme-spacing-card);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__data-grid > .ui-entity-card__data-cell:last-child {
    padding-inline-end: var(--theme-spacing-card);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__data-cell {
    min-width: 0;
    padding: var(--theme-spacing-md) var(--theme-spacing-lg);
    border-inline-end: 1px solid var(--theme-color-border);
    font-variant-numeric: tabular-nums;
    transition: border-color var(--theme-motion-duration-interaction) cubic-bezier(0.2, 0, 0, 1);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__data-cell dt {
    color: var(--theme-color-muted);
    font-size: var(--theme-text-micro);
    font-weight: var(--theme-text-micro--font-weight);
    line-height: var(--theme-text-micro--line-height);
    letter-spacing: var(--theme-text-micro--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__data-cell dd {
    margin: 2px 0 0;
    font-family: var(--theme-font-data);
    font-variant-numeric: tabular-nums;
    font-size: var(--theme-text-data);
    font-weight: 600;
    line-height: var(--theme-text-data--line-height);
}

/* A decision KPI never degrades to the data-cell's compact mono scale. */
:where([data-runtime-theme="target-u"]) .ui-entity-card__data-cell dd.ui-type-decision-kpi {
    font-family: var(--theme-font-serif);
    font-size: var(--theme-text-decision-kpi);
    font-weight: var(--theme-text-decision-kpi--font-weight);
    line-height: var(--theme-text-decision-kpi--line-height);
}

/* The shared owner closes the grid edge; route CSS must not re-own this. */
:where([data-runtime-theme="target-u"]) .ui-entity-card__data-cell:last-child {
    border-inline-end: 0;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__evidence {
    display: grid;
    gap: var(--theme-spacing-md);
    padding: var(--theme-spacing-lg) var(--theme-spacing-card);
    color: var(--theme-color-muted);
    font-size: var(--theme-text-supporting);
    line-height: 1.6;
}

/*
 * Bottom row: the subject list shares the line with the text guide. The subject
 * string may shrink and ellipsize; the guide never compresses, so a long list
 * can never cover "查看…".
 */
:where([data-runtime-theme="target-u"]) .ui-entity-card__footer {
    display: flex;
    min-height: 44px;
    align-items: center;
    justify-content: flex-end;
    gap: var(--theme-spacing-sm);
    padding-inline: var(--theme-spacing-card);
    padding-block-end: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__evidence-title {
    margin: 0 0 var(--theme-spacing-xs);
    color: var(--theme-color-muted);
    font-size: var(--theme-text-micro);
    font-weight: var(--theme-text-micro--font-weight);
    letter-spacing: var(--theme-text-micro--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .screening-row {
    display: flex;
    align-items: baseline;
    gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .screening-row .stage,
:where([data-runtime-theme="target-u"]) .screening-row .mult {
    flex: 0 0 auto;
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-data);
    font-variant-numeric: tabular-nums;
    font-size: var(--theme-text-supporting);
    font-weight: 600;
}

:where([data-runtime-theme="target-u"]) .screening-row .subjects {
    flex: 1 1 auto;
    min-width: 0;
    font-size: var(--theme-text-supporting);
    font-weight: 400;
    line-height: var(--theme-text-supporting--line-height);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__footer--split {
    box-sizing: border-box;
    min-height: 44px;
    padding-block: var(--theme-spacing-xs);
    justify-content: space-between;
    gap: var(--theme-spacing-lg);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__footer .ui-entity-card__action {
    flex: 0 0 auto;
    margin-inline: 0;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__subjects {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    align-items: baseline;
    gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__subjects-label {
    flex: 0 0 auto;
    color: var(--theme-color-muted);
    font-size: var(--theme-text-micro);
    font-weight: var(--theme-text-micro--font-weight);
    letter-spacing: var(--theme-text-micro--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__subjects-value {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: 1.6;
    text-overflow: ellipsis;
    white-space: nowrap;
}


:where([data-runtime-theme="target-u"]) .ui-entity-card__subjects-value:has(> .ui-subject-excerpt) {
    overflow: visible;
}

/* Without script the full list wraps. Only a measured overflow gets a control. */
:where([data-runtime-theme="target-u"]) .ui-subject-excerpt,
:where([data-runtime-theme="target-u"]) .ui-subject-excerpt__text {
    display: block;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}
:where([data-runtime-theme="target-u"]) [data-ui-subject-state="collapsed"] > .ui-subject-excerpt__text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
:where([data-runtime-theme="target-u"]) .ui-subject-excerpt__toggle {
    position: relative;
    z-index: 2;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--theme-color-primary);
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__subjects-value .w,
:where([data-runtime-theme="target-u"]) .ui-entity-card__subject-detail-list .w {
    font-family: var(--theme-font-data);
    font-size: var(--theme-text-micro);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/*
 * R06 exposes a separately keyboard-operable disclosure above the exact
 * Offering card's stretched navigation owner. The collapsed footer remains
 * the one-line comparison view.
 */
:where([data-runtime-theme="target-u"]) :is(.ui-entity-card--interactive, .favorite-card__main--interactive) .ui-entity-card__subject-details {
    position: relative;
    z-index: 2;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__subject-details > summary {
    position: relative;
    border-radius: 0 0 var(--theme-radius-entity) var(--theme-radius-entity);
    list-style: none;
    cursor: pointer;
}

:where([data-runtime-theme="target-u"])
.ui-entity-card__subject-details > summary::-webkit-details-marker {
    display: none;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__subject-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    min-height: 36px;
    align-items: center;
    gap: var(--theme-spacing-xs);
    color: var(--theme-color-primary);
    font-size: var(--theme-text-supporting);
    font-weight: 600;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__subject-toggle svg {
    transition: transform var(--theme-motion-duration-interaction) cubic-bezier(0.2, 0, 0, 1);
}

:where([data-runtime-theme="target-u"])
.ui-entity-card__subject-details[open] .ui-entity-card__subject-toggle svg {
    transform: rotate(180deg);
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__subject-detail-list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0 var(--theme-spacing-card) var(--theme-spacing-sm);
    border-top: 1px solid var(--theme-color-border);
    list-style: none;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__subject-detail-list li {
    display: flex;
    min-height: 36px;
    align-items: center;
    justify-content: space-between;
    gap: var(--theme-spacing-md);
    border-bottom: 1px solid var(--theme-color-border);
    font-size: var(--theme-text-supporting);
}

:where([data-runtime-theme="target-u"])
.ui-entity-card__subject-detail-list li:last-child {
    border-bottom: 0;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__subject-rank {
    color: var(--theme-color-muted);
    font-size: var(--theme-text-micro);
}

/*
 * Compact card geometry must follow every base data/decision/footer rule;
 * otherwise the cascade restores desktop padding and separates the triple
 * band's gridlines from the decision KPI rule. The 380px cutoff is the
 * canonical component breakpoint and follows the card's actual inline size.
 *
 * Compact densifies the card's INTERIOR only (cell insets, data scale).
 * The outer edge inset is invariant: every edge-touching leaf keeps
 * --theme-spacing-card at every container width, so cards laid out by
 * different route grids (2-up results, 3-up catalog) always present the
 * same frame and the corner control sits on the same pixel on every page.
 */
@container (max-width: 380px) {
    :where([data-runtime-theme="target-u"]) .ui-entity-card__data-cell,
    :where([data-runtime-theme="target-u"]) .ui-entity-card__data-grid > .ui-entity-card__data-cell {
        padding: var(--theme-spacing-md) 10px;
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card__data-cell dd {
        font-size: 0.8125rem;
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card__decision-main,
    :where([data-runtime-theme="target-u"]) .ui-entity-card__facts {
        padding-inline: var(--theme-spacing-card) var(--theme-spacing-md);
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card__decision-kpi {
        padding-inline: 10px var(--theme-spacing-card);
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card__decision--banded {
        grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    }
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__action {
    position: relative;
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: var(--theme-spacing-xs);
    padding-inline: 0;
    border: 0;
    background: transparent;
    color: var(--theme-color-primary);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    font-weight: 600;
    line-height: var(--theme-text-supporting--line-height);
    letter-spacing: var(--theme-text-supporting--letter-spacing);
    text-decoration: none;
    cursor: pointer;
    transition: color var(--theme-motion-duration-interaction);
}

/* Favorites share five bands across program and offering cards. */
/* Extra admission or academic-group badges can wrap. Reserve two lines across
   the collection only when that extra metadata is present. */
:where([data-runtime-theme="target-u"]) [data-favorites-grid]:has(.ui-entity-card__badges > :nth-child(3)) {
    --favorite-badge-row: max(28px, calc(1lh + 2 * var(--theme-spacing-xs) + 2px));
}
:where([data-runtime-theme="target-u"]) [data-favorites-grid] .ui-entity-card__status {
    font-size: var(--theme-text-supporting);
    line-height: var(--theme-text-supporting--line-height);
    min-block-size: max(60px, calc(var(--theme-spacing-lg) + 2 * var(--favorite-badge-row, 0px) + var(--theme-spacing-xs)));
}
:where([data-runtime-theme="target-u"]) [data-ui-route="favorites"] .ui-entity-card__tags,
:where([data-runtime-theme="target-u"]) [data-ui-route="favorites"] .ui-entity-card__identity > .ui-entity-card__code {
    font-size: var(--theme-text-micro);
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
:where([data-runtime-theme="target-u"]) [data-ui-route="favorites"] .ui-entity-card__footer {
    block-size: 44px;
    padding-block: 0;
}
:where([data-runtime-theme="target-u"]) [data-ui-route="favorites"] .favorite-card__main > .ui-entity-card__hit:focus {
    outline: none;
}
@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) [data-ui-route="favorites"] .favorite-card__main--interactive:not(:has(.ui-favorite-control:hover, .favorite-drag-handle:hover, .favorite-note-trigger:hover, .ui-entity-card__subject-details > summary:hover)):hover {
        background: var(--theme-color-surface-muted);
    }
    :where([data-runtime-theme="target-u"]) [data-ui-route="favorites"] .favorite-card__main--interactive:not(:has(.ui-favorite-control:hover, .favorite-drag-handle:hover, .favorite-note-trigger:hover, .ui-entity-card__subject-details > summary:hover)):hover .ui-entity-card__name,
    :where([data-runtime-theme="target-u"]) [data-ui-route="favorites"] .favorite-card__main--interactive:not(:has(.ui-favorite-control:hover, .favorite-drag-handle:hover, .favorite-note-trigger:hover, .ui-entity-card__subject-details > summary:hover)):hover .ui-entity-card__footer > .ui-entity-card__action {
        color: var(--theme-color-primary-light);
    }
    :where([data-runtime-theme="target-u"]) [data-ui-route="favorites"] .favorite-card__main--interactive:not(:has(.ui-favorite-control:hover, .favorite-drag-handle:hover, .favorite-note-trigger:hover, .ui-entity-card__subject-details > summary:hover)):hover .ui-entity-card__footer > .ui-entity-card__action > span::after {
        clip-path: inset(0);
    }
    :where([data-runtime-theme="target-u"]) [data-ui-route="favorites"] .favorite-card__main--interactive:not(:has(.ui-favorite-control:hover, .favorite-drag-handle:hover, .favorite-note-trigger:hover, .ui-entity-card__subject-details > summary:hover)):hover .ui-entity-card__footer > .ui-entity-card__action svg {
        transform: translateX(3px);
    }
}
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) [data-ui-route="favorites"] .favorite-card__main:has(> .ui-entity-card__hit:focus-visible) {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

/* Each track owns its disclosure. The row link and the preference action are siblings. */
:where([data-runtime-theme="target-u"]) .ui-program-tracks {
    display: grid;
    min-width: 0;
    gap: var(--theme-spacing-md);
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__section {
    min-width: 0;
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__section + .ui-program-tracks__section {
    padding-block-start: var(--theme-spacing-md);
    border-block-start: 1px solid var(--theme-color-border);
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__heading,
:where([data-runtime-theme="target-u"]) .ui-program-tracks__summary,
:where([data-runtime-theme="target-u"]) .ui-program-tracks__identity {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: var(--theme-spacing-xs) var(--theme-spacing-sm);
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__heading,
:where([data-runtime-theme="target-u"]) .ui-program-tracks__summary {
    box-sizing: border-box;
    min-block-size: max(44px, 2.75rem);
    align-items: center;
    flex-wrap: nowrap;
    padding-inline: var(--theme-spacing-xs);
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__heading {
    padding-block: var(--theme-spacing-xs);
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__summary {
    cursor: pointer;
    list-style: none;
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__summary::-webkit-details-marker {
    display: none;
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__track {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__count {
    flex: 0 0 auto;
    white-space: nowrap;
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__year {
    flex: 0 0 auto;
    margin-inline-start: auto;
    white-space: nowrap;
    color: var(--theme-color-muted);
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__disclosure[open] > summary svg {
    transform: rotate(180deg);
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__list {
    display: grid;
    list-style: none;
    margin: 0;
    padding: 0;
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 var(--theme-spacing-sm);
    padding-block: var(--theme-spacing-xs);
    border-block-start: 1px solid var(--theme-color-border);
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1 1 10rem;
    min-width: 0;
    min-height: 44px;
    gap: var(--theme-spacing-sm);
    padding: var(--theme-spacing-xs);
    color: var(--theme-color-foreground);
    text-decoration: none;
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__body {
    min-width: 0;
    display: grid;
    gap: var(--theme-spacing-xs);
    overflow-wrap: anywhere;
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks__arrow {
    flex: none;
    color: var(--theme-color-primary);
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks--stack .ui-program-tracks__item:has(> .offering-preference-action) > .ui-program-tracks__link {
    flex: 1 0 100%;
}
:where([data-runtime-theme="target-u"]) .ui-program-tracks--stack .ui-program-tracks__item > .offering-preference-action {
    margin-inline-start: 0;
    justify-content: flex-start;
    padding-inline: var(--theme-spacing-xs);
    padding-block-end: var(--theme-spacing-xs);
    max-width: 100%;
}
@media (min-width: 64rem) {
    :where([data-runtime-theme="target-u"]) .ui-program-tracks--columns {
        grid-template-columns: repeat(auto-fit, minmax(min(15.5rem, 100%), 1fr));
        align-items: start;
        gap: var(--theme-spacing-lg) var(--theme-spacing-xl);
    }
    :where([data-runtime-theme="target-u"]) .ui-program-tracks--columns > .ui-program-tracks__section + .ui-program-tracks__section {
        padding-block-start: 0;
        border-block-start: 0;
    }
}
@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .ui-program-tracks__summary:hover,
    :where([data-runtime-theme="target-u"]) a.ui-program-tracks__link:hover {
        background: var(--theme-color-surface-muted);
        color: var(--theme-color-primary);
    }
    :where([data-runtime-theme="target-u"]) a.ui-program-tracks__link:hover .ui-program-tracks__name {
        color: var(--theme-color-primary-light);
    }
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
    :where([data-runtime-theme="target-u"]) .ui-program-tracks__arrow {
        transition: transform var(--theme-motion-duration-interaction);
    }
    :where([data-runtime-theme="target-u"]) a.ui-program-tracks__link:hover .ui-program-tracks__arrow {
        transform: translateX(3px);
    }
}
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
:is(.ui-program-tracks__summary, .ui-program-tracks__link):focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

/* The text guide underline expands from the left, like Tertiary buttons. */
:where([data-runtime-theme="target-u"]) .ui-entity-card__action > span {
    position: relative;
    display: inline-block;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card__action > span::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: -3px;
    left: 0;
    height: 1px;
    background: currentColor;
    clip-path: inset(0 100% 0 0);
    transition: clip-path var(--theme-motion-duration-interaction) cubic-bezier(0.2, 0, 0, 1);
}

/* Size comes from the icon contract's step class; this only adds the travel. */
:where([data-runtime-theme="target-u"]) .ui-entity-card__action svg {
    transition: transform var(--theme-motion-duration-interaction) cubic-bezier(0.2, 0, 0, 1);
}

/*
 * Interactive cards restore the old theme's whole-card hit area. The text
 * guide stays the real focusable control, but it sits static so its ::before
 * resolves against the card and stretches the click surface over it. Its
 * visible text owns the underline so that decoration never stretches to the
 * complete hit area; card hover commits the full arrow travel instead.
 */
:where([data-runtime-theme="target-u"]) .ui-entity-card--interactive,
:where([data-runtime-theme="target-u"]) .favorite-card__main--interactive {
    cursor: pointer;
}

/*
 * The guide travels via its children: a transform on the action itself would
 * become the containing block for the stretched ::before and collapse the
 * whole-card hit area mid-hover.
 */
:where([data-runtime-theme="target-u"]) .ui-entity-card--interactive .ui-entity-card__action {
    position: static;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card--interactive .ui-entity-card__action::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* A secondary destination uses the same guide but owns only its link area. */
:where([data-runtime-theme="target-u"]) .ui-entity-card--interactive .ui-entity-card__action[data-independent-action] {
    position: relative;
}

:where([data-runtime-theme="target-u"]) .ui-entity-card--interactive .ui-entity-card__action[data-independent-action]::before {
    content: none;
}

/* A card without a visible text guide may expose the same stretched hit owner. */
:where([data-runtime-theme="target-u"]) .ui-entity-card__hit {
    position: absolute;
    z-index: 1;
    inset: 0;
    border-radius: inherit;
    outline: none;
}

/* Standalone controls (favorite, drag handles) stay clickable above the stretch. */
:where([data-runtime-theme="target-u"]) :is(.ui-entity-card--interactive, .favorite-card__main--interactive) .ui-favorite-control {
    position: relative;
    z-index: 2;
}

/* Stretched actions transfer their additive focus ring to the complete card. */
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-entity-card--interactive:has(.ui-entity-card__action:not([data-independent-action]):focus-visible),
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-entity-card--interactive:has(.ui-entity-card__hit:focus-visible) {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

:where([data-runtime-theme="target-u"])
.ui-entity-card--interactive .ui-entity-card__action:not([data-independent-action]):focus-visible,
:where([data-runtime-theme="target-u"])
.ui-entity-card--interactive .ui-entity-card__hit:focus-visible {
    outline: none;
    box-shadow: none;
}

/* The favorite is an unboxed heart, like the old theme: ink-only at rest. */
:where([data-runtime-theme="target-u"]) .ui-favorite-control {
    position: relative;
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    place-content: center;
    place-items: center;
    gap: var(--theme-spacing-sm);
    min-width: 44px;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: var(--theme-radius-control);
    background: transparent;
    color: var(--theme-color-muted);
    cursor: pointer;
    transition:
        color var(--theme-motion-duration-interaction),
        background-color var(--theme-motion-duration-interaction);
}

/* In a plain card status row the favorite owns the trailing edge.  When a
   change-set exists, that set already owns the auto margin and the favorite
   follows at the canonical 16px visual separation. */
:where([data-runtime-theme="target-u"])
.ui-entity-card__status:not(:has(> .ui-change-set)) > .ui-favorite-control {
    margin-inline-start: auto;
}

/*
 * The 44px control deliberately remains the touch owner around its 20px
 * glyph.  In an Entity Card status row only, reclaim part of that invisible
 * gap without shrinking the hit target.  Keeping about 12px around the
 * control's top and trailing edges gives every card corner a little more
 * breathing room while the heart still reads as part of the status row.
 */
:where([data-runtime-theme="target-u"])
.ui-entity-card__status > .ui-favorite-control--icon-only {
    align-self: flex-start;
    margin-block-start: -6px;
    margin-inline-end: -12px;
}

@media (hover: hover) and (pointer: fine) {
    /*
     * Structural-grid hover: every Entity card sharpens its outer boundary as
     * one unit without lifting, scaling, or growing a shadow. Whole-card
     * surface tint and reflection apply only to single-zone cards; multi-zone
     * conjoined cards (favorites, university catalog programs, preference
     * rows) tint only the interactive pane under the pointer.
     */
    :where([data-runtime-theme="target-u"]) .ui-entity-card:hover {
        border-color: color-mix(
            in oklch,
            var(--theme-color-primary) 38%,
            var(--theme-color-border)
        );
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card:not(.favorite-card, .catalog-program-card, .r16-pref-card, .r16-dist-card):not(:has(.ui-program-tracks)):hover {
        background: var(--theme-color-surface-muted);
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card:not(.favorite-card, .catalog-program-card, .r16-pref-card, .r16-dist-card):not(:has(.ui-program-tracks)):hover::before {
        opacity: 0.42;
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card:not(:has(.favorite-placement:hover)):hover .ui-entity-card__data-grid {
        border-color: var(--theme-color-border);
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card:not(:has(.favorite-placement:hover)):hover .ui-entity-card__decision--banded {
        border-block-color: var(--theme-color-border);
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card:not(:has(.favorite-placement:hover)):hover .ui-entity-card__data-cell {
        border-color: var(--theme-color-border);
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card:not(:has(.favorite-placement:hover)):hover .ui-entity-card__decision-kpi {
        border-inline-start-color: var(--theme-color-border);
    }

    /* Card hover previews its main guide. Independent links activate only
       themselves, and suspend the main guide while the pointer is on them. */
    :where([data-runtime-theme="target-u"]) .ui-entity-card--interactive:not(:has(.ui-entity-card__action[data-independent-action]:hover, .offering-preference-add:hover)):not(:has(.ui-favorite-control:hover, .ui-entity-card__subject-details > summary:hover, .ui-program-tracks__link:hover, .ui-program-tracks__summary:hover, .favorite-drag-handle:hover, .favorite-placement__action:hover, .favorite-note-trigger:hover)):hover .ui-entity-card__action:not([data-independent-action]) > span::after {
        clip-path: inset(0);
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card--interactive:not(:has(.ui-entity-card__action[data-independent-action]:hover, .offering-preference-add:hover)):not(:has(.ui-favorite-control:hover, .ui-entity-card__subject-details > summary:hover, .ui-program-tracks__link:hover, .ui-program-tracks__summary:hover, .favorite-drag-handle:hover, .favorite-placement__action:hover, .favorite-note-trigger:hover)):hover .ui-entity-card__action:not([data-independent-action]) svg {
        transform: translateX(3px);
    }

    /*
     * Guidance brightens on hover. Deepening an already high-contrast Navy is
     * almost invisible; lifting it is the change the eye can actually read.
     */
    :where([data-runtime-theme="target-u"]) .ui-entity-card__action:hover {
        color: var(--theme-color-primary-light);
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card__action:hover > span::after {
        clip-path: inset(0);
    }

    :where([data-runtime-theme="target-u"]) .ui-entity-card__action:hover svg {
        transform: translateX(6px);
    }

    /* On interactive cards the card is the control, so card hover lights the guide. */
    :where([data-runtime-theme="target-u"]) .ui-entity-card--interactive:not(:has(.ui-entity-card__action[data-independent-action]:hover, .offering-preference-add:hover)):not(:has(.ui-favorite-control:hover, .ui-entity-card__subject-details > summary:hover, .ui-program-tracks__link:hover, .ui-program-tracks__summary:hover, .favorite-drag-handle:hover, .favorite-placement__action:hover, .favorite-note-trigger:hover)):hover .ui-entity-card__action:not([data-independent-action]) {
        color: var(--theme-color-primary-light);
    }

    :where([data-runtime-theme="target-u"]) .ui-favorite-control:hover {
        background: var(--theme-color-surface-muted);
        color: var(--theme-color-primary);
    }
}

/* Direct card controls own the same ring without inheriting hover decoration. */
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-entity-card__action[data-independent-action]:focus-visible,
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-entity-card:not(.ui-entity-card--interactive) .ui-entity-card__action:focus-visible,
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-favorite-control:focus-visible,
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-entity-card__subject-details > summary:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

/* Saved is the same heart inverted — solid Navy ink, no surface behind it. */
:where([data-runtime-theme="target-u"]) .ui-favorite-control[aria-pressed="true"] {
    background: transparent;
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .ui-favorite-control[aria-pressed="true"] svg {
    fill: currentColor;
}

:where([data-runtime-theme="target-u"]) .ui-favorite-control[aria-busy="true"] {
    pointer-events: none;
    cursor: progress;
}

:where([data-runtime-theme="target-u"]) .ui-favorite-control:disabled,
:where([data-runtime-theme="target-u"]) .ui-favorite-control[aria-disabled="true"] {
    pointer-events: none;
    cursor: not-allowed;
    opacity: 0.52;
}

/* Feedback and semantic status -------------------------------------------- */
:where([data-runtime-theme="target-u"]) .ui-alert {
    display: grid;
    gap: var(--theme-spacing-sm);
    padding: var(--theme-spacing-md) var(--theme-spacing-lg);
    border: 1px solid var(--theme-color-border);
    border-radius: var(--theme-radius-control);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: var(--theme-text-supporting--line-height);
}

:where([data-runtime-theme="target-u"]) .ui-alert--info {
    border-color: var(--theme-color-status-info-border);
    background: var(--theme-color-status-info-surface);
    color: var(--theme-color-status-info-text);
}

:where([data-runtime-theme="target-u"]) .ui-alert--success {
    border-color: var(--theme-color-status-success-border);
    background: var(--theme-color-status-success-surface);
    color: var(--theme-color-status-success-text);
}

:where([data-runtime-theme="target-u"]) .ui-alert--warning {
    border-color: var(--theme-color-status-warning-border);
    background: var(--theme-color-status-warning-surface);
    color: var(--theme-color-status-warning-text);
}

:where([data-runtime-theme="target-u"]) .ui-alert--error {
    border-color: var(--theme-color-danger-border);
    background: var(--theme-color-danger-soft);
    color: var(--theme-color-danger);
}

:where([data-runtime-theme="target-u"]) .ui-empty-state {
    display: grid;
    justify-items: start;
    gap: var(--theme-spacing-md);
    padding-block: var(--theme-spacing-2xl);
    border-block: 1px dashed var(--theme-color-border-strong);
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .ui-destructive-guidance {
    padding: var(--theme-spacing-md) var(--theme-spacing-lg);
    border: 1px solid var(--theme-color-danger-border);
    border-radius: var(--theme-radius-control);
    background: var(--theme-color-danger-soft);
    color: var(--theme-color-danger);
    font-size: var(--theme-text-supporting);
    line-height: var(--theme-text-supporting--line-height);
}

:where([data-runtime-theme="target-u"]) .ui-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 22px;
    padding: 3px 10px;
    border-radius: var(--theme-radius-pill);
    background: var(--theme-color-realistic-bg);
    color: var(--theme-color-realistic-text);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: var(--theme-text-supporting--line-height);
    letter-spacing: var(--theme-text-supporting--letter-spacing);
}

/* Catalog academic-group badge is a shared Entity-card leaf, not a route
   decoration.  Every browse/result consumer gets the verification geometry. */
:where([data-runtime-theme="target-u"]) .catalog-badge {
    display: inline-flex;
    width: fit-content;
    min-height: 28px;
    align-items: center;
    padding: var(--theme-spacing-xs) var(--theme-spacing-sm);
    border-radius: var(--theme-radius-pill);
    background: var(--theme-color-primary-soft);
    color: var(--theme-color-primary);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: var(--theme-text-supporting--line-height);
    letter-spacing: var(--theme-text-supporting--letter-spacing);
}

/* 術科: same badge geometry, warning palette so it does not read as a 學群. */
:where([data-runtime-theme="target-u"]) .catalog-badge--special-exam {
    background: var(--theme-color-status-warning-surface);
    color: var(--theme-color-status-warning-text);
}

:where([data-runtime-theme="target-u"]) .catalog-data-value {
    display: block;
    margin: var(--theme-spacing-xs) 0 0;
    color: var(--theme-color-foreground);
    font-size: var(--theme-text-data);
    font-weight: 600;
}

:where([data-runtime-theme="target-u"]) .ui-badge--safe {
    background: var(--theme-color-safe-bg);
    color: var(--theme-color-safe-text);
}

:where([data-runtime-theme="target-u"]) .ui-badge--realistic {
    background: var(--theme-color-realistic-bg);
    color: var(--theme-color-realistic-text);
}

:where([data-runtime-theme="target-u"]) .ui-badge--aggressive {
    background: var(--theme-color-aggressive-bg);
    color: var(--theme-color-aggressive-text);
}

:where([data-runtime-theme="target-u"]) .ui-badge--dream {
    background: var(--theme-color-dream-bg);
    color: var(--theme-color-dream-text);
}

:where([data-runtime-theme="target-u"]) .ui-badge--low-probability {
    background: var(--theme-color-low-prob-bg);
    color: var(--theme-color-low-prob-text);
}

:where([data-runtime-theme="target-u"]) .ui-badge--failed {
    background: var(--theme-color-failed-bg);
    color: var(--theme-color-failed-text);
}

/* Staging only: marks a menu entry that production hides. */
:where([data-runtime-theme="target-u"]) .ui-badge--prod-hidden {
    display: inline-flex;
    min-height: 0;
    padding: 1px 6px;
    margin-inline: 4px 8px;
    background: var(--theme-color-status-warning-surface);
    color: var(--theme-color-status-warning-text);
    font-size: 0.6875rem;
    vertical-align: middle;
    white-space: nowrap;
}

:where([data-runtime-theme="target-u"]) li:has(> .ui-badge--prod-hidden) {
    display: flex;
    align-items: center;
}

/*
 * KPI ink variants color the decision number by placement classification —
 * the old theme's strongest scanning aid. Ink only, never a surface wash,
 * and always alongside the classification badge (text + color together).
 */
:where([data-runtime-theme="target-u"]) .ui-kpi--safe {
    color: var(--theme-color-safe-text);
}

:where([data-runtime-theme="target-u"]) .ui-kpi--realistic {
    color: var(--theme-color-realistic-text);
}

:where([data-runtime-theme="target-u"]) .ui-kpi--aggressive {
    color: var(--theme-color-aggressive-text);
}

:where([data-runtime-theme="target-u"]) .ui-kpi--dream {
    color: var(--theme-color-dream-text);
}

:where([data-runtime-theme="target-u"]) .ui-kpi--low-probability {
    color: var(--theme-color-low-prob-text);
}

:where([data-runtime-theme="target-u"]) .ui-kpi--failed {
    color: var(--theme-color-failed-text);
}

/*
 * Change flags are unboxed annotations in the decision-label voice: gold-brown
 * ink, no container and no pictogram. The flags of one entity read as a single
 * dotted run that starts right after the classification badge, so the status
 * row keeps one reading cluster and the favorite control keeps its own corner.
 */
:where([data-runtime-theme="target-u"]) .ui-change-set {
    display: inline-flex;
    flex: 1 1 0;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 2px 0;
    margin-inline: var(--theme-spacing-xs) var(--theme-spacing-sm);
}

/* Long-form change copy belongs to a variant's evidence/change slot, not to
 * the compact status row. It keeps the same ink while flowing from the
 * reading edge without borrowing status-row margins. */
:where([data-runtime-theme="target-u"]) .ui-entity-card__evidence > .ui-change-set {
    width: 100%;
    flex: 0 1 auto;
    margin-inline: 0;
}

:where([data-runtime-theme="target-u"]) .ui-change-inline {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    color: var(--theme-color-decision-ink);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: var(--theme-text-supporting--line-height);
    letter-spacing: var(--theme-text-supporting--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .ui-change-inline + .ui-change-inline::before {
    content: "\00B7";
    margin-inline: 6px;
    color: var(--theme-color-muted);
    font-weight: 400;
}

:where([data-runtime-theme="target-u"]) .ui-risk {
    display: inline-flex;
    align-items: center;
    gap: var(--theme-spacing-xs);
    padding: var(--theme-spacing-xs) var(--theme-spacing-sm);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: var(--theme-text-supporting--line-height);
}

:where([data-runtime-theme="target-u"]) .ui-risk--safe {
    background: var(--theme-color-risk-safe-bg);
    color: var(--theme-color-risk-safe-text);
}

:where([data-runtime-theme="target-u"]) .ui-risk--hard {
    background: var(--theme-color-risk-hard-bg);
    color: var(--theme-color-risk-hard-text);
}

:where([data-runtime-theme="target-u"]) .ui-risk--risk {
    background: var(--theme-color-risk-risk-bg);
    color: var(--theme-color-risk-risk-text);
}

:where([data-runtime-theme="target-u"]) .ui-risk--excess {
    background: var(--theme-color-risk-excess-bg);
    color: var(--theme-color-risk-excess-text);
}

:where([data-runtime-theme="target-u"]) .ui-risk--unavailable {
    background: var(--theme-color-risk-unavailable-bg);
    color: var(--theme-color-risk-unavailable-text);
}

/* Shared gate-history report ------------------------------------------------
 * Keep the mature reading order from the pre-152 analysis panel: the current
 * gate result is readable immediately, while dense historical evidence is an
 * explicit second step. This owner is shared by result and department views;
 * it is not an Entity card variant.
 */
:where([data-runtime-theme="target-u"]) .analysis-gate-report {
    display: grid;
    gap: var(--theme-spacing-lg);
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-report__header {
    display: grid;
    gap: var(--theme-spacing-xs);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-report__header > *,
:where([data-runtime-theme="target-u"]) .analysis-gate-card__identity p,
:where([data-runtime-theme="target-u"]) .analysis-gate-card__identity h4,
:where([data-runtime-theme="target-u"]) .analysis-gate-card__hint,
:where([data-runtime-theme="target-u"]) .analysis-gate-card__note {
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-card {
    display: grid;
    gap: var(--theme-spacing-lg);
    min-width: 0;
    padding: var(--theme-spacing-card);
    border: 1px solid var(--theme-color-border);
    border-radius: var(--theme-radius-entity);
    background: var(--theme-color-surface);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-card__header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: var(--theme-spacing-md);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-card__identity {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr);
    align-items: start;
    gap: var(--theme-spacing-md);
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-card__index {
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border-radius: var(--theme-radius-marker);
    background: var(--theme-color-primary-soft);
    color: var(--theme-color-primary);
    font-family: var(--theme-font-data);
    font-variant-numeric: tabular-nums;
    font-size: var(--theme-text-supporting);
    font-weight: 700;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-card__status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-card__hint {
    color: var(--theme-color-text);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-card__note {
    padding-inline-start: var(--theme-spacing-md);
    border-inline-start: 2px solid var(--theme-color-border-strong);
}

/* Gate report body (Spec 175): the reader's own numbers, one comparison chart,
 * then the yearly numbers behind a disclosure. Layout follows the report's own
 * width, because the same partial renders in a dialog and on the department
 * page.
 */
:where([data-runtime-theme="target-u"]) .analysis-gate-report {
    container-type: inline-size;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-report__title > h3 {
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--theme-spacing-xs) var(--theme-spacing-card);
    margin: var(--theme-spacing-md) 0 0;
    padding: 0;
    list-style: none;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-legend li {
    display: inline-flex;
    align-items: center;
    gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-legend__key {
    display: block;
    flex: 0 0 auto;
    width: 26px;
    height: 7px;
    background: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-legend__key--you {
    height: 14px;
    background: var(--theme-color-primary-soft);
    box-shadow: inset 1px 0 0 var(--theme-color-primary), inset -1px 0 0 var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-legend__key--ahead {
    height: 3px;
    background: var(--theme-color-risk-safe-text);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-legend__key--behind {
    height: 3px;
    background: var(--theme-color-risk-risk-text);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-legend__key--lap {
    background: var(--theme-color-risk-hard-text);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-tone--safe { color: var(--theme-color-risk-safe-text); }
:where([data-runtime-theme="target-u"]) .analysis-gate-tone--hard { color: var(--theme-color-risk-hard-text); }
:where([data-runtime-theme="target-u"]) .analysis-gate-tone--risk { color: var(--theme-color-risk-risk-text); }
:where([data-runtime-theme="target-u"]) .analysis-gate-tone--unavailable { color: var(--theme-color-muted); }

/* Baseline numbers: the reference every row below is compared against. */
:where([data-runtime-theme="target-u"]) .analysis-gate-self {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1.25fr 1fr;
    gap: var(--theme-spacing-lg) var(--theme-spacing-2xl);
    margin: 0;
    padding-block: var(--theme-spacing-md) var(--theme-spacing-lg);
    border-block: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-self dt,
:where([data-runtime-theme="target-u"]) .analysis-gate-self dd {
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-self dd {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 var(--theme-spacing-xs);
    margin-top: 2px;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-self__you {
    color: var(--theme-color-primary);
}

/* Comparison chart. The unit switch is a pair of radios, so it works without
 * script after an HTMX swap; the radios precede the panels they control.
 */
/* The visually hidden radios are absolutely positioned. Anchor them here:
 * left to the dialog shell, focusing one scrolls that clipped shell itself and
 * pushes the dialog header out of view.
 */
:where([data-runtime-theme="target-u"]) .analysis-gate-glance {
    position: relative;
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__cap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--theme-spacing-xs) var(--theme-spacing-lg);
    margin-bottom: var(--theme-spacing-md);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--theme-spacing-xs) var(--theme-spacing-sm);
    margin: 0;
    color: var(--theme-color-foreground);
    font-size: var(--theme-text-dense-label);
    font-weight: var(--theme-text-dense-label--font-weight);
    line-height: var(--theme-text-dense-label--line-height);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__pick {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__pick > span {
    color: var(--theme-color-border-strong);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__pick label {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding-inline: 1px;
    border-bottom: 1px solid transparent;
    color: var(--theme-color-muted);
    cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .analysis-gate-glance__pick label:hover {
        border-bottom-color: var(--theme-color-border-strong);
        color: var(--theme-color-foreground);
    }
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__radio[value="pr"]:checked ~ * label[data-unit="pr"],
:where([data-runtime-theme="target-u"]) .analysis-gate-glance__radio[value="rank"]:checked ~ * label[data-unit="rank"] {
    border-bottom-color: var(--theme-color-primary);
    color: var(--theme-color-primary);
    font-weight: 600;
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .analysis-gate-glance__radio[value="pr"]:focus-visible ~ * label[data-unit="pr"],
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .analysis-gate-glance__radio[value="rank"]:focus-visible ~ * label[data-unit="rank"] {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__radio[value="pr"]:not(:checked) ~ [data-unit-panel="pr"],
:where([data-runtime-theme="target-u"]) .analysis-gate-glance__radio[value="pr"]:not(:checked) ~ * [data-unit-panel="pr"],
:where([data-runtime-theme="target-u"]) .analysis-gate-glance__radio[value="rank"]:not(:checked) ~ [data-unit-panel="rank"],
:where([data-runtime-theme="target-u"]) .analysis-gate-glance__radio[value="rank"]:not(:checked) ~ * [data-unit-panel="rank"] {
    display: none;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__row,
:where([data-runtime-theme="target-u"]) .analysis-gate-glance__axis {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 68px;
    align-items: center;
    column-gap: var(--theme-spacing-md);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__row {
    min-height: 24px;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__label {
    color: var(--theme-color-muted);
    font-size: 0.8125rem;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__row--you .analysis-gate-glance__label {
    color: var(--theme-color-primary);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    font-weight: 600;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__verdict {
    font-size: var(--theme-text-supporting);
    font-weight: 600;
    line-height: var(--theme-text-supporting--line-height);
    white-space: nowrap;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-glance__axis {
    margin-top: var(--theme-spacing-xs);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-rail {
    position: relative;
    height: 24px;
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-rail::before {
    content: "";
    position: absolute;
    inset: 50% 0 auto;
    height: 1px;
    background: var(--theme-color-border-strong);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-rail--empty::before {
    border-top: 1px dashed var(--theme-color-border-strong);
    background: none;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-rail i {
    position: absolute;
    display: block;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-rail__tick {
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-rail__you {
    top: 0;
    bottom: 0;
    min-width: 2px;
    background: var(--theme-color-primary-soft);
    box-shadow: inset 1px 0 0 var(--theme-color-primary), inset -1px 0 0 var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-rail__you--solid {
    top: calc(50% - 4px);
    bottom: auto;
    height: 9px;
    background: var(--theme-color-primary);
    box-shadow: none;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-rail__gate,
:where([data-runtime-theme="target-u"]) .analysis-gate-rail__lap {
    top: calc(50% - 3px);
    height: 7px;
    min-width: 2px;
    background: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-rail__lap {
    background: var(--theme-color-risk-hard-text);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-rail__gap {
    top: calc(50% - 1px);
    height: 3px;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-rail__gap--green { background: var(--theme-color-risk-safe-text); }
:where([data-runtime-theme="target-u"]) .analysis-gate-rail__gap--red { background: var(--theme-color-risk-risk-text); }

:where([data-runtime-theme="target-u"]) .analysis-gate-axis {
    position: relative;
    height: 18px;
    color: var(--theme-color-muted);
    font-family: var(--theme-font-data);
    font-size: var(--theme-text-supporting);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    line-height: 18px;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-axis span {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    white-space: nowrap;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-axis span.is-first { transform: none; }
:where([data-runtime-theme="target-u"]) .analysis-gate-axis span.is-last { transform: translateX(-100%); }

/* Yearly numbers. One DOM for both layouts: a grid with table roles. */
:where([data-runtime-theme="target-u"]) .analysis-gate-history {
    min-width: 0;
    margin-bottom: calc(var(--theme-spacing-md) * -1);
    border-top: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-history[open] {
    margin-bottom: calc(var(--theme-spacing-xs) * -1);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-history__summary {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--theme-spacing-xs) var(--theme-spacing-card);
    min-height: 44px;
    padding: 11px 0 11px var(--theme-spacing-xl);
    color: var(--theme-color-primary);
    font-size: var(--theme-text-control);
    font-weight: var(--theme-text-control--font-weight);
    line-height: var(--theme-text-control--line-height);
    letter-spacing: var(--theme-text-control--letter-spacing);
    list-style: none;
    cursor: pointer;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-history__summary::-webkit-details-marker {
    display: none;
}

/* The year tally is a reading aid beside the disclosure label, not a status
 * chip: ink alone carries the level so the summary row stays calm.
 */
:where([data-runtime-theme="target-u"]) .analysis-gate-history__tally {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--theme-spacing-xs) var(--theme-spacing-lg);
    font-size: var(--theme-text-supporting);
    font-weight: 600;
    letter-spacing: var(--theme-text-supporting--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-history__tally .ui-type-data {
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-history__count {
    color: var(--theme-color-muted);
    font-weight: 500;
}

/* The disclosure arrow leads the label: it points right while closed and
 * turns down when the table opens. The shared chevron is drawn pointing down.
 */
:where([data-runtime-theme="target-u"]) .analysis-gate-history__summary .ico {
    position: absolute;
    top: 14px;
    left: 0;
    transform: rotate(-90deg);
    transition: transform var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-history[open]
.analysis-gate-history__summary .ico {
    transform: none;
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.analysis-gate-history__summary:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .analysis-gate-history__summary:hover {
        background: var(--theme-color-surface-muted);
    }
}

:where([data-runtime-theme="target-u"]) .analysis-gate-table {
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-table__head,
:where([data-runtime-theme="target-u"]) .analysis-gate-table__row {
    display: grid;
    grid-template-columns: 72px minmax(0, .5fr) minmax(0, 1.3fr) minmax(0, 1fr) 88px;
    align-items: baseline;
    column-gap: var(--theme-spacing-2xl);
    padding: 9px var(--theme-spacing-md);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-table__head {
    padding-block: var(--theme-spacing-sm);
    border-bottom: 1px solid var(--theme-color-border-strong);
    color: var(--theme-color-muted);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
    line-height: var(--theme-text-supporting--line-height);
    letter-spacing: var(--theme-text-supporting--letter-spacing);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-table__head > :last-child {
    justify-self: end;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-table__row + .analysis-gate-table__row {
    border-top: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-table__pair {
    display: grid;
    grid-template-columns: minmax(0, .85fr) minmax(0, 1fr);
    column-gap: var(--theme-spacing-md);
    text-align: right;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-table__unit,
:where([data-runtime-theme="target-u"]) .analysis-gate-table__mhead {
    display: none;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-table__year {
    color: var(--theme-color-foreground);
    font-size: var(--theme-text-dense-label);
    font-weight: 600;
    line-height: var(--theme-text-dense-label--line-height);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-table__year .ui-type-data {
    margin-right: 2px;
    font-weight: var(--theme-text-data-lead--font-weight);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-table__verdict {
    align-self: center;
    justify-self: end;
}

:where([data-runtime-theme="target-u"]) .analysis-gate-margin {
    font-weight: var(--theme-text-data-lead--font-weight);
}

:where([data-runtime-theme="target-u"]) .analysis-gate-margin--green { color: var(--theme-color-risk-safe-text); }
:where([data-runtime-theme="target-u"]) .analysis-gate-margin--yellow { color: var(--theme-color-risk-hard-text); }
:where([data-runtime-theme="target-u"]) .analysis-gate-margin--red { color: var(--theme-color-risk-risk-text); }
:where([data-runtime-theme="target-u"]) .analysis-gate-margin--unknown { color: var(--theme-color-muted); }

:where([data-runtime-theme="target-u"]) .analysis-gate-table__note {
    margin: 0;
    padding: 10px var(--theme-spacing-md) 0;
    border-top: 1px solid var(--theme-color-border);
}

@container (max-width: 899px) {
    :where([data-runtime-theme="target-u"]) .analysis-gate-table__head,
    :where([data-runtime-theme="target-u"]) .analysis-gate-table__row {
        grid-template-columns: 60px minmax(0, .5fr) minmax(0, 1.3fr) minmax(0, 1fr) 84px;
        column-gap: var(--theme-spacing-card);
    }
}

@container (max-width: 759px) {
    :where([data-runtime-theme="target-u"]) .analysis-gate-self {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px var(--theme-spacing-card);
    }

    :where([data-runtime-theme="target-u"]) .analysis-gate-glance__pick {
        gap: var(--theme-spacing-sm);
    }

    :where([data-runtime-theme="target-u"]) .analysis-gate-glance__pick label {
        min-height: 28px;
        padding-inline: 3px;
    }

    :where([data-runtime-theme="target-u"]) .analysis-gate-table__head {
        display: none;
    }

    :where([data-runtime-theme="target-u"]) .analysis-gate-table__mhead {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) auto;
        column-gap: var(--theme-spacing-md);
        padding: var(--theme-spacing-sm) var(--theme-spacing-md);
        border-bottom: 1px solid var(--theme-color-border-strong);
        color: var(--theme-color-muted);
        font-size: var(--theme-text-supporting);
        font-weight: var(--theme-text-supporting--font-weight);
        line-height: var(--theme-text-supporting--line-height);
        letter-spacing: var(--theme-text-supporting--letter-spacing);
    }

    :where([data-runtime-theme="target-u"]) .analysis-gate-table__row {
        grid-template-columns: minmax(0, 1fr) auto;
        row-gap: 6px;
        padding: 14px var(--theme-spacing-md);
    }

    :where([data-runtime-theme="target-u"]) .analysis-gate-table__year { grid-area: 1 / 1; }
    :where([data-runtime-theme="target-u"]) .analysis-gate-table__verdict { grid-area: 1 / 2; }

    :where([data-runtime-theme="target-u"]) .analysis-gate-table__pair {
        grid-column: 1 / -1;
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        column-gap: var(--theme-spacing-md);
        text-align: left;
    }

    :where([data-runtime-theme="target-u"]) .analysis-gate-table__pair > :last-child {
        margin-left: auto;
    }

    :where([data-runtime-theme="target-u"]) .analysis-gate-table__unit {
        display: block;
        flex: 0 0 44px;
        color: var(--theme-color-muted);
        font-size: var(--theme-text-supporting);
        font-style: normal;
        font-weight: var(--theme-text-supporting--font-weight);
        line-height: var(--theme-text-supporting--line-height);
        letter-spacing: var(--theme-text-supporting--letter-spacing);
    }
}

/* Overlay and toast -------------------------------------------------------- */
:where([data-runtime-theme="target-u"]) .ui-overlay {
    position: fixed;
    z-index: 120;
    inset: 0;
    display: grid;
    place-items: center;
    padding: var(--theme-spacing-xl);
    background: var(--theme-color-overlay-scrim);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--theme-motion-duration-overlay) var(--theme-motion-ease-overlay);
}

:where([data-runtime-theme="target-u"]) .ui-overlay[data-ui-dialog-state="open"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    animation: ui-overlay-scrim-in 180ms var(--theme-motion-ease-overlay) both;
}

/* The overlay paints the scrim and positions the existing dialog surface. */
:where([data-runtime-theme="target-u"]) :where(dialog).ui-overlay {
    margin: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: 0;
    color: inherit;
    overflow: visible;
}

:where([data-runtime-theme="target-u"]) dialog.ui-overlay::backdrop {
    background: transparent;
}

:where([data-runtime-theme="target-u"]) .ui-overlay--mobile-full {
    border-radius: var(--theme-radius-mobile-overlay);
}

:where([data-runtime-theme="target-u"]) .ui-dialog {
    box-sizing: border-box;
    /* Column flow rather than three fixed rows: the scrolling region is the
       body itself, so a Dialog may also carry a persistent status band
       without the free space landing on the wrong child. */
    display: flex;
    flex-direction: column;
    width: min(780px, calc(100vw - var(--theme-spacing-4xl)));
    max-height: min(780px, calc(100dvh - var(--theme-spacing-4xl)));
    overflow: hidden;
    overflow-anchor: none;
    border: 1px solid var(--theme-color-border-strong);
    border-radius: var(--theme-radius-dialog);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
    box-shadow: var(--theme-shadow-overlay);
    transform-origin: center;
}

:where([data-runtime-theme="target-u"])
.ui-overlay[data-ui-dialog-state="open"] .ui-dialog {
    animation: ui-dialog-in 220ms var(--theme-motion-ease-overlay) both;
}

@keyframes ui-overlay-scrim-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ui-dialog-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

:where([data-runtime-theme="target-u"]) .ui-overlay[data-ui-dialog-size="wide"] .ui-dialog {
    width: min(68rem, 100%);
}

/* Guarded so the mobile full-screen overlay keeps owning height below 48rem. */
@media (min-width: 48rem) {
    :where([data-runtime-theme="target-u"]) .ui-overlay[data-ui-dialog-size="wide"] .ui-dialog {
        max-height: min(880px, calc(100dvh - var(--theme-spacing-4xl)));
    }
}

:where([data-runtime-theme="target-u"]) body[data-ui-dialog-lock="true"] {
    overflow: hidden;
}

:where([data-runtime-theme="target-u"]) .ui-dialog__header {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--theme-spacing-lg);
    padding: 20px 22px;
    border-bottom: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__identity {
    flex: 1 1 0;
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__eyebrow,
:where([data-runtime-theme="target-u"]) .analysis-dialog__meta {
    margin: 0;
    color: var(--theme-color-muted);
    font-size: var(--theme-text-supporting);
    line-height: 1.55;
}

/* A dialog opened from an Entity card carries that card's identity, so the
 * school line and the name keep the card's face and ink; only the name steps
 * up one registered size for the dialog altitude.
 */
:where([data-runtime-theme="target-u"]) .analysis-dialog__eyebrow {
    margin-block-end: 2px;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__identity .ui-type-entity-title {
    color: var(--theme-color-primary);
    font-size: var(--theme-text-section-title);
    line-height: var(--theme-text-section-title--line-height);
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__status-line {
    display: flex;
    flex-wrap: wrap;
    gap: var(--theme-spacing-sm);
    margin-block-end: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__meta {
    margin-block-start: 3px;
    font-family: var(--theme-font-data);
    font-variant-numeric: tabular-nums;
}

/*
 * Dialog close is the same quiet, direct icon-control language as Favorite:
 * a 44px owner around a 20px glyph. The icon does not own focus or colour.
 */
:where([data-runtime-theme="target-u"]) .ui-dialog__close {
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    margin: -10px -10px -10px 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--theme-radius-control);
    background: transparent;
    color: var(--theme-color-muted);
    cursor: pointer;
    transition:
        color var(--theme-motion-duration-interaction),
        background-color var(--theme-motion-duration-interaction);
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .ui-dialog__close:hover {
        background: var(--theme-color-surface-muted);
        color: var(--theme-color-primary);
    }
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-dialog__close:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

/* Persistent warning/error band: stays beside the header instead of
   scrolling away with the swapped body content. */
:where([data-runtime-theme="target-u"]) .ui-dialog__status {
    flex: 0 0 auto;
    margin: var(--theme-spacing-md) var(--theme-spacing-card) 0;
}

:where([data-runtime-theme="target-u"]) .ui-dialog__status:empty {
    display: none;
}

:where([data-runtime-theme="target-u"]) .ui-dialog__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 22px;
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__body {
    display: grid;
    align-content: start;
    gap: var(--theme-spacing-2xl);
}

/*
 * Insight content follows the proven old-page reading order — status, key
 * numbers, supporting facts, evidence — while keeping the canonical Dialog
 * surface flat. It is intentionally not an Entity card inside another owner.
 */
:where([data-runtime-theme="target-u"]) .analysis-insight-summary {
    min-width: 0;
}

/* Insight summary (results dialog). Three bands, each one grid:
 * verdict beside the decision numbers, then the profile facts as an even
 * label-over-value grid, then this year's changes. Actions live in the dialog
 * header, so nothing interactive floats inside the reading area.
 */
/*
 * Header corner, two rows: 收藏學系 beside Close, then the preference action
 * spanning both columns, so the button is exactly as wide as the pair above
 * it. The row lifts by 10px so Close keeps its usual place against the
 * header's top edge; every box edge stays on the header's content edge.
 */
:where([data-runtime-theme="target-u"]) .analysis-dialog__actions {
    display: grid;
    flex: 0 0 auto;
    grid-template-areas:
        "favorite close"
        "preference preference";
    grid-template-columns: auto auto;
    align-items: center;
    row-gap: var(--theme-spacing-xs);
    margin-block-start: -10px;
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__actions .ui-dialog__close {
    grid-area: close;
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__actions > .ui-favorite-control {
    grid-area: favorite;
    /*
     * Reserve the pressed label (已收藏學系, five glyphs) so toggling never
     * resizes the corner: icon + gap + 5em + inline padding + border. The
     * heart stays put and the label grows into the reserved space.
     */
    min-width: calc(16px + var(--theme-spacing-sm) + 5em + 2 * var(--theme-spacing-md) + 2px);
    justify-content: start;
    /* Same control type as the preference button under it, not inherited body text. */
    font-size: var(--theme-text-control);
    font-weight: var(--theme-text-control--font-weight);
    line-height: var(--theme-text-control--line-height);
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__actions > .ui-favorite-control > .ico {
    width: 16px;
    height: 16px;
    --theme-icon-stroke: 2;
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__actions > .offering-preference-action {
    display: flex;
    grid-area: preference;
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__actions > .offering-preference-action > form {
    display: flex;
    flex: 1 1 auto;
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__actions > .offering-preference-action .ui-button {
    flex: 1 1 auto;
    justify-content: center;
}

/* The two guides sit on the code line as inline text links. */
:where([data-runtime-theme="target-u"]) .analysis-dialog__meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__links {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--theme-spacing-sm);
    font-size: var(--theme-text-supporting);
    line-height: 1.55;
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__links-separator {
    color: var(--theme-color-border-strong);
}

:where([data-runtime-theme="target-u"]) .analysis-dialog__links > .analysis-dialog__detail-link {
    margin-inline: 0;
    white-space: nowrap;
}

/* Preflight makes svg a block; inside an inline link it must stay on the line. */
:where([data-runtime-theme="target-u"]) .analysis-dialog__detail-link > .ico {
    display: inline-block;
    margin-inline-start: 2px;
    vertical-align: -1px;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-lead {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: var(--theme-spacing-lg) var(--theme-spacing-3xl);
    padding-block-end: var(--theme-spacing-card);
}

:where([data-runtime-theme="target-u"]) .analysis-insight-verdict {
    display: grid;
    gap: var(--theme-spacing-sm);
    min-width: 0;
    max-width: 68ch;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-verdict > p {
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-summary__status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--theme-spacing-sm);
}

/* Labels share one line and the numbers share one baseline, although the
 * lead number is a size larger: from 48rem the wrappers step aside so every
 * dt and dd is an item of the same two-row grid.
 */
:where([data-runtime-theme="target-u"]) .analysis-insight-kpis {
    display: grid;
    grid-template-rows: auto auto;
    grid-auto-flow: column;
    align-items: baseline;
    gap: 2px var(--theme-spacing-2xl);
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-kpis > div {
    display: contents;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-kpis dt {
    white-space: nowrap;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-kpis dd {
    margin: 0;
}

/* Secondary numbers keep the KPI face one registered size down from the lead. */
:where([data-runtime-theme="target-u"]) .analysis-insight-kpis__secondary .ui-type-decision-kpi {
    font-size: var(--theme-text-section-title);
    line-height: var(--theme-text-section-title--line-height);
}

:where([data-runtime-theme="target-u"]) .analysis-insight-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
    gap: var(--theme-spacing-lg) var(--theme-spacing-xl);
    margin: 0;
    padding-block: var(--theme-spacing-lg);
    border-block: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .analysis-insight-facts > div {
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-facts dt {
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .analysis-insight-facts dd {
    min-width: 0;
    margin: 2px 0 0;
    overflow-wrap: anywhere;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-changes {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--theme-spacing-xs) var(--theme-spacing-lg);
    padding-block: var(--theme-spacing-md);
    border-block-end: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .analysis-insight-changes > p {
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-changes__text {
    min-width: 0;
    color: var(--theme-color-foreground);
    font-size: var(--theme-text-body-compact);
    font-weight: var(--theme-text-body-compact--font-weight);
    line-height: var(--theme-text-body-compact--line-height);
}

@media (max-width: 47.999rem) {
    /*
     * Narrow: Close stays beside the title; 收藏學系 and the preference action
     * share the next row, the button taking the remaining width.
     */
    :where([data-runtime-theme="target-u"]) .ui-dialog__header--insight:has(.analysis-dialog__actions > .ui-favorite-control) {
        flex-wrap: wrap;
        row-gap: var(--theme-spacing-md);
        column-gap: var(--theme-spacing-sm);
    }

    /* The guides' line keeps a small breath under the code line. */
    :where([data-runtime-theme="target-u"]) .analysis-dialog__meta-row {
        row-gap: var(--theme-spacing-xs);
    }

    :where([data-runtime-theme="target-u"]) .ui-dialog__header--insight:has(.analysis-dialog__actions > .ui-favorite-control) .analysis-dialog__identity {
        flex: 1 1 calc(100% - 52px);
    }

    /* The guides take their own line under the code, without a leading dot. */
    :where([data-runtime-theme="target-u"]) .analysis-dialog__links {
        flex-basis: 100%;
    }

    :where([data-runtime-theme="target-u"]) .analysis-dialog__links > .analysis-dialog__links-separator:first-child {
        display: none;
    }

    :where([data-runtime-theme="target-u"]) .analysis-dialog__actions {
        display: contents;
    }

    :where([data-runtime-theme="target-u"]) .analysis-dialog__actions .ui-dialog__close {
        order: 1;
        align-self: flex-start;
        margin: -6px -12px 0 0;
    }

    :where([data-runtime-theme="target-u"]) .analysis-dialog__actions > .ui-favorite-control {
        order: 2;
        margin-inline-start: calc(var(--theme-spacing-md) * -1);
    }

    :where([data-runtime-theme="target-u"]) .analysis-dialog__actions > .offering-preference-action {
        order: 3;
        flex: 1 1 0;
    }

    :where([data-runtime-theme="target-u"]) .analysis-insight-lead {
        grid-template-columns: minmax(0, 1fr);
        align-items: start;
    }

    :where([data-runtime-theme="target-u"]) .analysis-insight-kpis {
        grid-template-rows: none;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-flow: row;
        align-items: end;
        gap: var(--theme-spacing-lg) var(--theme-spacing-xl);
    }

    :where([data-runtime-theme="target-u"]) .analysis-insight-kpis > div {
        display: block;
        min-width: 0;
    }

    :where([data-runtime-theme="target-u"]) .analysis-insight-kpis__lead {
        grid-column: 1 / -1;
    }

    :where([data-runtime-theme="target-u"]) .analysis-insight-facts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

:where([data-runtime-theme="target-u"]) .analysis-insight-methods {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--theme-spacing-sm) var(--theme-spacing-lg);
    margin-block-end: var(--theme-spacing-lg);
}

:where([data-runtime-theme="target-u"]) .analysis-insight-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0;
    border-block: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .analysis-insight-kpi-grid > div {
    min-width: 0;
    padding: var(--theme-spacing-lg);
    text-align: center;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-kpi-grid > div + div {
    border-inline-start: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .analysis-insight-kpi-grid dd {
    margin: 6px 0 0;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-kpi-unit {
    color: var(--theme-color-muted);
    font-family: var(--theme-font-data);
    font-variant-numeric: tabular-nums;
    font-size: var(--theme-text-body);
    font-weight: 500;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-position {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: var(--theme-spacing-sm) var(--theme-spacing-lg);
    margin: -1px 0 0;
    padding: var(--theme-spacing-md) var(--theme-spacing-lg);
    border-block: 1px solid var(--theme-color-border);
    color: var(--theme-color-muted);
    font-size: var(--theme-text-supporting);
}

:where([data-runtime-theme="target-u"]) .analysis-insight-position strong {
    color: var(--theme-color-foreground);
    font-size: var(--theme-text-body);
    font-weight: 600;
}

:where([data-runtime-theme="target-u"]) .analysis-insight-error-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--theme-spacing-sm);
    margin-block-start: var(--theme-spacing-md);
}

:where([data-runtime-theme="target-u"]) .ui-dialog__actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--theme-spacing-sm);
    padding: 14px 22px;
    border-top: 1px solid var(--theme-color-border);
    background: var(--theme-color-surface);
}

:where([data-runtime-theme="target-u"]) .ui-dialog__actions:not(:has(> :not([hidden]))) {
    display: none;
}

/* The Dialog surface and every programmatic focus destination use the shared
   owner ring. This covers async Alert/status targets as well as headings. */
:where([data-runtime-theme="target-u"]) .ui-dialog:focus,
:where([data-runtime-theme="target-u"]) .ui-dialog [tabindex="-1"]:focus {
    outline: none;
    box-shadow: none;
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-dialog:focus-visible,
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-dialog [tabindex="-1"]:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

:where([data-runtime-theme="target-u"]) .ui-toast {
    box-sizing: border-box;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: var(--theme-spacing-md);
    width: min(24rem, calc(100vw - var(--theme-spacing-2xl)));
    padding: 14px;
    border: 1px solid var(--theme-color-border-strong);
    border-radius: var(--theme-radius-toast);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
    box-shadow: var(--theme-shadow-overlay);
    pointer-events: auto;
    transition:
        opacity var(--theme-motion-duration-overlay) var(--theme-motion-ease-overlay),
        transform var(--theme-motion-duration-overlay) var(--theme-motion-ease-overlay);
}

:where([data-runtime-theme="target-u"]) [data-ui-toast-region] {
    position: fixed;
    z-index: 130;
    inset-block-start: calc(4rem + var(--theme-spacing-lg));
    inset-inline-end: var(--theme-spacing-lg);
    display: grid;
    justify-items: end;
    gap: var(--theme-spacing-sm);
    width: min(24rem, calc(100vw - var(--theme-spacing-2xl)));
    pointer-events: none;
}

:where([data-runtime-theme="target-u"]) [data-ui-toast-marker] {
    width: 10px;
    height: 10px;
    margin-block-start: 5px;
    background: var(--theme-color-status-info-border);
}

:where([data-runtime-theme="target-u"]) [data-ui-toast-content] {
    display: grid;
    gap: var(--theme-spacing-xs);
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) [data-ui-toast-label] {
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-control);
    font-weight: var(--theme-text-control--font-weight);
    line-height: var(--theme-text-control--line-height);
}

:where([data-runtime-theme="target-u"]) [data-ui-toast-message] {
    margin: 0;
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    line-height: var(--theme-text-supporting--line-height);
}

:where([data-runtime-theme="target-u"]) .ui-toast:has(> [data-ui-toast-action]) {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
}

:where([data-runtime-theme="target-u"]) .ui-toast__action {
    align-self: center;
    justify-self: end;
    width: fit-content;
    min-height: 36px;
    flex-shrink: 0;
    padding: 0 var(--theme-spacing-md);
    border: 1px solid var(--theme-color-border-strong);
    border-radius: 0;
    background: var(--theme-color-surface);
    color: var(--theme-color-primary);
    font-size: var(--theme-text-control);
    font-weight: var(--theme-text-control--font-weight);
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .ui-toast__action:hover {
        background: var(--theme-color-surface-muted);
        border-color: var(--theme-color-primary);
        color: var(--theme-color-primary-light);
    }
}

@media (max-width: 767px), (pointer: coarse) {
    :where([data-runtime-theme="target-u"]) .ui-toast__action {
        min-width: 44px;
        min-height: 44px;
    }
}

@media (max-width: 359px) {
    :where([data-runtime-theme="target-u"]) .ui-toast:has(> [data-ui-toast-action]) {
        grid-template-columns: auto minmax(0, 1fr) auto;
        row-gap: var(--theme-spacing-sm);
    }
    :where([data-runtime-theme="target-u"]) .ui-toast__action {
        grid-area: 2 / 2;
        justify-self: start;
    }
    :where([data-runtime-theme="target-u"]) .ui-toast__close {
        grid-area: 1 / 3;
    }
}

:where([data-runtime-theme="target-u"]) .ui-toast__close {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: -10px -10px -10px 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--theme-radius-control);
    background: transparent;
    color: var(--theme-color-muted);
    cursor: pointer;
    transition:
        color var(--theme-motion-duration-interaction),
        background-color var(--theme-motion-duration-interaction);
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .ui-toast__close:hover {
        background: var(--theme-color-surface-muted);
        color: var(--theme-color-primary);
    }
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-toast__close:focus-visible,
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-toast__action:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

:where([data-runtime-theme="target-u"]) .ui-toast--info [data-ui-toast-marker] {
    background: var(--theme-color-status-info-border);
}

:where([data-runtime-theme="target-u"]) .ui-toast--success [data-ui-toast-marker] {
    background: var(--theme-color-status-success-border);
}

:where([data-runtime-theme="target-u"]) .ui-toast--warning [data-ui-toast-marker] {
    background: var(--theme-color-status-warning-border);
}

:where([data-runtime-theme="target-u"]) .ui-toast--error [data-ui-toast-marker] {
    background: var(--theme-color-danger-border);
}

@media (max-width: 767px) {
    :where([data-runtime-theme="target-u"]) [data-ui-toast-region] {
        inset-block-start: auto;
        inset-block-end: calc(
            var(--theme-spacing-lg) + env(safe-area-inset-bottom, 0px)
        );
    }

    :where([data-runtime-theme="target-u"]) .ui-toast {
        cursor: pointer;
        touch-action: manipulation;
    }
}

:where([data-runtime-theme="target-u"]) .ui-toast[data-ui-toast-state="closing"] {
    opacity: 0;
    transform: translateX(var(--theme-spacing-lg));
}

/* Shared navigation names are present before shell migration so templates can
   move one control at a time without route-local visual rules. */
/* ---------------------------------------------------------------------------
   Public shell navigation.  Layout lives here, in the shared owner, so the
   navbar no longer depends on the Tailwind browser runtime to have a shape.
   --------------------------------------------------------------------------- */
:where([data-runtime-theme="target-u"]) .ui-nav {
    anchor-name: --ui-navbar;
    position: fixed;
    inset: 0 0 auto;
    z-index: 50;
    border-bottom: 1px solid var(--theme-color-border);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
}

/* Accessible-only text.  Previously supplied by the Tailwind browser runtime,
   which meant every sr-only label became visible whenever that script did not
   run.  The shared owner defines it so the shell never depends on the CDN. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

:where([data-runtime-theme="target-u"]) .ui-nav__link,
:where([data-runtime-theme="target-u"]) .ui-nav__trigger {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: var(--theme-spacing-xs);
    padding-inline: var(--theme-spacing-md);
    border: 1px solid transparent;
    border-radius: var(--theme-radius-control);
    background: transparent;
    color: var(--theme-color-muted);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-control);
    font-weight: var(--theme-text-control--font-weight);
    line-height: var(--theme-text-control--line-height);
    text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .ui-nav__trigger:where([data-ui-popover-trigger]):hover,
    :where([data-runtime-theme="target-u"]) :where(.ui-nav__menu, .ui-mobile-nav) :is(.ui-nav__link, .ui-nav__trigger):hover {
        background: color-mix(in oklch, var(--theme-color-primary-soft) 70%, var(--theme-color-surface));
        color: var(--theme-color-primary-light);
    }

    /* Logout ends the session: its row turns mineral red, never the blue wash (DESIGN v2.24).
       danger-soft matches the blue wash's lightness so the red row is not darker (v2.28). */
    :where([data-runtime-theme="target-u"]) .ui-nav__trigger--destructive:hover {
        background: var(--theme-color-danger-soft);
        color: var(--theme-color-danger);
    }
}

:where([data-runtime-theme="target-u"]) .ui-nav__link[aria-current="page"],
:where([data-runtime-theme="target-u"]) .ui-nav__link[aria-current="location"],
:where([data-runtime-theme="target-u"]) .ui-nav__trigger[aria-current="true"],
:where([data-runtime-theme="target-u"]) .ui-nav__trigger[aria-expanded="true"] {
    background: var(--theme-color-primary-soft);
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) :where(.ui-nav__menu, .ui-mobile-nav) .ui-nav__link[aria-current] {
    background: var(--theme-color-surface-selected);
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

/*
 * Top-level route entries share the lock-on mark language: no marks at rest,
 * arms fly in from the surface edge on hover, and the current route
 * keeps a resting frame — "you are here". Scoped to the bar so the account
 * trigger, popover menu rows and the mobile overlay stay plain.
 */
:where([data-runtime-theme="target-u"]) .ui-nav__bar > li > .ui-nav__link,
:where([data-runtime-theme="target-u"]) .ui-nav__bar > li > .ui-nav__trigger {
    position: relative;
}

:where([data-runtime-theme="target-u"]) .ui-nav__bar > li > .ui-nav__link::before,
:where([data-runtime-theme="target-u"]) .ui-nav__bar > li > .ui-nav__trigger::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(currentColor, currentColor) left top / 11px 1px no-repeat,
        linear-gradient(currentColor, currentColor) left top / 1px 11px no-repeat,
        linear-gradient(currentColor, currentColor) right bottom / 11px 1px no-repeat,
        linear-gradient(currentColor, currentColor) right bottom / 1px 11px no-repeat;
    color: var(--theme-color-primary);
    opacity: 0;
    pointer-events: none;
    transition:
        inset var(--theme-motion-duration-interaction),
        opacity var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .ui-nav__bar > li > .ui-nav__trigger[aria-expanded="true"]::before {
    inset: 4px;
    opacity: 1;
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-nav__link:focus-visible,
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.ui-nav__trigger:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

/* The current route rests on a quiet frame, below interaction opacity. */
:where([data-runtime-theme="target-u"]) .ui-nav__bar > li > .ui-nav__link[aria-current="page"]::before,
:where([data-runtime-theme="target-u"]) .ui-nav__bar > li > .ui-nav__trigger[aria-current="true"]::before {
    inset: 4px;
    opacity: 0.55;
}

@media (hover: hover) and (pointer: fine) {
    /* A direct top-level route (校系探索) and the signed-out 登入 link take the
       same wash and ink as the menu triggers beside them (DESIGN v2.25). */
    :where([data-runtime-theme="target-u"]) .ui-nav__bar > li > .ui-nav__link:hover,
    :where([data-runtime-theme="target-u"]) .ui-nav__account > .ui-nav__link:hover {
        background: color-mix(in oklch, var(--theme-color-primary-soft) 70%, var(--theme-color-surface));
        color: var(--theme-color-primary-light);
    }

    :where([data-runtime-theme="target-u"]) .ui-nav__bar > li > .ui-nav__link:hover::before,
    :where([data-runtime-theme="target-u"]) .ui-nav__bar > li > .ui-nav__trigger:hover::before {
        inset: 4px;
        opacity: 1;
    }
}

:where([data-runtime-theme="target-u"]) .ui-nav__trigger {
    gap: var(--theme-spacing-sm);
    cursor: pointer;
}

:where([data-runtime-theme="target-u"]) .ui-nav__shell {
    display: flex;
    box-sizing: border-box;
    width: 100%;
    max-width: var(--theme-shell-max-width);
    min-height: 4rem;
    align-items: center;
    gap: var(--theme-spacing-lg);
    margin-inline: auto;
    padding-inline: var(--theme-shell-padding-inline);
}

:where([data-runtime-theme="target-u"]) .ui-nav__brand {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    padding-inline: var(--theme-spacing-xs);
    color: var(--theme-color-primary);
    text-decoration: none;
}

/* Brand wordmark (DESIGN.md 品牌字標): the drawn TARGET U letters set in the house
   font Target U Display (static/fonts/target-u-display), always weight 400, the v12
   standard stroke. The caps are 0.75em tall and centred in the em, so inside a
   sentence the name matches the surrounding capitals, and 16px gives the 12px cap
   height of the standalone wordmark. Lowercase maps to the capitals: markup keeps
   "Target U" for copy, search and screen readers. T and U carry 0.1em side
   bearings; the negative margins put the box on the ink, as the old SVG was.
   Colour follows the text. Only the standalone wordmark
   (_partials/_brand_wordmark.html) wraps " U" in .brand-wordmark__u for the brand
   gold; the space stays in that span so the font's lone-U spacing still applies. */
@font-face {
    font-family: "Target U Display";
    font-style: normal;
    font-weight: 350;
    font-display: swap;
    src: url("../fonts/target-u-display/TargetUDisplay-SemiLight.08fd9eddfa06.woff2") format("woff2");
}

@font-face {
    font-family: "Target U Display";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/target-u-display/TargetUDisplay-Regular.a5abf95490e6.woff2") format("woff2");
}

@font-face {
    font-family: "Target U Display";
    font-style: normal;
    font-weight: 450;
    font-display: swap;
    src: url("../fonts/target-u-display/TargetUDisplay-RegularPlus.f2211fb1f301.woff2") format("woff2");
}

@font-face {
    font-family: "Target U Display";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/target-u-display/TargetUDisplay-Medium.9208805b3ad2.woff2") format("woff2");
}

:where([data-runtime-theme="target-u"]) .brand-wordmark {
    display: inline-block;
    margin-inline: -0.1em;
    font-family: var(--theme-font-brand);
    font-style: normal;
    font-weight: 400;
    font-synthesis: none;
    font-kerning: normal;
    font-variant-ligatures: contextual;
    font-feature-settings: normal;
    line-height: 1;
    letter-spacing: 0;
    word-spacing: 0;
    text-transform: none;
    white-space: nowrap;
}

:where([data-runtime-theme="target-u"]) .brand-wordmark--brand {
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .brand-wordmark__u {
    color: var(--theme-color-brand-gold);
}

/* Standalone in the navbar and footer: 12px cap height. A 0.75 line height makes
   the box exactly the caps (they sit centred in the em), so it is 12px tall with
   the baseline at its foot, the same box the SVG wordmark had. */
:where([data-runtime-theme="target-u"]) :is(.ui-nav__brand, .ui-footer__brand) > .brand-wordmark {
    display: block;
    flex: none;
    font-size: 16px;
    line-height: 0.75;
}

:where([data-runtime-theme="target-u"]) .ui-nav__bar,
:where([data-runtime-theme="target-u"]) .ui-nav__account {
    display: flex;
    align-items: center;
    gap: var(--theme-spacing-xs);
    margin: 0;
    padding: 0;
    list-style: none;
}

:where([data-runtime-theme="target-u"]) .ui-nav__account {
    min-width: 0;
    margin-inline-start: auto;
    gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .ui-nav__group {
    position: relative;
    display: flex;
}

:where([data-runtime-theme="target-u"]) .ui-nav__account > .ui-nav__group,
:where([data-runtime-theme="target-u"]) .ui-nav__account-trigger {
    min-width: 0;
    max-width: 100%;
}

:where([data-runtime-theme="target-u"]) .ui-nav__account-name {
    max-inline-size: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

:where([data-runtime-theme="target-u"]) .ui-nav__account-identity {
    display: none;
}

:where([data-runtime-theme="target-u"]) .ui-nav__menu {
    position: absolute;
    top: calc(100% + var(--theme-spacing-xs));
    left: 0;
    z-index: 50;
    min-width: 15rem;
    padding-block: var(--theme-spacing-xs);
    border: 1px solid var(--theme-color-border-strong);
    border-radius: var(--theme-radius-popover);
    background: var(--theme-color-surface);
    box-shadow: var(--theme-shadow-overlay);
}

:where([data-runtime-theme="target-u"]) .ui-nav__account .ui-nav__menu {
    min-width: 10rem;
}

:where([data-runtime-theme="target-u"]) .ui-nav__menu:not([data-ui-popover-initialized]) {
    position: static;
    min-width: 0;
    padding-block: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

:where([data-runtime-theme="target-u"]) .ui-nav__menu:not([data-ui-popover-initialized]) ul {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

:where([data-runtime-theme="target-u"]) .ui-nav__menu--end {
    right: 0;
    left: auto;
}

/* Dropdowns use their invoking button as the implicit anchor. */
:where([data-runtime-theme="target-u"]) .ui-nav__menu:popover-open {
    position: fixed;
    position-anchor: auto;
    inset: auto;
    top: calc(anchor(bottom) + var(--theme-spacing-xs));
    left: anchor(left);
    margin: 0;
    padding-inline: 0;
    color: inherit;
    overflow: visible;
}

:where([data-runtime-theme="target-u"]) .ui-nav__menu--end:popover-open {
    right: anchor(right);
    left: auto;
}

:where([data-runtime-theme="target-u"]) .ui-nav__menu ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

:where([data-runtime-theme="target-u"]) :is(.ui-nav__menu, .ui-mobile-nav) :is(.ui-nav__link, .ui-nav__trigger) {
    width: 100%;
    justify-content: flex-start;
    gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .ui-nav__link > .ui-badge--prod-hidden {
    margin-inline: auto 0;
}

:where([data-runtime-theme="target-u"]) .ui-nav__avatar {
    display: inline-grid;
    flex: none;
    width: 2rem;
    height: 2rem;
    place-items: center;
    overflow: hidden;
    border-radius: var(--theme-radius-marker);
    background: var(--theme-color-primary);
    color: var(--theme-color-surface);
    font-size: var(--theme-text-supporting);
    font-weight: 600;
}

/* An uploaded avatar fills the marker disc (accounts-and-guest BR-31). */
:where([data-runtime-theme="target-u"]) .ui-nav__avatar > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

:where([data-runtime-theme="target-u"]) .ui-mobile-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 40;
    box-sizing: border-box;
    max-height: calc(100dvh - 4rem - 1px);
    overflow-y: auto;
    padding: var(--theme-spacing-sm) var(--theme-shell-padding-inline)
             var(--theme-spacing-lg);
    border: 0;
    border-bottom: 1px solid var(--theme-color-border);
    background: var(--theme-color-surface);
    color: var(--theme-color-foreground);
}

:where([data-runtime-theme="target-u"]) .ui-mobile-nav:popover-open {
    position: fixed;
    inset: 4rem 0 auto;
    top: anchor(--ui-navbar bottom);
    width: auto;
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .ui-mobile-nav ul {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
}

:where([data-runtime-theme="target-u"]) .ui-mobile-nav__section {
    display: grid;
    gap: var(--theme-spacing-xs);
    padding-block: var(--theme-spacing-sm);
    border-top: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .ui-mobile-nav__section:first-child {
    border-top: 0;
}

:where([data-runtime-theme="target-u"]) .ui-mobile-nav__sub {
    padding-inline-start: var(--theme-spacing-lg);
}

/* Declared after the generic trigger rule so the burger's display wins. */
:where([data-runtime-theme="target-u"]) .ui-nav__burger {
    display: none;
}

@media (width < 1024px) {
    :where([data-runtime-theme="target-u"]) .ui-nav__shell {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        grid-template-rows: minmax(4rem, auto);
        gap: 0 var(--theme-spacing-sm);
    }

    :where([data-runtime-theme="target-u"]) .ui-nav__bar,
    :where([data-runtime-theme="target-u"]) .ui-nav__account > a,
    :where([data-runtime-theme="target-u"]) .ui-nav__account-name,
    :where([data-runtime-theme="target-u"]) .ui-nav__account-trigger [data-ui-chevron] {
        display: none;
    }

    :where([data-runtime-theme="target-u"]) .ui-nav__burger {
        display: inline-flex;
        grid-area: 1 / 1;
        justify-self: start;
    }

    :where([data-runtime-theme="target-u"]) .ui-nav__brand {
        grid-area: 1 / 2;
    }

    :where([data-runtime-theme="target-u"]) .ui-nav__account {
        grid-area: 1 / 3;
        justify-content: flex-end;
        margin: 0;
        container: nav-account / inline-size;
    }

    :where([data-runtime-theme="target-u"]) .ui-nav__burger,
    :where([data-runtime-theme="target-u"]) .ui-nav__account-trigger {
        width: 44px;
        justify-content: center;
        padding-inline: 0;
    }

    :where([data-runtime-theme="target-u"]) .ui-nav__account .ui-nav__menu[data-ui-popover-initialized] {
        min-width: 0;
        width: min(10rem, calc(100dvw - 2 * var(--theme-shell-padding-inline)));
        max-height: calc(100dvh - 4rem);
        overflow-y: auto;
        padding-inline: var(--theme-spacing-xs);
    }

    :where([data-runtime-theme="target-u"]) .ui-nav__account-identity {
        display: block;
        margin: 0;
        padding: var(--theme-spacing-sm) var(--theme-spacing-md);
        border-bottom: 1px solid var(--theme-color-border);
        overflow-wrap: anywhere;
    }

    /* With no runtime both lists occupy full rows below the header. */
    :where([data-runtime-theme="target-u"]:not([data-ui-js])) .ui-nav__account,
    :where([data-runtime-theme="target-u"]:not([data-ui-js])) .ui-nav__account > .ui-nav__group {
        display: contents;
    }

    :where([data-runtime-theme="target-u"]:not([data-ui-js])) .ui-nav__account-trigger {
        grid-area: 1 / 3;
        justify-self: end;
    }

    :where([data-runtime-theme="target-u"]:not([data-ui-js])) .ui-mobile-nav {
        grid-area: 2 / 1 / auto / -1;
        padding-inline: 0;
    }

    :where([data-runtime-theme="target-u"]:not([data-ui-js])) .ui-nav__account .ui-nav__menu {
        grid-area: 3 / 1 / auto / -1;
    }
}

@container nav-account (min-width: 9rem) {
    :where([data-runtime-theme="target-u"]) .ui-nav__account-identity {
        display: none;
    }

    :where([data-runtime-theme="target-u"]) .ui-nav__account-name,
    :where([data-runtime-theme="target-u"]) .ui-nav__account-trigger [data-ui-chevron] {
        display: block;
    }

    :where([data-runtime-theme="target-u"]) .ui-nav__account-trigger:has(.ui-nav__account-name) {
        width: auto;
        padding-inline: var(--theme-spacing-md);
    }
}

/* ---------------------------------------------------------------------------
   Public shell body and main content column.  The shell owns the horizontal
   safe area; routes never re-apply page padding.
   --------------------------------------------------------------------------- */
:where([data-runtime-theme="target-u"]) .ui-body {
    display: flex;
    min-height: 100dvh;
    flex-direction: column;
    background: var(--theme-color-background);
    color: var(--theme-color-foreground);
    font-family: var(--theme-font-sans);
    /* 中文與相鄰英數之間由瀏覽器補間距，文案不必逐句手動加空格。 */
    text-autospace: normal;
}

/* Text selection: a Navy field with cool-white ink instead of the browser
   blue. Navy sections reverse it in their own stylesheet. */
:where([data-runtime-theme="target-u"]) ::selection {
    background: var(--theme-color-primary);
    color: var(--theme-color-surface);
}

:where([data-runtime-theme="target-u"]) .ui-shell {
    flex: 1 1 auto;
    padding-block-start: 4rem;
    overflow-x: clip;
}

/* Staging only: a page that production hides (apps/core/feature_gates.py). */
:where([data-runtime-theme="target-u"]) .ui-prod-hidden-notice {
    margin-block: var(--theme-spacing-md);
}

:where([data-runtime-theme="target-u"]) .ui-shell__content {
    box-sizing: border-box;
    width: 100%;
    max-width: var(--theme-shell-max-width);
    margin-inline: auto;
    padding-inline: var(--theme-shell-padding-inline);
}

/* ---------------------------------------------------------------------------
   Public shell footer.
   --------------------------------------------------------------------------- */
:where([data-runtime-theme="target-u"]) .ui-footer {
    margin-block-start: auto;
    border-top: 1px solid var(--theme-color-border);
    background: var(--theme-color-surface);
}

:where([data-runtime-theme="target-u"]) .ui-footer__shell {
    display: flex;
    box-sizing: border-box;
    width: 100%;
    max-width: var(--theme-shell-max-width);
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--theme-spacing-md);
    margin-inline: auto;
    padding: var(--theme-spacing-lg) var(--theme-shell-padding-inline);
}

:where([data-runtime-theme="target-u"]) .ui-footer__identity {
    display: flex;
    align-items: baseline;
    /* The wordmark keeps about one U-width of clear space before the year. */
    gap: var(--theme-spacing-md);
}

:where([data-runtime-theme="target-u"]) .ui-footer__brand {
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .ui-footer__links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--theme-spacing-xs);
    margin: 0;
    padding: 0;
    list-style: none;
}

:where([data-runtime-theme="target-u"]) .ui-footer__support {
    display: flex;
    align-items: center;
}

/* Compact footer: the links take one full row, then the wordmark and the
   support link share the next, left and right. The negative margins line the
   link text up with the shell edge (links carry their own inline padding). */
@media (max-width: 767px) {
    :where([data-runtime-theme="target-u"]) .ui-footer__shell {
        row-gap: var(--theme-spacing-xs);
    }

    :where([data-runtime-theme="target-u"]) .ui-footer__links {
        order: -1;
        flex: 1 0 100%;
        justify-content: space-between;
        margin-inline: calc(-1 * var(--theme-spacing-md));
    }

    :where([data-runtime-theme="target-u"]) .ui-footer__support {
        margin-inline: auto calc(-1 * var(--theme-spacing-md));
    }
}

/* While the deferred runtime is still loading (base.html marks the root),
   uninitialized nav popovers stay closed instead of showing the no-JS
   fallback: inline desktop menus squeeze the bar labels into one character
   per line, and the expanded mobile menu covers half the screen. */
:where([data-runtime-theme="target-u"][data-ui-js]) .ui-nav [data-ui-popover]:not([data-ui-popover-initialized]) {
    display: none;
}

/* Without the shared runtime the mobile disclosure stays expanded.  A fixed
   bar would then float a full menu over the page and swallow its clicks, so
   the shell falls back to normal flow until theme_ui.js takes ownership. */
:where([data-runtime-theme="target-u"]:not([data-ui-js])) .ui-nav:has(
    .ui-mobile-nav:not([data-ui-popover-initialized])
) {
    position: static;
    /* Keep the expanded links reachable on the homepage's snapping scroller. */
    scroll-snap-align: start;
}

:where([data-runtime-theme="target-u"]:not([data-ui-js])) .ui-nav:has(
    .ui-mobile-nav:not([data-ui-popover-initialized])
) .ui-mobile-nav {
    position: static;
    max-height: none;
}

:where([data-runtime-theme="target-u"]:not([data-ui-js])) .ui-body:has(
    .ui-mobile-nav:not([data-ui-popover-initialized])
) .ui-shell {
    padding-block-start: 0;
}

@media (min-width: 768px) {
    :root {
        --theme-shell-padding-inline: var(--theme-spacing-4xl);
    }
}

@media (min-width: 1024px) {
    :root {
        --theme-shell-padding-inline: var(--theme-spacing-5xl);
    }

    /* Desktop exposes its site categories and guest actions inline. */
    :where([data-runtime-theme="target-u"]) .ui-nav__group--guest,
    :where([data-runtime-theme="target-u"]) .ui-mobile-nav {
        display: none;
    }
}



@media (max-width: 767px) {
    :where([data-runtime-theme="target-u"]) .ui-overlay {
        padding: 0;
    }

    :where([data-runtime-theme="target-u"]) .ui-overlay--mobile-full {
        place-items: stretch;
        width: 100vw;
        height: 100dvh;
        border-radius: var(--theme-radius-mobile-overlay);
    }

    :where([data-runtime-theme="target-u"]) .ui-overlay--mobile-full .ui-dialog {
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border: 0;
        border-radius: var(--theme-radius-mobile-overlay);
    }

    :where([data-runtime-theme="target-u"]) .ui-dialog__header {
        padding: var(--theme-spacing-lg);
    }

    :where([data-runtime-theme="target-u"]) .ui-dialog__close {
        margin: -6px -6px -6px 0;
    }

    :where([data-runtime-theme="target-u"]) .ui-dialog__body {
        padding: 18px var(--theme-spacing-lg);
    }

    :where([data-runtime-theme="target-u"]) .ui-dialog__actions {
        padding: var(--theme-spacing-md) var(--theme-spacing-lg);
    }

    :where([data-runtime-theme="target-u"]) .analysis-dialog__body {
        gap: var(--theme-spacing-xl);
    }

    :where([data-runtime-theme="target-u"]) .analysis-insight-kpi-grid > div {
        padding: 14px var(--theme-spacing-sm);
    }

}

/* Spec 158: labelled favorite spacing belongs to the shared control. */
:where([data-runtime-theme="target-u"]) .ui-favorite-control:not(.ui-favorite-control--icon-only) {
    gap: var(--theme-spacing-sm);
    padding-inline: var(--theme-spacing-md);
}

/*
 * 招生校系層的志願動作（加入候選／加入分發志願／已加入狀態），
 * 收藏與志願脫鉤施工單 2026-11-15。只排版，按鈕與字階沿用既有元件。
 */
:where([data-runtime-theme="target-u"]) .offering-preference-action {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .offering-preference-action > form {
    margin: 0;
}

/*
 * Result list tables scroll sideways instead of squeezing their columns
 * (results_table_scroll.js keeps the data-* state current). While content is
 * hidden past the right edge, a 2rem strip pinned to that edge softly blurs
 * and fades it, so the cut reads as "more this way" rather than a clip.
 */
:where([data-runtime-theme="target-u"]) [data-table-scroll] {
    display: flex;
}

:where([data-runtime-theme="target-u"]) [data-table-scroll] > table {
    flex: 1 0 auto;
}

:where([data-runtime-theme="target-u"]) [data-table-scroll] > table > tbody > tr > * {
    transition: background-color var(--theme-motion-duration-interaction);
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) [data-table-scroll] > table > tbody > tr:hover > * {
        background: color-mix(in oklch, var(--theme-color-primary) 4%, var(--theme-color-background));
    }
}

:where([data-runtime-theme="target-u"]) [data-table-scroll]::after {
    content: '';
    position: sticky;
    inset-inline-end: 0;
    flex: 0 0 var(--theme-spacing-2xl);
    margin-inline-start: calc(var(--theme-spacing-2xl) * -1);
    background: linear-gradient(
        to right,
        transparent,
        color-mix(in oklch, var(--theme-color-background) 85%, transparent)
    );
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    -webkit-mask-image: linear-gradient(to right, transparent, #000 70%);
    mask-image: linear-gradient(to right, transparent, #000 70%);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) [data-table-scroll][data-overflow-end]::after {
    opacity: 1;
}

:where([data-runtime-theme="target-u"]) [data-table-scroll][data-dragging],
:where([data-runtime-theme="target-u"]) [data-table-scroll][data-dragging] * {
    cursor: grabbing;
    user-select: none;
}

/* State and button stay in the DOM together on result routes; hidden wins
   over the shared button display. */
:where([data-runtime-theme="target-u"]) .offering-preference-action [hidden] {
    display: none;
}

/*
 * The plus glyph leaves about 3px of its 16px box empty on each side, so a
 * 4px gap and 12px leading padding read as the standard 8px／16px.
 */
:where([data-runtime-theme="target-u"]) .offering-preference-add:has(> .ico) {
    gap: var(--theme-spacing-xs);
    padding-inline-start: var(--theme-spacing-md);
}

/*
 * Three states of one execution control. Add is the soft-Navy fill; a
 * candidate is the same control checked — surface with a Navy hairline and a
 * check, hover deepening the line to say it can be pressed to remove; 正式志願
 * is settled elsewhere, so it rests on a blue-grey fill with muted ink and
 * never reacts.
 */
:where([data-runtime-theme="target-u"]) .offering-preference-add[aria-pressed="true"] {
    border-color: color-mix(in oklch, var(--theme-color-primary) 46%, var(--theme-color-border));
    background: var(--theme-color-surface);
    color: var(--theme-color-primary);
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .offering-preference-add[aria-pressed="true"]:hover {
        border-color: var(--theme-color-primary);
        background: var(--theme-color-surface-muted);
        color: var(--theme-color-primary-hover);
    }
}

/* Keep the settled state and its rank readable within the action slot. */
:where([data-runtime-theme="target-u"]) .offering-preference-formal[aria-disabled="true"],
:where([data-runtime-theme="target-u"]) .offering-preference-formal[aria-disabled="true"]:hover {
    flex-direction: column;
    gap: 0;
    line-height: 1.2;
    pointer-events: auto;
    cursor: default;
    border-color: transparent;
    background: color-mix(in oklch, var(--theme-color-muted) 12%, var(--theme-color-surface));
    /* Muted alone reads 4.3:1 on this fill; a touch of foreground clears 4.5:1. */
    color: color-mix(in oklch, var(--theme-color-muted) 75%, var(--theme-color-foreground));
    opacity: 1;
}

/*
 * Result cards: the preference action owns the status row's trailing corner
 * (the favourite moved to the analysis overlay). The status row's 60px floor
 * is 16px inset plus this 44px control, so the button's edge lands on the
 * card's 16px top and 20px trailing insets. It sits above the whole-card hit
 * layer so it stays an independent control.
 */
:where([data-runtime-theme="target-u"]) .ui-entity-card__status > .offering-preference-action {
    position: relative;
    z-index: 2;
    margin-inline-start: auto;
}
