:root {
    color-scheme: light;
    --core-surface: #fff;
    --core-text-primary: #0B1F3B;
    --core-text-muted: #64748b;
    --core-border: #E5ECF6;
    --core-accent: #0B1F3B;
    --core-on-accent: #fff;
    --core-focus: #f59e0b;
}

/* VF01: Core-internal presentation values, not a MiniApp/theming API. */
:where(.core-shell-workspace, .core-shell-runtime) {
    --core-space-1: 4px;
    --core-space-2: 8px;
    --core-space-3: 12px;
    --core-space-4: 16px;
    --core-space-6: 24px;
    --core-space-8: 32px;
    --core-space-12: 48px;
    --core-title-size: 28px;
    --core-section-size: 20px;
    --core-component-size: 18px;
    --core-body-size: 16px;
    --core-secondary-size: 14px;
    --core-caption-size: 13px;
    --core-radius: 12px;
    --core-sidebar-width: 14rem;
    --core-soft-surface: #E5ECF6;
    --core-danger: #a32626;
    --core-focus: #9a5700;
    font-size: var(--core-body-size);
    line-height: 1.5;
}

body.installer-page {
    min-height: 100vh;
    background: #f6f8f7;
}

body.core-shell {
    background: var(--core-surface);
    color: var(--core-text-primary);
    min-height: 100vh;
}

.core-layout {
    min-height: 100vh;
}

.core-sidebar {
    display: none;
}

.core-main-wrap {
    min-height: 100vh;
    padding-bottom: 0;
}

.core-shell-workspace .core-main-wrap {
    padding-bottom: calc(5.25rem + env(safe-area-inset-bottom));
}

