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

:root {
  --bg:         #1a1a2e;
  --surface:    #16213e;
  --surface2:   #0f3460;
  --accent:     #e94560;
  --accent2:    #f5a623;
  --text:       #e0e0e0;
  --text-muted: #9a9a9a;
  --radius:     12px;
  --nav-height: 64px;
  --header-h:   56px;
}

html { height: 100%; }
body {
  font-family: -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-logo {
  height: 44px;
  width: auto;
  display: block;
  filter: none;
}
.app-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent2);
}
.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;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 0;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn.active  { color: var(--accent2); }
.nav-btn:active  { color: var(--accent); }
.nav-icon        { font-size: 1.4rem; line-height: 1; }
.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(15,52,96,0.85) 0%, rgba(22,33,62,0.55) 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.92rem;
  font-weight: 600;
  color: var(--text);
}
.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 {
  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: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.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 28px;
  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;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
  pointer-events: none;
}
.book-cover-rating {
  position: absolute;
  bottom: 6px; left: 8px;
  font-size: 1rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
  pointer-events: none;
}

/* ─── BOOKS TOOLBAR ─────────────────────────────────────────────────────────── */
.books-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1rem;
}
.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); }
.books-toolbar-row {
  display: flex;
  gap: 8px;
}
.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); }
.hl-kindle-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 4px 0 0;
  opacity: 0.75;
}

/* ─── BOOKS GROUPS ──────────────────────────────────────────────────────────── */
.books-group { margin-bottom: 1.5rem; }
.books-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;
  padding-left: 8px;
  border-left: 3px solid transparent;
}
.books-group-heading.accent-reading    { border-left-color: #4caf50; }
.books-group-heading.accent-waitlisted { border-left-color: #9c6fda; }
.books-group-heading.accent-paused     { border-left-color: #f5a623; }
.books-group-heading.accent-completed  { border-left-color: #6ea8fe; }
.books-group-count {
  background: rgba(255,255,255,0.1);
  color: var(--text);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.7rem;
}

/* ─── 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-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.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-waitlisted { 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-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 {
  display: flex;
  gap: 8px;
  margin-bottom: 1rem;
  flex-direction: column;
}
.highlights-toolbar input {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
}
.highlights-toolbar input::placeholder { color: var(--text-muted); }
.highlights-toolbar-row {
  display: flex;
  gap: 8px;
}
.highlights-toolbar select {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
}
.hl-quote-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 10px;
  border-left: 4px solid var(--accent2);
  position: relative;
  cursor: pointer;
}
.hl-quote-mark  { font-size: 2rem; color: var(--text-muted); line-height: 0.8; display: block; margin-bottom: 4px; }
.hl-quote-text  { font-size: 0.88rem; line-height: 1.55; color: var(--text); }
.hl-quote-why   { font-size: 0.78rem; color: var(--text-muted); margin-top: 8px; font-style: italic; }
.hl-quote-date  { font-size: 0.7rem; color: var(--text-muted); margin-top: 6px; }
.hl-quote-source { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; }
.hl-quote-category { font-size: 0.65rem; color: var(--text-muted); font-style: italic; margin-left: 4px; }
.hl-delete { position: absolute; top: 8px; right: 8px; background: rgba(233,69,96,0.15); }

/* ─── HOME QUOTE CARDS ──────────────────────────────────────────────────────── */
.home-quote-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 10px;
  border-left: 4px solid var(--accent2);
  cursor: pointer;
}
.home-quote-mark   { font-size: 1.8rem; color: var(--text-muted); line-height: 0.8; display: block; }
.home-quote-text   { font-size: 0.85rem; line-height: 1.5; margin-top: 4px; }
.home-quote-source { font-size: 0.72rem; color: var(--text-muted); margin-top: 6px; }
.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: 10px; }
.essay-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s;
}
.essay-card:active { transform: scale(0.98); }
.essay-card-header h3 { font-size: 1rem; font-weight: 700; }
.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;
}

/* ─── FORMS (FULL SCREEN SHEET) ─────────────────────────────────────────────── */
.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-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
}
.radio-label input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.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);
}
.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; }

/* ─── RESPONSIVE: TABLET / DESKTOP ─────────────────────────────────────────── */
@media (min-width: 600px) {
  .home-covers { grid-template-columns: repeat(4, 1fr); }
  .book-meta-grid { grid-template-columns: 1fr 1fr; }
  .highlights-toolbar { flex-direction: row; align-items: center; }
  .highlights-toolbar input { flex: 2; }
  .highlights-toolbar select { flex: 1; }
  .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: rgba(245,166,35,0.15);
  color: var(--accent2);
  border: 1px solid rgba(245,166,35,0.3);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
  transition: background 0.15s;
}
.wishlist-move-btn:active { background: rgba(245,166,35,0.3); }
.wishlist-status-prompt {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.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;
}

/* ─── 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;
}

