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

:root {
  --bg:         #141A16;
  --surface:    #1A2820;
  --surface2:   #22382C;
  --accent:     #e94560;
  --accent2:    #E8DFC8;
  --text:       #e0e0e0;
  --text-muted: #9a9a9a;
  --radius:     12px;
  --nav-height: 64px;
  --header-h:   56px;
}

html { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
}

/* ─── HEADER ────────────────────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.app-title-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1 1 0;
  overflow: hidden;
}
.app-logo {
  height: 28px;
  width: auto;
  flex-shrink: 0;
  display: block;
}
.app-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent2);
  white-space: nowrap;
  line-height: 1;
}
.sync-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 20px;
  background: rgba(255,255,255,0.05);
  transition: background 0.2s;
}
.sync-status.sync-ok    { color: #4caf50; }
.sync-status.sync-error { color: var(--accent); }
.sync-status:active { background: rgba(255,255,255,0.1); }

/* ─── BOTTOM NAV ────────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  display: flex;
  border-top: 1px solid rgba(255,255,255,0.08);
  z-index: 100;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  border-top: 3px solid transparent;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  padding: 8px 0;
  transition: color 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn.active  { color: var(--accent); border-top-color: var(--accent); }
.nav-btn.active .nav-icon { transform: scale(1.15); }
.nav-btn:active  { color: var(--accent2); }
.nav-icon        { font-size: 1.4rem; line-height: 1; transition: transform 0.2s; }
.nav-label       { font-size: 0.65rem; font-weight: 500; letter-spacing: 0.04em; }

/* ─── VIEWS ─────────────────────────────────────────────────────────────────── */
main { min-height: 100%; }
.view { padding: 1rem; }
.view.hidden { display: none; }
.hidden      { display: none !important; }

/* ─── HOME ──────────────────────────────────────────────────────────────────── */
.home-hero {
  background: linear-gradient(135deg, rgba(34,56,44,0.9) 0%, rgba(26,40,32,0.6) 100%);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  border-left: 4px solid var(--accent2);
}
.home-hero-greeting {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent2);
  margin-bottom: 4px;
}
.home-hero-message {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}
.home-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  margin-top: 1.2rem;
}
#reading-books  { margin-bottom: 1.25rem; border-radius: var(--radius); padding: 1rem; border: 1px solid rgba(255,255,255,0.07); background: rgba(255,255,255,0.02); }
.home-bottom    { display: flex; flex-direction: column; gap: 1.25rem; }
#dog-eared,
#waitlisted-books {
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.02);
}
#reading-books .home-section-title,
#waitlisted-books .home-section-title,
#dog-eared .home-section-title {
  margin-top: 0;
}

/* ─── STALE NUDGE ───────────────────────────────────────────────────────────── */
.stale-nudge {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--surface);
  border-left: 3px solid var(--accent2);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  margin-top: 12px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.stale-nudge--arrow::before {
  content: '';
  position: absolute;
  top: -8px;
  left: var(--arrow-left, 20px);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 8px solid var(--surface);
}
.stale-nudge-text { font-size: 0.8rem; line-height: 1.45; color: var(--text-muted); }
.stale-nudge em { color: var(--text); font-style: italic; }
.stale-nudge:hover { opacity: 0.75; }
.stale-nudge-dismiss { flex-shrink: 0; font-size: 0.7rem; color: var(--text-muted); align-self: flex-start; }

/* ─── DOG-EARED SECTION ─────────────────────────────────────────────────────── */
.dog-eared-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dog-eared-header .home-section-title { margin-bottom: 0; }
.dog-eared-refresh {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 50%;
  line-height: 1;
  transition: color 0.15s, transform 0.2s;
}
.dog-eared-refresh:hover { color: var(--accent2); transform: rotate(45deg); }
.dog-eared-card { margin-top: 0.75rem; }
.dog-eared-empty {
  margin-top: 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-start;
}
.dog-eared-empty-quote {
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}
.dog-eared-add-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.45rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.dog-eared-add-btn:active { opacity: 0.85; }

/* ─── HIGHLIGHT DETAIL VIEW ─────────────────────────────────────────────────── */
.highlight-detail-actions {
  margin-bottom: 1.25rem;
}
.highlight-detail-actions button {
  background: none;
  border: none;
  color: var(--accent2);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
}
.highlight-detail-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  border-left: 4px solid var(--accent2);
}
.highlight-detail-mark   { font-size: 2rem; color: var(--text-muted); line-height: 0.8; display: block; }
.highlight-detail-text   { font-size: 1rem; line-height: 1.6; margin-top: 6px; }
.highlight-detail-source { font-size: 0.78rem; color: var(--text-muted); margin-top: 8px; font-style: italic; }
.highlight-detail-section { margin-top: 1rem; }
.highlight-detail-label  { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); display: block; margin-bottom: 4px; }
.highlight-detail-body   { font-size: 0.88rem; line-height: 1.55; margin: 0; }


.home-covers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.book-cover {
  position: relative;
  border-radius: var(--radius);
  min-height: 130px;
  display: flex;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.book-cover:active { transform: scale(0.97); }
.book-cover-spine {
  width: 10px;
  background: rgba(0,0,0,0.25);
  flex-shrink: 0;
}
.book-cover-body {
  flex: 1;
  padding: 10px 8px 42px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.book-cover-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  word-break: break-word;
}
.book-cover-category {
  font-size: 0.58rem;
  color: rgba(255,255,255,0.65);
  margin-top: 4px;
  font-style: italic;
}
.book-cover-delete {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.5);
  border: none; border-radius: 50%;
  width: 26px; height: 26px;
  font-size: 0.7rem; line-height: 26px; text-align: center;
  color: #fff; cursor: pointer;
  display: none;
}
.book-cover:hover .book-cover-delete { display: block; }
.book-cover-medium {
  position: absolute;
  bottom: 6px; right: 6px;
  font-size: 1rem;
  line-height: 1;
  color: rgba(255,255,255,0.9);
  background: rgba(0,0,0,0.35);
  border-radius: 20px;
  padding: 3px 5px;
  pointer-events: none;
}
.book-cover-rating {
  position: absolute;
  bottom: 6px; left: 18px;
  font-size: 1rem;
  line-height: 1;
  color: rgba(255,255,255,0.9);
  background: rgba(0,0,0,0.35);
  border-radius: 20px;
  padding: 3px 5px;
  pointer-events: none;
}

