/* ============================================================
   Sheetly — Design System
   Primary: Indigo/Purple (#667eea)
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    /* Brand */
    --primary:        #667eea;
    --primary-dark:   #5a67d8;
    --primary-darker: #4c51bf;
    --primary-light:  #ebf4ff;
    --primary-subtle: #f0f4ff;
    --secondary:      #764ba2;
    --gradient:       linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* Text */
    --text:           #1a202c;
    --text-secondary: #4a5568;
    --text-muted:     #718096;
    --text-xmuted:    #a0aec0;

    /* Surfaces */
    --bg:             #ffffff;
    --bg-subtle:      #f7fafc;
    --bg-muted:       #f0f4f8;
    --border:         #e2e8f0;
    --border-strong:  #cbd5e0;

    /* Semantic */
    --success:        #48bb78;
    --success-bg:     #f0fff4;
    --success-text:   #276749;
    --error:          #f56565;
    --error-bg:       #fff5f5;
    --error-text:     #c53030;
    --warning:        #ed8936;
    --warning-bg:     #fffbeb;
    --warning-text:   #92400e;
    --info:           #4299e1;
    --info-bg:        #ebf8ff;
    --info-text:      #2b6cb0;

    /* Code */
    --code-bg:        #f3f4f6;
    --code-text:      #4c51bf;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.06);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
    --shadow:    0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 20px -4px rgba(0,0,0,0.1), 0 4px 8px -2px rgba(0,0,0,0.06);
    --shadow-lg: 0 16px 40px -8px rgba(0,0,0,0.12), 0 8px 16px -4px rgba(0,0,0,0.08);
    --shadow-xl: 0 24px 48px -12px rgba(0,0,0,0.18);
    --shadow-primary: 0 4px 14px rgba(102,126,234,0.35);

    /* Border radius */
    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Header height (used for sticky offset) */
    --header-h: 58px;

    /* Legacy aliases (keeps old variable references working) */
    --primary-color:   var(--primary);
    --secondary-color: var(--primary-dark);
    --accent-color:    var(--primary);
    --text-color:      var(--text);
    --text-light:      var(--text-muted);
    --bg-color:        var(--bg);
    --bg-light:        var(--bg-subtle);
    --border-color:    var(--border);
    --success-color:   var(--success);
    --warning-color:   var(--warning);
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg-subtle);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; height: auto; }

a { color: var(--primary); }

/* ── Layout ────────────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-5);
}

main { padding: var(--space-12) 0; }

/* ── Header & Navigation ───────────────────────────────────── */
header {
    background: #0d0b1e;
    border-bottom: 1px solid rgba(102,126,234,0.18);
    box-shadow: 0 1px 12px rgba(0,0,0,0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 0;
    min-height: var(--header-h);
    gap: var(--space-4);
}

/* Logo */
.logo {
    font-size: 1.35rem;
    font-weight: 800;
    color: #ffffff;
    text-decoration: none;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    transition: opacity 0.2s;
    flex-shrink: 0;
}
.logo:hover { opacity: 0.85; color: #ffffff; }
.logo svg { opacity: 0.85; }

/* Nav */
nav ul {
    display: flex;
    list-style: none;
    gap: 0.2rem;
    align-items: center;
}

nav a {
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}
nav a:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.1);
}
nav a.active {
    color: #ffffff;
    background: rgba(102,126,234,0.25);
}

/* Nav search */
.nav-search {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius);
    overflow: hidden;
    transition: background 0.2s, border-color 0.2s;
}
.nav-search:focus-within {
    background: rgba(255,255,255,0.13);
    border-color: rgba(102,126,234,0.5);
}
.nav-search input {
    background: transparent;
    border: none;
    outline: none;
    padding: 0.45rem 0.75rem;
    color: #fff;
    font-size: 0.875rem;
    width: 160px;
}
.nav-search input::placeholder { color: rgba(255,255,255,0.4); }
.nav-search button {
    background: transparent;
    border: none;
    border-left: 1px solid rgba(255,255,255,0.12);
    padding: 0.45rem 0.65rem;
    cursor: pointer;
    color: rgba(255,255,255,0.6);
    font-size: 1rem;
    line-height: 1;
    transition: color 0.15s;
}
.nav-search button:hover { color: #fff; }

/* ── Page Headers ──────────────────────────────────────────── */
/* Rich purple gradient — used for category, browse, tools, etc. */
.page-header {
    background: linear-gradient(135deg, #0d0b1e 0%, #1a1040 40%, #2d1b69 72%, #4338ca 100%);
    color: white;
    padding: var(--space-16) 0 var(--space-12);
    margin-bottom: var(--space-8);
    position: relative;
    overflow: hidden;
}

.page-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 60% at 15% 55%, rgba(102,126,234,0.3) 0%, transparent 60%),
        radial-gradient(ellipse 50% 70% at 85% 25%, rgba(118,75,162,0.2) 0%, transparent 60%);
    pointer-events: none;
}

