/* ========================================
   The Book Summaries
   Warm Minimal · shadcn/ui-inspired
   Beige / Stone / Professional
   ======================================== */

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; }
button { cursor: pointer; font: inherit; }
a { text-decoration: none; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }

/* --- Design Tokens (Light) --- */
:root {
    color-scheme: light;

    --font-display: 'Instrument Serif', Georgia, serif;
    --font-sans: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
    --font-reading: 'Source Serif 4', Georgia, serif;

    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;

    --container: 1200px;
    --gutter: 1.5rem;

    --bg: #FAF9F6;
    --bg-alt: #F3F1EC;
    --surface: #FFFFFF;
    --border: #E8E4DD;
    --border-hover: #D4CFC6;
    --text: #1A1714;
    --text-secondary: #57524C;
    --text-muted: #8A847B;
    --accent: #1A1714;
    --accent-fg: #FAF9F6;
    --star: #C4A265;
    --ring: rgba(26, 23, 20, 0.08);
    --shadow-sm: 0 1px 2px rgba(26, 23, 20, 0.04);
    --shadow: 0 2px 8px rgba(26, 23, 20, 0.06);
    --shadow-lg: 0 4px 16px rgba(26, 23, 20, 0.08);

    --cover-sat: 16%;
    --cover-lit: 52%;
}

/* --- Design Tokens (Dark) --- */
[data-theme="dark"] {
    color-scheme: dark;

    --bg: #141210;
    --bg-alt: #1E1B17;
    --surface: #24211E;
    --border: #3A3632;
    --border-hover: #524D47;
    --text: #EDE9E3;
    --text-secondary: #B0AAA1;
    --text-muted: #7D776E;
    --accent: #EDE9E3;
    --accent-fg: #141210;
    --star: #C4A265;
    --ring: rgba(237, 233, 227, 0.08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.3);

    --cover-sat: 12%;
    --cover-lit: 30%;
}

/* --- Base --- */
body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-feature-settings: 'kern' 1, 'liga' 1;
    text-rendering: optimizeLegibility;
    font-optical-sizing: auto;
}

a { color: var(--text); transition: color 0.15s; }
a:hover { color: var(--text-secondary); }

/* --- Layout --- */
.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding-left: var(--gutter);
    padding-right: var(--gutter);
}
main { flex: 1; padding-top: 1rem; padding-bottom: 3rem; }

/* --- Typography --- */
h1, h2, h3 {
    font-weight: 600;
    line-height: 1.25;
    color: var(--text);
    text-wrap: balance;
    letter-spacing: -0.01em;
}
h1 { font-size: 1.5rem; letter-spacing: -0.015em; }
h2 { font-size: 1.125rem; }
h3 { font-size: 0.9375rem; letter-spacing: 0; }

/* --- Navigation --- */
.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 50;
}
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 3.5rem;
    gap: 1.5rem;
}
.nav-logo {
    font-family: 'Inter', var(--font-sans);
    font-size: 1.3125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
}
.nav-logo:hover { color: var(--text); }

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Search in nav */
.nav-search {
    position: relative;
    display: flex;
    align-items: center;
}
.nav-search .search-icon {
    position: absolute;
    left: 0.625rem;
    color: var(--text-muted);
    pointer-events: none;
    width: 15px;
    height: 15px;
}
.nav-search input[type="search"] {
    width: 240px;
    padding: 0.4375rem 0.75rem 0.4375rem 2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-family: var(--font-sans);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.nav-search input[type="search"]:focus {
    border-color: var(--border-hover);
    box-shadow: 0 0 0 3px var(--ring);
}
.nav-search input[type="search"]::placeholder { color: var(--text-muted); }
.nav-search input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.nav-link {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
}
.nav-link:hover {
    color: var(--text);
    background: var(--bg-alt);
}

.nav-lang {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, background 0.15s;
}
.nav-lang:hover {
    border-color: var(--border-hover);
    background: var(--bg-alt);
    color: var(--text);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    transition: color 0.15s, background 0.15s;
}
.btn-icon:hover { color: var(--text); background: var(--bg-alt); }
.btn-icon svg { width: 16px; height: 16px; }

/* Theme toggle icon visibility */
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5625rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
}
.btn-primary:hover { opacity: 0.88; color: var(--accent-fg); }

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
.btn-outline:hover { background: var(--bg-alt); border-color: var(--border-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); }

