@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* =============================================
   BOOKMARKD DESIGN SYSTEM
   Near-black canvas + electric yellow voltage.
   Inter everywhere. No shadows — depth comes
   from surface contrast and hairlines.
   Tokens: DESIGN-clickhouse.md
   ============================================= */

:root {
    /* color */
    --primary: #faff69;
    --primary-active: #e6eb52;
    --primary-disabled: #3a3a1f;
    --ink: #ffffff;
    --body: #cccccc;
    --body-strong: #e6e6e6;
    --muted: #888888;
    --muted-soft: #5a5a5a;
    --hairline: #2a2a2a;
    --hairline-strong: #3a3a3a;
    --canvas: #0a0a0a;
    --surface-soft: #121212;
    --surface-card: #1a1a1a;
    --surface-elevated: #242424;
    --on-primary: #0a0a0a;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;

    /* shape */
    --r-xs: 4px;
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-pill: 9999px;

    /* type */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;

    /* layout */
    --nav-h: 64px;
    --container: 1200px;
}

/* =============================================
   BASE
   ============================================= */

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    background: var(--canvas);
    color: var(--body);
    min-height: 100vh;
}

h1, h2, h3, h4 {
    color: var(--ink);
    font-weight: 700;
    line-height: 1.15;
}

h1 { font-size: 40px; letter-spacing: -1.5px; }
h2 { font-size: 32px; letter-spacing: -1px; line-height: 1.2; }
h3 { font-size: 18px; font-weight: 600; letter-spacing: 0; line-height: 1.4; }
h4 { font-size: 16px; font-weight: 600; line-height: 1.4; }

.display-lg { font-size: 56px; letter-spacing: -2px; line-height: 1.1; }
.display-xl { font-size: 72px; letter-spacing: -2.5px; line-height: 1.05; }

a { color: inherit; text-decoration: none; }

a.text-link {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}
a.text-link:hover { color: var(--primary-active); }

::selection { background: var(--primary); color: var(--on-primary); }

code, pre { font-family: var(--mono); font-size: 14px; }

img { max-width: 100%; }

/* =============================================
   LAYOUT UTILITIES
   ============================================= */

.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
}

.page {
    padding-top: calc(var(--nav-h) + 40px);
    padding-bottom: 96px;
}

.narrow { max-width: 760px; }
.medium { max-width: 920px; }

.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.gap-xs { gap: 8px; }
.gap-sm { gap: 12px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }

.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 16px; }

.mt-xs { margin-top: 8px; }
.mt-sm { margin-top: 12px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mt-xl { margin-top: 32px; }
.mt-xxl { margin-top: 48px; }
.mb-xs { margin-bottom: 8px; }
.mb-sm { margin-bottom: 12px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.mb-xl { margin-bottom: 32px; }
.mb-xxl { margin-bottom: 48px; }

.center { text-align: center; }
.hidden { display: none !important; }

.text-ink { color: var(--ink); }
.text-body { color: var(--body); }
.text-muted { color: var(--muted); }
.text-soft { color: var(--muted-soft); }
.text-primary { color: var(--primary); }
.text-error { color: var(--error); }
.text-sm { font-size: 14px; }
.text-xs { font-size: 13px; }
.w-500 { font-weight: 500; }
.w-600 { font-weight: 600; }
.w-700 { font-weight: 700; }

.caption-upper {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.divider { border: none; border-top: 1px solid var(--hairline); }

.section-rule { border-top: 1px solid var(--hairline); }

/* =============================================
   NAVIGATION (injected by js/ui.js)
   ============================================= */

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: var(--canvas);
    border-bottom: 1px solid var(--hairline);
    z-index: 100;
}

.top-nav-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--ink);
    flex-shrink: 0;
}

.nav-logo-img {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: block;
}

.nav-logo .logo-mark { color: var(--primary); }

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    transition: color 0.15s ease;
    padding: 4px 0;
}

.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--ink); }

.nav-cta { flex-shrink: 0; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--ink);
    cursor: pointer;
    padding: 8px;
    margin-right: -8px;
}

.nav-toggle svg { display: block; width: 22px; height: 22px; }

/* mobile menu */
.nav-menu-mobile {
    display: none;
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: var(--canvas);
    border-bottom: 1px solid var(--hairline);
    padding: 12px 24px 20px;
    z-index: 99;
}

.nav-menu-mobile.open { display: block; }

.nav-menu-mobile .nav-link {
    display: block;
    padding: 12px 0;
    font-size: 16px;
    border-bottom: 1px solid var(--hairline);
}

.nav-menu-mobile .nav-link:last-of-type { border-bottom: none; }