.page-header::after {
    content: '';
    position: absolute;
    top: -30%;
    right: -5%;
    width: 480px;
    height: 480px;
    border-radius: 50%;
    background: rgba(102,126,234,0.06);
    border: 1px solid rgba(255,255,255,0.04);
    pointer-events: none;
}

.page-header .container {
    position: relative;
    z-index: 1;
    text-align: center;
}

.page-header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: var(--space-3);
    text-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

.page-header .subtitle {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    opacity: 0.85;
    max-width: 560px;
    margin: 0 auto var(--space-6);
    line-height: 1.6;
}

.page-header .count {
    font-size: 0.95rem;
    opacity: 0.7;
    margin-top: var(--space-2);
}

/* Cheatsheet header (same visual) */
.cheatsheet-header {
    background: linear-gradient(135deg, #0d0b1e 0%, #1a1040 40%, #2d1b69 72%, #4338ca 100%);
    color: white;
    padding: var(--space-12) 0;
    margin-bottom: var(--space-8);
    position: relative;
    overflow: hidden;
}

.cheatsheet-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 70% 55% at 15% 55%, rgba(102,126,234,0.25) 0%, transparent 60%);
    pointer-events: none;
}

.cheatsheet-header .container {
    position: relative;
    z-index: 1;
}

.cheatsheet-header h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: var(--space-2);
}

.cheatsheet-header .subtitle {
    font-size: 1.05rem;
    opacity: 0.85;
    line-height: 1.6;
}

/* Sitemap header (browse/all-sheets) */
.sitemap-header {
    background: var(--gradient);
    color: white;
    padding: var(--space-12) 0 var(--space-8);
    text-align: center;
}
.sitemap-header h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); margin-bottom: var(--space-2); font-weight: 800; }
.sitemap-header p { font-size: 1.15rem; opacity: 0.9; }

