/* frontier.css: Frontier interface: shell, theme studio, social sharing, reference shell, responsive fallback, navigation polish. */
/* ============================================================
   Frontier interface shell
   The shell changes framing, atmosphere, and token values while reusing the
   existing server-rendered navigation and responsive layout. At 1024px and
   below the current bottom tab bar remains the structural navigation.
   ============================================================ */
body.interface-frontier {
    --gradient-primary: linear-gradient(120deg, var(--color-primary) 0%, var(--color-violet) 58%, var(--color-reward) 100%);
    --vignette: radial-gradient(125% 125% at 50% 18%, transparent 52%, color-mix(in srgb, var(--bg-body) 45%, transparent) 100%);
}

body.interface-frontier .frontier-shell {
    position: relative;
    isolation: isolate;
    max-width: 1280px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    overflow: clip;
    background: var(--bg-body);
    border-inline: 1px solid color-mix(in srgb, var(--border-color) 78%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-violet) 10%, transparent), var(--shadow-lg);
}

body.interface-frontier .frontier-shell__hero {
    position: absolute;
    inset: 0 0 auto;
    z-index: -1;
    height: 190px;
    background-image: linear-gradient(180deg, color-mix(in srgb, var(--bg-body) 12%, transparent), var(--bg-body) 92%), var(--frontier-header-art, none);
    background-position: center top;
    background-size: cover;
    opacity: .94;
    pointer-events: none;
}

body.interface-frontier .frontier-shell__hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, color-mix(in srgb, var(--color-violet) 14%, transparent), transparent 38%, color-mix(in srgb, var(--color-primary) 10%, transparent));
    mix-blend-mode: screen;
}

body.interface-frontier .site-body {
    background: color-mix(in srgb, var(--bg-body) 90%, transparent);
}

body.interface-frontier .site-sidebar {
    background-image: linear-gradient(180deg, color-mix(in srgb, var(--bg-surface) 86%, transparent), var(--bg-body) 86%), var(--frontier-rail-art, none);
    background-position: center top;
    background-size: cover;
    border-right-color: var(--border-color);
}

body.interface-frontier .sidebar-nav a,
body.interface-frontier .sidebar-nav-group > summary {
    border-radius: 10px;
}

body.interface-frontier .sidebar-nav a.is-active,
body.interface-frontier .sidebar-nav-group[open] > summary {
    background: color-mix(in srgb, var(--color-violet) 14%, var(--bg-hover));
    color: var(--text-primary);
}

body.interface-frontier .sidebar-nav a.is-active::before {
    background: var(--color-primary);
    box-shadow: 0 0 10px color-mix(in srgb, var(--color-primary) 52%, transparent);
}

body.interface-frontier .page-title {
    letter-spacing: -0.045em;
}

body.interface-frontier .site-body > .page-container {
    max-width: none;
    padding: 30px clamp(20px, 3.2vw, 42px) 66px;
}

body.interface-frontier .page-header {
    padding-top: 6px;
}