/* ─── BOOKS TOOLBAR ─────────────────────────────────────────────────────────── */
.books-toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 0 12px;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.books-toolbar-top {
  display: flex;
  gap: 8px;
  align-items: center;
}
.books-toolbar-top #books-search {
  flex: 1;
  min-width: 0;
}
.status-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.status-pills::-webkit-scrollbar { display: none; }
.status-pill {
  flex-shrink: 0;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.status-pill.active {
  background: var(--accent2);
  color: #1a1a2e;
  border-color: var(--accent2);
  font-weight: 700;
}
.status-pill:not(.active):active { background: var(--surface2); }

/* ─── CATEGORY DIVIDER TABS ─────────────────────────────────────────────────── */
.cat-dividers {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.cat-dividers::-webkit-scrollbar { display: none; }
.cat-divider {
  flex-shrink: 0;
  /* darkened category colour for the resting face */
  background: color-mix(in srgb, var(--cat-color) 65%, #000 35%);
  color: rgba(255,255,255,0.82);
  border: 1px solid rgba(255,255,255,0.12);
  /* thicker bottom edge mimics physical divider tab depth */
  border-bottom: 3px solid color-mix(in srgb, var(--cat-color) 40%, #000 60%);
  border-radius: 4px 4px 2px 2px;
  padding: 5px 13px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
  transition: border-color 0.15s, box-shadow 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.cat-divider.active {
  color: #fff;
  border-color: rgba(212,175,55,0.85);
  border-bottom-color: rgba(212,175,55,0.85);
  box-shadow: 0 2px 10px rgba(212,175,55,0.28);
}
.cat-divider:not(.active):active { filter: brightness(1.2); }
.books-toolbar-row select {
  flex: 1;
  min-width: 0;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
}
.fab-inline {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.fab-inline:active { opacity: 0.85; }
.kindle-import-btn {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.kindle-import-btn:active { background: var(--surface3, var(--surface2)); color: var(--text); }

/* ─── OCR SECTION (inside Add Highlight form) ───────────────────────────────── */
.ocr-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.08);
}
.ocr-preview {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}
.ocr-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.ocr-status-text {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.ocr-progress-bar-track {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.ocr-progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent2);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.hl-kindle-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 4px 0 0;
  opacity: 0.75;
}

/* ─── BOOKS GROUPS ──────────────────────────────────────────────────────────── */
.books-group { margin-bottom: 2.5rem; }
.books-group-heading {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.books-group-heading.accent-reading    { color: #9c6fda; }
.books-group-heading.accent-queued-up { color: #9c6fda; }
.books-group-heading.accent-paused     { color: #9c6fda; }
.books-group-heading.accent-completed  { color: #9c6fda; }
.books-group-count {
  background: rgba(255,255,255,0.1);
  color: var(--text);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.7rem;
}

/* ─── BOOKS SEARCH ──────────────────────────────────────────────────────────── */
#books-search {
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 0.82rem;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  outline: none;
}
#books-search::placeholder {
  color: var(--text-muted);
  font-style: italic;
}
#books-search:focus {
  border-color: var(--accent);
}

/* ─── BOOK ROWS ─────────────────────────────────────────────────────────────── */
.book-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 7px;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.book-row:active { opacity: 0.75; }
.book-row-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.book-row-title {
  font-size: 0.95rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
.book-row-author {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.book-row-medium-icon {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.3);
  flex-shrink: 0;
}
.book-row-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  font-size: 0.95rem;
}
.book-row-rating-text {
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
.book-row-rating-icon {
  font-size: 1rem;
  color: rgba(255,255,255,0.65);
  display: flex;
  align-items: center;
}
.book-row-medium-icon {
  font-size: 1rem;
  color: rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
}
.book-row-cat-pill {
  font-size: 0.65rem;
  font-weight: 600;
  color: #fff;
  border-radius: 20px;
  padding: 3px 9px;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: center;
}

/* ─── BOOK SUB-GROUPS ───────────────────────────────────────────────────────── */
.book-subgroup {
  margin-bottom: 0.75rem;
}
.book-subgroup-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.65rem;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(255,255,255,0.2);
  cursor: pointer;
  padding: 4px 0 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 6px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.book-subgroup-toggle {
  margin-left: auto;
  transition: transform 0.2s;
}
.book-subgroup-toggle.rotated {
  transform: rotate(-90deg);
}
.book-subgroup-list.collapsed {
  display: none;
}

/* ─── BOOK PILE / SPINE STACK VIEW ─────────────────────────────────────────── */
.book-pile-section {
  margin-bottom: 3rem;
}
.pile-label {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1.1rem;
  font-weight: 400;
  color: rgba(255,255,255,0.55);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 7px;
}
.pile-rating-icon {
  font-size: 1rem;
  line-height: 1;
}
.pile-count {
  background: rgba(255,255,255,0.1);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.7rem;
  font-family: 'Inter', sans-serif;
  font-style: normal;
  font-weight: 500;
}
.pile-stack {
  /* extra horizontal padding so tilted spines don't clip */
  padding: 4px 18px 20px;
  position: relative;
}
.book-spine {
  position: relative;
  height: 46px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  cursor: pointer;
  margin-bottom: -6px;   /* slight overlap to look stacked */
  /* Layered background: highlight ridge (top 30%), side lighting, then category colour */
  background:
    linear-gradient(to bottom, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 32%),
    linear-gradient(to right,  rgba(255,255,255,0.09) 0%, rgba(0,0,0,0.13) 100%),
    var(--spine-bg, #7A8FA6);
  /* Stronger downward cast shadow onto the spine below */
  box-shadow: 0 8px 14px rgba(0,0,0,0.65);
  border-top: 2px solid rgba(212,175,55,0.55);
  border-bottom: 1px solid rgba(212,175,55,0.28);
  /* Pages edge — cream strip on the right simulating book thickness */
  border-right: 4px solid #e8d9b8;
  transition: box-shadow 0.15s, filter 0.15s;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
/* gold accent stripes flanking the text */
.book-spine::before,
.book-spine::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(212,175,55,0.35);
}
.book-spine::before { left: 12px; }
.book-spine::after  { right: 12px; }
.book-spine:active {
  filter: brightness(1.15);
  box-shadow: 0 6px 18px rgba(0,0,0,0.65);
  z-index: 100 !important;
}
.spine-body {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
  padding: 0 10px;   /* stay clear of gold stripes */
  overflow: hidden;
}
.spine-title {
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: rgba(255,255,255,0.97);
  /* stronger shadow to stay crisp against both lighter (left) and darker (right) areas */
  text-shadow: 0 1px 4px rgba(0,0,0,0.7), 0 0 2px rgba(0,0,0,0.4);
}
.spine-sep {
  flex-shrink: 0;
  color: rgba(212,175,55,0.65);
  font-size: 0.75rem;
}
.spine-author {
  flex: 0 2 auto;
  min-width: 0;
  max-width: 40%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.72rem;
  font-style: italic;
  color: rgba(255,255,255,0.75);
  text-shadow: 0 1px 3px rgba(0,0,0,0.65), 0 0 2px rgba(0,0,0,0.35);
}
.spine-medium {
  margin-left: 8px;
  flex-shrink: 0;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.38);
  display: flex;
  align-items: center;
}

/* ─── BOOK DETAIL ───────────────────────────────────────────────────────────── */
.book-detail-actions {
  margin-bottom: 1rem;
}
.book-detail-actions button {
  background: none;
  border: none;
  color: var(--accent2);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.book-detail-header {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.book-detail-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.book-detail-title { font-family: 'Playfair Display', serif; font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; line-height: 1.25; }
.book-detail-author { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 8px; font-style: italic; }
.book-detail-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.book-pill {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
}
.book-status-reading    { background: #1e5c1e; color: #a8ffa8; }
.book-status-completed  { background: #1a3a6e; color: #a8c8ff; }
.book-status-paused     { background: #5c3a00; color: #ffcc80; }
.book-status-queued-up { background: #3a1a5c; color: #d4a8ff; }
.book-pill-category     { background: rgba(255,255,255,0.1); color: var(--text-muted); }
.book-pill-medium       { background: rgba(255,255,255,0.1); color: var(--text); }
.book-pill-rating       { background: rgba(255,255,255,0.08); color: var(--text); }
.book-detail-icon-btns { display: flex; gap: 8px; flex-shrink: 0; }
.icon-btn {
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 8px;
  width: 38px; height: 38px;
  font-size: 1rem; cursor: pointer;
  color: var(--text); line-height: 38px; text-align: center;
  transition: background 0.2s;
}
.icon-btn:active       { background: rgba(255,255,255,0.18); }
.icon-btn-delete:active { background: rgba(233,69,96,0.3); }
.book-meta-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 1rem;
}
.book-meta-item { background: var(--surface); border-radius: var(--radius); padding: 10px 12px; }
.book-meta-item span:not(.book-meta-label) { font-size: 0.8rem; line-height: 1.4; }
.book-meta-label { display: block; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 4px; }
.book-highlights-heading { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin: 1rem 0 0.75rem; }

/* ─── HIGHLIGHT QUOTE CARDS ─────────────────────────────────────────────────── */
.highlights-toolbar {
  margin-bottom: 1rem;
}
.highlights-toolbar-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
#highlight-search {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
}
#highlight-search::placeholder {
  color: var(--text-muted);
  font-style: italic;
}
#highlight-search:focus {
  border-color: var(--accent);
}
.hl-add-wrap {
  position: relative;
  flex-shrink: 0;
}
.hl-add-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.hl-add-btn:active { opacity: 0.85; }
.hl-add-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  z-index: 300;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  overflow: hidden;
}
.hl-add-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 12px 16px;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}
.hl-add-menu button i {
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}
.hl-add-menu button:not(:last-child) {
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.hl-add-menu button:active { background: rgba(255,255,255,0.07); }
#all-highlights .home-quote-card { margin-bottom: 14px; }
.hl-quote-category-inline { font-size: 0.65rem; color: #9a8a70; font-style: italic; margin-left: 4px; }
.hl-quote-why-inline  { font-size: 0.78rem; color: #7a6a50; margin-top: 8px; font-style: italic; }
.hl-quote-date-inline { font-size: 0.7rem;  color: #9a8a70; margin-top: 5px; }

/* ─── HOME QUOTE CARDS ──────────────────────────────────────────────────────── */
.home-quote-card {
  position: relative;
  background: #f5f0e4;
  border-radius: var(--radius);
  border-top-right-radius: 0; /* fold replaces rounded corner */
  padding: 10px 44px 12px 16px; /* right padding keeps text clear of the fold */
  margin-bottom: 20px;
  border-top: 4px solid var(--card-accent, var(--accent2));
  border-left: none;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
  transform: rotate(-0.4deg);
  transition: transform 0.15s, box-shadow 0.15s;
}
.home-quote-card:hover {
  transform: rotate(0deg);
  box-shadow: 0 6px 24px rgba(0,0,0,0.6);
}
/* cut: covers top-right corner including the 4px border-top */
.home-quote-card::before {
  content: '';
  position: absolute;
  top: -4px; right: 0; /* -4px to sit over the border-top edge */
  width: 34px; height: 34px; /* 30px card area + 4px border */
  background: linear-gradient(225deg, var(--bg) 50%, transparent 50%);
  z-index: 1;
}
/* fold flap: slightly darker cream — the folded-back page */
.home-quote-card::after {
  content: '';
  position: absolute;
  top: -4px; right: 0;
  width: 34px; height: 34px;
  background: linear-gradient(45deg, #c8bc98 50%, transparent 50%);
  box-shadow: -2px 2px 4px rgba(0,0,0,0.25);
  z-index: 2;
}
.home-quote-text {
  font-family: 'Caveat', cursive;
  font-size: 1.1rem;
  line-height: 26px;
  color: #261e10;
  font-style: italic;
  margin: 0;
}
.home-quote-source {
  font-size: 0.8rem;
  color: #7a6a50;
  margin-top: 10px;
  font-family: 'Playfair Display', serif;
  font-style: italic;
}
.home-waitlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.15s;
}
.home-waitlist-item.dragging { opacity: 0.35; }
.home-waitlist-spine { width: 6px; height: 38px; border-radius: 3px; flex-shrink: 0; align-self: stretch; }
.home-waitlist-info { display: flex; flex-direction: column; gap: 2px; flex: 1; cursor: pointer; min-width: 0; }
.home-waitlist-title { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-waitlist-author { font-size: 0.75rem; color: var(--text-muted); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-waitlist-category { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.home-waitlist-info:active .home-waitlist-title { color: var(--accent2); }
.drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 1rem;
  letter-spacing: -3px;
  padding: 4px 6px 4px 0;
  touch-action: none;
  flex-shrink: 0;
  line-height: 1;
}
.drag-handle:active { cursor: grabbing; color: var(--accent2); }
.home-empty { color: var(--text-muted); font-size: 0.85rem; padding: 0.5rem 0; }

/* ─── ESSAYS ────────────────────────────────────────────────────────────────── */
.essays-view-toolbar { margin-bottom: 1rem; }
.essays-view-toolbar button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
#essays-view > button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 1rem;
  display: block;
}
.essays-grid { display: flex; flex-direction: column; gap: 14px; }
.essay-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.1rem 1.1rem 0.85rem 1.25rem;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  border-left: 3px solid rgba(232,223,200,0.18);
  transition: background 0.15s, transform 0.12s, border-color 0.15s;
}
.essay-card:hover  { background: var(--surface2); border-left-color: rgba(232,223,200,0.45); }
.essay-card:active { transform: scale(0.985); background: var(--surface2); border-left-color: rgba(232,223,200,0.6); }
.essay-card-body   { display: flex; flex-direction: column; gap: 0.2rem; }
.essay-card-title  {
  font-size: 0.95rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}
.essay-card-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}
.essay-card-date {
  font-size: 0.72rem;
  color: var(--accent2);
  opacity: 0.55;
  margin: 0;
}
/* keep old classes alive for essay detail view */
.essay-subtitle  { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.essay-meta      { font-size: 0.7rem; color: var(--text-muted); margin-top: 6px; }
.essay-tags      { font-style: italic; }
.essay-preview   { font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; line-height: 1.45; }
.essay-detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.essay-detail-actions button {
  background: var(--surface);
  border: none;
  border-radius: 8px;
  color: var(--text);
  padding: 8px 14px;
  font-size: 0.8rem;
  cursor: pointer;
}
.essay-detail-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.essay-detail-meta     { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.essay-body            { margin-top: 1rem; line-height: 1.7; font-size: 0.9rem; }
.essay-body h1,.essay-body h2,.essay-body h3 { margin: 1.2em 0 0.5em; }
.essay-body p  { margin-bottom: 0.9em; }
.essay-body blockquote {
  border-left: 4px solid var(--accent2);
  padding-left: 1rem;
  color: var(--text-muted);
  margin: 1rem 0;
}
.essay-body code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ─── ESSAY RELATED SECTIONS ────────────────────────────────────────────────── */
.essay-related-section { margin-top: 2rem; }
.related-section-header {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 0.85rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.07);
}

/* Related highlights */
.related-highlights-list { display: flex; flex-direction: column; gap: 0.65rem; }
.related-highlight-card {
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
}
.related-highlight-card:hover { background: rgba(255,255,255,0.06); }
.related-highlight-text  { font-size: 0.85rem; color: var(--text); margin: 0 0 0.25rem; font-style: italic; line-height: 1.5; }
.related-highlight-source{ font-size: 0.75rem; color: var(--text-muted); margin: 0; }

/* Related essays */
.related-essays-list { display: flex; flex-direction: column; gap: 0.65rem; }
.related-essay-card {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
}
.related-essay-card:hover    { background: rgba(255,255,255,0.06); }
.related-essay-title    { font-size: 0.95rem; font-weight: 600; color: var(--text); margin: 0 0 0.2rem; }
.related-essay-subtitle { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 0.3rem; }
.related-essay-tags     { font-size: 0.75rem; color: var(--accent2); opacity: 0.7; margin: 0; }
.form {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  flex-direction: column;
  overflow-y: auto;
  padding: 1rem 1rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  display: none;
}
.form h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
  padding-top: 0.5rem;
}
.form form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.form label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.radio-group {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.radio-group .radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08) !important;
  background: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.radio-group .radio-label.active {
  color: var(--text);
  border-color: var(--accent2) !important;
  background: rgba(245,166,35,0.08);
}
#highlight-book-filter {
  margin-bottom: 6px;
}
#highlight-book-select[size] {
  height: auto;
  padding: 4px 0;
  overflow-y: auto;
}
#highlight-book-select[size] option {
  padding: 7px 10px;
  font-size: 0.85rem;
}
.book-combobox {
  position: relative;
}
.book-combobox input {
  width: 100%;
  padding-right: 32px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239a9a9a' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.book-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
}
.book-dropdown-item {
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}
.book-dropdown-item:hover { background: rgba(255,255,255,0.07); }
.book-dropdown-empty {
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.form input,
.form textarea,
.form select {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.9rem;
  font-family: inherit;
  -webkit-appearance: none;
}
.form textarea { resize: vertical; min-height: 100px; }
#essay-content-input,
#edit-essay-content { min-height: 200px; }
.form input:focus,
.form textarea:focus,
.form select:focus {
  outline: none;
  border-color: var(--accent2);
}
.category-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: -0.25rem;
  margin-bottom: 0.5rem;
  min-height: 1em;
}
.form button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}
.form button[type="button"] {
  background: rgba(255,255,255,0.07);
  color: var(--text);
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 0.85rem;
  cursor: pointer;
}
.form button:active { opacity: 0.85; }

/* ─── MEDIUM SEGMENTED CONTROL ──────────────────────────────────────────────── */
.medium-btn-group {
  display: flex;
  gap: 8px;
}
.medium-btn {
  flex: 1;
  background: rgba(255,255,255,0.07);
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.medium-btn.active {
  background: var(--surface2);
  color: var(--accent2);
  border-color: var(--accent2);
}
.medium-btn:active { opacity: 0.8; }

/* ─── DELETE BUTTON (GENERIC) ───────────────────────────────────────────────── */
.delete-btn {
  background: rgba(233,69,96,0.12);
  border: none;
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
  padding: 5px 8px;
  font-size: 0.8rem;
  transition: background 0.2s;
}
.delete-btn:active { background: rgba(233,69,96,0.3); }

/* ─── SPRINT ────────────────────────────────────────────────────────────────── */
.sprint-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.sprint-page-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0;
}
.sprint-new-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.sprint-new-btn:active { opacity: 0.85; }

.sprint-form {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.sprint-form.hidden { display: none !important; }
.sprint-form input[type="text"],
.sprint-form input[type="number"],
.sprint-form input[type="date"] {
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
  width: 100%;
  box-sizing: border-box;
}
.sprint-duration-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.sprint-duration-btn {
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.sprint-duration-btn.active {
  background: var(--accent2);
  color: #fff;
  border-color: var(--accent2);
}
#sprint-custom-dates {
  display: flex;
  gap: 8px;
}
#sprint-custom-dates input { flex: 1; }
.sprint-form-actions {
  display: flex;
  gap: 8px;
}
.sprint-form-actions button {
  flex: 1;
  padding: 0.5rem;
  border-radius: var(--radius);
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.sprint-form-actions button:first-child { background: var(--accent); color: #fff; }
.sprint-form-actions button:last-child  { background: var(--surface); color: var(--text-muted); border: 1px solid rgba(255,255,255,0.1); }

.sprint-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
}
.sprint-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 10px;
}
.sprint-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.sprint-card-name {
  font-size: 0.92rem;
  font-weight: 700;
}
.sprint-card-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.sprint-card-delete:hover { color: var(--danger); }
.sprint-motivation {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 0.75rem;
}
.sprint-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
}
.sprint-progress-text {
  font-size: 0.85rem;
  font-weight: 600;
}
.sprint-days-left {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.sprint-bar-track {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.sprint-bar-fill {
  height: 100%;
  background: var(--accent2);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.sprint-bar-fill-dim { background: rgba(255,255,255,0.2); }

.sprint-card-achieved { border-left: 3px solid var(--accent2); }
.sprint-achieved-headline {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}
.sprint-achieved-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 0.25rem;
}
.sprint-achieved-range {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.sprint-card-archived { opacity: 0.55; }

/* ─── BUILD ESSAY OVERLAY ──────────────────────────────────────────────────── */
/* ─── ESSAYS VIEW ────────────────────────────────────────────────────────────── */
.essays-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0 1rem;
}
.essays-action-btn {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.essays-action-btn:hover  { opacity: 0.88; }
.essays-action-btn:active { opacity: 0.75; }
.essays-tag-wrap {
  position: relative;
}
.essays-tag-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 3.5rem;
  height: calc(100% - 0.75rem); /* match padding-bottom of the scroll row */
  background: linear-gradient(to right, transparent, var(--bg));
  pointer-events: none;
  transition: opacity 0.2s;
}
.essays-tag-wrap.scrolled-end::after { opacity: 0; }
.essays-tag-filters {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0.4rem;
  padding-bottom: 1rem;
  scrollbar-width: none;
}
.essays-tag-filters::-webkit-scrollbar { display: none; }
.essay-tag-pill {
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.essay-tag-pill:hover  { background: rgba(255,255,255,0.07); color: var(--text); }
.essay-tag-pill.active { background: rgba(232,223,200,0.12); color: var(--accent2); border-color: rgba(232,223,200,0.35); }
.essays-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.essays-count {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent2);
}
.essays-sort-row {
  display: flex;
  gap: 0.2rem;
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.2rem;
}
.essays-sort-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.essays-sort-btn:hover  { color: var(--text); }
.essays-sort-btn.active { background: rgba(232,223,200,0.12); color: var(--accent2); font-weight: 600; }
.build-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 500;
  display: flex;
  flex-direction: column;
}
.build-overlay.hidden { display: none; }
.build-header {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 10;
  flex-shrink: 0;
}
.build-step-indicator {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent2);
  font-weight: 600;
}
.build-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  flex-shrink: 0;
}
.build-close-btn:hover { color: var(--text); background: rgba(255,255,255,0.07); }
.build-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem;
  padding-bottom: calc(3rem + env(safe-area-inset-bottom, 0px));
}
.build-step {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}
.build-prompt {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent2);
  line-height: 1.4;
}
.build-prompt-small {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.build-textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.9rem;
  font-family: inherit;
  min-height: 120px;
  resize: vertical;
}
.build-textarea:focus { outline: none; border-color: var(--accent2); }
.build-nav {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}
.build-nav-row { justify-content: flex-start; }
.build-next-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.build-next-btn:active { opacity: 0.8; }
.build-skip-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 0.9rem;
  cursor: pointer;
}
.feeling-pills { display: flex; flex-direction: column; gap: 0.5rem; }
.feeling-pill {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 11px 14px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.15s, background 0.15s;
}
.feeling-pill.active { border-color: var(--accent2); background: rgba(232,223,200,0.07); }
.feeling-label { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.feeling-desc  { font-size: 0.77rem; color: var(--text-muted); }
.stage-header  { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.stage-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: var(--surface2);
  border-radius: 20px;
  padding: 3px 10px;
}
.stage-name {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent2);
}
.question-pills { display: flex; flex-direction: column; gap: 0.45rem; }
.question-pill {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 11px 14px;
  text-align: left;
  cursor: pointer;
  font-size: 0.87rem;
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.question-pill.active { border-color: var(--accent2); color: var(--text); background: rgba(232,223,200,0.06); }
.stage-existing-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 12px;
  border-left: 2px solid rgba(232,223,200,0.2);
}
.compiled-thought-box {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  font-size: 0.93rem;
  line-height: 1.75;
  color: var(--text);
  min-height: 80px;
}
.compiled-thought-box.loading { opacity: 0.5; }
.build-ai-feedback {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 2px 0;
  font-style: italic;
}
.build-ai-feedback.hidden { display: none; }
.refinement-area {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}
.build-refine-input {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-family: inherit;
  resize: none;
  min-height: 42px;
}
.build-refine-input:focus { outline: none; border-color: var(--accent2); }
.build-refine-send {
  background: var(--surface2);
  color: var(--accent2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.build-validation { margin-top: 0.25rem; }
.build-option-btn {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.84rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.build-option-btn.active-btn { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.build-option-btn:hover { border-color: var(--accent2); color: var(--text); }
.build-options-stack { display: flex; flex-direction: column; gap: 0.75rem; }
.build-option-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.build-option-card:hover { border-color: var(--accent2); background: var(--surface2); }
.build-option-title { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.build-option-desc  { font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }
.build-close-modal {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 1.5rem;
}
.build-close-modal.hidden { display: none; }
.build-close-modal-box {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.5rem;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.build-close-modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.build-close-modal-btn {
  width: 100%;
  padding: 13px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.build-close-modal-btn.primary { background: var(--accent2); color: #141A16; border: none; }
.build-close-modal-btn.danger  { background: rgba(233,69,96,0.12); color: var(--accent); border: 1px solid rgba(233,69,96,0.3); }
.build-close-modal-btn.ghost   { background: none; color: var(--text-muted); border: 1px solid rgba(255,255,255,0.1); }

/* ─── STEP 5: RESEARCH ───────────────────────────────────────────────────────── */
.build-prompt-small { font-size: 0.85rem; color: var(--text-muted); margin: 0.5rem 0 0.65rem; }
.build-nav-row { flex-direction: row; justify-content: flex-end; margin-bottom: 0.5rem; }

.research-category { margin-top: 1.25rem; }
.research-cat-label { font-size: 0.72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent2); margin: 0 0 0.5rem; }

.research-item {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
}
.research-item-name  { font-weight: 600; font-size: 0.95rem; margin: 0 0 0.25rem; color: var(--text); }
.research-item-what  { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 0.2rem; }
.research-item-core  { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 0.2rem; }
.research-item-why   { font-size: 0.82rem; color: var(--accent2); opacity: 0.85; margin: 0.3rem 0 0.6rem; }
.research-use-row    { margin-top: 0.5rem; }
.research-placement-picker { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid rgba(255,255,255,0.06); }
.research-placement-picker.hidden { display: none; }
.research-used-badge { display: inline-block; font-size: 0.78rem; color: var(--accent2); background: rgba(232,223,200,0.1); border-radius: 20px; padding: 0.2rem 0.65rem; margin-top: 0.5rem; }

/* ─── STEP 6: OUTLINE ────────────────────────────────────────────────────────── */
#outline-editor { margin-top: 0.5rem; }
.outline-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.4rem;
}
.outline-title-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0;
  outline: none;
  font-family: inherit;
}
.outline-item-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
.outline-move-btn, .outline-del-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  transition: color 0.15s;
}
.outline-move-btn:hover { color: var(--text); }
.outline-del-btn:hover  { color: var(--accent); }

/* ─── STEP 7: WRITE ──────────────────────────────────────────────────────────── */
.compiled-thought-box.loading { opacity: 0.5; }
.stage-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }

/* ─── SETTINGS ───────────────────────────────────────────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.header-settings-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 7px;
  border-radius: 8px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}
.header-settings-btn:active,
.header-settings-btn:hover {
  color: var(--accent2);
  background: rgba(255,255,255,0.07);
}
.settings-container {
  padding: 1.25rem 1rem;
}
.settings-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 1.5rem;
}
.settings-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.settings-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.settings-section-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.settings-field {
  margin-bottom: 1rem;
}
.settings-field label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.settings-field select,
.settings-field input[type="password"],
.settings-field input[type="text"] {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  -webkit-appearance: none;
}
.settings-field select:focus,
.settings-field input:focus {
  outline: none;
  border-color: var(--accent2);
}
.settings-key-row {
  position: relative;
  display: flex;
  align-items: center;
}
.settings-key-row input {
  padding-right: 42px !important;
}
.settings-key-toggle {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 1rem;
  display: flex;
  align-items: center;
}
.settings-key-toggle:hover { color: var(--accent2); }
.settings-save-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 0.25rem;
  transition: opacity 0.15s;
}
.settings-save-btn:active { opacity: 0.8; }
.settings-save-msg {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: #4caf50;
  font-weight: 500;
}
.settings-save-msg.error { color: var(--accent); }

/* ─── RESPONSIVE: TABLET / DESKTOP ─────────────────────────────────────────── */
@media (min-width: 600px) {
  .home-covers { grid-template-columns: repeat(4, 1fr); }
  .book-meta-grid { grid-template-columns: 1fr 1fr; }
  .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); border-left: 1px solid rgba(255,255,255,0.08); border-right: 1px solid rgba(255,255,255,0.08); }
  .app-header { max-width: 480px; left: 50%; transform: translateX(-50%); border-left: 1px solid rgba(255,255,255,0.08); border-right: 1px solid rgba(255,255,255,0.08); }
  main { max-width: 480px; margin: 0 auto; }
  .form { max-width: 480px; left: 50%; transform: translateX(-50%); }
  body { padding-top: var(--header-h); }
}

/* ─── PRINT STYLES ──────────────────────────────────────────────────────────── */
@media print {
  .no-print, .bottom-nav, .app-header { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .essay-body { font-size: 11pt; line-height: 1.6; }
}

/* ─── WISHLIST ───────────────────────────────────────────────────────────────── */
.wishlist-group { margin-bottom: 1.5rem; }
.wishlist-group-heading {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.wishlist-cat-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.wishlist-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
}
.wishlist-item-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}
.wishlist-item-title  { font-size: 0.95rem; font-weight: 600; }
.wishlist-item-author { font-size: 0.78rem; color: var(--text-muted); }
.wishlist-item-note   { font-size: 0.78rem; color: var(--text-muted); font-style: italic; margin-top: 2px; }
.wishlist-item-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.wishlist-move-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.wishlist-move-btn:active { color: var(--accent2); border-color: rgba(245,166,35,0.4); }
.wishlist-status-prompt {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  padding-top: 8px;
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* Wishlist draggable rows need to wrap so the status prompt sits below */
#wishlist-draggable-list .home-waitlist-item {
  flex-wrap: wrap;
}

.wishlist-prompt-label { font-size: 0.75rem; color: var(--text-muted); }
.wishlist-status-btn {
  background: var(--surface2);
  color: var(--text);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.wishlist-status-btn:active { background: var(--accent); color: #fff; }
.wishlist-cancel-btn {
  background: none;
  color: var(--text-muted);
  border: none;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 8px 4px;
}

/* ─── FIND YOUR NEXT READ ────────────────────────────────────────────────────── */

/* Zone 1: FNR entry card */
.fnr-zone-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.fnr-zone-card:active { background: var(--surface2); }
.fnr-zone-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fnr-zone-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 7px;
}
.fnr-zone-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.fnr-zone-arrow {
  font-size: 1.1rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Zone 2: Wishlist section */
.wishlist-section {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
}
.wishlist-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.wishlist-section-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.wishlist-add-icon-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
}
.wishlist-add-icon-btn:active { opacity: 0.85; }
#wishlist-list .home-waitlist-item:last-child {
  border-bottom: none;
}
/* Items inside the wishlist section card are rows, not individual cards */
#wishlist-list .home-waitlist-item {
  background: transparent;
  border-radius: 0;
  margin-bottom: 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding: 12px 14px;
}

/* Header */
.fnr-header {
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.fnr-back-btn {
  background: none;
  border: none;
  color: var(--accent2);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0;
}
.fnr-back-btn:active { opacity: 0.7; }

/* Form */
.fnr-ornament {
  font-size: 0.85rem;
  color: #e8c97e;
  margin-bottom: 10px;
  opacity: 0.7;
  letter-spacing: 0.3em;
}
.fnr-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 400;
  font-style: italic;
  color: #e8c97e;
  margin-bottom: 10px;
  line-height: 1.2;
}
.fnr-intro {
  font-size: 0.88rem;
  color: rgba(255,255,255,0.5);
  font-style: italic;
  margin-bottom: 2.25rem;
  line-height: 1.5;
}
.fnr-prompt {
  margin-bottom: 2.5rem;
}
.fnr-prompt-label {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
  line-height: 1.4;
}
.fnr-prompt-sublabel {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 12px 0 6px;
}
.fnr-support-text {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.42);
  font-style: italic;
  margin-bottom: 12px;
  line-height: 1.5;
}
.fnr-text-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(220, 185, 120, 0.14);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.fnr-text-input:focus { border-color: var(--accent); }
.fnr-text-input.hidden { display: none; }
.fnr-textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(220, 185, 120, 0.14);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.82rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  line-height: 1.6;
  transition: border-color 0.15s;
}
.fnr-textarea:focus { border-color: var(--accent); }
.fnr-textarea::placeholder,
.fnr-text-input::placeholder { color: var(--text-muted); font-style: italic; }

/* Pills */
.fnr-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.fnr-pill {
  background: var(--surface);
  color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px;
  padding: 7px 15px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.fnr-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 0 3px rgba(219, 80, 96, 0.18);
}
.fnr-pill:not(.active):active { background: var(--surface2); }

/* Autocomplete */
.fnr-autocomplete-wrap {
  position: relative;
  margin-bottom: 6px;
}
.fnr-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  z-index: 50;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}
.fnr-suggestions.hidden { display: none; }
.fnr-suggestion-item {
  padding: 9px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.fnr-suggestion-item:last-child { border-bottom: none; }
.fnr-suggestion-item:active { background: rgba(255,255,255,0.06); }
.fnr-sug-title  { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.fnr-sug-author { font-size: 0.7rem; color: var(--text-muted); font-style: italic; }
.fnr-lookup-loading { font-size: 0.75rem; color: var(--text-muted); padding: 8px 12px; }

/* Error & Submit */
.fnr-error {
  font-size: 0.8rem;
  color: #f87171;
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 1rem;
}
.fnr-error.hidden { display: none; }
.fnr-submit-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 16px 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.03em;
  margin-top: 0.75rem;
  transition: opacity 0.15s;
}
.fnr-submit-btn:active { opacity: 0.85; }

/* Result cards */
.fnr-result-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.fnr-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.fnr-card-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.fnr-card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.fnr-card-author {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}
.fnr-gb-link {
  color: var(--text-muted);
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 2px;
  text-decoration: none;
  transition: color 0.15s;
}
.fnr-gb-link:hover { color: var(--accent2); }
.fnr-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 6px;
}
.fnr-card-why {
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.5;
  border-left: 3px solid var(--accent);
  padding-left: 8px;
  margin-bottom: 10px;
}
.fnr-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.fnr-feel-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.fnr-feel-tag {
  font-size: 0.65rem;
  background: rgba(255,255,255,0.07);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 2px 8px;
}
.fnr-effort-badge {
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 20px;
  padding: 2px 8px;
}
.fnr-effort-easy     { background: rgba(76,175,80,0.15);  color: #81c784; }
.fnr-effort-moderate { background: rgba(245,166,35,0.15); color: #ffb74d; }
.fnr-effort-dense    { background: rgba(100,149,237,0.15);color: #90caf9; }
.fnr-card-actions {
  display: flex;
  gap: 8px;
}
.fnr-replace-btn,
.fnr-wishlist-btn {
  flex: 1;
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.15s, color 0.15s;
}
.fnr-replace-btn  { color: var(--text-muted); }
.fnr-wishlist-btn { color: var(--accent2); border-color: rgba(232,223,200,0.2); }
.fnr-replace-btn:active  { background: rgba(255,255,255,0.06); }
.fnr-wishlist-btn:active { background: rgba(232,223,200,0.08); }
.fnr-wishlist-btn.fnr-wish-added { color: #81c784; border-color: rgba(76,175,80,0.3); cursor: default; }
.fnr-wishlist-btn:disabled { opacity: 0.7; }

/* Skeleton loader */
.fnr-skeleton { pointer-events: none; }
.fnr-skel-title,
.fnr-skel-line {
  background: rgba(255,255,255,0.07);
  border-radius: 4px;
  animation: fnr-pulse 1.2s ease-in-out infinite;
}
.fnr-skel-title { height: 16px; width: 60%; margin-bottom: 10px; }
.fnr-skel-line  { height: 11px; width: 90%; margin-bottom: 8px; }
.fnr-skel-short { width: 55%; }
@keyframes fnr-pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.9; }
}

/* Spinning replace icon */
.fnr-spin {
  display: inline-block;
  animation: fnr-rotate 0.8s linear infinite;
}
@keyframes fnr-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ─── VOICE INPUT ────────────────────────────────────────────────────────────── */
.voice-field {
  position: relative;
  display: flex;
  align-items: stretch;
}
.voice-field input,
.voice-field textarea {
  flex: 1;
  padding-right: 2.8rem !important;
}
.mic-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  z-index: 1;
}
.voice-field textarea ~ .mic-btn {
  top: 12px;
  transform: none;
}
.mic-btn:active { color: var(--accent2); }
.mic-btn.listening {
  color: var(--accent);
  animation: mic-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes mic-pulse {
  from { opacity: 1;   transform: translateY(-50%) scale(1);    }
  to   { opacity: 0.5; transform: translateY(-50%) scale(1.25); }
}
.voice-field textarea ~ .mic-btn.listening {
  animation: mic-pulse-textarea 0.8s ease-in-out infinite alternate;
}
@keyframes mic-pulse-textarea {
  from { opacity: 1;   transform: scale(1);    }
  to   { opacity: 0.5; transform: scale(1.25); }
}

/* ─── BOOK LOOKUP SUGGESTIONS ───────────────────────────────────────────────── */
.book-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.book-suggestions.hidden { display: none; }
.book-lookup-loading {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 4px 0;
  font-style: italic;
}
.book-suggestion-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.book-suggestion-card:active { border-color: var(--accent); }
.book-sug-thumb {
  width: 44px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.book-sug-thumb-placeholder {
  background: var(--surface);
  border-radius: 4px;
}
.book-sug-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.book-sug-title  { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-sug-author { font-size: 0.75rem; color: var(--text-muted); font-style: italic; }
.book-sug-category { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.book-sug-none {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px 0;
  text-align: left;
  text-decoration: underline;
}
.lookup-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 6px 12px;
  cursor: pointer;
  margin-bottom: 8px;
  align-self: flex-start;
}

/* ─── CATEGORY MODAL ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--surface2);
  border-radius: 16px;
  padding: 24px 20px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-title { font-size: 1rem; font-weight: 700; margin: 0; }
.modal-subtitle { font-size: 0.8rem; color: var(--text-muted); margin: 0; }
.modal-book-row {
  background: var(--surface);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.modal-book-title  { font-size: 0.88rem; font-weight: 600; }
.modal-book-author { font-size: 0.78rem; color: var(--text-muted); font-style: italic; }
.modal-category-select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  width: 100%;
}
.modal-actions { display: flex; gap: 10px; margin-top: 4px; }
.modal-confirm-btn {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.modal-cancel-btn {
  background: none;
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.88rem;
  cursor: pointer;
}

/* ─── RATING BUTTONS ─── */
.rating-btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.rating-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.rating-btn.active {
  border-color: var(--accent);
  background: rgba(233,69,96,0.15);
  color: var(--text);
  font-weight: 600;
}

