 :root {
    --ds-radius: 4px;
    --ds-font-family: Inter, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    --ds-font-size: 14px;
    --ds-line-height: 1.45;
    --ds-header-height: 64px;
    --ds-footer-height: 36px;
    --ds-subheader-height: 40px;
    --ds-left-panel-width: 280px;
    --ds-left-panel-collapsed-width: 56px;
    --ds-content-max-width: none;
    --ds-shadow-sm: 0 1px 2px rgba(0, 0, 0, .18);
    --ds-shadow-md: 0 8px 24px rgba(0, 0, 0, .22);
    --ds-transition-fast: 140ms ease;
    --ds-transition-med: 220ms ease;

    --ds-accent: #2f6dff;
    --ds-default: #6b7280;
    --ds-success: #16a34a;
    --ds-warning: #d97706;
    --ds-danger: #dc2626;
    --ds-info: #0891b2;
    --ds-accent-contrast: #ffffff;
}

html[data-theme="dark"] {
    --ds-bg: #141414;
    --ds-bg-elevated: #1d1d1d;
    --ds-bg-panel: #1a1a1a;
    --ds-bg-panel-2: #202020;
    --ds-bg-hover: #2c2c2c;
    --ds-bg-active: #282828;
    --ds-text: #ececec;
    --ds-text-muted: #b2b2b2;
    --ds-text-soft: #8a8a8a;
    --ds-border: #353535;
    --ds-border-strong: #4b4b4b;
    --ds-accent: #2f6dff;
    --ds-default: #6b7280;
    --ds-success: #16a34a;
    --ds-warning: #d97706;
    --ds-danger: #dc2626;
    --ds-info: #0891b2;
    --ds-accent-contrast: #ffffff;
    --ds-overlay: rgba(0, 0, 0, 0.62);
    --ds-header-bg: #181818;
    --ds-footer-bg: #181818;
    color-scheme: dark;
}

html[data-theme="light"] {
    --ds-bg: #f2f3f5;
    --ds-bg-elevated: #ffffff;
    --ds-bg-panel: #ffffff;
    --ds-bg-panel-2: #f7f8fb;
    --ds-bg-hover: #eceef2;
    --ds-bg-active: #eef1f5;
    --ds-text: #1c222b;
    --ds-text-muted: #4b5565;
    --ds-text-soft: #6a7483;
    --ds-border: #d7dce4;
    --ds-border-strong: #bec5d0;
    --ds-accent: #2f6dff;
    --ds-default: #6b7280;
    --ds-success: #16a34a;
    --ds-warning: #d97706;
    --ds-danger: #dc2626;
    --ds-info: #0891b2;
    --ds-accent-contrast: #ffffff;
    --ds-overlay: rgba(9, 12, 18, 0.42);
    --ds-header-bg: #ffffff;
    --ds-footer-bg: #ffffff;
    color-scheme: light;
}

html[data-theme="alpine"] {
    --ds-bg: #10161a;
    --ds-bg-elevated: #182026;
    --ds-bg-panel: #141b20;
    --ds-bg-panel-2: #1d262d;
    --ds-bg-hover: #2b3943;
    --ds-bg-active: #26313a;
    --ds-text: #e7edf2;
    --ds-text-muted: #b5c1cb;
    --ds-text-soft: #8897a3;
    --ds-border: #42525f;
    --ds-border-strong: #607483;
    --ds-accent: #7b7fd7;
    --ds-default: #72808d;
    --ds-success: #37946e;
    --ds-warning: #c69b45;
    --ds-danger: #b65b4b;
    --ds-info: #4ea6d3;
    --ds-accent-contrast: #f5f4ff;
    --ds-overlay: rgba(5, 9, 12, 0.74);
    --ds-header-bg: #12181d;
    --ds-footer-bg: #12181d;
    color-scheme: dark;
}

html[data-theme="midnight-ink"] {
    --ds-bg: #0d1117;
    --ds-bg-elevated: #141a22;
    --ds-bg-panel: #10161d;
    --ds-bg-panel-2: #161d27;
    --ds-bg-hover: #243043;
    --ds-bg-active: #1f2936;
    --ds-text: #ecf1f7;
    --ds-text-muted: #b7c1cf;
    --ds-text-soft: #8591a3;
    --ds-border: #2c394b;
    --ds-border-strong: #42546d;
    --ds-accent: #4e7dff;
    --ds-default: #6c7a8b;
    --ds-success: #1fb56d;
    --ds-warning: #e28a18;
    --ds-danger: #e05252;
    --ds-info: #1fa9d6;
    --ds-accent-contrast: #f8fbff;
    --ds-overlay: rgba(4, 8, 14, 0.76);
    --ds-header-bg: #0f141b;
    --ds-footer-bg: #0f141b;
    color-scheme: dark;
}