/* ── Hero Section ──────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, #0d0b1e 0%, #1a1040 40%, #2d1b69 72%, #4338ca 100%);
    color: white;
    text-align: center;
    padding: var(--space-16) 0;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 60% at 20% 55%, rgba(102,126,234,0.3) 0%, transparent 60%),
        radial-gradient(ellipse 50% 70% at 80% 25%, rgba(118,75,162,0.2) 0%, transparent 60%);
    pointer-events: none;
}
.hero .container { position: relative; z-index: 1; }

.hero h1 {
    font-size: clamp(1.75rem, 5vw, 2.75rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.025em;
    margin-bottom: var(--space-4);
}

.hero-subtitle {
    font-size: clamp(1rem, 2.5vw, 1.2rem) !important;
    max-width: 640px !important;
    margin: 0 auto var(--space-8) !important;
    opacity: 0.88 !important;
    line-height: 1.6 !important;
}

.hero p {
    font-size: 0.95rem;
    max-width: 520px;
    margin: 0.35rem auto 0.75rem;
    opacity: 0.8;
}

.hero-search {
    max-width: 580px;
    margin: 0 auto var(--space-6);
    display: flex;
    gap: 0.4rem;
    background: rgba(255,255,255,0.12);
    padding: 0.4rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255,255,255,0.18);
    backdrop-filter: blur(8px);
}
.hero-search input {
    flex: 1;
    padding: 0.7rem var(--space-5);
    border: none;
    background: transparent;
    font-size: 1rem;
    border-radius: var(--radius-full);
    outline: none;
    color: white;
}
.hero-search input::placeholder { color: rgba(255,255,255,0.5); }
.hero-search .search-btn {
    padding: 0.7rem var(--space-6);
    background: white;
    color: var(--primary);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.2s;
}
.hero-search .search-btn:hover { background: #f0f4ff; transform: translateY(-1px); }

.hero-cta {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    margin-bottom: var(--space-8);
    flex-wrap: wrap;
}

/* Search box (standalone) */
.search-box {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}
.search-box input {
    width: 100%;
    padding: 1rem var(--space-6);
    font-size: 1rem;
    border: none;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
}
.search-box input:focus {
    outline: none;
    box-shadow: var(--shadow-lg), 0 0 0 3px rgba(102,126,234,0.25);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.925rem;
    font-weight: 600;
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-primary {
    background: var(--gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: var(--shadow-primary);
}
.btn-primary:hover { opacity: 0.88; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102,126,234,0.45); color: #fff; }

.btn-secondary {
    background: transparent;
    color: #fff;
    border-color: rgba(255,255,255,0.6);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); border-color: #fff; color: #fff; }

.btn-outline {
    background: var(--bg);
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary-subtle); transform: translateY(-1px); color: var(--primary); }

.btn-ghost {
    background: transparent;
    color: var(--primary);
    border-color: transparent;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}
.btn-ghost:hover { color: var(--primary-dark); text-decoration: underline; }

.btn-danger {
    background: var(--bg);
    color: var(--error-text);
    border-color: var(--error);
}
.btn-danger:hover { background: var(--error-bg); transform: translateY(-1px); }

.btn-danger-solid {
    background: var(--error);
    color: #fff;
    border-color: transparent;
}
.btn-danger-solid:hover { background: var(--error-text); }

/* ── Cards ─────────────────────────────────────────────────── */
.cheatsheet-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    text-decoration: none;
    color: var(--text);
    display: block;
}
.cheatsheet-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(102,126,234,0.3);
}
.cheatsheet-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: var(--space-2);
    color: var(--primary);
    line-height: 1.35;
}
.cheatsheet-card p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }

.cheatsheet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: var(--space-5);
}

/* ── Category Section ──────────────────────────────────────── */
.category-section { margin-bottom: var(--space-16); }

.category-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--border);
}

.category-icon { font-size: 1.75rem; }
.category-icon.svg-icon {
    width: 1.75rem; height: 1.75rem;
    display: inline-block; color: var(--primary);
}
.category-icon.svg-icon svg { width: 100%; height: 100%; }

.category-header h2 {
    font-size: clamp(1.4rem, 3vw, 1.875rem);
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

/* ── Categories Grid ───────────────────────────────────────── */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-5);
    margin: var(--space-8) 0;
}

.category-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gradient);
    transform: scaleX(0);
    transition: transform 0.25s ease;
}
.category-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: rgba(102,126,234,0.25); }
.category-card:hover::before { transform: scaleX(1); }
.category-card:hover .category-icon { transform: scale(1.08); }
.category-card .category-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-4);
    display: block;
    transition: transform 0.2s;
}
.category-card .category-icon.svg-icon { width: 2.5rem; height: 2.5rem; margin: 0 auto var(--space-4); }
.category-card h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: var(--space-3); line-height: 1.3; }
.category-card h3 a { color: var(--primary); text-decoration: none; }
.category-card h3 a:hover { color: var(--primary-dark); }
.category-card p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: var(--space-4); line-height: 1.5; }
.category-card .category-count { font-weight: 600; color: var(--primary); font-size: 0.875rem; }

/* Category buttons (small grid on homepage) */
.category-buttons {
    background: white;
    padding: var(--space-4) 0 var(--space-6);
}
.category-buttons p {
    font-size: 0.8rem;
    text-align: center;
    color: var(--text-muted);
    margin-bottom: var(--space-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.button-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--space-3); }
.category-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0.65rem 0.5rem;
    border-radius: var(--radius);
    border: 1.5px solid rgba(102,126,234,0.3);
    background: white;
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    aspect-ratio: 1;
    min-height: 110px;
    text-align: center;
    box-sizing: border-box;
}
.category-button:hover, .category-button:focus-visible {
    transform: translateY(-2px);
    background: var(--gradient);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-primary);
}

