/*
  Books — style.css
  cmrabdu // Design System v5
  Space Grotesk · Fibonacci · Dark oklch · // signature
*/

/* ── Typography ── */
:root {
  --font:      'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono: 'Space Mono', 'SF Mono', 'Consolas', monospace;
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-md:   1.25rem;
  --text-lg:   1.5rem;
  --text-xl:   2rem;
  --text-2xl:  2.5rem;
  --text-3xl:  clamp(2.5rem, 5vw + 1rem, 4rem);
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-bold:   700;
  --leading-tight:  1.15;
  --leading-snug:   1.3;
  --leading-normal: 1.55;
  --tracking-tight:  -0.02em;
  --tracking-wide:   0.06em;
}

/* ── Fibonacci spacing ── */
:root {
  --sp-1: 0.3125rem;
  --sp-2: 0.5rem;
  --sp-3: 0.8125rem;
  --sp-4: 1.3125rem;
  --sp-5: 2.125rem;
  --sp-6: 3.4375rem;
  --sp-7: 5.5625rem;
}

/* ── Shape ── */
:root {
  --radius:      8px;
  --radius-full: 9999px;
  --duration: 200ms;
  --ease:     cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition: var(--duration) var(--ease);
  --measure-narrow: 45ch;
  --measure:        60ch;
  --measure-wide:   75ch;
  --density: 1;
}

/* ── Light tokens ── */
:root {
  --ink:       #0a0a0b;
  --ink-2:     #605f56;
  --ink-3:     #84847a;
  --paper:     #f9f8f4;
  --paper-2:   #f0efea;
  --line:      #dfddd6;
  --accent:       #2535f5;
  --accent-hover: #1020cc;
  --accent-soft:  rgba(37, 53, 245, 0.06);
  --on-accent:    #ffffff;
  --negative:      #b8191b;
  --negative-soft: rgba(184, 25, 27, 0.06);
  --warning:      #b45309;
  --warning-soft: rgba(180, 83, 9, 0.06);
  --positive:     #16a34a;
  --positive-soft: rgba(22, 163, 74, 0.06);
  --violet:       #7c3aed;
  --violet-soft:  rgba(124, 58, 237, 0.06);
  --shadow:         0 1px 3px rgba(0,0,0,0.04), 0 6px 16px rgba(0,0,0,0.04);
  --shadow-overlay: 0 20px 60px rgba(0,0,0,0.14);
}

/* ── Dark tokens ── */
.dark, [data-theme="dark"] {
  --ink:       rgba(255,255,255,0.90);
  --ink-2:     rgba(255,255,255,0.58);
  --ink-3:     rgba(255,255,255,0.40);
  --paper:     oklch(0.14 0.012 260);
  --paper-2:   oklch(0.18 0.012 260);
  --line:      oklch(0.24 0.010 260);
  --accent:       #5570ff;
  --accent-hover: #7b8fff;
  --accent-soft:  rgba(85, 112, 255, 0.14);
  --on-accent:    #ffffff;
  --negative:      #f87171;
  --negative-soft: rgba(248, 113, 113, 0.08);
  --warning:      #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.10);
  --positive:     #4ade80;
  --positive-soft: rgba(74, 222, 128, 0.10);
  --violet:       #a78bfa;
  --violet-soft:  rgba(167, 139, 250, 0.10);
  --shadow:         0 1px 3px rgba(0,0,0,0.24), 0 6px 16px rgba(0,0,0,0.20);
  --shadow-overlay: 0 20px 60px rgba(0,0,0,0.50);
}

@media (prefers-color-scheme: dark) {
  :root:not(.light):not([data-theme="light"]) {
    --ink:       rgba(255,255,255,0.90);
    --ink-2:     rgba(255,255,255,0.58);
    --ink-3:     rgba(255,255,255,0.40);
    --paper:     oklch(0.14 0.012 260);
    --paper-2:   oklch(0.18 0.012 260);
    --line:      oklch(0.24 0.010 260);
    --accent:       #5570ff;
    --accent-hover: #7b8fff;
    --accent-soft:  rgba(85, 112, 255, 0.14);
    --on-accent:    #ffffff;
    --negative:      #f87171;
    --negative-soft: rgba(248, 113, 113, 0.08);
    --warning:      #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.10);
    --positive:     #4ade80;
    --positive-soft: rgba(74, 222, 128, 0.10);
    --violet:       #a78bfa;
    --violet-soft:  rgba(167, 139, 250, 0.10);
    --shadow:         0 1px 3px rgba(0,0,0,0.24), 0 6px 16px rgba(0,0,0,0.20);
    --shadow-overlay: 0 20px 60px rgba(0,0,0,0.50);
  }
}


