/* ===========================================================================
   Sam Ngo Universal Design System v1
   Canonical spec: design.md — when this file and the spec disagree, spec wins.
   Palette: monochromatic dark canvas + warm orange accent (#FF6B00).
   =========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Space+Mono:ital,wght@0,400;0,700;1,400&family=JetBrains+Mono:wght@400;500;600&family=Noto+Serif+TC:wght@700&display=swap');

/* ---------- Variables: Dark theme (default) ---------- */
:root {
    --bg-primary:    #000000;
    --bg-card:       #13131a;
    --bg-card-alt:   #1a1a24;
    --text-primary:  #e8e8ed;
    --text-secondary:#9ca3af;
    --text-muted:    #6b7280;

    --accent:        #FF6B00;
    --accent-hover:  #FF8C42;
    --accent-glow:   rgba(255, 107, 0, 0.15);

    --border:        #1f1f2e;
    --border-strong: #2a2a3a;
    --tag-bg:        #1a1a24;
    --tag-text:      #FF6B00;

    --shadow:        0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-hover:  0 8px 30px rgba(0, 0, 0, 0.3);

    --nav-bg:   rgba(0, 0, 0, 0.92);
    --nav-text: #e8e8ed;

    --hero-bg:               #000000;
    --hero-text:             #e8e8ed;
    --hero-muted:            #6b7280;
    --hero-orbit:            rgba(255, 107, 0, 0.12);
    --hero-orbit-lg:         rgba(255, 107, 0, 0.06);
    --hero-btn-border:       rgba(255, 255, 255, 0.2);
    --hero-pic-shadow:       0 0 30px rgba(255, 107, 0, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
    --hero-pic-shadow-hover: 0 0 40px rgba(255, 107, 0, 0.25), 0 20px 60px rgba(0, 0, 0, 0.5);

    --timeline-line: #2a2a3a;
    --grain-opacity: 0.04;
}

/* ---------- Variables: Light theme ---------- */
[data-theme="light"] {
    --bg-primary:    #f5f5f0;
    --bg-card:       #ffffff;
    --bg-card-alt:   #f0efe8;
    --text-primary:  #1a1a1f;
    --text-secondary:#4a4a55;
    --text-muted:    #8a8a95;

    --accent:        #D95A00;
    --accent-hover:  #FF6B00;
    --accent-glow:   rgba(217, 90, 0, 0.10);

    --border:        #e8e6e1;
    --border-strong: #d0cdc6;
    --tag-bg:        #f0ede6;
    --tag-text:      #8A3500;

    --shadow:        0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-hover:  0 8px 30px rgba(0, 0, 0, 0.08);

    --nav-bg:   rgba(245, 245, 240, 0.92);
    --nav-text: #1a1a1f;

    --hero-bg:               #f5f5f0;
    --hero-text:             #1a1a1f;
    --hero-muted:            #6b7280;
    --hero-orbit:            rgba(217, 90, 0, 0.10);
    --hero-orbit-lg:         rgba(217, 90, 0, 0.05);
    --hero-btn-border:       rgba(26, 26, 31, 0.18);
    --hero-pic-shadow:       0 0 30px rgba(217, 90, 0, 0.12), 0 12px 40px rgba(0, 0, 0, 0.1);
    --hero-pic-shadow-hover: 0 0 40px rgba(217, 90, 0, 0.2), 0 12px 40px rgba(0, 0, 0, 0.12);

    --timeline-line: #d0cdc6;
    --grain-opacity: 0.03;
}

/* ---------- Reset + base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { font-size: 18px; -webkit-font-smoothing: antialiased; }
body {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    transition: background 0.4s ease, color 0.4s ease;
    overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---------- Skip link (a11y) ---------- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 8px;
    z-index: 10000;
    padding: 8px 16px;
    background: var(--accent);
    color: #0a0a0f;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}
.skip-link:focus { left: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Typography ---------- */
h1 {
    font-size: clamp(2.8rem, 6vw, 4.2rem);
    font-weight: 900;
    font-family: 'Space Mono', monospace;
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: var(--text-primary);
}
h2 {
    font-size: 1.3rem;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
h3 {
    font-size: 1.05rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}
h4 {
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
}
p { margin-bottom: 1rem; }
code, pre, .mono { font-family: 'JetBrains Mono', monospace; font-variant-ligatures: none; }
code {
    background: var(--bg-card-alt);
    padding: 2px 6px;
    border-radius: 2px;
    font-size: 0.85em;
    color: var(--accent);
}
.meta {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.76rem;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}
.small { font-size: 0.75rem; color: var(--text-muted); }

/* The signature H1 split-italic */
header h1 em,
.split-italic em,
em.accent {
    font-style: italic;
    color: var(--accent);
}

/* ---------- Decorative: grain overlay ---------- */
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: var(--grain-opacity);
    background-image: radial-gradient(circle, var(--text-muted) 0.5px, transparent 0.5px);
    background-size: 24px 24px;
}

/* ---------- Navbar ---------- */
.navbar {
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 1000;
    background: var(--nav-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid transparent;
    padding: 0 32px;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.navbar.scrolled {
    border-bottom-color: var(--border);
    box-shadow: 0 1px 12px rgba(0, 0, 0, 0.06);
}
.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.nav-brand {
    color: var(--accent);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 1.05rem;
}
.nav-brand svg { color: var(--accent); flex-shrink: 0; }
.nav-links {
    display: flex; align-items: center; gap: 32px;
    list-style: none;
}
.nav-links a {
    color: var(--nav-text);
    font-family: 'Outfit', sans-serif;
    font-size: 0.92rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-decoration: none;
    opacity: 0.65;
    transition: opacity 0.25s, color 0.25s;
    position: relative;
}
.nav-links a:hover,
.nav-links a.active {
    opacity: 1;
    color: var(--nav-text);
}
.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -4px; left: 0; right: 0;
    height: 1.5px;
    background: var(--accent);
}
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--nav-text);
    font-size: 0.95rem;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.theme-toggle:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent);
}
.nav-hamburger {
    display: none;
    background: none; border: none;
    font-size: 1.3rem; padding: 4px;
    cursor: pointer;
    color: var(--nav-text);
}
@media (max-width: 768px) {
    .navbar { padding: 0 20px; }
    .nav-hamburger { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        top: 60px; left: 0; right: 0;
        background: var(--nav-bg);
        backdrop-filter: blur(16px);
        flex-direction: column;
        padding: 20px;
        gap: 16px;
    }
    .nav-links.open { display: flex; }
}