.theme-preview--frontier {
    background: linear-gradient(135deg, #15102a 0%, #284363 58%, #8764b7 100%);
}
.theme-preview--frontier-data {
    background: linear-gradient(135deg, var(--theme-preview-start) 0%, var(--theme-preview-mid) 58%, var(--theme-preview-end) 100%);
}
.theme-preview--frontier-night {
    background: linear-gradient(135deg, #15102a 0%, #284363 58%, #8764b7 100%);
}
.theme-preview--frontier-bloom {
    background: linear-gradient(135deg, #182238 0%, #3d6b70 55%, #c78b73 100%);
}
.theme-preview--frontier-coast {
    background: linear-gradient(135deg, #101d31 0%, #246878 55%, #4e7b9d 100%);
}

.interface-style-choices,
.frontier-theme-picker { margin-top: 18px; }

.theme-card--frontier .theme-card__status { color: var(--color-primary); }

.theme-studio-layout {
    display: grid;
    grid-template-columns: minmax(220px, .7fr) minmax(0, 1.6fr);
    gap: 18px;
    align-items: start;
}
.theme-studio-layout > *,
.theme-studio-layout .panel,
.theme-studio-layout form,
.theme-studio-layout fieldset,
.theme-studio-layout .form-grid { min-width: 0; max-width: 100%; }
.theme-studio-list { display: grid; gap: 8px; margin-bottom: 16px; }
.theme-studio-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 10px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    color: var(--text-primary);
}
.theme-studio-card.is-selected { border-color: var(--color-primary); text-decoration: none; }
@media (hover: hover) {
    .theme-studio-card:hover { border-color: var(--color-primary); text-decoration: none; }
}
.theme-studio-card__swatch { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px; background: var(--theme-swatch-bg); box-shadow: inset 0 0 0 5px var(--theme-swatch), 0 0 0 1px var(--border-color); }
.theme-studio-card__preview { display: grid; place-items: center; width: 84px; height: 48px; flex: 0 0 auto; overflow: hidden; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-body); }
.theme-studio-card__preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.theme-studio-card__preview .theme-studio-card__swatch { width: 32px; height: 32px; }
.theme-studio-card__copy { display: grid; gap: 3px; min-width: 0; flex: 1; }
.theme-studio-card__copy span { color: var(--text-muted); font-family: var(--font-mono); font-size: .68rem; overflow-wrap: anywhere; }
.theme-studio-card .state-chip { white-space: nowrap; }
.theme-studio-editor .panel__header { align-items: flex-start; }
.theme-studio-guide { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; padding: 16px 18px; border: 1px solid color-mix(in srgb, var(--color-primary) 38%, var(--border-color)); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--color-primary) 7%, var(--bg-surface)); }
.theme-studio-guide strong { display: block; margin-top: 4px; font-family: var(--font-heading); font-size: 1.05rem; }
.theme-studio-guide p { max-width: 62ch; margin: 4px 0 0; color: var(--text-secondary); font-size: .84rem; }
.theme-studio-guide__steps { display: flex; flex-wrap: wrap; gap: 8px; color: var(--text-muted); font-family: var(--font-mono); font-size: .7rem; text-transform: uppercase; white-space: nowrap; }
.theme-studio-guide__steps span { display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px; border: 1px solid var(--border-subtle); border-radius: var(--radius-pill); }
.theme-studio-guide__steps b { color: var(--color-primary); }
.theme-upload-fieldset,
.theme-color-fieldset { margin: 18px 0 0; padding: 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.theme-upload-fieldset legend,
.theme-color-fieldset legend { padding: 0 6px; font-family: var(--font-heading); font-weight: 700; }
.theme-upload-field { display: grid; gap: 6px; align-content: start; }
.theme-upload-field__spec { color: var(--color-primary); font-family: var(--font-mono); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; }
.theme-studio-artwork-status { display: grid; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-subtle); }
.theme-studio-artwork-status__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.theme-studio-artwork-status__grid > div { display: grid; gap: 6px; min-width: 0; color: var(--text-secondary); font-size: .78rem; }
.theme-studio-artwork-status__grid img { display: block; width: 100%; height: 82px; object-fit: cover; border: 1px solid var(--border-subtle); border-radius: 8px; background: var(--bg-body); }
.theme-studio-artwork-status__empty { display: grid; place-items: center; min-height: 82px; border: 1px dashed var(--border-color); border-radius: 8px; color: var(--text-muted); font-size: .78rem; }
.theme-color-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.theme-color-field { display: grid; gap: 5px; color: var(--text-secondary); font-size: .76rem; font-weight: 700; }
.theme-color-input { width: 100%; min-height: 42px; padding: 3px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--bg-body); cursor: pointer; }
.theme-publication-box { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border-subtle); }
.theme-publication-box p { margin: 4px 0 0; color: var(--text-secondary); font-size: .84rem; line-height: 1.45; }

.theme-contrast-report { margin: 18px 0 0; padding: 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-subtle); }
.theme-contrast-report--bad { border-color: color-mix(in srgb, var(--color-error-ink) 45%, var(--border-color)); }
.theme-contrast-report__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.theme-contrast-report__header strong { font-family: var(--font-heading); }
.theme-contrast-report p.form-hint { margin: 6px 0 0; }
.theme-contrast-report__list { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.theme-contrast-report__list li { padding: 8px 10px; border: 1px solid color-mix(in srgb, var(--color-error-ink) 35%, var(--border-color)); border-radius: 7px; background: color-mix(in srgb, var(--color-error-ink) 6%, var(--bg-body)); color: var(--text-secondary); font-size: .82rem; line-height: 1.4; }

.frontier-preview-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    padding: 12px 14px;
    border: 1px solid color-mix(in srgb, var(--color-primary) 45%, var(--border-color));
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--color-primary) 8%, var(--bg-surface));
    color: var(--text-secondary);
}
.frontier-preview-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.frontier-preview-condition { display: flex; align-items: center; gap: 16px; }
.frontier-preview-condition .conditions-strip__body { flex: 1; }
.frontier-preview-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .8fr); gap: 18px; margin-top: 18px; }
.frontier-preview-card { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; margin-top: 14px; padding: 16px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-subtle); }
.frontier-preview-card p { grid-column: 1 / -1; margin: 0; color: var(--text-secondary); }
.frontier-preview-progress { grid-column: 1 / -1; height: 8px; overflow: hidden; border-radius: var(--radius-pill); background: var(--bg-hover); }
.frontier-preview-progress span { display: block; height: 100%; border-radius: inherit; background: var(--gradient-primary); }
.frontier-preview-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.frontier-preview-stats > div { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-subtle); }
.frontier-preview-stats strong { font-family: var(--font-display); font-size: 1.35rem; }

@media (min-width: 1024px) {
    body.interface-frontier .site-sidebar { width: 202px; padding: 22px 12px; }
}

@media (width < 1024px) {
    body.interface-frontier .frontier-shell { min-height: 0; margin: 0; border-inline: 0; box-shadow: none; }
    body.interface-frontier .frontier-shell__hero { height: 128px; }
    body.interface-frontier .site-body > .page-container { padding: 22px 16px 60px; }
    .theme-studio-layout { grid-template-columns: minmax(0, 1fr); }
    .frontier-preview-grid { grid-template-columns: 1fr; }
    .theme-color-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
    .frontier-preview-banner,
    .frontier-preview-header,
    .frontier-preview-condition,
    .theme-publication-box { align-items: stretch; flex-direction: column; }
    .theme-studio-card { align-items: flex-start; }
    .theme-studio-card .state-chip { white-space: normal; text-align: right; }
    .theme-color-grid { grid-template-columns: 1fr; }
}