html[data-theme="paper-ink"] {
    --ds-bg: #f3efe6;
    --ds-bg-elevated: #fbf8f1;
    --ds-bg-panel: #fcf9f3;
    --ds-bg-panel-2: #f5efe4;
    --ds-bg-hover: #ebe3d6;
    --ds-bg-active: #ede5d8;
    --ds-text: #27231d;
    --ds-text-muted: #5f5548;
    --ds-text-soft: #7b7062;
    --ds-border: #d2c7b6;
    --ds-border-strong: #b8aa97;
    --ds-accent: #365f9c;
    --ds-default: #746a5e;
    --ds-success: #2f7d55;
    --ds-warning: #bf7a12;
    --ds-danger: #b23a33;
    --ds-info: #1f78a8;
    --ds-accent-contrast: #ffffff;
    --ds-overlay: rgba(29, 24, 18, 0.28);
    --ds-header-bg: #f8f4ec;
    --ds-footer-bg: #f8f4ec;
    color-scheme: light;
}

html[data-theme="hot-cocoa"] {
    --ds-bg: #151010;
    --ds-bg-elevated: #1d1616;
    --ds-bg-panel: #241c1c;
    --ds-bg-panel-2: #2d2323;
    --ds-bg-hover: #352929;
    --ds-bg-active: #403030;
    --ds-text: #f0e8e1;
    --ds-text-soft: #c3b4aa;
    --ds-text-muted: #9f8f86;
    --ds-border: #4a3937;
    --ds-border-strong: #5a4642;
    --ds-accent: #cc8a4a;
    --ds-accent-contrast: #180f08;
    --ds-success: #6cab77;
    --ds-warning: #d5a450;
    --ds-danger: #d77d73;
    --ds-info: #7cb0d2;
    --ds-default: #b9aaa0;
    --ds-overlay: rgba(10, 6, 6, .72);
}

html[data-theme="parchment"] {
    --ds-bg: #e4dacb;
    --ds-bg-elevated: #eee5d8;
    --ds-bg-panel: #f1e8dc;
    --ds-bg-panel-2: #e8ddcf;
    --ds-bg-hover: #d9cdbd;
    --ds-bg-active: #ded2c2;
    --ds-text: #33281f;
    --ds-text-muted: #5c4b3c;
    --ds-text-soft: #786250;
    --ds-border: #bda88f;
    --ds-border-strong: #9a8167;
    --ds-accent: #7a5438;
    --ds-default: #7a6859;
    --ds-success: #536947;
    --ds-warning: #b07a1b;
    --ds-danger: #9d4a39;
    --ds-info: #4d7087;
    --ds-accent-contrast: #fffaf4;
    --ds-overlay: rgba(31, 22, 14, 0.30);
    --ds-header-bg: #ddd0be;
    --ds-footer-bg: #ddd0be;
    color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
html { font-size: var(--ds-font-size); }
body {
    margin: 0;
    font-family: var(--ds-font-family);
    line-height: var(--ds-line-height);
    background: var(--ds-bg);
    color: var(--ds-text);
}

a {
    color: var(--ds-accent);
    text-decoration: none;
}
a:hover { text-decoration: underline; }
button, input, select, textarea {
    font: inherit;
    color: inherit;
}
button { cursor: pointer; }
img { max-width: 100%; display: block; }
strong { font-weight: 600; }
small, .small { font-size: 12px; }
hr {
    margin: 16px 0;
    border: 0;
    border-top: 1px solid var(--ds-border);
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 12px;
    line-height: 1.2;
    font-weight: 600;
}
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }

.app-shell {
    min-height: 100vh;
}

.app-header,
.app-footer {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 1000;
}

.app-header {
    top: 0;
    background: var(--ds-header-bg);
    height: var(--ds-header-height);
    border-bottom: 1px solid var(--ds-border);
    display: grid;
    grid-template-columns: 280px minmax(360px, 1fr) 360px;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
}

.app-footer {
    bottom: 0;
    background: var(--ds-footer-bg);
    height: var(--ds-footer-height);
    border-top: 1px solid var(--ds-border);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: center;
    padding: 0 16px;
    font-size: 12px;
    color: var(--ds-text-soft);
}

.app-main {
    min-height: 100vh;
    padding-top: var(--ds-header-height);
    padding-bottom: var(--ds-footer-height);
}

.app-subheader {
    position: sticky;
    top: var(--ds-header-height);
    z-index: 900;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: var(--ds-subheader-height);
    padding: 0 16px;
    background: color-mix(in srgb, var(--ds-header-bg) 88%, var(--ds-bg));
    border-bottom: 1px solid var(--ds-border);
}

.app-subnav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--ds-subheader-height);
    flex-wrap: wrap;
}

.app-subnav__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: var(--ds-radius);
    color: var(--ds-text-soft);
}

.app-subnav__link:hover {
    background: var(--ds-bg-hover);
    color: var(--ds-text);
    text-decoration: none;
}

.app-subnav__link.is-active {
    background: var(--ds-bg-active);
    border-color: var(--ds-border);
    color: var(--ds-text);
}

