:root {
    --sidebar-width: 260px;
}

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

.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg, var(--bg));
    border-right: 1px solid var(--sidebar-border, var(--border));
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
    height: var(--app-chrome-height);
    min-height: var(--app-chrome-height);
    padding: 0 18px;
    text-decoration: none;
    color: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
    border-bottom: 1px solid var(--sidebar-border, var(--border));
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 10px;
}

.sidebar-upgrade {
    flex-shrink: 0;
    margin-top: auto;
    padding: 12px 10px 0;
}

.sidebar-resources {
    flex-shrink: 0;
    padding: 8px 10px 8px;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-upgrade-btn {
    display: block;
    width: 100%;
    text-align: center;
    text-decoration: none;
    font-size: 14px;
    padding: 10px 16px;
    box-sizing: border-box;
}

.sidebar-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sidebar-text-muted, var(--text-muted));
    padding: 8px 10px 6px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 2px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav-item:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.sidebar-nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.sidebar-nav-item.disabled {
    opacity: 0.45;
    pointer-events: none;
}

.sidebar-nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar-nav-icon svg {
    width: 18px;
    height: 18px;
}

.sidebar-nav-item.active .sidebar-nav-icon {
    opacity: 1;
}

.app-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.app-header-icon-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

.app-header-icon-btn:hover {
    border-color: var(--border-strong);
    background: var(--bg-elevated);
}

.app-header-icon-btn.hidden {
    display: none;
}

.app-header-sign-out-btn:hover {
    color: var(--error);
    border-color: rgba(255, 59, 48, 0.35);
    background: var(--error-bg);
}

.app-header-sign-out-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.app-header-sign-out-btn.hidden {
    display: none;
}

.app-header-sign-out-label {
    white-space: nowrap;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-main-header {
    display: flex;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    height: var(--app-chrome-height);
    min-height: var(--app-chrome-height);
    padding: 0 24px;
    border-bottom: 1px solid var(--sidebar-border);
    background: var(--sidebar-bg);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}

.sidebar-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-md);
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

.app-main-title {
    flex: 1;
    min-width: 0;
}

.app-main-title h1 {
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.25;
    margin: 0;
}

.app-main-subtitle {
    font-size: 0.6875rem;
    line-height: 1.25;
    color: var(--sidebar-text-muted, var(--text-muted));
    margin: 2px 0 0;
}

.app-main-title:has(.app-main-subtitle:not(.hidden)) h1 {
    font-size: 1rem;
}

.app-main-body {
    flex: 1;
    padding: 24px;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
}

.app-main-body:has(#setupPanel:not(.hidden)) {
    max-width: min(100%, 1200px);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 150;
}

.sidebar-overlay.visible {
    display: block;
}

#signedOutPanel {
    max-width: 480px;
    margin: 0 auto;
    text-align: center;
}

#signedOutPanel h2 {
    margin-bottom: 12px;
}

#signedOutPanel p {
    color: var(--sidebar-text-muted, var(--text-muted));
    margin-bottom: 24px;
    line-height: 1.6;
}

.signed-out-actions,
.account-guest-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

#signedOutPanel .btn-notion {
    max-width: 280px;
    margin: 0 auto;
}

.account-view .panel-card:first-child .account-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--sidebar-border);
    font-size: 14px;
}

.account-view .panel-card:first-child .account-detail-row:last-child {
    border-bottom: none;
}

.account-view .panel-card:first-child .account-detail-label {
    color: var(--sidebar-text-muted, var(--text-muted));
    font-weight: 500;
}

.account-plan-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
    background: var(--bg-surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.account-plan-badge.premium {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border-color: transparent;
}

.account-upgrade-actions {
    margin-top: 20px;
}

.account-upgrade-actions .btn {
    width: 100%;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
}

.account-upgrade-hint {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--sidebar-border);
    font-size: 14px;
    color: var(--sidebar-text-muted, var(--text-muted));
    line-height: 1.5;
}

.account-upgrade-hint a {
    color: var(--accent);
    font-weight: 500;
}

#signedOutError {
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .app-main-body {
        padding: 16px;
    }
}