/* ── Cheatsheet Content Page ───────────────────────────────── */
.action-buttons {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-6);
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.625rem 1.25rem;
    background: rgba(255,255,255,0.14);
    border: 1.5px solid rgba(255,255,255,0.25);
    border-radius: var(--radius);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
    text-decoration: none;
}
.action-btn:hover {
    background: rgba(255,255,255,0.22);
    border-color: rgba(255,255,255,0.45);
    transform: translateY(-2px);
}
.action-btn:active { transform: translateY(0); }
.action-btn .btn-icon { font-size: 1.1rem; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.15s;
}
.back-link:hover { color: white; }

.cheatsheet-content {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: var(--space-8);
}

/* Sections inside cheatsheet */
.section { margin-bottom: var(--space-10); }

.section h2 {
    font-size: clamp(1.35rem, 3vw, 1.75rem);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--border);
    line-height: 1.3;
}

.section h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
    margin: var(--space-6) 0 var(--space-3);
    line-height: 1.4;
}

/* Command items */
.command-list, .reference-table { margin: var(--space-4) 0; }

.command-item {
    background: var(--bg-subtle);
    border-left: 3px solid var(--primary);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: border-color 0.15s, background 0.15s;
}
.command-item:hover { background: var(--primary-subtle); border-left-color: var(--primary-dark); }

.command-item code {
    background: var(--bg);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    color: var(--primary-darker);
    font-weight: 500;
    border: 1px solid var(--border);
}
.command-item .description {
    margin-top: var(--space-2);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
}