@media (width < 768px) {
    .theme-studio-guide { align-items: stretch; flex-direction: column; gap: 12px; }
    .theme-studio-guide__steps { white-space: normal; }
    .theme-studio-artwork-status__grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    body.interface-frontier .frontier-shell__hero { scroll-behavior: auto; }
}

/* ── Social sharing ──────────────────────────────────────────────────────────
 * The share button cluster on pet_detail / user_profile, and the standalone
 * public share pages (game:share_pet / game:share_profile) that carry the OG
 * card a pasted link unfurls in Discord/Facebook. See game/social.py. */
.share-cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.share-menu-wrap { position: relative; display: inline-flex; gap: 2px; }
.share-btn--toggle { padding-inline: 10px; }
.share-menu {
    position: absolute;
    z-index: 20;
    top: calc(100% + 8px);
    right: 0;
    min-width: 224px;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    box-shadow: var(--shadow-md);
}
.share-menu button,
.share-menu a {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    gap: 8px;
    padding: 9px 11px;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    background: transparent;
    text-align: left;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
}
.share-menu button:focus-visible,
.share-menu a:focus-visible {
    background: var(--bg-hover);
    color: var(--color-primary);
    outline: none;
}
@media (hover: hover) {
    .share-menu button:hover,
    .share-menu a:hover {
        background: var(--bg-hover);
        color: var(--color-primary);
    }
}
.share-status {
    font-size: 0.8rem;
    color: var(--color-primary);
    padding: 2px 10px;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-pill);
    white-space: nowrap;
}
.pet-detail-share,
.profile-share {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-top: 16px;
}
.share-section-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Public share landing pages (anonymous: no site header, so center the card). */
.share-page {
    max-width: 760px;
    margin: 0 auto;
    padding: 32px 16px 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    min-height: 70dvh;
    justify-content: center;
    text-align: center;
}
.share-card-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 28px;
}
.share-card-art { flex-shrink: 0; }
.share-card-art img {
    border-radius: var(--radius-lg);
    max-width: 100%;
    height: auto;
    box-shadow: var(--shadow-sm);
}
.share-card-art__placeholder {
    width: 200px;
    height: 200px;
    display: grid;
    place-items: center;
    font-size: 5rem;
    color: var(--color-primary);
    background: var(--bg-cool);
    border-radius: var(--radius-lg);
}
.share-card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.share-card-body h1 { margin: 4px 0; }
.share-card-subtitle {
    margin: 0;
    color: var(--color-primary);
    font-weight: 700;
}
.share-card-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: center;
    margin: 2px 0 0;
}
.share-fact {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
}
.share-fact span {
    color: var(--text-muted);
    font-size: 0.67rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.share-fact strong {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.86rem;
}
.share-card-context {
    margin: 2px 0 0;
    color: var(--text-secondary);
}
.share-card-bio {
    max-width: 52ch;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.5;
}
.share-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 12px;
}
.share-card-panel .share-cluster { justify-content: center; margin-top: 6px; }

@media (min-width: 640px) {
    .share-card-panel {
        flex-direction: row;
        align-items: center;
        text-align: left;
    }
    .share-card-body { align-items: flex-start; }
    .share-card-facts,
    .share-cta { justify-content: flex-start; }
    .share-card-panel .share-cluster { justify-content: flex-start; }
}

@media (max-width: 480px) {
    .share-menu { min-width: min(224px, calc(100vw - 32px)); }
    .share-cta { width: 100%; }
    .share-cta .btn { width: 100%; }
}

/* ============================================================
   Frontier reference shell
   The live Frontier reference uses four visual layers: a scenic masthead,
   a compact resource strip, a painted navigation rail, and a translucent
   content field. Keep these layers Frontier-only so Legacy remains byte-for-
   byte in spirit and route content stays server-rendered and reusable.
   ============================================================ */
body.interface-frontier {
    --frontier-shell-border: color-mix(in srgb, var(--color-primary) 58%, var(--border-color));
    --frontier-nav-start: color-mix(in srgb, var(--color-violet) 62%, var(--bg-surface));
    --frontier-nav-end: color-mix(in srgb, var(--color-primary) 64%, var(--bg-body));
    --frontier-nav-sub-end: color-mix(in srgb, var(--color-primary) 28%, var(--bg-surface));
    --frontier-panel: color-mix(in srgb, var(--color-violet) 16%, var(--bg-surface));
    --frontier-field: var(--bg-body);
    background-color: var(--bg-body);
    background-image:
        linear-gradient(180deg, color-mix(in srgb, var(--bg-body) 10%, transparent), color-mix(in srgb, var(--bg-body) 36%, transparent)),
        var(--frontier-rail-art, none),
        radial-gradient(circle at 16% 18%, color-mix(in srgb, var(--color-primary) 26%, transparent) 0 1px, transparent 1.5px),
        radial-gradient(circle at 76% 11%, color-mix(in srgb, var(--color-reward) 20%, transparent) 0 1px, transparent 1.5px),
        radial-gradient(circle at 42% 66%, color-mix(in srgb, var(--color-violet) 28%, transparent) 0 1px, transparent 1.5px),
        var(--vignette);
    background-position: center, center, center, center, center, center;
    background-size: cover, cover, 176px 164px, 231px 207px, 263px 241px, auto;
    background-attachment: fixed;
}