/* --- Form Elements --- */
select {
    appearance: none;
    padding: 0.4375rem 2.25rem 0.4375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    background-color: var(--surface);
    color: var(--text);
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    /* Chevron icon */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A39D95' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.625rem center;
}
select:focus {
    border-color: var(--border-hover);
    box-shadow: 0 0 0 3px var(--ring);
}

/* --- Hero --- */
.hero {
    text-align: center;
    padding: 3.5rem 1rem 3rem;
    position: relative;
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(196, 162, 101, 0.05) 0%, transparent 70%);
    pointer-events: none;
}
.hero h1 {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 2.75rem;
    font-weight: 400;
    letter-spacing: -0.025em;
    line-height: 1.12;
    margin-bottom: 0.75rem;
    position: relative;
}
.hero-sub {
    font-family: var(--font-reading);
    font-size: 1.1875rem;
    color: var(--text-secondary);
    margin-bottom: 1.75rem;
    max-width: 40ch;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.7;
    letter-spacing: 0.005em;
    position: relative;
}

/* --- Sections --- */
.section { margin: 3rem 0; }
.section > h2 {
    font-size: 0.8125rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.25rem;
}
.section-header h2 {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.375rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    margin-bottom: 0;
}
.section-link {
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: color 0.15s;
}
.section-link:hover { color: var(--text); }

/* --- Category Grid --- */
.category-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.625rem;
}
.category-grid .category-card {
    flex: 0 1 calc(16.666% - 0.625rem);
    min-width: 170px;
}
.category-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6875rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.category-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
    color: var(--text);
}
.category-card span:first-child {
    font-size: 0.875rem;
    font-weight: 450;
    color: var(--text);
    letter-spacing: 0.005em;
}
.category-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* --- Book Grid --- */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1.25rem;
}

/* --- Book Card --- */
.book-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.book-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    color: var(--text);
}

/* Cover placeholder */
.book-cover {
    aspect-ratio: 3 / 4;
    background: hsl(var(--hue, 30), var(--cover-sat), var(--cover-lit));
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.25rem 1rem;
    position: relative;
    overflow: hidden;
}
.book-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0) 55%);
    pointer-events: none;
}
.cover-title, .cover-author { position: relative; z-index: 1; color: #FFFCF7; }
.cover-title {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cover-author {
    font-size: 0.6875rem;
    margin-top: 0.25rem;
    opacity: 0.8;
}

/* Real cover image — overlays the HSL placeholder */
.book-cover img, .book-header-cover img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    z-index: 1;
}
/* Hide placeholder text when real cover is present */
.book-cover:has(img) .cover-title,
.book-cover:has(img) .cover-author,
.book-header-cover:has(img) .cover-title,
.book-header-cover:has(img) .cover-author { display: none; }
.book-cover:has(img)::after,
.book-header-cover:has(img)::after { display: none; }

.book-info {
    padding: 0.75rem 0.875rem 0.875rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}
.book-title {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: -0.005em;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.book-author {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}
.book-meta {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}
.meta-rating { color: var(--star); }
.book-category {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: auto;
    padding-top: 0.25rem;
}

/* --- Catalog Page --- */
.catalog-header { margin-bottom: 1.25rem; }
.catalog-header h1 {
    font-size: 1.375rem;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.catalog-header .muted {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--text-muted);
}

.filters-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.filter-chips {
    display: flex;
    gap: 0.375rem;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1;
    mask-image: linear-gradient(to right, black calc(100% - 2rem), transparent);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 2rem), transparent);
}
.filter-chips::-webkit-scrollbar { display: none; }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.3125rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    color: var(--text-secondary);
    background: var(--surface);
    transition: all 0.15s;
}
.chip:hover {
    border-color: var(--border-hover);
    color: var(--text);
}
.chip.active {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
}

.sort-control { flex-shrink: 0; }
.sort-control select { min-width: 140px; }

/* --- Pagination --- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 2.5rem 0 0.5rem;
}
.pagination a {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, background 0.15s;
}
.pagination a:hover {
    border-color: var(--border-hover);
    background: var(--bg-alt);
    color: var(--text);
}
.page-info { font-size: 0.8125rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-secondary);
    font-size: 1rem;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1875rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-alt);
    transition: border-color 0.15s;
}
a.badge:hover { border-color: var(--border-hover); color: var(--text); }

/* List toggle buttons (My Books, Mark as Read) */
.list-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.list-btn:hover { border-color: var(--border-hover); color: var(--text); }
.list-btn.active {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
}
.list-btn.active:hover { opacity: 0.85; }
.list-btn[disabled] { opacity: 0.5; cursor: wait; }