/* Code blocks */
code {
    background: var(--code-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', Courier, monospace;
    font-size: 0.875em;
    color: var(--code-text);
}
pre {
    background: var(--code-bg);
    padding: var(--space-5);
    border-radius: var(--radius);
    overflow-x: auto;
    margin: var(--space-4) 0;
    border: 1px solid var(--border);
}
pre code { background: none; padding: 0; color: var(--text); font-size: 0.9rem; border: none; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin: var(--space-4) 0; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
th { background: var(--bg-subtle); font-weight: 700; color: var(--text); font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: var(--bg-subtle); }

/* Tip / note boxes */
.tip-box {
    background: var(--info-bg);
    border-left: 4px solid var(--info);
    padding: var(--space-4);
    margin: var(--space-4) 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.tip-box strong { color: var(--info-text); }

/* ── Related Sheets ────────────────────────────────────────── */
.related-section {
    background: var(--bg-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    border: 1px solid var(--border);
    margin-bottom: var(--space-6);
}

.related-grid {
    margin-top: var(--space-4);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
}

.related-card {
    background: white;
    border-radius: var(--radius);
    padding: var(--space-4);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: transform 0.2s, box-shadow 0.2s;
}
.related-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.related-card h3 { font-size: 1rem; color: var(--primary-dark); margin-bottom: var(--space-2); line-height: 1.35; }
.related-card p { font-size: 0.875rem; color: var(--text-muted); }

.related-sheets {
    background: var(--bg-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    margin: var(--space-8) 0;
    border: 1px solid var(--border);
}
.related-sheets h2 { font-size: 1.4rem; font-weight: 700; color: var(--primary); margin-bottom: var(--space-4); }
.related-sheets ul {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-3);
}
.related-sheets li {
    background: white;
    border-radius: var(--radius);
    padding: 0.7rem var(--space-4);
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.related-sheets li:hover { transform: translateX(4px); box-shadow: var(--shadow-sm); border-color: rgba(102,126,234,0.3); }
.related-sheets a { color: var(--text); text-decoration: none; font-weight: 500; font-size: 0.9rem; }
.related-sheets a:hover { color: var(--primary); }
.related-sheets .browse-more { margin-top: var(--space-6); text-align: center; font-size: 0.95rem; }
.related-sheets .browse-more a { color: var(--primary); font-weight: 600; }

/* ── Category Page Layout ──────────────────────────────────── */
.category-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: var(--space-8);
}
.category-main { min-width: 0; }
.category-sidebar { position: sticky; top: calc(var(--header-h) + 1.5rem); height: fit-content; }

.sidebar-section {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: var(--space-5);
}
.sidebar-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: var(--space-4); color: var(--primary); }

.category-links { list-style: none; }
.category-links li { margin-bottom: var(--space-1); }
.category-links a {
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    padding: 0.45rem var(--space-3);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: all 0.15s;
}
.category-links a:hover { background: var(--primary-subtle); color: var(--primary); padding-left: var(--space-4); }

/* Cheatsheet list */
.cheatsheet-list { display: flex; flex-direction: column; gap: var(--space-5); }
.cheatsheet-item {
    background: var(--bg);
    border-radius: var(--radius);
    padding: var(--space-5) var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.cheatsheet-item:hover { transform: translateX(4px); box-shadow: var(--shadow-md); border-color: rgba(102,126,234,0.25); }
.cheatsheet-item h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: var(--space-2); line-height: 1.35; }
.cheatsheet-item h3 a { color: var(--primary); text-decoration: none; }
.cheatsheet-item h3 a:hover { color: var(--primary-dark); }
.cheatsheet-item p { color: var(--text-muted); margin-bottom: var(--space-3); font-size: 0.9rem; }
.cheatsheet-item .keywords { font-size: 0.82rem; color: var(--text-xmuted); font-style: italic; }

/* Back to category */
.back-to-category { text-align: center; padding: var(--space-6); margin: var(--space-8) 0; background: var(--bg-subtle); border-radius: var(--radius); border: 1px solid var(--border); }
.back-to-category a { color: var(--primary); text-decoration: none; margin: 0 var(--space-4); font-weight: 500; }
.back-to-category a:hover { text-decoration: underline; }

/* ── Browse / Filters ──────────────────────────────────────── */
.filters-bar {
    display: flex;
    gap: var(--space-4);
    margin: var(--space-8) 0;
    flex-wrap: wrap;
    align-items: center;
}
.filter-search { flex: 1; min-width: 280px; }
.filter-search input, .filter-category select, .filter-controls select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s;
}
.filter-search input:focus, .filter-category select:focus, .filter-controls select:focus {
    outline: none;
    border-color: var(--primary);
}
.filter-category select { min-width: 200px; }

.filter-controls { display: flex; gap: var(--space-4); align-items: center; margin: var(--space-4) 0 var(--space-8); flex-wrap: wrap; }
.filter-controls select { padding: 0.5rem 1rem; min-width: 200px; }
.result-count { color: var(--text-muted); font-size: 0.9rem; margin-left: auto; }

/* Sortable table */
.sortable-header { cursor: pointer; user-select: none; position: relative; padding-right: 2rem !important; }
.sortable-header::after { content: '⇅'; position: absolute; right: 0.75rem; opacity: 0.3; }
.sortable-header:hover::after { opacity: 0.6; }
.sortable-header.sort-asc::after { content: '↑'; opacity: 1; color: var(--primary); }
.sortable-header.sort-desc::after { content: '↓'; opacity: 1; color: var(--primary); }

/* Pagination */
.pagination-controls {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    align-items: center;
    margin: var(--space-8) 0;
    flex-wrap: wrap;
}
.page-btn {
    padding: 0.5rem 1rem;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    min-width: 36px;
    min-height: 36px;
    transition: all 0.15s;
}
.page-btn:hover { background: var(--bg-subtle); border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--gradient); color: white; border-color: transparent; box-shadow: var(--shadow-primary); }
.pagination-ellipsis { padding: 0.5rem; color: var(--text-muted); }

/* ── Email Capture ─────────────────────────────────────────── */
.email-capture {
    max-width: 480px;
    margin: var(--space-8) auto 0;
    background: rgba(255,255,255,0.1);
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12);
}
.email-wrapper label, .email-capture label {
    display: block;
    margin-bottom: var(--space-3);
    font-size: 1rem;
    font-weight: 600;
    color: white;
}
.email-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.email-row input {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem 1rem;
    border: 1.5px solid rgba(255,255,255,0.25);
    border-radius: var(--radius);
    font-size: 1rem;
    background: rgba(255,255,255,0.88);
    color: var(--text);
    transition: border-color 0.2s;
}
.email-row input:focus { outline: none; border-color: white; background: white; }
.email-row button {
    padding: 0.75rem var(--space-6);
    background: white;
    color: var(--primary);
    border: none;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.email-row button:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.privacy-note { margin-top: var(--space-2) !important; font-size: 0.75rem !important; opacity: 0.75 !important; text-align: center !important; color: rgba(255,255,255,0.75) !important; }
.email-message { margin-top: var(--space-3); padding: 0.75rem; border-radius: var(--radius-sm); font-size: 0.875rem; text-align: center; }
.email-message.success { background: rgba(16,185,129,0.2); color: white; border: 1px solid rgba(255,255,255,0.25); }
.email-message.error   { background: rgba(239,68,68,0.2);  color: white; border: 1px solid rgba(255,255,255,0.25); }

/* ── Breadcrumbs ───────────────────────────────────────────── */
.breadcrumbs { margin-bottom: var(--space-4); font-size: 0.875rem; opacity: 0.85; line-height: 1; }
.breadcrumbs a { color: white; text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs span { opacity: 0.6; }

/* ── Favorites ─────────────────────────────────────────────── */
.favorite-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.625rem 1.25rem;
    background: rgba(255,255,255,0.14);
    border: 1.5px solid rgba(255,255,255,0.25);
    border-radius: var(--radius);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
}
.favorite-toggle:hover { background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.45); transform: translateY(-2px); }
.favorite-toggle.favorited { background: rgba(255,215,0,0.2); border-color: rgba(255,215,0,0.45); }
.favorite-toggle.favorited .favorite-icon { color: #FFD700; animation: star-pop 0.3s ease; }
@keyframes star-pop { 0%,100%{transform:scale(1)} 50%{transform:scale(1.3)} }
.favorite-icon { font-size: 1.25rem; line-height: 1; }

/* Favorites count badge */
.favorites-link { position: relative; }
.favorites-count {
    position: absolute;
    top: -8px; right: -8px;
    background: var(--error);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: var(--radius-full);
    min-width: 16px;
    text-align: center;
    line-height: 1.4;
}

/* Favorites grid */
.favorites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-5);
    margin: var(--space-8) 0;
}
.favorite-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all 0.2s;
    position: relative;
}
.favorite-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: rgba(102,126,234,0.25); }
.favorite-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: var(--space-2); line-height: 1.35; }
.favorite-card h3 a { color: var(--primary); text-decoration: none; }
.favorite-card h3 a:hover { color: var(--primary-dark); }
.favorite-card .category-badge { display: inline-block; padding: 0.2rem 0.65rem; background: var(--primary-light); color: var(--primary-darker); border-radius: var(--radius-sm); font-size: 0.8rem; font-weight: 600; margin-bottom: var(--space-2); }
.favorite-card .added-date { font-size: 0.82rem; color: var(--text-xmuted); margin-top: var(--space-2); }
.favorite-card .remove-favorite { position: absolute; top: var(--space-4); right: var(--space-4); background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--text-muted); transition: all 0.2s; padding: 0; line-height: 1; }
.favorite-card .remove-favorite:hover { color: var(--error); transform: scale(1.2); }