.nav-menu-mobile .btn { width: 100%; margin-top: 12px; }

/* =============================================
   BUTTONS
   ============================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 20px;
    border-radius: var(--r-md);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

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

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

.btn-primary:disabled {
    background: var(--primary-disabled);
    color: var(--muted);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface-card);
    color: var(--ink);
    border: 1px solid var(--hairline);
}

.btn-secondary:hover { background: var(--surface-elevated); border-color: var(--hairline-strong); }

.btn-ghost {
    background: transparent;
    color: var(--body);
}

.btn-ghost:hover { color: var(--ink); background: var(--surface-card); }

.btn-danger {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--hairline);
}

.btn-danger:hover { border-color: var(--error); background: rgba(239, 68, 68, 0.08); }

.btn-lg { height: 48px; padding: 0 28px; font-size: 15px; }
.btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* =============================================
   INPUTS
   ============================================= */

.input {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    background: var(--surface-card);
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    transition: border-color 0.15s ease;
    outline: none;
}

textarea.input { height: auto; padding: 10px 14px; resize: vertical; line-height: 1.55; }

.input:focus { border-color: var(--primary); }

.input::placeholder { color: var(--muted-soft); }

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 38px;
    cursor: pointer;
}

.field-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--body-strong);
    margin-bottom: 8px;
}

.field-hint { font-size: 13px; color: var(--muted-soft); margin-top: 6px; }

.form-error {
    padding: 10px 14px;
    border-radius: var(--r-md);
    border: 1px solid rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.08);
    color: var(--error);
    font-size: 14px;
}

/* =============================================
   CARDS
   ============================================= */

.card {
    background: var(--surface-card);
    border: 1px solid var(--hairline);
    border-radius: var(--r-lg);
    padding: 32px;
}

.card-md { padding: 24px; }
.card-sm { padding: 16px; }

.card-hover { transition: border-color 0.15s ease, background 0.15s ease; cursor: pointer; }
.card-hover:hover { border-color: var(--hairline-strong); background: var(--surface-elevated); }

/* nested inside a card */
.card-nested {
    background: var(--surface-elevated);
    border-radius: var(--r-md);
    padding: 12px;
}

/* full-bleed yellow CTA band */
.cta-band {
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--r-lg);
    padding: 64px 32px;
    text-align: center;
}

.cta-band h2 { color: var(--on-primary); }

.cta-band .btn {
    background: var(--on-primary);
    color: var(--primary);
}

.cta-band .btn:hover { background: #1f1f1f; }

/* =============================================
   BOOK CARDS / COVERS
   ============================================= */

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.book-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.book-card {
    background: var(--surface-card);
    border: 1px solid var(--hairline);
    border-radius: var(--r-lg);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    display: block;
    color: inherit;
}

.book-card:hover { border-color: var(--hairline-strong); background: var(--surface-elevated); }

.book-card-body { padding: 14px; }

.book-cover {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    display: block;
    background: var(--surface-elevated);
}

.book-cover-sm {
    width: 64px;
    height: 96px;
    object-fit: cover;
    border-radius: var(--r-sm);
    background: var(--surface-elevated);
    flex-shrink: 0;
}

/* =============================================
   BADGES
   ============================================= */

.rating-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: var(--on-primary);
    padding: 3px 9px;
    border-radius: var(--r-xs);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.badge-pill {
    display: inline-block;
    background: var(--surface-elevated);
    color: var(--body);
    font-size: 13px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: var(--r-pill);
}

.genre-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    background: var(--surface-elevated);
    color: var(--muted);
    border-radius: var(--r-pill);
    margin-right: 4px;
    margin-bottom: 4px;
}

/* =============================================
   STATS
   ============================================= */

.stat-value {
    color: var(--primary);
    font-size: 40px;
    font-weight: 700;
    letter-spacing: -1.5px;
    line-height: 1;
}

.stat-value-lg { font-size: 56px; }

.stat-label {
    font-size: 13px;
    color: var(--muted);
    margin-top: 6px;
}

/* =============================================
   TABS
   ============================================= */

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }

.tab-btn {
    padding: 8px 14px;
    border: none;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--muted);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.tab-btn:hover { color: var(--body-strong); }

.tab-btn.active {
    background: var(--surface-card);
    color: var(--ink);
}

/* =============================================
   RATING INPUT
   ============================================= */

.rating-input { display: flex; gap: 8px; flex-wrap: wrap; }

.rating-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    background: var(--surface-card);
    color: var(--body);
    cursor: pointer;
    font-family: var(--font);
    font-weight: 600;
    font-size: 14px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.rating-btn:hover { border-color: var(--hairline-strong); color: var(--ink); }