/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--ink);
  background: var(--paper);
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}


/* ── Layout ── */
.stack   { display: flex; flex-direction: column; gap: var(--sp-3); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.grid    { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px,100%),1fr)); gap: var(--sp-3); }

.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.main {
  flex: 1;
  padding: var(--sp-4);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  min-height: 100dvh;
}

.view { animation: fadeIn 200ms var(--ease); }
.hidden { display: none !important; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.page-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-3);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-bottom: var(--sp-3);
}
.section-label::before {
  content: '//';
  color: var(--accent);
  letter-spacing: -0.05em;
}


/* ── Typography ── */
.text-display   { font-size: var(--text-3xl); font-weight: var(--weight-bold); letter-spacing: -0.03em; line-height: var(--leading-tight); }
.text-title     { font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); }
.text-heading   { font-size: var(--text-xl); font-weight: var(--weight-bold); line-height: var(--leading-snug); }
.text-subheading{ font-size: var(--text-lg); font-weight: var(--weight-bold); line-height: var(--leading-snug); }
.text-body      { font-size: var(--text-base); line-height: var(--leading-normal); max-width: var(--measure); }
.text-small     { font-size: var(--text-sm); color: var(--ink-2); }
.text-caption   { font-size: var(--text-xs); color: var(--ink-3); }
.text-mono      { font-family: var(--font-mono); }
.text-accent    { color: var(--accent); }


/* ── Separator ── */
.separator {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--ink-3);
  font-size: var(--text-sm);
}
.separator::before {
  content: '//';
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: var(--weight-normal);
  letter-spacing: -0.05em;
}


/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: calc(44px * var(--density));
  padding: 0 var(--sp-4);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary { background: transparent; color: var(--ink); border-color: var(--ink-3); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ink-2); }

.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--ink-3); background: var(--paper-2); }

.btn-negative { background: var(--negative); color: #fff; border-color: var(--negative); }
.btn-negative:hover:not(:disabled) { opacity: 0.88; }

.btn-sm { height: calc(34px * var(--density)); padding: 0 var(--sp-3); font-size: var(--text-xs); }
.btn-lg { height: calc(48px * var(--density)); padding: 0 var(--sp-5); font-size: var(--text-base); }

.btn-icon {
  width: calc(44px * var(--density));
  padding: 0;
  border-radius: var(--radius);
}


/* ── Cards ── */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--sp-4);
  transition: box-shadow var(--transition);
}
.card-hover:hover { box-shadow: var(--shadow); }


/* ── Inputs ── */
.label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-2);
  margin-bottom: var(--sp-1);
}

.input {
  display: block;
  width: 100%;
  height: calc(44px * var(--density));
  padding: 0 var(--sp-3);
  font-family: var(--font);
  font-size: var(--text-sm);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition);
}
.input::placeholder { color: var(--ink-3); }
.input:focus { border-color: var(--accent); }
.input:disabled { opacity: 0.4; cursor: not-allowed; }

textarea.input { height: auto; min-height: 100px; padding: var(--sp-3); resize: vertical; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23ffffff61' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: var(--sp-5);
}


/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  background: var(--paper-2);
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-read      { color: var(--positive); background: var(--positive-soft); }
.badge-read .badge-dot { background: var(--positive); }
.badge-reading   { color: var(--accent); background: var(--accent-soft); }
.badge-reading .badge-dot { background: var(--accent); }
.badge-to_read   { color: var(--warning); background: var(--warning-soft); }
.badge-to_read .badge-dot { background: var(--warning); }
.badge-wishlist  { color: var(--violet); background: var(--violet-soft); }
.badge-wishlist .badge-dot { background: var(--violet); }


/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.40);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  z-index: 100;
  animation: fadeIn 150ms var(--ease);
}
.modal-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--sp-5);
  box-shadow: var(--shadow-overlay);
  max-width: 400px;
  width: 100%;
  animation: scaleIn 200ms var(--ease);
}