body.interface-frontier .frontier-shell {
    max-width: 1252px;
    margin: 8px auto 24px;
    overflow: clip;
    border: 1px solid var(--frontier-shell-border);
    border-radius: 100px;
    background: var(--frontier-field);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-primary) 14%, transparent), 0 24px 70px rgba(3, 4, 16, .52);
}

body.interface-frontier .frontier-shell__hero {
    position: relative;
    inset: auto;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 150px;
    padding: 0 24px;
    opacity: 1;
    overflow: hidden;
    border-radius: 99px 99px 0 0;
    background-image:
        linear-gradient(180deg, color-mix(in srgb, var(--bg-body) 12%, transparent), color-mix(in srgb, var(--bg-body) 50%, transparent)),
        var(--frontier-header-art, none);
    background-position: center top;
    background-size: cover;
}

body.interface-frontier .frontier-shell__hero::after {
    z-index: 0;
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--color-violet) 22%, transparent), transparent 42%, color-mix(in srgb, var(--color-primary) 18%, transparent)),
        linear-gradient(180deg, transparent 55%, color-mix(in srgb, var(--bg-body) 46%, transparent));
    mix-blend-mode: normal;
}

body.interface-frontier .frontier-shell__brand {
    position: relative;
    z-index: 1;
    max-width: 100%;
    color: #fff;
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 6vw, 4.75rem);
    font-style: italic;
    font-weight: 700;
    letter-spacing: .08em;
    line-height: 1;
    text-align: center;
    text-shadow: 0 2px 0 color-mix(in srgb, var(--color-violet) 60%, #000), 0 0 18px color-mix(in srgb, var(--color-primary) 46%, transparent);
    white-space: nowrap;
}
body.interface-frontier .frontier-shell__brand span { color: color-mix(in srgb, var(--color-primary) 72%, #fff); }
@media (hover: hover) {
    body.interface-frontier .frontier-shell__brand:hover { color: #fff; text-decoration: none; filter: brightness(1.08); }
}

body.interface-frontier .site-brand { display: none; }
body.interface-frontier .site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 53px;
    padding: 0 24px;
    background: color-mix(in srgb, var(--bg-surface) 52%, transparent);
    border-top: 1px solid color-mix(in srgb, var(--color-primary) 48%, transparent);
    border-bottom-color: color-mix(in srgb, var(--color-primary) 46%, var(--border-color));
    backdrop-filter: saturate(1.25) blur(10px);
    -webkit-backdrop-filter: saturate(1.25) blur(10px);
}
body.interface-frontier .site-nav-right { gap: 10px; }
body.interface-frontier .weather-chip,
body.interface-frontier .nav-currency {
    border-color: color-mix(in srgb, var(--color-primary) 48%, var(--border-color));
    background: color-mix(in srgb, var(--color-violet) 22%, transparent);
}
body.interface-frontier .weather-chip { color: var(--text-primary); }
body.interface-frontier .nav-currency { color: var(--text-primary); }

/* Every .state-chip--* variant reads its text straight off a raw signal token
   (--color-primary, or a --*-ink alias that maps to the same un-clamped reward/warning/
   error hex) in Legacy, which is safe there because every Legacy palette is hand-curated
   for it. A Frontier draft's signal colors are arbitrary staff-picked hexes validated (at
   publish only, and never while drafting) against --bg-body alone, not against the
   --bg-subtle/panel surfaces these chips actually sit on, so the same chip that reads fine
   in Legacy can wash out here. Route every variant's text through --text-primary (validated
   against all six Frontier backgrounds) and leave each variant's tinted border alone. */
body.interface-frontier .state-chip--active,
body.interface-frontier .state-chip--done,
body.interface-frontier .state-chip--ready,
body.interface-frontier .state-chip--warn,
body.interface-frontier .state-chip--bad {
    color: var(--text-primary);
}

body.interface-frontier .site-body {
    min-height: calc(100dvh - 203px);
    background-color: var(--bg-body);
    background-image:
        linear-gradient(180deg, color-mix(in srgb, var(--bg-body) 48%, transparent), color-mix(in srgb, var(--bg-body) 76%, transparent)),
        var(--frontier-rail-art, none),
        radial-gradient(circle at 17% 12%, color-mix(in srgb, var(--color-primary) 20%, transparent) 0 1px, transparent 1.5px),
        radial-gradient(circle at 82% 22%, color-mix(in srgb, var(--color-violet) 25%, transparent) 0 1px, transparent 1.5px),
        linear-gradient(135deg, color-mix(in srgb, var(--color-violet) 6%, transparent), transparent 44%);
    background-position: center, center, center, center, center;
    background-size: cover, cover, 190px 178px, 247px 221px, auto;
    background-attachment: fixed;
}

@media (min-width: 1024px) {
    body.interface-frontier .site-sidebar {
        width: 202px;
        /* The scenic chrome occupies 212px before the rail begins at the top of
           the page. The rail surface follows the app column to the footer; the
           inner list below owns the column cap so a short menu stays compact
           while expanded groups still scroll inside their own surface. */
        min-height: 0;
        height: auto;
        max-height: none;
        padding: 0;
        position: relative;
        top: auto;
        border-right-color: var(--frontier-shell-border);
        border-radius: 0;
        align-self: stretch;
        overflow: visible;
        background-image:
            linear-gradient(180deg, color-mix(in srgb, var(--color-violet) 24%, transparent), color-mix(in srgb, var(--bg-body) 68%, transparent) 82%),
            var(--frontier-rail-art, none);
        background-position: center top;
        background-size: cover;
    }

    body.interface-frontier .site-sidebar .sidebar-nav {
        position: sticky;
        top: 53px;
        /* Once the rail is sticky, its visible viewport starts at this 53px
           offset. The shell's 212px initial top would leave dead space below
           the menu and make a fitting expansion scroll too early. */
        max-height: min(100%, calc(100vh - 53px));
        max-height: min(100%, calc(100dvh - 53px));
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: auto;
        /* Do not reserve a scrollbar lane while the menu fits. The browser should
           create the scroll affordance only when an expanded group actually overflows. */
        scrollbar-gutter: auto;
    }

    body.interface-frontier .frontier-shell__hero { height: 203px; }
    body.interface-frontier .site-header { margin-top: -53px; }

    body.interface-frontier .sidebar-nav { gap: 0; }
    body.interface-frontier .sidebar-nav a,
    body.interface-frontier .sidebar-nav-group > summary {
        min-height: 62px;
        padding: 17px 18px;
        border-bottom: 1px solid color-mix(in srgb, var(--color-primary) 42%, var(--border-color));
        border-radius: 0;
        background: linear-gradient(180deg, color-mix(in srgb, var(--color-violet) 58%, transparent), color-mix(in srgb, var(--bg-body) 78%, transparent));
        color: color-mix(in srgb, var(--color-primary) 72%, #fff);
        font-weight: 700;
        text-shadow: 0 0 5px color-mix(in srgb, var(--color-primary) 62%, transparent), 0 0 15px color-mix(in srgb, var(--color-violet) 70%, transparent);
    }
    body.interface-frontier .sidebar-nav-group__items a {
        min-height: 38px;
        padding: 9px 12px;
        background: linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 28%, transparent), color-mix(in srgb, var(--color-violet) 32%, transparent));
        color: color-mix(in srgb, var(--color-primary) 84%, #fff);
        font-size: .86rem;
        text-shadow: 0 0 5px color-mix(in srgb, var(--color-primary) 64%, transparent);
    }
    body.interface-frontier .sidebar-nav a.is-active,
    body.interface-frontier .sidebar-nav-group[open] > summary {
        background: linear-gradient(180deg, var(--frontier-nav-start), var(--frontier-nav-end));
        color: #fff;
        text-shadow: 0 0 5px color-mix(in srgb, var(--color-primary) 72%, #fff), 0 0 16px var(--color-primary);
    }
    body.interface-frontier .sidebar-nav-group[open] .sidebar-nav-group__items a {
        background: linear-gradient(180deg, var(--frontier-nav-sub-end), color-mix(in srgb, var(--color-violet) 36%, transparent));
    }
    body.interface-frontier .sidebar-nav a.is-active::before { display: none; }
    body.interface-frontier .sidebar-nav a:focus-visible,
    body.interface-frontier .sidebar-nav-group > summary:focus-visible {
        outline: 3px solid var(--color-primary);
        outline-offset: -3px;
    }
    @media (hover: hover) {
        body.interface-frontier .sidebar-nav a:hover,
        body.interface-frontier .sidebar-nav-group > summary:hover {
            background: linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 62%, var(--color-violet)), var(--color-primary));
            color: #fff;
            letter-spacing: .035em;
        }
    }

    body.interface-frontier .site-body > .page-container {
        max-width: none;
        padding: 25px 25px 60px;
        border-radius: 0 0 99px 0;
        background: color-mix(in srgb, var(--bg-body) 90%, transparent);
    }
}

body.interface-frontier .panel,
body.interface-frontier .conditions-strip {
    border-color: color-mix(in srgb, var(--color-violet) 72%, var(--border-color));
    border-radius: 20px;
    background: color-mix(in srgb, var(--frontier-panel) 86%, transparent);
    box-shadow: 0 10px 28px color-mix(in srgb, var(--bg-body) 24%, transparent);
}

body.interface-frontier .page-title {
    font-size: clamp(1.8rem, 3.4vw, 2.55rem);
    letter-spacing: -.025em;
}
body.interface-frontier .page-subtitle { max-width: 56ch; }
body.interface-frontier .eyebrow { letter-spacing: .2em; }
body.interface-frontier .conditions-strip { align-items: center; }
body.interface-frontier .conditions-strip__body { min-width: 0; }

@media (min-width: 768px) {
    /* The URL reference keeps the active work column dominant and the summary
       column visible. The legacy orbit is retained for Legacy only. */
    body.interface-frontier .command-grid {
        grid-template-columns: minmax(0, 1fr) minmax(240px, .62fr);
        grid-template-areas: "command glance";
        gap: 18px;
    }
    body.interface-frontier .command-grid::before { display: none; }
    body.interface-frontier .command-column {
        display: grid;
        grid-area: command;
        gap: 18px;
        align-content: start;
    }
    body.interface-frontier .command-column > section,
    body.interface-frontier .command-recently,
    body.interface-frontier .command-glance {
        grid-area: auto;
        align-self: start;
    }
    body.interface-frontier .command-glance { grid-area: glance; }
}

@media (width < 768px) {
    body.interface-frontier .command-grid { display: block; }
    body.interface-frontier .command-column { display: grid; gap: 18px; }
    body.interface-frontier .command-glance { margin-top: 18px; }
}

@media (max-width: 560px) {
    body.interface-frontier .frontier-shell__hero {
        height: 104px;
        border-radius: 0;
    }
    body.interface-frontier .frontier-shell__brand {
        font-size: clamp(1.8rem, 10vw, 2.65rem);
        letter-spacing: .045em;
    }
    body.interface-frontier .site-header {
        height: 56px;
        padding: 0 10px;
    }
    body.interface-frontier .site-body > .page-container {
        padding: 18px 14px 60px;
        border-radius: 0;
    }
    body.interface-frontier .conditions-strip {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 12px;
        padding: 14px;
    }
    body.interface-frontier .conditions-strip > .btn,
    body.interface-frontier .conditions-strip > a {
        grid-column: 1 / -1;
        justify-self: start;
    }
}

@media (width < 1024px) {
    body.interface-frontier .frontier-shell {
        max-width: none;
        margin: 0;
        border-inline: 0;
        border-radius: 0;
        box-shadow: none;
    }
    body.interface-frontier .frontier-shell__hero {
        height: 124px;
        border-radius: 0;
    }
    body.interface-frontier .site-header {
        height: 56px;
        padding-inline: 14px;
    }
    body.interface-frontier .site-body > .page-container {
        border-radius: 0;
    }
}

@media (max-width: 560px) {
    body.interface-frontier .frontier-shell__hero { height: 104px; }
}

@media (prefers-reduced-motion: reduce) {
    body.interface-frontier .sidebar-nav a,
    body.interface-frontier .sidebar-nav-group > summary,
    body.interface-frontier .frontier-shell__brand { transition: none; }
}

/* ============================================================
   Frontier responsive fallback
   Frontier's scenic shell is a desktop frame. Below the desktop rail
   breakpoint, keep the established mobile/tablet structure and use the
   selected Frontier tokens only for restrained surface accents.
   ============================================================ */
@media (width < 1024px) {
    body.interface-frontier {
        background-image: none;
        background-attachment: scroll;
    }

    body.interface-frontier .frontier-shell {
        max-width: none;
        min-height: 0;
        margin: 0;
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    body.interface-frontier .frontier-shell__hero { display: none; }
    body.interface-frontier .site-brand { display: inline; }

    body.interface-frontier .site-header {
        height: var(--header-height);
        padding: 0 14px;
        background: color-mix(in srgb, var(--bg-surface) 84%, transparent);
        border-top: 0;
        border-bottom-color: var(--border-color);
    }

    body.interface-frontier .site-nav-right { gap: 14px; }

    body.interface-frontier .site-body {
        min-height: 0;
        background: transparent;
        background-image: none;
        background-attachment: scroll;
    }

    body.interface-frontier .site-body > .page-container {
        max-width: 1100px;
        padding: 24px 20px 60px;
        border-radius: 0;
        background: transparent;
    }

    body.interface-frontier .page-header { padding-top: 0; }
    body.interface-frontier .page-title {
        font-size: clamp(1.7rem, 1.15rem + 2.3vw, 2.45rem);
        letter-spacing: -0.02em;
    }

    body.interface-frontier .panel {
        border-color: var(--border-color);
        border-radius: var(--radius-lg);
        background: var(--bg-surface);
        box-shadow: var(--shadow-sm);
    }

    body.interface-frontier .conditions-strip {
        display: flex;
        grid-template-columns: none;
        gap: 16px;
        padding: 15px 20px;
        margin-bottom: 20px;
        border-color: var(--border-subtle);
        border-radius: var(--radius-lg);
        box-shadow: none;
    }

    /* Restore the normal one-column phone and 1.6fr/1fr tablet dashboard
       geometry. The named Frontier command/glance layout starts at desktop. */
    body.interface-frontier .command-grid {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-areas: none;
        gap: 18px;
    }
    body.interface-frontier .command-grid::before { display: none; }
    body.interface-frontier .command-column {
        display: grid;
        grid-area: auto;
        gap: 18px;
        align-content: start;
    }
    body.interface-frontier .command-glance {
        grid-area: auto;
        margin-top: 0;
    }
}

@media (768px <= width < 1024px) {
    body.interface-frontier .command-grid {
        grid-template-columns: 1.6fr 1fr;
    }
}

@media (max-width: 380px) {
    body.interface-frontier .site-header { padding: 0 12px; }
}

/* ---- Frontier responsive cleanup ----
   The shell is desktop-only, but its header still carries desktop context at tablet
   widths. Keep the conditions and summary readable instead of compressing them into
   narrow flex items. */
@media (width < 1024px) {
    body.interface-frontier .weather-chip,
    body.interface-frontier .site-clock--header { display: none; }
    body.interface-frontier .account-menu-clock { display: flex; }
    body.interface-frontier .site-nav-right { gap: 10px; }
}

@media (768px <= width < 1024px) {
    /* The summary panel needs the full tablet reading width; keeping it as a narrow
       second column turns every stat and action into a tall stack. */
    body.interface-frontier .command-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    /* The icon, long consequence copy, and Star Map action each get a readable row on
       phones. This prevents the body from collapsing to ~47px beside the two side items. */
    body.interface-frontier .conditions-strip {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
        padding: 14px 16px;
    }
    body.interface-frontier .conditions-strip__icon { align-self: flex-start; }
    body.interface-frontier .conditions-strip__body {
        flex: 0 1 auto;
        width: 100%;
    }
    body.interface-frontier .conditions-strip > .btn,
    body.interface-frontier .conditions-strip > a { align-self: flex-start; }

    /* A single resource opener is easier to scan and leaves the notification and
       account controls their own space. The hidden chips remain in the DOM for updates. */
    body.interface-frontier .currency-cluster { display: none; }
    body.interface-frontier .nav-currency-more__3,
    body.interface-frontier .nav-currency-more__4 { display: none; }
    body.interface-frontier .nav-currency-more__label { display: inline; }
    body.interface-frontier .nav-currency-more {
        flex: 0 0 auto;
        min-width: 76px;
        min-height: 38px;
        padding: 6px 8px;
        font-size: .72rem;
    }
}

@media (max-width: 380px) {
    body.interface-frontier .site-nav-right { gap: 6px; }
    body.interface-frontier [data-surface="command-post"] .page-header__actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        width: 100%;
    }
    body.interface-frontier [data-surface="command-post"] .page-header__actions > .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (width < 1024px) and (pointer: coarse) {
    body.interface-frontier .nav-currency-more { min-width: 76px; min-height: 44px; }
    body.interface-frontier .notif-bell-toggle,
    body.interface-frontier .account-menu-toggle { min-width: 44px; }
}

/* ---- Left-side mobile/tablet navigation ----
   This preference mirrors only the responsive navigation affordances. The
   desktop mouse rail and the order of the five primary destinations stay unchanged. */
@media (width < 1024px) {
    /* The Menu opener moves to the leading edge when the drawer is mirrored. It is one
       button ordered by CSS, not a second copy of the markup: two mutually-exclusive
       template branches put the same id in the file twice, which a static reader cannot
       tell apart from a real duplicate. The five primary destinations keep their order. */
    body.mobile-nav-mirrored .mobile-tabbar > button { order: -1; }

    body.mobile-nav-mirrored .nav-drawer {
        right: auto;
        left: 0;
        border-left: 0;
        border-right: 1px solid var(--border-color);
    }
}

/* Landscape touch tablets can cross the desktop width breakpoint while still
   needing the navigation on the opposite side. Keep ordinary desktop mouse
   layouts unchanged; this only mirrors the full rail for coarse-pointer devices. */
@media (min-width: 1024px) and (hover: none) and (pointer: coarse) {
    body.mobile-nav-mirrored .site-sidebar {
        order: 2;
        border-right: 0;
        border-left: 1px solid var(--border-subtle);
    }

    body.mobile-nav-mirrored .site-sidebar .sidebar-nav a.is-active::before {
        right: -14px;
        left: auto;
        border-radius: 3px 0 0 3px;
    }

    body.interface-frontier.mobile-nav-mirrored .site-sidebar {
        border-left-color: var(--frontier-shell-border);
        border-radius: 0;
    }

    body.interface-frontier.mobile-nav-mirrored .site-body > .page-container {
        border-radius: 0 0 0 99px;
    }
}

/* ============================================================
   Frontier navigation polish
   Keep the authored neon palette, but give the rail a calmer console rhythm:
   one clear surface per destination, a quieter nested hierarchy, and a
   scrollbar that reads as utility chrome instead of a second accent. These
   rules are Frontier-only; Legacy navigation keeps its existing treatment.
   ============================================================ */
html.frontier-document {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--color-violet, #9B7CFF) 52%, var(--border-color, #40305A)) transparent;
}

body.interface-frontier .site-sidebar,
body.interface-frontier .nav-drawer,
body.interface-frontier .site-sidebar .sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--color-violet) 52%, var(--border-color)) transparent;
}