/* ---------- Hero Section ---------- */
header {
    background: var(--hero-bg);
    color: var(--hero-text);
    padding: 140px 32px 80px;
    position: relative;
    overflow: hidden;
}
header::before {
    content: '';
    position: absolute;
    top: -120px; right: -80px;
    width: 400px; height: 400px;
    border: 1px solid var(--hero-orbit);
    border-radius: 50%;
    animation: orbit-slow 25s linear infinite;
    pointer-events: none;
}
header::after {
    content: '';
    position: absolute;
    bottom: -200px; left: -100px;
    width: 500px; height: 500px;
    border: 1px solid var(--hero-orbit-lg);
    border-radius: 50%;
    animation: orbit-slow 35s linear infinite reverse;
    pointer-events: none;
}
@keyframes orbit-slow {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.hero-canvas {
    position: fixed; top: 0; left: 0;
    width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 0;
}
.hero-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 48px;
    align-items: center;
    position: relative; z-index: 1;
}
.hero-text { max-width: 640px; }
.hero-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--accent);
    margin-bottom: 16px;
    display: flex; align-items: center; gap: 10px;
}
.hero-label::before {
    content: '';
    width: 24px; height: 1px;
    background: var(--accent);
}
header p.headline {
    font-size: 1.1rem;
    color: var(--hero-muted);
    max-width: 440px;
    line-height: 1.6;
    margin-top: 16px;
}
header p.location {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--hero-muted);
    margin-top: 8px;
    letter-spacing: 0.02em;
}
.header-actions {
    display: flex; gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.contact-bar {
    margin-top: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--hero-muted);
}
.contact-bar a { color: var(--accent); }
.profile-pic, .hero-mark {
    width: 200px; height: 200px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid rgba(255, 107, 0, 0.4);
    box-shadow: var(--hero-pic-shadow);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    background: var(--bg-card);
}
.profile-pic:hover, .hero-mark:hover {
    transform: scale(1.02);
    box-shadow: var(--hero-pic-shadow-hover);
}
.hero-mark {
    display: flex; align-items: center; justify-content: center;
    font-family: 'Songti TC', 'Songti SC', 'Noto Serif TC', 'Noto Serif CJK TC', 'PingFang TC', 'Microsoft JhengHei', serif;
    font-size: 7rem;
    font-weight: 700;
    background: linear-gradient(135deg, #FF6B00 0%, #FF8C42 60%, #FF6B00 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    border-color: rgba(255, 107, 0, 0.3);
}
@media (max-width: 768px) {
    header { padding: 110px 20px 60px; }
    .hero-inner { grid-template-columns: 1fr; gap: 32px; }
    .hero-photo { order: -1; justify-self: center; }
    .profile-pic, .hero-mark { width: 120px; height: 120px; }
    .hero-mark { font-size: 4.2rem; }
}

/* ---------- Sections ---------- */
main {
    max-width: 800px;
    margin: 0 auto;
    padding: 48px 24px;
    position: relative;
    z-index: 1;
}
main.wide { max-width: 1000px; }
section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 36px 40px;
    margin-bottom: 20px;
    transition: background 0.3s, border-color 0.3s;
    position: relative;
}
section h2 {
    font-family: 'Space Mono', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    margin-left: -40px;
    margin-right: -40px;
    padding: 0 40px 12px;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.02em;
}
section h2::before {
    content: '// ';
    color: var(--accent);
    font-weight: 400;
}
section h3 { margin-top: 16px; margin-bottom: 8px; }
section p + p { margin-top: 8px; }
section ul, section ol { margin-left: 1.4rem; margin-bottom: 1rem; }
section li { margin-bottom: 6px; }
.section-alt { background: var(--bg-card-alt); }
.section-accent-divider {
    width: 60px; height: 1px;
    background: var(--accent);
    margin: 32px auto;
    opacity: 0.5;
}
@media (max-width: 768px) {
    main { padding: 32px 16px; }
    section { padding: 28px 24px; }
    section h2 { margin-left: -24px; margin-right: -24px; padding: 0 24px 12px; }
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 24px;
    border-radius: 4px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s ease;
    border: none;
    cursor: pointer;
    letter-spacing: 0.01em;
    line-height: 1;
}
.btn-primary {
    background: var(--accent);
    color: #0a0a0f;
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: #0a0a0f;
    box-shadow: 0 4px 20px rgba(255, 107, 0, 0.3);
}
.btn-outline {
    background: transparent;
    color: var(--hero-text);
    border: 1px solid var(--hero-btn-border);
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(255, 107, 0, 0.06);
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}
.btn-ghost:hover {
    color: var(--accent);
    border-color: var(--border);
}