/* ── Divider ── */
.divider { border: none; height: 1px; background: var(--line); }


/* ── Bottom Navbar ── */
.navbar-bottom {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: var(--sp-2) 0;
  padding-bottom: calc(var(--sp-2) + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  z-index: 90;
}
.navbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--ink-3);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--transition);
  padding: var(--sp-1);
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}
.navbar-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.navbar-item.active,
.navbar-item:hover { color: var(--accent); }

.navbar-item-add {
  position: relative;
}
.navbar-item-add svg {
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 50%;
  padding: 4px;
  width: 32px;
  height: 32px;
}
.navbar-item-add span { color: var(--accent); font-weight: var(--weight-medium); }


/* ── Auth ── */
.auth-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--sp-4);
}
.auth-card {
  max-width: 380px;
  width: 100%;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.auth-brand-slash {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  color: var(--accent);
  letter-spacing: -0.05em;
}
.auth-kicker {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.auth-copy {
  margin-bottom: var(--sp-4);
}
.auth-form {
  margin-bottom: var(--sp-3);
}
.auth-error {
  color: var(--negative);
  font-size: var(--text-sm);
  padding: var(--sp-2) var(--sp-3);
  background: var(--negative-soft);
  border-radius: var(--radius);
}


/* ── Book Card ── */
.book-card {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: var(--ink);
}
.book-card:hover { box-shadow: var(--shadow); border-color: var(--ink-3); }

.book-cover {
  width: 60px;
  height: 90px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--paper-2);
  flex-shrink: 0;
}
.book-cover-placeholder {
  width: 60px;
  height: 90px;
  border-radius: 4px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  color: var(--accent);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

.book-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.book-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.book-author {
  font-size: var(--text-xs);
  color: var(--ink-2);
}


/* ── Book Detail ── */
.book-detail-header {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.book-detail-cover {
  width: 120px;
  height: 180px;
  border-radius: var(--radius);
  object-fit: cover;
  box-shadow: var(--shadow);
}
.book-detail-cover-placeholder {
  width: 120px;
  height: 180px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  color: var(--accent);
  font-weight: var(--weight-bold);
}
.book-detail-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.book-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}


/* ── Rating Stars ── */
.rating {
  display: inline-flex;
  gap: 2px;
}
.rating-star {
  width: 20px;
  height: 20px;
  cursor: pointer;
  color: var(--ink-3);
  transition: color var(--transition);
}
.rating-star.active { color: var(--warning); }
.rating-star:hover { color: var(--warning); }


/* ── Search / Add ── */
.search-bar {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.search-bar .input { flex: 1; }

.search-result {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.search-result:hover { background: var(--paper-2); }

.tab-bar {
  display: flex;
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.tab {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-3);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--ink); }


/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  margin-bottom: var(--sp-4);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  font-family: var(--font);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.filter-chip:hover { border-color: var(--ink-3); }
.filter-chip.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }


/* ── Stats ── */
.stat-card {
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}
.stat-value {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--accent);
}
.stat-label {
  font-size: var(--text-xs);
  color: var(--ink-3);
  margin-top: var(--sp-1);
}

.chart-container {
  position: relative;
  width: 100%;
  margin-bottom: var(--sp-4);
}
.chart-bar-container {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-1);
  height: 160px;
  padding-top: var(--sp-3);
}
.chart-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}
.chart-bar {
  width: 100%;
  max-width: 32px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height var(--transition);
}
.chart-bar-label {
  font-size: 9px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}
.chart-bar-value {
  font-size: 10px;
  color: var(--ink-2);
  font-weight: var(--weight-medium);
}

/* Donut chart */
.donut-container {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.donut-svg {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
}
.donut-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}


/* ── AI ── */
.ai-loading {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4);
  justify-content: center;
  color: var(--accent);
}
.ai-slash {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  letter-spacing: -0.05em;
}

.ai-result {
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
}
.ai-result p { margin-bottom: var(--sp-3); line-height: var(--leading-normal); }
.ai-result ul { padding-left: var(--sp-4); margin-bottom: var(--sp-3); }
.ai-result li { margin-bottom: var(--sp-1); font-size: var(--text-sm); }

.takeaway-list {
  list-style: none;
  padding: 0;
}
.takeaway-item {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}
.takeaway-item::before {
  content: '→';
  color: var(--accent);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

.topic-tag {
  display: inline-block;
  padding: 2px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-full);
}