html.frontier-document::-webkit-scrollbar,
body.interface-frontier .site-sidebar::-webkit-scrollbar,
body.interface-frontier .site-sidebar .sidebar-nav::-webkit-scrollbar,
body.interface-frontier .nav-drawer::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

html.frontier-document::-webkit-scrollbar-track,
body.interface-frontier .site-sidebar::-webkit-scrollbar-track,
body.interface-frontier .site-sidebar .sidebar-nav::-webkit-scrollbar-track,
body.interface-frontier .nav-drawer::-webkit-scrollbar-track {
    background: transparent;
}

html.frontier-document::-webkit-scrollbar-thumb,
body.interface-frontier .site-sidebar::-webkit-scrollbar-thumb,
body.interface-frontier .site-sidebar .sidebar-nav::-webkit-scrollbar-thumb,
body.interface-frontier .nav-drawer::-webkit-scrollbar-thumb {
    min-height: 44px;
    border: 2px solid transparent;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-violet, #9B7CFF) 48%, var(--border-color, #40305A));
    background-clip: padding-box;
}

@media (hover: hover) {
    html.frontier-document::-webkit-scrollbar-thumb:hover,
    body.interface-frontier .site-sidebar::-webkit-scrollbar-thumb:hover,
    body.interface-frontier .site-sidebar .sidebar-nav::-webkit-scrollbar-thumb:hover,
    body.interface-frontier .nav-drawer::-webkit-scrollbar-thumb:hover {
        background: color-mix(in srgb, var(--color-primary, #64D8FF) 62%, var(--border-color, #40305A));
        background-clip: padding-box;
    }
}

body.interface-frontier .site-sidebar {
    background-image:
        linear-gradient(180deg, color-mix(in srgb, var(--bg-surface) 38%, transparent), color-mix(in srgb, var(--bg-body) 74%, transparent) 88%),
        var(--frontier-rail-art, none);
    box-shadow: inset -1px 0 color-mix(in srgb, var(--color-primary) 24%, transparent);
}

body.interface-frontier .site-sidebar .sidebar-nav,
body.interface-frontier .nav-drawer .sidebar-nav {
    gap: 6px;
}

body.interface-frontier .site-sidebar .sidebar-nav {
    padding: 10px 8px 16px;
}

body.interface-frontier .sidebar-nav > a,
body.interface-frontier .sidebar-nav-group > summary {
    min-height: 52px;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--color-primary) 15%, transparent);
    border-radius: 12px;
    background: color-mix(in srgb, var(--bg-surface) 40%, transparent);
    color: var(--text-secondary);
    text-shadow: none;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
                box-shadow var(--dur) var(--ease), color var(--dur) var(--ease);
}