/* ── Toast ─────────────────────────────────────────────────── */
.toast-notification {
    position: fixed;
    bottom: var(--space-8);
    right: var(--space-8);
    background: #1a202c;
    color: white;
    padding: 0.875rem var(--space-6);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(12px);
    transition: all 0.3s ease;
    z-index: 10000;
    font-size: 0.9rem;
    max-width: 320px;
    border-left: 3px solid var(--primary);
}
.toast-notification.show { opacity: 1; transform: translateY(0); }

/* ── Empty States ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: var(--space-16) var(--space-8); color: var(--text-muted); }
.empty-state-icon { font-size: 3.5rem; margin-bottom: var(--space-4); opacity: 0.4; display: block; }
.empty-state h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: var(--space-2); color: var(--text); }
.empty-state p { margin-bottom: var(--space-6); line-height: 1.6; }

/* ── Loading ───────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

.loading {
    text-align: center;
    padding: var(--space-12);
    color: var(--text-muted);
}
.loading::after {
    content: '';
    display: inline-block;
    width: 1.75rem;
    height: 1.75rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-left: var(--space-3);
    vertical-align: middle;
}

/* Data controls */
.data-controls { display: flex; gap: var(--space-4); margin: var(--space-8) 0; flex-wrap: wrap; }
.data-control-btn {
    padding: 0.5rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}
