/* CSS Variables for theming */
:root {
    /* Light mode (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f5;
    --bg-hover: #eee;
    --bg-active: #e8f0fe;

    --text-primary: #1a1a1a;
    --text-secondary: #444;
    --text-tertiary: #555;
    --text-muted: #666;
    --text-faint: #888;

    --border-color: #e5e5e5;
    --border-light: #eee;

    --accent-color: #0066cc;
    --accent-hover: #0052a3;

    /* Status colors */
    --success: #059669;
    --success-bg: #ecfdf5;
    --success-text: #065f46;
    --warning: #d97706;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --danger-bg: #fef2f2;
    --danger-text: #991b1b;

    --code-inline-bg: #f1f3f5;
    --code-inline-color: #d63384;
    --code-block-bg: #1e1e1e;
    --code-block-color: #d4d4d4;

    --header-bg: #1a1a2e;
    --header-text: #ffffff;
    --header-text-muted: rgba(255, 255, 255, 0.7);
    --tab-active-bg: rgba(255, 255, 255, 0.1);
    --tab-hover-bg: rgba(255, 255, 255, 0.05);

    /* Shadows - matches TodoStack */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Border radius - matches TodoStack */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Transitions - matches TodoStack */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;

    /* Layout */
    --header-height: 56px;
    --max-width: 1600px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #242424;
        --bg-tertiary: #2d2d2d;
        --bg-hover: #333;
        --bg-active: #1e3a5f;

        --text-primary: #e5e5e5;
        --text-secondary: #ccc;
        --text-tertiary: #bbb;
        --text-muted: #999;
        --text-faint: #777;

        --border-color: #404040;
        --border-light: #333;

        --accent-color: #4da6ff;
        --accent-hover: #80bdff;

        --code-inline-bg: #2d2d2d;
        --code-inline-color: #ff79c6;
        --code-block-bg: #0d0d0d;
        --code-block-color: #e5e5e5;

        --header-bg: #0d0d0d;
        --header-text: #ffffff;
        --header-text-muted: rgba(255, 255, 255, 0.7);
        --tab-active-bg: rgba(255, 255, 255, 0.15);
        --tab-hover-bg: rgba(255, 255, 255, 0.08);

        /* Dark mode shadows */
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);

        /* Dark mode status colors */
        --success-bg: #064e3b;
        --success-text: #6ee7b7;
        --danger-bg: #7f1d1d;
        --danger-text: #fca5a5;
    }
}

/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-secondary);
}

a {
    color: var(--accent-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    color: var(--accent-hover);
}

/* Site Header */
.site-header {
    background: var(--header-bg);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    flex-direction: column;
    max-width: 1600px;
    margin: 0 auto;
}

/* Logo row - matches cardstack/todostack 56px height */
.header-content > div:first-child {
    height: 56px;
    padding: 0 16px;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--header-text);
    white-space: nowrap;
}

.site-logo:hover {
    color: var(--header-text);
    text-decoration: none;
}

.site-logo-img {
    height: 32px;
    width: auto;
    border-radius: 6px;
}

.site-logo-emoji {
    font-size: 28px;
    line-height: 1;
}

.header-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-tabs {
    display: flex;
    gap: 24px;
    margin: 0;
    padding: 0;
}

.header-external-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--header-text-muted);
    padding: 8px 12px;
    margin-left: 8px;
    transition: color 0.2s ease;
}

.header-external-link:hover {
    color: var(--header-text);
    text-decoration: none;
}

.header-external-link img {
    border-radius: 4px;
}

.header-tab {
    display: flex;
    align-items: center;
    padding: 12px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--header-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.header-tab:hover {
    color: var(--header-text);
    text-decoration: none;
}

.header-tab.active {
    color: var(--header-text);
    border-bottom-color: var(--header-text);
}

/* Header Right */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: var(--header-text);
    cursor: pointer;
    transition: all 0.15s ease;
}

.user-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s ease;
}