/* ---------- Cards ---------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 28px 24px;
    transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
    overflow: hidden;
}
.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 2px;
    height: 0;
    background: var(--accent);
    transition: height 0.35s ease;
}
.card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow), var(--shadow-hover);
    transform: translateY(-4px);
    color: inherit;
}
.card:hover::before { height: 100%; }
.card h3 { color: var(--text-primary); margin-bottom: 8px; }
.card p { color: var(--text-secondary); font-size: 0.92rem; margin-bottom: 12px; }

/* ---------- Tag / badge ---------- */
.card-tag, .tag {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    background: var(--tag-bg);
    color: var(--tag-text);
    padding: 3px 10px;
    border-radius: 2px;
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-right: 6px;
    margin-bottom: 6px;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; display: flex; flex-direction: column; gap: 6px; }
.form-group label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.form-group input,
.form-group textarea,
.form-group select {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.9rem;
    font-family: 'Outfit', sans-serif;
    background: var(--bg-card-alt);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    outline: none;
}

/* ---------- Timeline (chronological list) ---------- */
.timeline { list-style: none; margin-left: 0; }
.experience-item, .timeline > li {
    margin-bottom: 28px;
    padding-left: 24px;
    position: relative;
    list-style: none;
}
.experience-item::before,
.timeline > li::before {
    content: '';
    position: absolute;
    left: 0; top: 8px; bottom: -28px;
    width: 1px;
    background: var(--timeline-line);
}
.experience-item::after,
.timeline > li::after {
    content: '';
    position: absolute;
    left: -3px; top: 8px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 0 2px var(--accent);
}
.experience-item:last-child::before,
.timeline > li:last-child::before { bottom: 0; }

/* ---------- Skill bar ---------- */
.skill-bar { margin-bottom: 12px; }
.skill-bar-label {
    display: flex; justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 6px;
}
.skill-bar-track {
    height: 4px;
    background: var(--bg-card-alt);
    border-radius: 2px;
    overflow: hidden;
}
.skill-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    width: 0;
    transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.fade-in.visible .skill-bar-fill { width: var(--target-width); }