.data-control-btn:hover { background: var(--gradient); color: white; border-color: transparent; }
.data-control-btn.danger:hover { background: var(--error); border-color: transparent; }

/* ── Footer ────────────────────────────────────────────────── */
footer {
    background: #0d0b1e;
    color: rgba(255,255,255,0.7);
    padding: var(--space-8) 0;
    margin-top: var(--space-16);
    border-top: 1px solid rgba(255,255,255,0.06);
    text-align: center;
    font-size: 0.9rem;
}
footer a { color: rgba(102,126,234,0.9); text-decoration: none; }
footer a:hover { color: var(--primary); text-decoration: underline; }

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-8);
    text-align: left;
    padding: var(--space-8) 0;
}
.footer-section h3 { color: white; margin-bottom: var(--space-4); font-size: 1rem; font-weight: 700; }
.footer-section ul { list-style: none; }
.footer-section li { margin-bottom: var(--space-2); }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.08); margin-top: var(--space-8); padding-top: var(--space-8); }

/* ── Responsive: Tablet (≤ 1024px) ────────────────────────── */
@media (max-width: 1024px) {
    .category-layout { grid-template-columns: 1fr 260px; }
    .nav-search input { width: 130px; }
}

/* ── Responsive: Mobile (≤ 768px) ─────────────────────────── */
@media (max-width: 768px) {
    main { padding: var(--space-8) 0; }
    .container { padding: 0 var(--space-4); }

    .page-header { padding: var(--space-12) 0 var(--space-8); }

    nav ul { display: none; }   /* mobile nav handled by JS hamburger if present */
    .nav-search { display: none; }

    .hero { padding: var(--space-12) 0; }
    .hero-cta { flex-direction: column; padding: 0 var(--space-4); }
    .btn { width: 100%; justify-content: center; }
    .hero-search { margin: 0 var(--space-4) var(--space-6); }

    .cheatsheet-grid { grid-template-columns: 1fr; }
    .categories-grid { grid-template-columns: 1fr 1fr; }
    .button-grid { grid-template-columns: repeat(2, 1fr); }

    .category-layout { grid-template-columns: 1fr; }
    .category-sidebar { position: static; }

    .cheatsheet-content { padding: var(--space-5); }
    .action-buttons { gap: var(--space-2); }
    .action-btn { padding: 0.5rem 0.875rem; font-size: 0.85rem; }

    .filters-bar { flex-direction: column; align-items: stretch; }
    .filter-search, .filter-category select { width: 100%; min-width: unset; }
    .result-count { margin: 0; text-align: center; }

    .footer-content { grid-template-columns: 1fr; text-align: center; }
    .related-sheets ul { grid-template-columns: 1fr; }

    .page-btn { padding: 0.45rem 0.75rem; font-size: 0.82rem; }
    .toast-notification { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); }

    table { font-size: 0.875rem; }
    th, td { padding: 0.6rem 0.75rem; }

    .favorites-grid { grid-template-columns: 1fr; }
    .email-row { flex-direction: column; }
    .email-row button { width: 100%; }
}

@media (max-width: 480px) {
    .categories-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.6rem; }
}