.user-menu-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-info {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.user-menu-email {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    word-break: break-all;
}

.user-menu-role {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.user-menu-role.role-admin {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
}

.user-menu-role.role-editor {
    background: rgba(22, 163, 74, 0.1);
    color: #16a34a;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 14px;
    text-decoration: none;
    transition: background 0.15s;
}

.user-menu-item:hover {
    background: var(--bg-hover);
    text-decoration: none;
    color: var(--text-primary);
}

.user-menu-item svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.user-menu-item-danger {
    color: #dc2626;
}

.user-menu-item-danger svg {
    color: #dc2626;
}

.user-menu-item-danger:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 280px 1fr 260px;
    min-height: calc(100vh - 100px);
    max-width: 1600px;
    margin: 0 auto;
    background: var(--bg-primary);
}


@media (max-width: 1200px) {
    .layout {
        grid-template-columns: 280px 1fr;
    }
    .toc {
        display: none;
    }
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        width: 280px;
        height: 100vh;
        transition: left 0.3s ease;
        z-index: 1001;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-nav {
        padding-top: 80px;
    }

    /* Mobile menu button */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        margin-right: 12px;
    }

    .mobile-menu-btn svg {
        width: 24px;
        height: 24px;
        color: var(--header-text);
    }

    /* Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
    }

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

    /* Close button in sidebar */
    .sidebar-close {
        display: flex;
        position: absolute;
        top: 16px;
        right: 16px;
        width: 32px;
        height: 32px;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        cursor: pointer;
        color: var(--text-muted);
        border-radius: 4px;
    }

    .sidebar-close:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
    }

    .sidebar-close svg {
        width: 20px;
        height: 20px;
    }

    /* Header adjustments */
    .header-content {
        padding: 12px 16px 0;
    }

    .site-logo {
        margin-bottom: 8px;
    }

    .header-tabs {
        gap: 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 1px;
    }

    .header-tabs::-webkit-scrollbar {
        display: none;
    }

    .header-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .header-external-link {
        display: none;
    }

    .content {
        padding: 24px 20px;
    }

    .doc-content h1 {
        font-size: 26px;
    }

    .doc-content h2 {
        font-size: 20px;
    }

    .doc-content h3 {
        font-size: 18px;
    }

    .doc-content h1,
    .doc-content h2,
    .doc-content h3,
    .doc-content h4,
    .doc-content h5,
    .doc-content h6 {
        scroll-margin-top: 80px;
    }

    .breadcrumb {
        font-size: 13px;
        margin-bottom: 16px;
    }

    .doc-content pre {
        padding: 12px 14px;
        font-size: 13px;
        border-radius: 6px;
    }

    .doc-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .doc-content th,
    .doc-content td {
        padding: 8px 10px;
        font-size: 14px;
        white-space: nowrap;
    }
}

/* Hide mobile elements on desktop */
@media (min-width: 901px) {
    .mobile-menu-btn,
    .sidebar-overlay,
    .sidebar-close {
        display: none;
    }
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    height: calc(100vh - 100px);
    position: sticky;
    top: 100px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    padding: 40px 16px 16px 16px;
    flex: 1;
}

.sidebar-footer {
    padding: 16px 20px;
    font-size: 12px;
    color: var(--text-faint);
    text-align: center;
    line-height: 1.5;
}

.sidebar-footer .footer-text {
    margin-bottom: 8px;
}

.sidebar-footer .powered-by a {
    color: var(--text-muted);
    text-decoration: none;
}

.sidebar-footer .powered-by a:hover {
    color: var(--text-secondary);
    text-decoration: underline;
}

/* Sidebar sections (directories) */
.sidebar-section {
    margin-bottom: 8px;
}