.rating-btn.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

.status-btn {
    height: 36px;
    padding: 0 16px;
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    background: var(--surface-card);
    color: var(--body);
    cursor: pointer;
    font-family: var(--font);
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.status-btn:hover { border-color: var(--hairline-strong); color: var(--ink); }

.status-btn.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

/* =============================================
   TOAST
   ============================================= */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface-elevated);
    color: var(--ink);
    padding: 12px 20px;
    border-radius: var(--r-md);
    border: 1px solid var(--hairline-strong);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    pointer-events: none;
    font-weight: 500;
    font-size: 14px;
    max-width: 360px;
}

.toast.show { opacity: 1; transform: translateY(0); }

.toast.error { border-color: rgba(239, 68, 68, 0.5); color: var(--error); }

/* =============================================
   SPINNER / LOADING
   ============================================= */

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--hairline);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-block { text-align: center; padding: 64px 0; }

/* =============================================
   MODAL
   ============================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
}

.modal {
    background: var(--surface-card);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-lg);
    padding: 24px;
    max-width: 440px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover { color: var(--ink); }

/* list picker rows inside modals */
.select-card {
    background: var(--surface-elevated);
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.select-card:hover { border-color: var(--hairline-strong); }

.select-card.selected { border-color: var(--primary); }

/* =============================================
   EMPTY STATES
   ============================================= */

.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--muted);
}

.empty-state p { margin-bottom: 16px; }

/* =============================================
   FEED / REVIEW ITEMS
   ============================================= */

.feed-card {
    background: var(--surface-card);
    border: 1px solid var(--hairline);
    border-radius: var(--r-lg);
    padding: 20px;
}

.feed-card .username {
    color: var(--primary);
    font-weight: 600;
}

.feed-card .username:hover { text-decoration: underline; text-underline-offset: 2px; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--muted);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.15s ease;
}

.icon-btn:hover { color: var(--ink); }

.icon-btn.liked { color: var(--primary); }

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

/* drag & drop list rows */
.book-item {
    background: var(--surface-card);
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    padding: 14px;
    cursor: grab;
    transition: border-color 0.15s ease;
}

.book-item:active { cursor: grabbing; }
.book-item.dragging { opacity: 0.4; }
.book-item.drag-over { border-color: var(--primary); }

.list-rank {
    font-size: 18px;
    font-weight: 700;
    color: var(--muted-soft);
    width: 28px;
    flex-shrink: 0;
    text-align: center;
}

/* =============================================
   CODE BLOCKS (embed generator)
   ============================================= */

.code-window {
    background: var(--canvas);
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    padding: 16px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--body);
    white-space: pre;
}

.code-tab {
    padding: 6px 14px;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    border: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.code-tab:hover { color: var(--body-strong); }
.code-tab.active { background: var(--surface-elevated); color: var(--ink); }

.style-btn {
    padding: 14px 10px;
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    background: var(--surface-elevated);
    color: var(--muted);
    cursor: pointer;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    transition: border-color 0.15s ease, color 0.15s ease;
    text-align: center;
}

.style-btn:hover { border-color: var(--hairline-strong); color: var(--body-strong); }

.style-btn.active {
    border-color: var(--primary);
    color: var(--primary);
}

/* =============================================
   FOOTER (injected by js/ui.js)
   ============================================= */

.site-footer {
    border-top: 1px solid var(--hairline);
    padding: 40px 0;
    color: var(--muted-soft);
    font-size: 14px;
}

.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--ink); }

/* =============================================
   MISC
   ============================================= */

.hero {
    padding: 96px 0 64px;
    text-align: center;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--canvas); }
::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a4a; }

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

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    h1 { font-size: 32px; letter-spacing: -1px; }
    h2 { font-size: 26px; letter-spacing: -0.5px; }
    .display-lg { font-size: 38px; letter-spacing: -1.5px; }
    .display-xl { font-size: 42px; letter-spacing: -1.5px; }

    .nav-links, .nav-cta { display: none; }
    .nav-toggle { display: block; }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

    .book-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
    .book-grid-compact { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }

    .card { padding: 20px; }
    .cta-band { padding: 40px 20px; }
    .page { padding-top: calc(var(--nav-h) + 24px); padding-bottom: 64px; }
    .hero { padding: 48px 0 40px; }

    .toast { left: 16px; right: 16px; bottom: 16px; max-width: none; }

    .stat-value { font-size: 30px; }
    .stat-value-lg { font-size: 38px; }
}