/* ---------- Stat block ---------- */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    margin: 24px 0;
}
.stat {
    text-align: center;
    padding: 16px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border);
    border-radius: 2px;
}
.stat-value {
    font-family: 'Space Mono', monospace;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}
.stat-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 8px;
}

/* ---------- Motion ---------- */
.fade-in {
    opacity: 0.15;
    transform: translateY(12px);
    transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}
.fade-in:nth-child(2) { transition-delay: 0.06s; }
.fade-in:nth-child(3) { transition-delay: 0.12s; }
.fade-in:nth-child(4) { transition-delay: 0.18s; }
.fade-in:nth-child(5) { transition-delay: 0.24s; }
.fade-in:nth-child(6) { transition-delay: 0.30s; }

.hero-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.hero-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}
.hero-reveal:nth-child(1) { transition-delay: 0s; }
.hero-reveal:nth-child(2) { transition-delay: 0.1s; }
.hero-reveal:nth-child(3) { transition-delay: 0.2s; }
.hero-reveal:nth-child(4) { transition-delay: 0.3s; }
.hero-reveal:nth-child(5) { transition-delay: 0.4s; }

@keyframes float-gentle {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}
.float-gentle { animation: float-gentle 5s ease-in-out infinite; }

@keyframes skeleton-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* ---------- Footer ---------- */
footer {
    text-align: center;
    padding: 48px 24px 32px;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    position: relative;
    z-index: 1;
}
.footer-logo { margin-bottom: 8px; display: flex; justify-content: center; }
.footer-logo svg {
    color: var(--accent);
    opacity: 0.6;
}
.footer-tagline {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    margin-bottom: 16px;
    opacity: 0.6;
    text-transform: uppercase;
}
.footer-links {
    display: flex;
    justify-content: center;
    gap: 28px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.footer-links a {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
footer a {
    color: var(--text-muted);
    transition: color 0.2s;
}
footer a:hover { color: var(--accent); }

/* ---------- Back-to-top FAB ---------- */
.back-to-top {
    position: fixed;
    bottom: 24px; right: 24px;
    width: 40px; height: 40px;
    border-radius: 8px;
    background: var(--accent);
    color: #0a0a0f;
    border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s, transform 0.3s, background 0.2s;
    z-index: 999;
    pointer-events: none;
}
.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.back-to-top:hover { background: var(--accent-hover); }

/* ---------- App-specific lightweight components ---------- */

/* Flashcard (Lexicon family) */
.flashcard {
    perspective: 1200px;
    margin: 24px auto;
    max-width: 480px;
}
.flashcard-inner {
    position: relative;
    width: 100%;
    aspect-ratio: 5 / 3;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-style: preserve-3d;
    cursor: pointer;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
    position: absolute; inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    display: flex; align-items: center; justify-content: center;
    padding: 32px;
    text-align: center;
    box-shadow: var(--shadow);
}
.flashcard-face.back { transform: rotateY(180deg); background: var(--bg-card-alt); }
.flashcard-face .word {
    font-family: 'Space Mono', monospace;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}
.flashcard-face .romanisation {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}
.flashcard-face .meaning {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-top: 4px;
}
.flashcard-face .example {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 12px;
    font-style: italic;
}
.flashcard-controls {
    display: flex; gap: 12px;
    justify-content: center;
    margin-top: 16px;
}

/* Codex entry list */
.codex-entry {
    display: block;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 2px;
    margin-bottom: 10px;
    transition: all 0.25s ease;
    text-decoration: none;
    color: inherit;
}
.codex-entry:hover {
    border-color: var(--accent);
    color: inherit;
    background: var(--bg-card-alt);
}
.codex-entry .title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.codex-entry .meta {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* Sieve rule list */
.rule-list { list-style: none; margin-left: 0; }
.rule-item {
    display: grid;
    grid-template-columns: 100px 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 2px;
    margin-bottom: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}
.rule-item .rule-kind {
    color: var(--accent);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
}
.rule-item .rule-pattern {
    color: var(--text-primary);
    word-break: break-all;
}
.rule-item .rule-action {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ---------- Print ---------- */
@media print {
    .navbar, footer, .back-to-top, .hero-canvas, body::after { display: none !important; }
    body { background: white; color: black; }
    section { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
}