.sidebar-section-header {
    padding: 6px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-section-link {
    color: inherit;
    text-decoration: none;
}

.sidebar-section-link:hover {
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-section-content {
    padding-left: 12px;
}

/* Sidebar links (files) */
.sidebar-link {
    display: block;
    padding: 4px 0;
    font-size: 14px;
    color: var(--text-tertiary);
}

.sidebar-link:hover {
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-link.active {
    color: var(--accent-color);
    font-weight: 500;
}

/* Nav-only items (visible for navigation but not accessible) */
.sidebar-link.nav-only,
.sidebar-section-header.nav-only span:first-child {
    color: var(--text-muted);
    font-style: italic;
    cursor: default;
}

.sidebar-link.nav-only:hover {
    color: var(--text-muted);
}

.sidebar-section.nav-only > .sidebar-section-header {
    color: var(--text-muted);
}

/* Content area */
.content {
    max-width: 900px;
    padding: 40px 60px;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .content {
        padding: 20px;
    }
}

/* Breadcrumb */
.breadcrumb {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--accent-color);
}

.breadcrumb-separator {
    margin: 0 8px;
    color: var(--text-faint);
}

/* Document content */
.doc-content h1,
.doc-content h2,
.doc-content h3,
.doc-content h4,
.doc-content h5,
.doc-content h6 {
    scroll-margin-top: 120px;
}

.doc-content h1 {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 24px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.doc-content h2 {
    font-size: 24px;
    font-weight: 600;
    margin: 40px 0 16px 0;
}

.doc-content h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 32px 0 12px 0;
}

.doc-content h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 24px 0 8px 0;
}

.doc-content p {
    margin: 0 0 16px 0;
}

.doc-content ul, .doc-content ol {
    margin: 0 0 16px 0;
    padding-left: 24px;
}

.doc-content li {
    margin-bottom: 8px;
}

.doc-content blockquote {
    margin: 0 0 16px 0;
    padding: 12px 20px;
    border-left: 4px solid var(--accent-color);
    background: var(--bg-secondary);
    color: var(--text-tertiary);
}

.doc-content blockquote p:last-child {
    margin-bottom: 0;
}

/* Code blocks */
.doc-content code {
    font-family: "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 14px;
}

.doc-content p code,
.doc-content li code {
    background: var(--code-inline-bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--code-inline-color);
}

.doc-content pre {
    background: var(--code-block-bg);
    padding: 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0 0 16px 0;
    border: 1px solid var(--border-color);
}

.doc-content pre code {
    background: none;
    padding: 0;
    color: var(--code-block-color);
}

/* Tables */
.doc-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 16px 0;
}

.doc-content th, .doc-content td {
    padding: 12px;
    text-align: left;
    border: 1px solid var(--border-color);
}

.doc-content th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.doc-content tr:hover {
    background: var(--bg-secondary);
}

/* Task lists */
.doc-content input[type="checkbox"] {
    margin-right: 8px;
}

/* Heading anchors */
.heading-anchor {
    color: var(--text-faint);
    font-weight: normal;
    margin-left: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.doc-content h2:hover .heading-anchor,
.doc-content h3:hover .heading-anchor,
.doc-content h4:hover .heading-anchor {
    opacity: 1;
}

.heading-anchor:hover {
    color: var(--accent-color);
    text-decoration: none;
}

/* Table of Contents */
.toc {
    padding: 40px 60px 40px 20px;
    height: calc(100vh - 100px);
    position: sticky;
    top: 100px;
    overflow-y: auto;
    min-width: 200px;
}

.toc-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-faint);
    margin-bottom: 12px;
}

.toc-nav {
    display: flex;
    flex-direction: column;
}

.toc-link {
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 0;
    border-left: 2px solid transparent;
    padding-left: 12px;
    margin-left: -2px;
}

.toc-link:hover {
    color: var(--accent-color);
    text-decoration: none;
}

.toc-level-3 {
    padding-left: 24px;
}

.toc-level-4 {
    padding-left: 36px;
}

/* Images */
.doc-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Horizontal rule */
.doc-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 32px 0;
}

/* ============================================
   Syntax Highlighting - Light Mode
   ============================================ */
.hljs {
    color: #383a42;
    background: #fafafa;
}

.hljs-comment,
.hljs-quote {
    color: #a0a1a7;
    font-style: italic;
}

.hljs-doctag,
.hljs-keyword,
.hljs-formula {
    color: #a626a4;
}

.hljs-section,
.hljs-name,
.hljs-selector-tag,
.hljs-deletion,
.hljs-subst {
    color: #e45649;
}

.hljs-literal {
    color: #0184bb;
}

.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-attribute,
.hljs-meta .hljs-string {
    color: #50a14f;
}

.hljs-attr,
.hljs-variable,
.hljs-template-variable,
.hljs-type,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo,
.hljs-number {
    color: #986801;
}

.hljs-symbol,
.hljs-bullet,
.hljs-link,
.hljs-meta,
.hljs-selector-id,
.hljs-title {
    color: #4078f2;
}

.hljs-built_in,
.hljs-title.class_,
.hljs-class .hljs-title {
    color: #c18401;
}