/* ── Print ─────────────────────────────────────────────────── */
@media print {
    header, nav, footer, .nav-search, .breadcrumbs,
    .action-buttons, .favorite-toggle, .data-controls,
    .search-box, .email-capture, button,
    .toast-notification, .related-sheets { display: none !important; }

    *, *::before, *::after {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    @page { margin: 1.5cm; size: A4; }

    body { font-size: 11pt; line-height: 1.45; }
    h1 { font-size: 20pt; page-break-after: avoid; margin-bottom: 12pt; }
    h2 { font-size: 15pt; margin-top: 16pt; margin-bottom: 8pt; page-break-after: avoid; border-bottom: 1pt solid #000; padding-bottom: 4pt; }
    h3 { font-size: 12pt; margin-top: 12pt; margin-bottom: 6pt; page-break-after: avoid; }
    p, li { orphans: 3; widows: 3; }

    pre, code { font-family: 'Courier New', Courier, monospace; font-size: 9pt; border: 1pt solid #000; page-break-inside: avoid; }
    pre { padding: 8pt; white-space: pre-wrap; word-wrap: break-word; }
    code { padding: 2pt 4pt; background: #f0f0f0 !important; }

    table { border-collapse: collapse; width: 100%; page-break-inside: avoid; }
    th, td { border: 1pt solid #000; padding: 6pt; }
    th { background: #e0e0e0 !important; font-weight: bold; }

    .cheatsheet-content { box-shadow: none; padding: 0; border: none; }
    .cheatsheet-header { background: none !important; color: black !important; padding: var(--space-4) 0; border-bottom: 2pt solid #000; margin-bottom: 16pt; }
    .command-item { border-left: 2pt solid #000; padding: 6pt; margin-bottom: 8pt; page-break-inside: avoid; background: #f9f9f9 !important; }
    .section { page-break-inside: avoid; margin-bottom: 16pt; }

    .container { max-width: 100%; padding: 0; }
    a { color: #000; text-decoration: underline; }
    a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; font-style: italic; }
    a[href^="/"]::after, a[href^="#"]::after { content: ""; }
}

/* ── Cheatsheet Intro ── */
.cheatsheet-intro {
    font-size: 1.05rem;
    line-height: 1.65;
    color: #4a5568;
    max-width: 800px;
    margin: 0 auto 1.5rem;
    padding: 1rem 1.5rem;
    background: #f8f9ff;
    border: 1px solid #eef2ff;
    border-left: 4px solid #667eea;
    border-radius: 8px;
}

/* ── Empire Builder Ads ── */
.eb-ad-slot{margin:20px 0;min-height:0;}.eb-ad-slot.is-active{display:block;}
.empire-ad{display:flex;flex-direction:column;text-decoration:none;color:inherit;background:#f8f9ff;border:1px solid #eef2ff;border-radius:12px;overflow:hidden;transition:box-shadow .2s,transform .2s;position:relative;}.empire-ad:hover{box-shadow:0 6px 24px rgba(99,102,241,.1);transform:translateY(-2px);}.empire-ad::before{content:"Ad";position:absolute;top:6px;right:6px;font-size:.55rem;font-weight:700;letter-spacing:.06em;text-transform:uppercase;background:rgba(0,0,0,.45);color:#fff;padding:2px 6px;border-radius:2px;z-index:1;}.empire-ad-img{width:100%;aspect-ratio:1200/630;object-fit:cover;display:block;}.empire-ad-body{padding:14px 18px;}.empire-ad-label{font-size:.6rem;font-weight:700;letter-spacing:.1em;text-transform:uppercase;color:#6366f1;margin-bottom:4px;}.empire-ad-name{font-size:.95rem;font-weight:700;line-height:1.3;margin-bottom:4px;}.empire-ad-cta{font-size:.72rem;color:#999;text-transform:uppercase;letter-spacing:.05em;}.empire-ad-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px;}
/* ── Subscribe Banner ── */
.subscribe-banner{background:linear-gradient(135deg,#f0f4ff,#f8f9ff);border:1px solid #eef2ff;border-radius:14px;padding:28px 24px;margin:24px 0;text-align:center}
.subscribe-banner h3{font-size:1.15rem;font-weight:700;margin-bottom:6px;color:#1a1a2e}
.subscribe-banner p{font-size:.88rem;color:#666;max-width:450px;margin:0 auto 14px}
.subscribe-banner form{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;max-width:400px;margin:0 auto}
.subscribe-banner input[type=email]{flex:1;min-width:200px;padding:10px 14px;border:1px solid #eef2ff;border-radius:8px;font-size:.9rem;outline:none}
.subscribe-banner input[type=email]:focus{border-color:#6366f1}
.subscribe-banner button{background:#6366f1;color:#fff;border:none;padding:10px 20px;border-radius:8px;font-weight:600;font-size:.9rem;cursor:pointer}
.subscribe-banner .subscribe-msg{margin-top:10px;font-size:.85rem;min-height:22px}