/* Empty state message */
.empty-state {
    color: var(--text-muted);
    font-size: 0.9375rem;
    padding: 2rem 0;
}

/* --- My Books: Row List --- */
.book-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
}
.book-row {
    display: flex;
    align-items: center;
    background: var(--card-bg);
}
.book-row-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    text-decoration: none;
    color: var(--text);
    min-width: 0;
}
.book-row-link:hover { background: var(--bg-hover); }
.book-row-cover {
    width: 40px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 3px;
    overflow: hidden;
    background: hsl(var(--hue, 30) 25% 85%);
}
.book-row-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.book-row-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}
.book-row-title {
    font-weight: 500;
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.book-row-author {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.book-row-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.book-row-remove {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    margin-right: 0.5rem;
}
.book-row-remove:hover {
    background: var(--bg-hover);
    color: var(--text);
}
@media (max-width: 640px) {
    .book-row-meta { display: none; }
}

/* --- Breadcrumb --- */
.breadcrumb {
    font-size: 0.875rem;
    color: var(--text-muted);
    max-width: 40rem;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    max-width: 54rem;
    margin-left: auto;
    margin-right: auto;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { color: var(--border-hover); font-size: 0.75rem; }
.breadcrumb .current { color: var(--text-secondary); }

/* --- Reading Progress Bar --- */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 1000;
    background: transparent;
}
.reading-progress-fill {
    height: 100%;
    width: 0%;
    background: #c8b99a; /* sand/beige */
    transition: width 80ms linear;
}
[data-theme="dark"] .reading-progress-fill { background: #a89274; }

/* --- Book Detail --- */
.book-detail {
    max-width: 54rem;
    margin: 0 auto;
}
.book-header {
    display: flex;
    gap: 2rem;
    max-width: 40rem;
    margin: 0 auto 2.5rem;
    align-items: flex-start;
}
.book-header-cover {
    width: 200px;
    min-width: 200px;
    aspect-ratio: 3 / 4;
    border-radius: var(--radius-lg);
    background: hsl(var(--hue, 30), var(--cover-sat), var(--cover-lit));
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.5rem 1.125rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.book-header-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0) 55%);
    pointer-events: none;
}
.book-header-cover .cover-title { font-size: 1.125rem; }
.book-header-cover .cover-author { font-size: 0.75rem; }

.book-header-info { flex: 1; padding-top: 0.25rem; }
.book-header-info h1 {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.875rem;
    font-weight: 400;
    margin-bottom: 0.375rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
}
.subtitle {
    font-family: var(--font-reading);
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-style: italic;
    letter-spacing: 0.005em;
}
.author {
    font-size: 0.875rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}
.author strong { color: var(--text); font-weight: 500; }
.book-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
}
.book-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}
.book-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Book sections — narrower for ~90 char lines at reading font size */
.book-section {
    max-width: 40rem;
    margin: 0 auto 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}