.hljs-emphasis {
    font-style: italic;
}

.hljs-strong {
    font-weight: bold;
}

.hljs-link {
    text-decoration: underline;
}

/* ============================================
   Syntax Highlighting - Dark Mode
   ============================================ */
@media (prefers-color-scheme: dark) {
    .hljs {
        color: #abb2bf;
        background: #0d0d0d;
    }

    .hljs-comment,
    .hljs-quote {
        color: #5c6370;
        font-style: italic;
    }

    .hljs-doctag,
    .hljs-keyword,
    .hljs-formula {
        color: #c678dd;
    }

    .hljs-section,
    .hljs-name,
    .hljs-selector-tag,
    .hljs-deletion,
    .hljs-subst {
        color: #e06c75;
    }

    .hljs-literal {
        color: #56b6c2;
    }

    .hljs-string,
    .hljs-regexp,
    .hljs-addition,
    .hljs-attribute,
    .hljs-meta .hljs-string {
        color: #98c379;
    }

    .hljs-attr,
    .hljs-variable,
    .hljs-template-variable,
    .hljs-type,
    .hljs-selector-class,
    .hljs-selector-attr,
    .hljs-selector-pseudo,
    .hljs-number {
        color: #d19a66;
    }

    .hljs-symbol,
    .hljs-bullet,
    .hljs-link,
    .hljs-meta,
    .hljs-selector-id,
    .hljs-title {
        color: #61afef;
    }

    .hljs-built_in,
    .hljs-title.class_,
    .hljs-class .hljs-title {
        color: #e6c07b;
    }
}

/* ============================================
   Password Protection Page
   ============================================ */
.password-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 100px);
    background: var(--bg-secondary);
    padding: 20px;
}

.password-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 48px 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.password-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.password-container h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.password-section-name {
    color: var(--text-muted);
    margin: 0 0 24px 0;
    font-size: 15px;
}

.password-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

@media (prefers-color-scheme: dark) {
    .password-error {
        background: #450a0a;
        color: #fca5a5;
    }
}

.password-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.password-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.password-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}

.password-submit {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 500;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.password-submit:hover {
    background: var(--accent-hover);
}

.password-hint {
    margin: 20px 0 0 0;
    font-size: 13px;
    color: var(--text-faint);
}

/* ============================================
   Buttons - matches TodoStack
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.btn-icon {
    padding: 8px;
    background: transparent;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ============================================
   Form Elements - matches TodoStack
   ============================================ */
.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.9rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-help {
    display: block;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   Modal System - matches TodoStack
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: 1000;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.show .modal {
    transform: translateY(0);
}

.modal.modal-sm {
    max-width: 400px;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    flex: 1;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    flex-shrink: 0;
}

.modal-body {
    padding: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ============================================
   Users Page - matches TodoStack/CardStack
   ============================================ */
.users-page-container {
    padding: 32px 16px;
    max-width: 900px;
    margin: 0 auto;
}

.users-page {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.users-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.users-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease;
}

.user-card:hover {
    border-color: var(--accent-color);
}

.user-card-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-card-email {
    font-weight: 500;
    color: var(--text-primary);
}

.user-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.role-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 500;
}

.role-admin {
    background: #dbeafe;
    color: #1d4ed8;
}

.role-editor {
    background: #dcfce7;
    color: #166534;
}

.role-readonly {
    background: #f3f4f6;
    color: #6b7280;
}

@media (prefers-color-scheme: dark) {
    .role-admin {
        background: #1e3a5f;
        color: #60a5fa;
    }

    .role-editor {
        background: #14532d;
        color: #86efac;
    }

    .role-readonly {
        background: #374151;
        color: #9ca3af;
    }
}

.super-admin-badge {
    font-size: 11px;
    padding: 2px 8px;
    background: #8b5cf6;
    color: white;
    border-radius: 9999px;
    font-weight: 500;
}

.user-card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-card-actions .text-muted {
    align-self: center;
    margin-top: -2px;
}

.users-empty,
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ============================================
   Focus States for Accessibility
   ============================================ */
.btn:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* ============================================
   Scrollbar Styling - matches TodoStack
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Responsive - Users Page
   ============================================ */
@media (max-width: 600px) {
    .user-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .user-card-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