.core-topbar {
    align-items: center;
    background: var(--core-surface);
    border-bottom: 1px solid var(--core-border);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.core-main {
    margin: 0 auto;
    max-width: 1120px;
    padding: 1rem;
}

.core-kicker {
    color: var(--core-accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.core-brand {
    align-items: center;
    color: var(--core-text-primary);
    display: flex;
    font-weight: 800;
    gap: 0.75rem;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    text-decoration: none;
}

.core-brand-mark {
    align-items: center;
    background: var(--core-surface);
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    flex: 0 0 2.5rem;
    font-weight: 800;
    height: 2.5rem;
    justify-content: center;
    width: 2.5rem;
}

.core-nav {
    display: grid;
    gap: 0.4rem;
}

.core-nav-link,
.core-bottom-link {
    align-items: center;
    border-radius: 8px;
    color: var(--core-text-primary);
    display: flex;
    gap: 0.75rem;
    min-height: 2.75rem;
    padding: 0.7rem 0.85rem;
    text-decoration: none;
}

.core-nav-link:hover,
.core-bottom-link:hover {
    background: var(--core-border);
    color: var(--core-accent);
}

.core-nav-link.is-active,
.core-bottom-link.is-active {
    background: var(--core-accent);
    color: #fff;
    font-weight: 700;
    outline: 2px solid transparent;
}

.core-nav-icon {
    align-items: center;
    display: inline-flex;
    flex: 0 0 1.25rem;
    font-size: 1.1rem;
    justify-content: center;
    width: 1.25rem;
}

.core-nav-icon-favorites::before {
    content: "★";
}

.core-nav-icon-apps::before {
    content: "▦";
}

.core-nav-icon-recent::before {
    content: "↻";
}

.core-user-card {
    border-top: 1px solid var(--core-border);
    display: grid;
    gap: 0.35rem;
    margin-top: auto;
    padding-top: 1rem;
}

.core-user-card span,
.core-user-card small {
    color: #64748b;
    overflow-wrap: anywhere;
}

.core-user-card form {
    margin-top: 0.5rem;
}

.core-topbar-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.core-bottom-nav {
    align-items: stretch;
    background: #fff;
    border-top: 1px solid var(--core-border);
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    left: 0;
    padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    z-index: 20;
}

.core-bottom-link {
    flex-direction: column;
    font-size: 0.78rem;
    gap: 0.15rem;
    justify-content: center;
    min-height: 4.25rem;
    padding: 0.35rem;
    text-align: center;
}

.launcher-heading {
    align-items: end;
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.launcher-heading h1 {
    font-size: var(--core-title-size, clamp(1.65rem, 4vw, 2.35rem));
    line-height: 1.2;
    font-weight: 800;
    margin-bottom: 0.35rem;
}

.launcher-heading p:last-child {
    color: #64748b;
    margin-bottom: 0;
}

.launcher-empty {
    background: #fff;
    border: 1px solid var(--core-border);
    border-radius: var(--core-radius);
    padding: var(--core-space-4);
}

.launcher-empty-icon {
    align-items: center;
    background: var(--core-border);
    border-radius: var(--core-radius);
    color: var(--core-accent);
    display: inline-flex;
    font-weight: 800;
    height: 3rem;
    justify-content: center;
    margin-bottom: 1rem;
    width: 3rem;
}

.launcher-empty-icon::before {
    content: "▦";
}

.app-grid {
    display: grid;
    gap: var(--core-space-4);
}

.app-card {
    background: #fff;
    border: 1px solid var(--core-border);
    border-radius: var(--core-radius);
    display: grid;
    gap: 1rem;
    padding: 1rem;
}

.app-card-main {
    align-items: start;
    display: grid;
    gap: var(--core-space-4);
    grid-template-columns: auto minmax(0, 1fr);
    min-width: 0;
}

.app-icon {
    align-items: center;
    background: var(--core-border);
    border-radius: var(--core-radius);
    color: var(--core-accent);
    display: inline-flex;
    flex: 0 0 3rem;
    font-weight: 800;
    height: 3rem;
    justify-content: center;
    width: 3rem;
}

.app-icon::before {
    content: "▦";
}

.app-card-copy {
    min-width: 0;
}

.app-card-copy h2 {
    font-size: var(--core-component-size);
    font-weight: 800;
    margin-bottom: 0.25rem;
    overflow-wrap: anywhere;
}

.app-card-copy p {
    color: #64748b;
    margin-bottom: 0;
    overflow-wrap: anywhere;
    font-size: var(--core-secondary-size);
}

.app-card-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* The inert in-flow copy shares intrinsic sizing with the fixed surface. */
.miniapp-local-nav,
.miniapp-local-nav-reserve {
    background: var(--core-surface);
    border-top: 1px solid var(--core-border);
    box-sizing: border-box;
    display: grid;
    gap: 0.25rem;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    min-height: calc(4rem + env(safe-area-inset-bottom));
    max-height: 50vh;
    max-height: 50dvh;
    overflow-y: auto;
    padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
}

.miniapp-local-nav {
    bottom: 0;
    left: 0;
    position: fixed;
    right: 0;
    z-index: 20;
}

.miniapp-local-nav-reserve {
    /* Match the viewport surface width across Core's mobile 1rem main padding. */
    margin-inline: -1rem;
    visibility: hidden;
    pointer-events: none;
}

.miniapp-local-nav-item {
    align-items: center;
    border: 1px solid var(--core-border);
    border-radius: var(--core-radius);
    color: var(--core-text-primary);
    display: flex;
    flex-direction: column;
    font-size: var(--core-secondary-size);
    font-weight: 600;
    gap: 0.25rem;
    justify-content: center;
    min-height: 44px;
    min-width: 0;
    overflow-wrap: anywhere;
    padding: 0.5rem 0;
    text-align: center;
    text-decoration: none;
}

.miniapp-local-nav-label,
.miniapp-local-nav-disabled-reason {
    flex-shrink: 0;
    max-width: 100%;
}

.miniapp-local-nav-item.is-active {
    background: var(--core-accent);
    color: var(--core-on-accent);
    box-shadow: inset 0 3px 0 var(--core-on-accent);
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.miniapp-local-nav-item.is-disabled {
    border-style: dashed;
}

.miniapp-local-nav-disabled-reason {
    color: var(--core-text-muted);
    font-size: var(--core-caption-size);
    font-weight: 400;
}

.miniapp-local-nav-item:focus-visible {
    outline: 3px solid var(--core-focus);
    outline-offset: -3px;
}

/* Primary action stays in document flow, separate from the fixed local navigation. */
.miniapp-primary-action {
    margin-bottom: 1rem;
    padding-bottom: env(safe-area-inset-bottom);
    overflow-wrap: anywhere;
}

.miniapp-primary-action-control {
    align-items: center;
    background: var(--core-accent);
    border: 2px solid var(--core-accent);
    border-radius: var(--core-radius);
    box-sizing: border-box;
    color: var(--core-on-accent);
    display: flex;
    font: inherit;
    font-weight: 700;
    gap: var(--core-space-2);
    justify-content: center;
    min-height: 48px;
    padding: 0.75rem 1rem;
    text-align: center;
    text-decoration: none;
    width: 100%;
}

.miniapp-primary-action-label {
    min-width: 0;
}

.miniapp-primary-action-control:hover {
    color: var(--core-on-accent);
    text-decoration: underline;
}

.miniapp-primary-action-control.is-disabled {
    background: var(--core-soft-surface);
    border-color: var(--core-border);
    border-style: dashed;
    color: var(--core-text-muted);
}

.miniapp-primary-action-control:focus-visible {
    outline: 3px solid var(--core-focus);
    outline-offset: 2px;
}

.miniapp-primary-action-reason {
    color: var(--core-text-primary);
    margin: 0.5rem 0 0;
}

/* Touched Core controls only: domain-owned MiniApp forms/cards are not restyled. */
:where(.core-shell-workspace, .core-shell-runtime) :is(.core-main-wrap, .core-main, .core-topbar > div) {
    min-width: 0;
}
:where(.core-shell-workspace, .core-shell-runtime) .core-topbar {
    flex-wrap: wrap;
    gap: var(--core-space-3);
}
:where(.core-shell-workspace, .core-shell-runtime) .core-kicker {
    color: var(--core-accent);
    font-size: var(--core-caption-size);
    letter-spacing: 0.06em;
}
:where(.core-shell-workspace, .core-shell-runtime) .core-brand {
    overflow-wrap: anywhere;
    font-size: var(--core-component-size);
}
:where(.core-shell-workspace, .core-shell-runtime) .launcher-heading {
    margin-bottom: var(--core-space-6);
    overflow-wrap: anywhere;
}
:where(.core-shell-workspace, .core-shell-runtime) .core-main {
    width: 100%;
}
:where(.core-shell-workspace, .core-shell-runtime) :is(.core-topbar, .core-user-card, .app-card-actions) .btn,
:where(.core-shell-workspace, .core-shell-runtime) .core-workspace-return {
    --bs-btn-border-radius: var(--core-radius);
    --bs-btn-font-size: var(--core-secondary-size);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--core-space-2);
    padding: var(--core-space-2) var(--core-space-3);
    white-space: normal;
}
/* Ordinary Core actions use brand colors; success alerts/validation stay semantic. */
.core-shell .btn-success,
.installer-shell .btn-primary {
    --bs-btn-color: var(--core-on-accent);
    --bs-btn-bg: var(--core-accent);
    --bs-btn-border-color: var(--core-accent);
    --bs-btn-hover-color: var(--core-on-accent);
    --bs-btn-hover-bg: var(--core-accent);
    --bs-btn-hover-border-color: var(--core-accent);
    --bs-btn-active-color: var(--core-on-accent);
    --bs-btn-active-bg: var(--core-accent);
    --bs-btn-active-border-color: var(--core-accent);
    --bs-btn-disabled-color: var(--core-on-accent);
    --bs-btn-disabled-bg: var(--core-accent);
    --bs-btn-disabled-border-color: var(--core-accent);
    --bs-btn-focus-shadow-rgb: 11, 31, 59;
}
.core-shell .btn-outline-success {
    --bs-btn-color: var(--core-accent);
    --bs-btn-border-color: var(--core-accent);
    --bs-btn-hover-color: var(--core-on-accent);
    --bs-btn-hover-bg: var(--core-accent);
    --bs-btn-hover-border-color: var(--core-accent);
    --bs-btn-active-color: var(--core-on-accent);
    --bs-btn-active-bg: var(--core-accent);
    --bs-btn-active-border-color: var(--core-accent);
    --bs-btn-disabled-color: var(--core-accent);
    --bs-btn-disabled-border-color: var(--core-accent);
    --bs-btn-focus-shadow-rgb: 11, 31, 59;
}
.app-card-actions {
    justify-content: space-between;
    margin-top: auto;
}
.launcher-empty h2 { font-size: var(--core-section-size); }
.core-shell-workspace .core-bottom-link { font-size: var(--core-caption-size); }
.core-shell-workspace :is(.core-nav-link, .core-bottom-link).is-active {
    text-decoration: underline;
    text-underline-offset: 0.25em;
}
:where(.core-shell-workspace, .core-shell-runtime) :is(a, button, [tabindex]):focus-visible {
    outline: 3px solid var(--core-focus);
    outline-offset: 2px;
    box-shadow: none;
}
.miniapp-local-nav-icon,
.miniapp-primary-action-icon {
    font-size: var(--core-section-size);
    line-height: 1;
    flex: 0 0 auto;
}
.miniapp-local-nav-item:focus-visible { outline-offset: -3px; }
.miniapp-primary-action-control[aria-busy="true"] { cursor: progress; }

/* Narrow stress: retain bottom navigation, give full labels wider natural rows. */
@media (max-width: 359.98px) {
    .miniapp-local-nav,
    .miniapp-local-nav-reserve {
        grid-auto-flow: row;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-columns: auto;
    }
    .miniapp-local-nav-item:only-child { grid-column: 1 / -1; }
}

.admin-panel {
    display: grid;
    gap: 1rem;
}

.admin-action-card,
.admin-table-wrap,
.admin-form,
.admin-assignment-list {
    background: #fff;
    border: 1px solid var(--core-border);
    border-radius: 8px;
}

.admin-action-card {
    color: var(--core-text-primary);
    display: grid;
    gap: 0.25rem;
    padding: 1rem;
    text-decoration: none;
}

.admin-action-card:hover {
    border-color: var(--core-accent);
    color: var(--core-accent);
}

.admin-action-card span,
.admin-assignment-row small {
    color: #64748b;
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-form {
    display: grid;
    gap: 1rem;
    padding: 1rem;
}

.admin-assignment-list {
    display: grid;
}

.admin-assignment-row {
    align-items: start;
    border-bottom: 1px solid var(--core-border);
    cursor: pointer;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: auto 1fr;
    margin: 0;
    padding: 0.9rem 1rem;
}

.admin-assignment-row:last-child {
    border-bottom: 0;
}

.admin-assignment-row span {
    display: grid;
    gap: 0.15rem;
    min-width: 0;
}

.admin-assignment-row strong,
.admin-assignment-row small {
    overflow-wrap: anywhere;
}

.favorite-icon {
    display: inline-block;
    min-width: 1rem;
}

:focus-visible {
    outline: 3px solid #f59e0b;
    outline-offset: 2px;
}

.installer-shell {
    max-width: 760px;
}

.requirements-list {
    display: grid;
    gap: 0.75rem;
}

.requirement-row {
    align-items: start;
    background: #fff;
    border: 1px solid var(--core-border);
    border-radius: 8px;
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr auto;
    padding: 1rem;
}

.installation-evidence {
    display: grid;
    gap: 0.75rem;
}

.installation-evidence div {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.75rem;
}

.installation-evidence dt {
    font-weight: 700;
}

.installation-evidence dd {
    margin-bottom: 0;
}

.installer-steps {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    list-style: none;
    padding: 0;
}

.installer-steps li {
    align-items: center;
    color: #64748b;
    display: grid;
    gap: 0.35rem;
    justify-items: center;
    min-width: 0;
    text-align: center;
}

.installer-steps span {
    align-items: center;
    background: #e5e7eb;
    border-radius: 999px;
    display: inline-flex;
    font-weight: 700;
    height: 2rem;
    justify-content: center;
    width: 2rem;
}

.installer-steps strong {
    font-size: 0.75rem;
    font-weight: 600;
}

.installer-steps .is-active {
    color: var(--core-accent);
}

.installer-steps .is-active span,
.installer-steps .is-done span {
    background: #198754;
    color: #fff;
}

.installer-form {
    display: grid;
    gap: 0.6rem;
}

.installer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

@media (max-width: 575.98px) {
    .requirement-row {
        grid-template-columns: 1fr;
    }

    .requirement-row .badge {
        justify-self: start;
    }

    .installer-steps {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .installer-actions {
        display: grid;
    }
}

@media (min-width: 768px) {
    .miniapp-primary-action {
        margin-left: auto;
        max-width: 28rem;
        padding-bottom: 0;
    }

    .miniapp-runtime-view.has-local-navigation {
        padding-bottom: 0;
    }

    .miniapp-local-nav {
        height: auto;
        min-height: 0;
        max-height: none;
        margin-bottom: 1rem;
        padding: 0.5rem;
        border: 1px solid var(--core-border);
        border-radius: var(--core-radius);
        position: static;
    }

    .miniapp-local-nav-reserve {
        display: none;
    }

    .core-layout {
        display: grid;
        grid-template-columns: var(--core-sidebar-width, 17rem) minmax(0, 1fr);
    }

    .core-sidebar {
        background: #fff;
        border-right: 1px solid var(--core-border);
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        padding: 1.25rem;
        position: sticky;
        top: 0;
    }

    .core-shell-workspace .core-main-wrap {
        padding-bottom: 0;
    }

    .core-topbar,
    .core-bottom-nav {
        display: none;
    }

    .core-main {
        padding: 2rem;
    }

    .app-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    }
}

@media (min-width: 1100px) {
    .app-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