body.interface-frontier .sidebar-nav-group {
    margin-top: 0;
}

body.interface-frontier .sidebar-nav-group__hint {
    color: var(--text-muted);
}

body.interface-frontier .sidebar-nav-group__chevron {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: .95rem;
}

body.interface-frontier .sidebar-nav-group__label {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: break-word;
}

body.interface-frontier .sidebar-nav > a {
    min-width: 0;
    overflow-wrap: anywhere;
}

body.interface-frontier .sidebar-nav a.is-active,
body.interface-frontier .sidebar-nav-group[open] > summary {
    border-color: color-mix(in srgb, var(--color-primary) 48%, var(--border-color));
    background: linear-gradient(135deg, color-mix(in srgb, var(--color-violet) 42%, var(--bg-surface)), color-mix(in srgb, var(--color-primary) 24%, var(--bg-body)));
    color: var(--text-primary);
    box-shadow: inset 3px 0 var(--color-primary), 0 6px 16px color-mix(in srgb, var(--bg-body) 24%, transparent);
}

body.interface-frontier .sidebar-nav-group__items {
    gap: 3px;
    margin: 2px 0 2px 8px;
    padding: 3px 0 3px 8px;
    border-left: 1px solid color-mix(in srgb, var(--color-primary) 30%, var(--border-subtle));
}