.book-section:last-child { border-bottom: none; padding-bottom: 0; }
.book-section h2 {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 0.875rem;
    font-family: var(--font-sans);
}
/* --- Prose — Tailwind Typography-style readable text --- */
.prose {
    font-family: var(--font-reading);
    font-size: 1.0625rem;
    line-height: 1.75;
    color: var(--text-secondary);
    font-feature-settings: 'onum' 1, 'kern' 1, 'liga' 1;
    font-optical-sizing: auto;
    hanging-punctuation: first;
}
.prose p { margin-bottom: 1.25em; }
.prose p:last-child { margin-bottom: 0; }
.prose h2 {
    font-family: var(--font-reading);
    font-size: 1.25em;
    font-weight: 600;
    margin-top: 2em;
    margin-bottom: 0.75em;
    line-height: 1.33;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text);
}
.prose h3 {
    font-family: var(--font-reading);
    font-size: 1.125em;
    font-weight: 600;
    margin-top: 1.6em;
    margin-bottom: 0.5em;
    line-height: 1.4;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text);
}
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.prose a:hover { color: var(--text); }
.prose strong { font-weight: 600; color: var(--text); }
.prose blockquote {
    border-left: 2px solid var(--border-hover);
    padding-left: 1.25em;
    margin: 1.5em 0;
    font-style: italic;
    color: var(--text-muted);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose ul, .prose ol { padding-left: 1.625em; margin-bottom: 1.25em; }
.prose li { margin-bottom: 0.5em; }
.prose ul > li { list-style: disc; }
.prose ol > li { list-style: decimal; }
.prose li > ul, .prose li > ol { margin-top: 0.5em; margin-bottom: 0; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.prose code {
    font-size: 0.875em;
    background: var(--bg-alt);
    padding: 0.125em 0.375em;
    border-radius: 0.25rem;
}
.prose pre {
    font-size: 0.875em;
    background: var(--bg-alt);
    padding: 1em 1.25em;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 1.5em 0;
}
.prose pre code { background: none; padding: 0; }
.prose img { border-radius: var(--radius); margin: 1.5em 0; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }

/* Prose size variant for the main reading content (Key Ideas) */
.prose-lg {
    font-size: 1.125rem;
    line-height: 1.82;
    color: var(--text);
    letter-spacing: 0.003em;
}

/* Related books section */
.related-section {
    max-width: 54rem;
    margin: 2rem auto 0;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

/* Book language switch */
.book-lang-switch {
    text-align: center;
    padding: 1.5rem 0 1rem;
    max-width: 54rem;
    margin-left: auto;
    margin-right: auto;
}
.book-lang-switch a {
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, color 0.15s;
}
.book-lang-switch a:hover { border-color: var(--border-hover); color: var(--text); }

/* --- Content Gate CTA --- */
.content-gate {
    max-width: 40rem;
    margin: 2rem auto 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}
.gate-card {
    text-align: center;
    padding: 2.5rem 2rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.gate-card h2 {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 400;
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 0.5rem;
    text-transform: none;
    letter-spacing: -0.015em;
}
.gate-card p {
    font-family: var(--font-reading);
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 42ch;
    margin: 0 auto 1.5rem;
    line-height: 1.7;
}
.gate-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* --- Auth Forms --- */
.auth-container {
    max-width: 400px;
    margin: 3rem auto;
    padding: 0 1rem;
}
.auth-container h1 {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 400;
    font-size: 1.75rem;
    letter-spacing: -0.02em;
    text-align: center;
    margin-bottom: 1.5rem;
}
.auth-container form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.auth-container input[type="email"],
.auth-container input[type="password"],
.auth-container input[type="text"] {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    transition: border-color 0.15s;
}
.auth-container input:focus {
    outline: none;
    border-color: var(--accent);
}
.auth-container .btn { width: 100%; justify-content: center; margin-top: 0.25rem; }
.auth-error {
    text-align: center;
    color: #c33;
    font-size: 0.8125rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: rgba(204, 51, 51, 0.06);
    border-radius: var(--radius);
}
.auth-switch {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 1.25rem;
}
.auth-switch a {
    color: var(--text);
    font-weight: 500;
}
.auth-switch a:hover { color: var(--accent); }

/* --- Footer --- */
.site-footer {
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    letter-spacing: 0.01em;
    font-variant-numeric: tabular-nums;
}
.footer-sep { opacity: 0.5; }
.footer-inner a { color: var(--text-muted); }
.footer-inner a:hover { color: var(--text-secondary); }

/* --- Mobile Nav --- */
.nav-burger { display: none; }
.nav-burger .icon-close { display: none; }
.nav-burger[aria-expanded="true"] .icon-menu { display: none; }
.nav-burger[aria-expanded="true"] .icon-close { display: block; }

.nav-drawer {
    display: none;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.nav-drawer a {
    display: block;
    padding: 0.75rem var(--gutter);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.15s, background 0.15s;
}
.nav-drawer a:first-child { border-top: 1px solid var(--border); }
.nav-drawer a:hover { color: var(--text); background: var(--bg-alt); }

/* --- Admin Inline Editing --- */
.admin-bar {
    max-width: 54rem;
    margin: 0 auto 1rem;
    display: flex;
    justify-content: flex-end;
}
textarea.edit-field {
    width: 100%;
    min-height: 6rem;
    padding: 0.75rem;
    font-family: var(--font-reading);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    resize: vertical;
    margin-top: 0.5rem;
}
textarea.edit-field:focus {
    outline: none;
    border-color: var(--border-hover);
    box-shadow: 0 0 0 3px var(--ring);
}
.edit-ce {
    outline: 1px dashed var(--border-hover);
    border-radius: var(--radius-sm);
    padding: 0 0.25rem;
    min-width: 2rem;
}
.edit-ce:focus { outline-color: var(--accent); }
.edit-save {
    margin-top: 0.5rem;
    padding: 0.375rem 1rem;
    font-size: 0.8125rem;
}
.edit-save.edit-ok {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

/* --- Animations --- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.book-grid .book-card {
    animation: fadeUp 0.35s ease both;
}
.book-grid .book-card:nth-child(2) { animation-delay: 0.04s; }
.book-grid .book-card:nth-child(3) { animation-delay: 0.08s; }
.book-grid .book-card:nth-child(4) { animation-delay: 0.12s; }
.book-grid .book-card:nth-child(5) { animation-delay: 0.16s; }
.book-grid .book-card:nth-child(6) { animation-delay: 0.2s; }
.book-grid .book-card:nth-child(7) { animation-delay: 0.24s; }
.book-grid .book-card:nth-child(8) { animation-delay: 0.28s; }

/* --- Responsive --- */

/* Tablet */
@media (max-width: 768px) {
    :root { --gutter: 1rem; }

    /* Nav: hide links, show hamburger + drawer */
    .nav-link { display: none; }
    .nav-burger { display: inline-flex; }
    .nav-drawer.open { display: block; }

    .hero { padding: 2.5rem 0.5rem 2rem; }
    .hero h1 { font-size: 2rem; }
    .hero-sub { font-size: 0.9375rem; }

    .nav-search input[type="search"] { width: 160px; }

    .book-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 0.875rem; }
    .category-grid .category-card { flex: 0 1 calc(50% - 0.625rem); min-width: 140px; }

    /* Book detail: stack cover + info */
    .book-header { flex-direction: column; align-items: center; text-align: center; }
    .book-header-cover { width: 160px; min-width: 160px; }
    .book-header-info h1 { font-size: 1.5rem; }
    .book-meta, .book-categories, .book-actions { justify-content: center; }

    /* Scale down prose for narrower screens */
    .prose { font-size: 1rem; }
    .prose-lg { font-size: 1rem; }

    /* Catalog */
    .filters-bar { flex-direction: column; align-items: stretch; }
    .filter-chips { mask-image: none; -webkit-mask-image: none; }
    .sort-control { width: 100%; }
    .sort-control select { width: 100%; }

    /* Auth */
    .auth-container { margin: 2rem auto; }
}

/* Mobile */
@media (max-width: 480px) {
    .hero h1 { font-size: 1.625rem; }
    .hero-sub { font-size: 0.875rem; }

    /* Nav: tighten everything */
    .nav { height: 3rem; gap: 0.75rem; }
    .nav-logo { font-size: 1.125rem; }
    .nav-search input[type="search"] { width: 110px; font-size: 0.75rem; padding-left: 1.75rem; }
    .nav-search .search-icon { width: 13px; height: 13px; }
    .nav-actions { gap: 0.25rem; }

    /* Cards */
    .book-grid { grid-template-columns: repeat(2, 1fr); gap: 0.625rem; }
    .cover-title { font-size: 0.85rem; }
    .book-info { padding: 0.5rem 0.625rem 0.625rem; }
    .book-title { font-size: 0.8125rem; }

    /* Section headers */
    .section-header { flex-direction: column; gap: 0.25rem; }
    .section-header h2 { font-size: 1.125rem; }

    /* Book detail */
    .book-header-cover { width: 140px; min-width: 140px; }
    .book-header-info h1 { font-size: 1.375rem; }
    .subtitle { font-size: 0.875rem; }
    .book-section h2 { font-size: 0.625rem; }
    .prose { font-size: 0.9375rem; line-height: 1.7; }
    .prose-lg { font-size: 0.9375rem; }

    /* Gate card */
    .gate-card { padding: 1.75rem 1.25rem; }
    .gate-card h2 { font-size: 1.25rem; }
    .gate-card p { font-size: 0.875rem; }

    /* Auth */
    .auth-container { margin: 1.5rem auto; }
    .auth-container h1 { font-size: 1.5rem; }

    /* Footer */
    .footer-inner { font-size: 0.6875rem; padding: 1.25rem 0; }
}