.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--accent);
}


/* ── Recommend ── */
.recommend-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.recommend-response {
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  white-space: pre-wrap;
}


/* ── Knowledge Graph ── */
.graph-header {
  margin-bottom: var(--sp-3);
}
.graph-header .page-title {
  margin-bottom: var(--sp-2);
}
.graph-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.graph-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
}

.graph-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.graph-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  user-select: none;
}
.graph-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--line);
  border-radius: var(--radius-full);
  transition: background var(--transition);
}
.graph-toggle-track.active {
  background: var(--accent);
}
.graph-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--paper);
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.graph-toggle-track.active .graph-toggle-knob {
  transform: translateX(16px);
}
.graph-toggle-label {
  font-size: var(--text-xs);
  color: var(--ink-2);
  font-weight: var(--weight-medium);
}

.graph-ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: all var(--transition);
}
.graph-ctrl-btn:hover {
  border-color: var(--ink-3);
  color: var(--ink);
  background: var(--paper-2);
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  padding: var(--sp-2) 0;
}
.graph-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink-3);
}
.graph-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.graph-legend-dot-topic {
  background: var(--accent) !important;
  opacity: 0.6;
}

.graph-container {
  width: 100%;
  height: calc(100dvh - 280px);
  min-height: 350px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
  position: relative;
}
.graph-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

.graph-tooltip {
  position: fixed;
  padding: var(--sp-2) var(--sp-3);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--text-xs);
  line-height: 1.4;
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 1000;
  max-width: 220px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 150ms var(--ease), transform 150ms var(--ease);
}
.graph-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
.graph-tooltip strong {
  color: var(--ink);
  display: block;
  margin-bottom: 2px;
}
.graph-tooltip-author {
  color: var(--ink-3);
  font-size: 10px;
}
.graph-tooltip-topic {
  color: var(--accent);
  font-weight: var(--weight-medium);
}
.graph-tooltip-count {
  color: var(--ink-3);
  font-size: 10px;
}

.graph-node {
  transition: opacity 200ms var(--ease);
}
.graph-node .book-ring {
  transition: stroke-opacity 200ms var(--ease);
}
.graph-node:hover .book-ring {
  stroke-opacity: 0.9 !important;
}


/* ── DNA ── */
.dna-section {
  margin-bottom: var(--sp-4);
}
.dna-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.dna-bar-label {
  font-size: var(--text-xs);
  color: var(--ink-2);
  min-width: 80px;
  text-align: right;
}
.dna-bar-track {
  flex: 1;
  height: 8px;
  background: var(--paper-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.dna-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 600ms var(--ease-spring);
}


/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  color: var(--ink-3);
}
.empty-state-label {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-3);
}
.empty-state-label::before {
  content: '// ';
  color: var(--accent);
}


/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  color: var(--ink-3);
}


/* ── Status select ── */
.status-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}
.status-option {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: all var(--transition);
  background: transparent;
  color: var(--ink);
  font-family: var(--font);
}
.status-option:hover { border-color: var(--ink-3); }
.status-option.active { border-color: var(--accent); background: var(--accent-soft); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot-read     { background: var(--positive); }
.status-dot-reading  { background: var(--accent); }
.status-dot-to_read  { background: var(--warning); }
.status-dot-wishlist { background: var(--violet); }


/* ── Keyframes ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes revealLine { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@keyframes slashSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes slashPulse { 0%, 100% { opacity: 0.12; } 40%, 60% { opacity: 1; } }

.animate-fade-in  { animation: fadeIn 200ms var(--ease); }
.animate-slide-up { animation: slideUp 200ms var(--ease); }
.animate-scale-in { animation: scaleIn 200ms var(--ease); }
.animate-slash-spin  { display: inline-block; animation: slashSpin 3s linear infinite; }
.animate-slash-pulse { animation: slashPulse 2.4s ease-in-out infinite; }

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


/* ── Toggle switch ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) 0;
}
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--line);
  border-radius: var(--radius-full);
  cursor: pointer;
  border: none;
  transition: background var(--transition);
}
.toggle.active { background: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle.active::after { transform: translateX(20px); }


/* ── Density ── */
.density-compact     { --density: 0.85; }
.density-comfortable { --density: 1.15; }