body.interface-frontier .sidebar-nav-group__items a,
body.interface-frontier .sidebar-nav-group[open] .sidebar-nav-group__items a {
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--text-secondary);
    font-size: .8rem;
    text-shadow: none;
}

body.interface-frontier .sidebar-nav-group__items a.is-active {
    border-color: color-mix(in srgb, var(--color-primary) 34%, transparent);
    background: color-mix(in srgb, var(--color-primary) 18%, var(--bg-surface));
    color: var(--text-primary);
}

@media (hover: hover) {
    body.interface-frontier .sidebar-nav > a:hover,
    body.interface-frontier .sidebar-nav-group > summary:hover {
        border-color: color-mix(in srgb, var(--color-primary) 38%, var(--border-color));
        background: color-mix(in srgb, var(--color-violet) 28%, var(--bg-hover));
        color: var(--text-primary);
        letter-spacing: normal;
    }

    body.interface-frontier .sidebar-nav-group__items a:hover {
        border-color: color-mix(in srgb, var(--color-primary) 24%, transparent);
        background: color-mix(in srgb, var(--color-violet) 18%, var(--bg-hover));
        color: var(--text-primary);
        letter-spacing: normal;
    }
}

body.interface-frontier .nav-drawer {
    background: var(--bg-elevated);
    border-left-color: color-mix(in srgb, var(--color-primary) 36%, var(--border-color));
}

body.interface-frontier .nav-drawer__head {
    border-bottom-color: color-mix(in srgb, var(--color-primary) 22%, var(--border-subtle));
}

body.interface-frontier .mobile-tabbar {
    background: var(--bg-surface);
    border-top-color: color-mix(in srgb, var(--color-primary) 34%, var(--border-color));
    box-shadow: 0 -10px 26px color-mix(in srgb, var(--bg-body) 34%, transparent);
}

body.interface-frontier .mobile-tab {
    border: 1px solid transparent;
    color: var(--text-muted);
}

body.interface-frontier .mobile-tab.is-active {
    border-color: color-mix(in srgb, var(--color-primary) 34%, transparent);
    background: color-mix(in srgb, var(--color-violet) 24%, transparent);
    color: var(--text-primary);
}

body.interface-frontier .mobile-tab.is-active .nav-ico {
    filter: drop-shadow(0 0 4px color-mix(in srgb, var(--color-primary) 62%, transparent));
}