.app-brand,
.app-header-center,
.app-header-right {
    min-width: 0;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-logo {
    width: 34px;
    height: 34px;
    border: 1px solid var(--ds-border-strong);
    border-radius: var(--ds-radius);
    background: linear-gradient(135deg, var(--ds-bg-panel-2), var(--ds-bg-panel));
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    box-shadow: var(--ds-shadow-sm);
}

.app-logo svg {
    width: 18px;
    height: 18px;
    stroke: var(--ds-accent);
    fill: none;
    stroke-width: 1.8;
}

.app-brand-name {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}

.app-brand-tag {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--ds-text-soft);
}

.app-header-center {
    display: flex;
    justify-content: center;
}

.app-header-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.footer-left,
.footer-center,
.footer-right {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
}

.footer-left { justify-content: flex-start; }
.footer-center { justify-content: center; white-space: nowrap; }
.footer-right { justify-content: flex-end; }
.footer-link { color: var(--ds-text-soft); }
.footer-link:hover { color: var(--ds-text); text-decoration: none; }

.surface {
    background: var(--ds-bg-elevated);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius);
    box-shadow: var(--ds-shadow-sm);
}

.page-wrap {
    width: 100%;
    max-width: none;
    margin: 0;
}

.page-head {
    position: relative;
    border-bottom: 0;
    padding: 1em;
}

    .page-head::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: -1px;
        height: 1px;
        background: linear-gradient( 90deg, transparent 0%, var(--ds-border) 18%, var(--ds-border) 50%, var(--ds-border) 82%, transparent 100% );
        opacity: 0.7;
        pointer-events: none;
        z-index: 1;
    }

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}
.page-kicker {
    font-size: 12px;
    color: var(--ds-text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 6px;
}
.page-description {
    color: var(--ds-text-soft);
    margin: 0;
}

.content-card {
    padding: 16px;
}

.content-section + .content-section { margin-top: 16px; }

.mobile-header-actions {
    display: none;
    align-items: center;
    gap: 8px;
}
.mobile-sheet {
    display: none;
}
.mobile-sheet__title {
    margin: 0;
    font-size: 14px;
}
.mobile-sheet__body > *:last-child {
    margin-bottom: 0;
}
.mobile-sheet .left-panel__inner {
    position: static;
    top: auto;
    height: auto;
    overflow: visible;
    padding: 0;
}
.mobile-sheet .left-panel__header {
    display: none;
}
.mobile-sheet .module-group__trigger.is-static {
    cursor: default;
}
.mobile-sheet .module-group__trigger.is-static .module-group__caret {
    display: none;
}
.mobile-sheet .module-group__menu {
    display: block;
}
.mobile-sheet .module-group__menu[hidden] {
    display: none !important;
}
.mobile-sheet .app-subnav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    justify-content: stretch;
}
.mobile-sheet .app-subnav__link {
    min-height: 36px;
    border-color: var(--ds-border);
    background: var(--ds-bg-panel);
}

@media (max-width: 1220px) {
    .app-header {
        grid-template-columns: 240px minmax(260px, 1fr) 300px;
    }
}

@media (max-width: 980px) {
    .app-header {
        grid-template-columns: 1fr;
        height: auto;
        padding: 12px;
    }
    .app-header-center,
    .app-header-right {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .app-main { padding-top: calc(var(--ds-mobile-header-offset, 132px) + 8px); }
    .app-subheader {
        position: static;
        justify-content: flex-start;
        padding: 6px 12px;
    }
    .app-subnav {
        justify-content: flex-start;
        min-height: 0;
    }
    .app-footer {
        grid-template-columns: 1fr;
        height: auto;
        padding: 8px 12px;
        gap: 6px;
    }
    .footer-left,
    .footer-center,
    .footer-right { justify-content: flex-start; flex-wrap: wrap; }
    .app-main { padding-bottom: 92px; }
}

@media (max-width: 900px) {
    .mobile-header-actions {
        display: inline-flex;
    }
    .app-subheader {
        display: none;
    }
    .app-header-right .dropdown-menu {
        position: fixed;
        top: calc(var(--ds-mobile-header-offset, 132px) - 6px);
        left: 12px;
        right: 12px;
        width: auto;
        min-width: 0;
        max-width: none;
    }
    .app-header-right .dropdown-menu[data-align="left"] {
        left: 12px;
        right: 12px;
    }
    .mobile-sheet {
        position: fixed;
        top: var(--ds-mobile-header-offset, 132px);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 980;
        overflow: auto;
        background: color-mix(in srgb, var(--ds-bg) 94%, transparent);
        border-top: 1px solid var(--ds-border);
        box-shadow: var(--ds-shadow-md);
    }
    .mobile-sheet.is-open {
        display: block;
    }
    .mobile-sheet__inner {
        min-height: 100%;
        padding: 12px;
        background: var(--ds-bg);
    }
    .mobile-sheet__header {
        position: sticky;
        top: 0;
        z-index: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 10px 12px;
        margin: -12px -12px 12px;
        background: var(--ds-bg-elevated);
        border-bottom: 1px solid var(--ds-border);
    }
}
