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

/* ── Tokens ── */
:root {
  /* Palette — dusty rose + warm linen + muted sage */
  --bg:           #fdf8f2;        /* warm linen page */
  --surface:      #faf3eb;        /* card surface */
  --surface-2:    #f2e9dc;        /* subtle hover / input bg */
  --border:       #e8ddd0;        /* quiet border */
  --border-focus: #c4957a;        /* warm terracotta focus */

  --ink:          #3d3530;        /* deep warm brown for headings */
  --ink-mid:      #7a6a60;        /* body text */
  --ink-soft:     #b09e93;        /* labels, hints */

  --rose:         #d4878a;        /* primary accent — muted rose */
  --rose-deep:    #b86b6e;        /* hover / active */
  --rose-wash:    #f7ecec;        /* pill bg */

  --sage:         #8aab8c;        /* completed accent */
  --sage-wash:    #eef5ee;

  --amber:        #c49a5a;        /* star color */
  --amber-wash:   #fdf4e3;

  --status-progress-bg:  #fde8b0;  /* in-progress pill — more saturated than amber-wash */
  --status-progress-ink: #8a5f1a;

  --blue-wash:    #edf0f8;
  --blue-ink:     #6070a8;

  --tab-h:        62px;
  --header-h:     calc(56px + var(--tab-h));
  --radius-sm:    8px;
  --radius-md:    14px;
  --radius-lg:    20px;
  --radius-pill:  999px;

  --font-serif:   'Lora', Georgia, serif;
  --font-sans:    'Nunito', system-ui, sans-serif;

  --shadow-card:  0 2px 8px rgba(100,70,50,.07), 0 0 0 1px rgba(100,70,50,.05);
  --shadow-modal: 0 24px 60px rgba(60,40,30,.18);

  --surface-input: white;       /* overridden in dark mode */

  --teal:         #4a9a8c;
  --teal-wash:    #e4f0ee;

  --red:          #b03030;
  --red-wash:     #fceeed;

  --amber-ink:    #a07030;

  --red-border:   #e8a09b;
  --log-success:  #2e7d38;

  /* rank badge palette */
  --rank1-bg: #fff7e0; --rank1-ink: #a07000;
  --rank2-bg: #f2f2f2; --rank2-ink: #666666;
  --rank3-bg: #fef0e8; --rank3-ink: #b06030;
  --rank4-bg: #eef3fb; --rank4-ink: #4a6fa5;
  --rank11-bg: #f3eefb; --rank11-ink: #7a4aa5;
}

/* ── Base ── */
html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink-mid);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.65;
  min-height: 100vh;
  overflow-y: scroll; /* prevent layout shift from scrollbar appearing/disappearing */
}

/* ── Header ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-top {
  display: flex;
  align-items: baseline;
  justify-content: center;
  padding: .9rem 1.75rem .5rem;
  gap: 1rem;
  max-width: 860px;
  margin: 0 auto;
}
.greeting {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--ink);
  font-style: italic;
}
.greeting strong { font-style: normal; font-weight: 500; color: var(--rose-deep); }

/* Tabs */
.tab-row {
  display: flex;
  gap: 0;
  padding: 0 1.25rem;
  max-width: 860px;
  margin: 0 auto;
  justify-content: center;
}
.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: .65rem 1.25rem;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  font-family: var(--font-sans);
  font-size: .88rem;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .18s, border-color .18s;
  white-space: nowrap;
}
.tab:hover { color: var(--ink-mid); }
.tab.active { color: var(--rose-deep); border-bottom-color: var(--rose); }

/* ── Main ── */
.main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-ico {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--ink-soft);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: .55rem .85rem .55rem 2.1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-input);
  font-family: var(--font-sans);
  font-size: .875rem;
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.search-input::placeholder { color: var(--ink-soft); }
.search-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(196,149,122,.15); }

.pill-select {
  padding: .5rem 2rem .5rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-input);
  font-family: var(--font-sans);
  font-size: .8rem;
  color: var(--ink-mid);
  cursor: pointer;
  outline: none;
  transition: border-color .18s;
  appearance: none;
  -webkit-appearance: none;
  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='%239a8880' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
}
.pill-select:focus { border-color: var(--border-focus); }

.btn-add {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: .52rem 1.1rem;
  background: var(--rose);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s, transform .1s;
  white-space: nowrap;
}
.btn-add:hover { background: var(--rose-deep); }
.btn-add:active { transform: scale(.97); }

/* ── FAB (mobile only) ── */
.fab-add {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.25rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--rose);
  color: white;
  border: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  transition: background .18s, transform .1s;
  z-index: 40;
}
.fab-add:hover  { background: var(--rose-deep); }
.fab-add:active { transform: scale(.93); }
.fab-add[hidden] { display: none !important; }

/* ── Cards grid ── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem 1rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: .55rem;
  transition: box-shadow .2s, transform .2s, border-color .15s, background .15s;
  cursor: default;
}
@media (hover: hover) {
  .card:hover {
    box-shadow: 0 6px 20px rgba(100,70,50,.11), 0 0 0 1px rgba(100,70,50,.08);
    transform: translateY(-2px);
  }
  .card:hover .card-actions { opacity: 1; }
}

/* ── Bulk select mode ── */
.card-select-check {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  z-index: 2;
}
.cards.select-mode { cursor: pointer; }
.cards.select-mode .card-select-check { display: block; }
.cards.select-mode .card-actions,
.cards.select-mode .card-list-actions { display: none; }
/* .card-select-check is an absolute overlay, not a grid item, so it never
   reserves its own space - without this, hiding .card-list-actions above
   lets the title column expand into the checkbox's corner, and a long
   wrapped title runs straight under it. */
.cards.select-mode .card-list-title { padding-right: 38px; }
.card.selected, .card-list.selected { border-color: var(--rose); background: var(--rose-wash); }
.card.selected .card-select-check,
.card-list.selected .card-select-check {
  background: var(--rose);
  border-color: var(--rose);
}
.card.selected .card-select-check::after,
.card-list.selected .card-select-check::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
}

/* ── Drag-to-reorder mode (list view only) ── */
.cards.reorder-mode .card-list-actions { display: none; }
.card-list-drag-handle {
  display: none;
  grid-column: 3;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  color: var(--ink-soft);
  cursor: grab;
  /* Only the handle blocks native touch scrolling — the rest of the row
     stays scrollable, so swiping the list doesn't accidentally drag a card. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.cards.reorder-mode .card-list-drag-handle { display: flex; }
.card-list-drag-handle:active { cursor: grabbing; }
.card-list.dragging {
  opacity: .6;
  box-shadow: var(--shadow-modal);
  z-index: 5;
}
.view-btn:disabled { opacity: .35; cursor: not-allowed; }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
}
.card-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .18s;
}
.card-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .8rem;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .14s, color .14s;
}
.card-btn:hover { background: var(--surface-2); color: var(--ink); }
.card-btn.edit {
  background: var(--amber-wash);
  color: var(--amber-ink);
  border: 1.5px solid var(--amber);
}
.card-btn.edit:hover {
  background: var(--amber);
  color: var(--surface);
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.35;
}
.card-sub {
  font-size: .77rem;
  color: var(--ink-soft);
  margin-top: 1px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-top: .2rem;
  flex-wrap: wrap;
}
.status-tag {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-tag:hover { opacity: .75; }
.tag-completed        { background: var(--sage-wash);  color: var(--sage); }
.tag-completed-season { background: var(--teal-wash);  color: var(--teal); }
.tag-in-progress      { background: var(--status-progress-bg); color: var(--status-progress-ink); }
.tag-plan             { background: var(--blue-wash);  color: var(--blue-ink); }
.tag-dropped          { background: var(--red-wash);   color: var(--red); }

.card-stars { font-size: .85rem; letter-spacing: 1.5px; color: var(--amber); cursor: pointer; }
.card-stars:hover { opacity: .75; }
.card-stars .off { color: var(--border); }

.card-date { font-size: .72rem; color: var(--ink-soft); }
.card-notes {
  font-size: .78rem;
  color: var(--ink-soft);
  font-style: italic;
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: .5rem;
  margin-top: .1rem;
  word-break: break-word;
}
.card-links { display: flex; gap: 6px; font-size: .7rem; margin-top: .4rem; }
.card-ext-link { color: var(--ink-soft); text-decoration: none; }
.card-ext-link:hover { color: var(--ink); text-decoration: underline; }

/* ── Empty state ── */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem 3rem;
  color: var(--ink-soft);
}
.empty-emoji { font-size: 2.8rem; margin-bottom: .75rem; }
.empty-msg { font-size: .92rem; line-height: 1.7; }
.empty-msg strong { color: var(--ink-mid); font-weight: 500; }

/* ── Modal overlay ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(50, 35, 25, .45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.overlay[hidden] { display: none; }

.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain; /* stop scroll chaining to the page behind once the modal hits its own scroll boundary */
  box-shadow: var(--shadow-modal);
  padding: 1.75rem 1.75rem 1.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-sizing: border-box;
}
.modal-x {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 30px;
  height: 30px;
  border: none;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  color: var(--ink-mid);
  font-size: .8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .14s;
}
.modal-x:hover { background: var(--border); }
.modal-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--ink);
  padding-right: 2rem;
}

/* Form fields */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label {
  font-size: .73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
}
.req { color: var(--rose); }
.opt { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-soft); opacity: .8; font-size: .72rem; }
.field-input {
  padding: .55rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-input);
  font-family: var(--font-sans);
  font-size: .9rem;
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
  box-sizing: border-box;
}
.field-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(196,149,122,.15); }
.field-textarea { resize: vertical; min-height: 72px; }

/* Genre/tag pill display (Anime modal) */
.field-pills[hidden] { display: none; }
.field-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
  min-height: 38px;
  padding: 6px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.field-pill {
  font-size: .71rem;
  font-family: var(--font-sans);
  padding: 3px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--ink);
  white-space: nowrap;
  line-height: 1.6;
}
.field-pill--tag {
  background: rgba(196,149,122,.1);
  border-color: rgba(196,149,122,.3);
}
.pill-rank { opacity: .55; font-size: .68rem; }
.field-pills-empty {
  font-size: .71rem;
  color: var(--ink-soft);
  opacity: .65;
  font-style: italic;
  align-self: center;
}

/* ── AniList title typeahead ── */
.title-suggestions {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
  margin-top: 4px;
}
.title-suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.title-suggest-item:last-child { border-bottom: none; }
@media (hover: hover) {
  .title-suggest-item:hover { background: var(--surface-2); }
}
.title-suggest-cover {
  width: 30px;
  height: 42px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--surface-2);
}
.title-suggest-info { flex: 1; min-width: 0; }
.title-suggest-title {
  font-size: .8rem;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.title-suggest-sub {
  font-size: .7rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.title-suggest-year {
  font-size: .7rem;
  color: var(--ink-soft);
  white-space: nowrap;
  flex-shrink: 0;
}
.title-suggest-msg {
  padding: 10px 12px;
  font-size: .78rem;
  color: var(--ink-soft);
  text-align: center;
}

/* Hide number input spinners — except Episode Progress / Total Episodes, where
   step buttons are genuinely handy for nudging a count up or down by one. */
input[type=number].field-input:not(.progress-input)::-webkit-inner-spin-button,
input[type=number].field-input:not(.progress-input)::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number].field-input:not(.progress-input) { -moz-appearance: textfield; }
input[type=number].progress-input { -moz-appearance: number-input; }

/* Style select consistently — hide native arrow, add custom one */
select.field-input {
  appearance: none;
  -webkit-appearance: none;
  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='%239a8880' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .85rem center;
  padding-right: 2.2rem;
  cursor: pointer;
}

/* Category toggle */
.type-row { display: flex; gap: 6px; }
.type-opt {
  flex: 1;
  padding: .5rem .5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-input);
  font-family: var(--font-sans);
  font-size: .82rem;
  color: var(--ink-mid);
  cursor: pointer;
  transition: all .16s;
  text-align: center;
}
.type-opt:hover { border-color: var(--border-focus); color: var(--ink); }
.type-opt.active { background: var(--rose-wash); border-color: var(--rose); color: var(--rose-deep); font-weight: 600; }

/* Star picker */
.star-row { display: flex; gap: 2px; }
.star {
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--border);
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  transition: transform .12s;
}
/* No transition on color: updateStars() toggles the .on class on all 5 stars in one
   synchronous loop, and animating that in WebKit is a known trigger for a repaint bug
   where some elements get stuck on a stale/intermediate frame (only some stars end up
   colored). Instant color change sidesteps the whole bug class. */
.star.on, .star:hover { color: var(--amber); }
.star:hover { transform: scale(1.2); }

/* Form footer */
.modal-source-ref { font-size: .75rem; color: var(--ink-soft); margin: 0 0 .25rem; }
.modal-source-ref a { color: var(--ink-soft); text-decoration: underline; text-underline-offset: 2px; }
.form-err { font-size: .8rem; color: var(--rose-deep); min-height: 1.2em; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; padding-top: .25rem; }
.btn-cancel {
  padding: .5rem 1.1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  font-family: var(--font-sans);
  font-size: .875rem;
  color: var(--ink-mid);
  cursor: pointer;
  transition: background .15s;
}
.btn-cancel:hover { background: var(--surface-2); }
.btn-save {
  padding: .5rem 1.4rem;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--rose);
  font-family: var(--font-sans);
  font-size: .875rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: background .15s;
}
.btn-save:hover  { background: var(--rose-deep); }
.btn-stop {
  padding: .5rem 1.4rem;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--rose-deep);
  font-family: var(--font-sans);
  font-size: .875rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn-stop:hover    { background: #9a5558; }
.btn-stop:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  padding: .5rem 1.4rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  font-family: var(--font-sans);
  font-size: .85rem;
  font-weight: 500;
  color: var(--ink-mid);
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--surface-2); }
.export-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 0;
  border-bottom: 1px solid var(--border);
}
.export-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.export-icon--excel { background: var(--sage-wash); color: var(--sage); }
.export-icon--csv   { background: var(--blue-wash); color: var(--blue-ink); }
.export-row-body { flex: 1; min-width: 0; }
.export-row-title { font-size: .9rem; font-weight: 500; color: var(--ink); }
.export-row-hint { font-size: .78rem; color: var(--ink-soft); margin-top: 1px; }
.export-row .btn-save { flex-shrink: 0; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: var(--bg);
  font-size: .83rem;
  padding: .55rem 1.25rem;
  border-radius: var(--radius-pill);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-action {
  font: inherit;
  font-weight: 700;
  color: var(--bg);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  flex-shrink: 0;
}
.toast-action:hover { opacity: .8; }

/* ── Bulk action bar ── */
.bulk-bar[hidden] { display: none; }
.bulk-bar {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-modal);
  border-radius: var(--radius-lg);
  padding: .6rem .9rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  max-width: calc(100% - 2rem);
  z-index: 250;
}
.bulk-bar-count { font-size: .82rem; color: var(--ink-mid); font-weight: 600; white-space: nowrap; }
.bulk-bar select.pill-select { min-height: 34px; font-size: .78rem; }
.btn-bulk-delete, .btn-bulk-cancel {
  font-family: var(--font-sans);
  font-size: .8rem;
  padding: .4rem .8rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
}
.btn-bulk-delete { border: 1px solid var(--red-border); background: var(--red-wash); color: var(--red); }
.btn-bulk-cancel { border: 1px solid var(--border); background: none; color: var(--ink-soft); }
.btn-bulk-cancel:hover { background: var(--surface-2); }

/* ── Focus ring ── */
:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* ── Mobile ── */
@media (max-width: 600px) {
  .header-top { padding: .75rem 1.1rem .4rem; }
  .tab-row { padding: 0 .75rem; }
  .tab { padding: .6rem .85rem; font-size: .82rem; }
  .main { padding: 1.25rem 1rem 3rem; }
  .cards { grid-template-columns: 1fr; }
  .card-actions { opacity: 1; }
  .modal { padding: 1.4rem 1.2rem 1.2rem; }
}

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

/* ── Two-column field row ── */
.field-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 400px) {
  .field-row-2 { grid-template-columns: 1fr; }
}

/* ── Progress bar on cards ── */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.progress-bar {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--rose);
  border-radius: 999px;
  transition: width .3s ease;
}
.progress-label {
  font-size: .72rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ── Card index number ── */
.card-index {
  font-family: var(--font-serif);
  font-size: .78rem;
  font-style: italic;
  color: var(--ink-soft);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  line-height: 1.4;
  flex-shrink: 0;
}

/* ── Episode stepper on cards ── */
.card-stepper-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.card-stepper-row .now-stepper-btn {
  width: 28px;
  height: 28px;
}
.card-list .now-stepper-btn {
  width: 26px;
  height: 26px;
  font-size: .85rem;
}
.card-list .card-stepper-row { margin: 6px 0; }

/* ── Dashboard ── */
.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.dash-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: .2rem;
}
.dash-sub {
  font-size: .75rem;
  color: var(--ink-soft);
  font-style: italic;
}
.dash-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dash-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.dash-stat-val {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--ink);
  line-height: 1.1;
}
.dash-stat-lbl {
  font-size: .72rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: .3rem;
}

/* Author table */
.author-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-input);
}
.author-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
  min-width: 620px;
}
.author-table thead {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.author-table th {
  padding: .7rem 1rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
  white-space: nowrap;
}
.author-table th.col-rank,
.author-table td.col-rank { text-align: center; width: 60px; }
.author-table th.col-author,
.author-table td.col-author { text-align: left; max-width: 200px; }
.author-table th.col-books,
.author-table td.col-books { text-align: right; width: 80px; }
.author-table th.col-rating,
.author-table td.col-rating { text-align: right; width: 110px; }
.author-table th.col-score,
.author-table td.col-score { text-align: right; width: 100px; }

.author-table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--surface);
  color: var(--ink-mid);
  vertical-align: middle;
}
.author-table tbody tr:last-child td { border-bottom: none; }
.author-table tbody tr:hover td { background: var(--surface); }

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: .78rem;
  font-weight: 600;
  font-family: var(--font-serif);
  font-style: italic;
}
.rank-1  { background: var(--rank1-bg);  color: var(--rank1-ink); }
.rank-2  { background: var(--rank2-bg);  color: var(--rank2-ink); }
.rank-3  { background: var(--rank3-bg);  color: var(--rank3-ink); }
.rank-n  { background: var(--surface-2); color: var(--ink-soft); }
.rank-4  { background: var(--rank4-bg);  color: var(--rank4-ink); }
.rank-11 { background: var(--rank11-bg); color: var(--rank11-ink); }

.author-name { color: var(--ink); font-weight: 500; }
.score-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.score-bar {
  width: 60px;
  height: 5px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}
.score-bar-fill {
  height: 100%;
  background: var(--rose);
  border-radius: 999px;
}
.score-val { min-width: 36px; text-align: right; font-weight: 500; color: var(--ink); }

.dash-empty {
  padding: 3rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: .88rem;
}

/* ── View toggle ── */
.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 3px;
}
.view-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.view-btn:hover { color: var(--ink-mid); }
.view-btn.active { background: var(--surface-input); color: var(--rose-deep); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ── Rating groups ── */
.rating-group { margin-bottom: 1.75rem; }
.rating-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: .75rem;
}
.rating-group-stars {
  font-size: .95rem;
  color: var(--amber);
  letter-spacing: 1px;
}
.rating-group-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-soft);
}
.rating-group-count {
  font-size: .72rem;
  color: var(--ink-soft);
  background: var(--surface-2);
  padding: 1px 8px;
  border-radius: var(--radius-pill);
}
.rating-group-divider {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Sample data button ── */

/* ── Sample data toolbar button ── */

/* ── Tab count badge ── */
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 600;
  font-family: var(--font-sans);
  background: var(--surface-2);
  color: var(--ink-soft);
  margin-left: 4px;
  vertical-align: middle;
  transition: background .15s, color .15s;
}
.tab.active .tab-count {
  background: rgba(255,255,255,.18);
  color: var(--rose);
}

/* ── Search & filter rows ── */
.filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

/* ── Category locked in edit mode ── */
.type-row.locked .type-opt {
  pointer-events: none;
  opacity: .45;
}
.type-row.locked .type-opt.active {
  opacity: 1;
  cursor: default;
}
.type-locked-note {
  font-size: .72rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 4px;
}

/* ── Reset button (icon, shown only when filter/search active) ── */
.btn-reset {
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--rose);
  border-radius: 50%;
  background: transparent;
  color: var(--rose-deep);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}
.btn-reset.active { display: flex; }
.btn-reset:hover  { background: var(--rose-wash); }

/* ── Interactive chart elements ── */
.chart-bar-group.clickable { cursor: pointer; }
.chart-bar-group.clickable:hover .chart-bar { opacity: 0.55 !important; }
.chart-slice { transition: opacity .15s; }
.chart-slice.clickable { cursor: pointer; }
.chart-slice.clickable:hover { opacity: 0.6 !important; }
.donut-legend-item.clickable { cursor: pointer; }
.donut-legend-item.clickable:hover span { text-decoration: underline; }

/* ── Author expand ── */
.author-name {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .15s;
}
.author-name:hover { color: var(--rose-deep); }
.author-chevron {
  font-size: .65rem;
  color: var(--ink-soft);
  transition: transform .2s;
  display: inline-block;
}
.author-name.expanded .author-chevron { transform: rotate(90deg); }

.author-books-row td {
  padding: 0 !important;
  border-bottom: 1px solid var(--surface) !important;
}
.author-books-panel {
  background: var(--surface);
  padding: .75rem 1rem .75rem 3.5rem;
  display: none;
}
.author-books-panel.open { display: block; }

.book-expand-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.book-expand-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .65rem .9rem;
}
.book-expand-num {
  font-family: var(--font-serif);
  font-size: .72rem;
  font-style: italic;
  color: var(--ink-soft);
  min-width: 28px;
  padding-top: 2px;
}
.book-expand-body { flex: 1; min-width: 0; }
.book-expand-title {
  font-size: .88rem;
  font-weight: 500;
  color: var(--ink);
  font-family: var(--font-serif);
}
.book-expand-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}
.book-expand-stars { color: var(--amber); font-size: .8rem; letter-spacing: 1px; }
.book-expand-date  { font-size: .72rem; color: var(--ink-soft); }
.book-expand-status { font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.book-expand-notes {
  font-size: .78rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 5px;
  line-height: 1.5;
}

/* ── Field hint ── */
.field-hint[hidden] { display: none; }
.field-hint {
  display: inline;
  font-size: .68rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-soft);
  opacity: .75;
  margin-left: 6px;
  font-style: italic;
}

/* ── Results count ── */
.results-count {
  font-size: .78rem;
  color: var(--ink-soft);
  margin-bottom: .75rem;
  padding-left: 2px;
}
.results-count strong { color: var(--ink-mid); font-weight: 500; }

/* ── Sort order button ── */
.btn-sort-order {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: .5rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-input);
  font-family: var(--font-sans);
  font-size: .78rem;
  color: var(--ink-mid);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.btn-sort-order:hover { border-color: var(--border-focus); color: var(--ink); }
.btn-sort-order.desc svg { transform: rotate(180deg); }

/* ── Compact modal to avoid scrolling ── */
.modal {
  gap: .65rem;
  padding: 1.25rem 1.5rem 1.1rem;
}
.modal-body { gap: .65rem; }
.field { gap: 3px; }
.field-label { margin-bottom: 2px; font-size: .7rem; }
.field-input { padding: .42rem .75rem; font-size: 16px !important; box-sizing: border-box; width: 100%; }
.field-textarea { min-height: 60px; }
.type-opt { padding: .38rem .5rem; font-size: .8rem; }
.star { font-size: 1.5rem; }
.modal-title { font-size: 1.15rem; }
.modal-btns { padding-top: .1rem; }
.field-row-2 { gap: 8px; }

/* ── Progress x / x input ── */
.progress-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-input {
  flex: 1;
  min-width: 0;
}
.progress-sep {
  font-size: 1.1rem;
  color: var(--ink-soft);
  font-weight: 300;
  line-height: 1;
}

/* ── Card clickable edit ── */
.card[data-id] { cursor: pointer; }
.card[data-id]:hover {
  border-color: var(--rose);
  box-shadow: 0 4px 16px rgba(196,149,122,.15), 0 0 0 1px var(--rose);
}

/* ── Search row layout ── */
.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: .75rem;
}
.search-row .search-box { flex: 1; min-width: 0; }

/* ── Author filter link on book cards ── */
.author-filter-link {
  color: var(--ink-mid);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px dashed var(--ink-soft);
  transition: color .15s, border-color .15s;
}
.author-filter-link:hover {
  color: var(--rose-deep);
  border-bottom-color: var(--rose);
}

/* ── Episode + button ── */
/* ── Done button ── */
.card-btn.done {
  background: var(--sage-wash);
  color: var(--sage);
  border: 1.5px solid var(--sage);
}
.card-btn.done:hover {
  background: var(--sage);
  color: var(--surface);
}

/* ── Delete button ── */
.card-btn.del {
  background: var(--red-wash);
  color: var(--red);
  border: 1.5px solid var(--red-border);
}
.card-btn.del:hover {
  background: var(--red);
  color: var(--surface);
  border-color: var(--red);
}

.rec-error {
  font-size: .85rem;
  color: var(--red);
  background: var(--red-wash);
  padding: .65rem .9rem;
  border-radius: var(--radius-md);
}

/* ── Tab entry count ── */
.tab-entry-count {
  font-size: .78rem;
  color: var(--ink-soft);
  margin-bottom: .75rem;
  padding-left: 2px;
}
.tab-entry-count strong { color: var(--ink-mid); font-weight: 500; }

/* ── Mobile responsive overhaul ── */
@media (max-width: 768px) {
  /* Header */
  .header-top { padding: .6rem 1rem .3rem; }
  .greeting { font-size: 1rem; }

  /* Tabs */
  .tab-row { padding: 0 .5rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { padding: .55rem .75rem; font-size: .8rem; white-space: nowrap; }

  /* Main content */
  .main { padding: 1rem .75rem 3rem; }

  /* Search row */
  .search-row { flex-wrap: wrap; gap: 6px; }
  .search-row .search-box { flex: 1; min-width: 0; }
  .btn-add { display: none; }
  .fab-add { display: flex; }
  
  /* Filter row — single scrollable line */
  .filter-row { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
  .filter-row::-webkit-scrollbar { display: none; }
  .pill-select { flex-shrink: 0; padding: .45rem 2rem .45rem .7rem; }
  .btn-sort-order { font-size: .75rem; padding: .4rem .7rem; }

  /* Prevent iOS zoom on input focus (requires font-size >= 16px) — a <16px focused
     control makes iOS Safari zoom the whole page in, which looks like a broken/resized
     layout until the field loses focus again. */
  .field-input, select.field-input, input.field-input, textarea.field-input,
  .search-input, .pill-select {
    font-size: 16px !important;
  }

  /* Fix date input full width on iOS */
  input[type="date"].field-input {
    width: 100%;
    box-sizing: border-box;
    display: block;
  }

  /* Cards */
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: .9rem 1rem .85rem; }
  .card-actions { opacity: 1 !important; }
  .overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
    max-height: 92dvh; /* dvh tracks the visible viewport, so the sheet shrinks above an open on-screen keyboard instead of extending under it (vh above is a fallback for browsers without dvh support) */
    width: 100%;
    padding: 1.25rem 1.1rem 1.5rem;
  }

  /* Dashboard */
  .dash-header { flex-direction: column; gap: .75rem; }
  .dash-controls { flex-wrap: wrap; }
  .dash-stats { grid-template-columns: repeat(3, 1fr); }
  .author-table-wrap { font-size: .78rem; }
  .author-table th, .author-table td { padding: .6rem .65rem; }
  .score-bar { width: 40px; }

  /* List view on mobile */
  .cards.list-view .card-title { font-size: .85rem; }
}

@media (max-width: 400px) {
  .tab { padding: .5rem .6rem; font-size: .75rem; }
  .dash-stats { grid-template-columns: repeat(2, 1fr); }
  .pill-select { padding: .4rem 2rem .4rem .65rem; } /* font-size stays 16px !important (see 768px query) to avoid iOS zoom-on-focus */
}

/* ── Upload panel ── */
.import-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
}
.import-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .85rem;
  color: var(--ink-mid);
}
.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--rose);
  color: white;
  font-size: .75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.import-form {
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.import-file-input {
  width: 100%;
  padding: .5rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: .875rem;
  cursor: pointer;
  background: var(--surface);
}
.import-file-input:hover { border-color: var(--rose); }
.data-actions { display: flex; gap: 8px; }
.data-log {
  font-size: .82rem;
  line-height: 1.6;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: .75rem 1rem;
  max-height: 200px;
  overflow-y: auto;
}
#api-test-log { max-height: none; }
.log-success { color: var(--log-success); }
.log-error   { color: var(--red); }
.log-info    { color: var(--ink-mid); }
.log-warn    { color: var(--amber-ink); }
.log-timing  { color: var(--ink-soft); font-size: .85em; }
.dup-actions { display: flex; gap: .6rem; margin-top: .75rem; flex-wrap: wrap; }

/* ── List view ── */
.cards.list-view {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
}
.card-list {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .6rem 1rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  column-gap: 8px;
  row-gap: 4px;
  box-shadow: var(--shadow-card);
  transition: border-color .15s, background .15s;
}
.card-list:hover { border-color: var(--ink-faint); }
.card-list-index {
  grid-column: 1;
  font-family: var(--font-serif);
  font-size: .72rem;
  font-style: italic;
  color: var(--ink-soft);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}
.card-list-title {
  grid-column: 2;
  font-family: var(--font-serif);
  font-size: .95rem;
  color: var(--ink);
  line-height: 1.3;
}
.card-list-actions {
  grid-column: 3;
  display: flex;
  flex-direction: row;
  gap: 4px;
  opacity: 0;
  transition: opacity .18s;
}
.card-list:hover .card-list-actions { opacity: 1; }
.card-list-sub { grid-column: 2 / -1; font-size: .78rem; color: var(--ink-soft); }
.card-list .card-stepper-row { grid-column: 2 / -1; }
.card-list-bottom {
  grid-column: 2 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.card-list .card-links { grid-column: 2 / -1; }

/* ── Template download button ── */
.import-download { margin-bottom: 1rem; }
.btn-download-template {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: .5rem 1.1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-input);
  font-family: var(--font-sans);
  font-size: .85rem;
  color: var(--ink-mid);
  text-decoration: none;
  transition: border-color .15s, color .15s;
}
.btn-download-template:hover { border-color: var(--rose); color: var(--rose-deep); }

/* ── Author Dashboard mobile ── */
@media (max-width: 768px) {
  .author-table-wrap { border-radius: var(--radius-md); }
  .author-table { font-size: .75rem; min-width: unset; }
  .author-table th, .author-table td { padding: .5rem .5rem; }
  /* Hide score bar on mobile, just show number */
  .score-bar { display: none; }
  .score-bar-wrap { justify-content: flex-end; }
  /* Shorten column headers */
  .col-books::after { content: ''; }
  .col-rating { white-space: nowrap; }
  /* Compact rank badge */
  .rank-badge { width: 24px; height: 24px; font-size: .7rem; }
  /* Author expand panel */
  .author-books-panel { padding: .5rem .75rem .5rem 1rem; }
  .book-expand-item { grid-template-columns: 20px 1fr auto auto; gap: 0 8px; }
  /* Dashboard stats */
  .dash-stats { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .dash-stat-val { font-size: 1.2rem; }
  .dash-controls { flex-direction: column; gap: 6px; width: 100%; }
  .dash-controls .pill-select { width: 100%; }
}

/* ── Dashboard author expand — mobile font fix ── */
@media (max-width: 768px) {
  .book-expand-title { font-size: .82rem; }
  .author-name { font-size: .85rem; }
}

/* ── Data panel ── */
.data-panel { display: flex; flex-direction: column; gap: 0; }
.data-section { padding: 0 0 1.5rem; }
.data-section-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: .2rem;
}
.data-section-desc {
  font-size: .85rem;
  color: var(--ink-mid);
  line-height: 1.6;
  margin-bottom: 1.1rem;
}
.data-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* ── Dashboard table controls ── */
.dash-table-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: .75rem;
  flex-wrap: wrap;
}

/* ── Sortable column headers ── */
.author-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.author-table th.sortable:hover { color: var(--ink); }
.author-table th.sort-active { color: var(--ink); }
.sort-tri {
  font-size: .6rem;
  opacity: .3;
  margin-left: 2px;
}
.sort-active .sort-tri {
  opacity: 1;
  color: var(--ink);
}

/* ── Inline template link ── */
.btn-download-template.inline {
  display: inline-flex;
  align-items: center;
  padding: .15rem .55rem;
  font-size: .78rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-input);
  color: var(--ink-mid);
  text-decoration: none;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-download-template.inline:hover { border-color: var(--rose); color: var(--rose-deep); }


/* ── Mobile tap to reveal actions ── */
.card.show-actions .card-actions { opacity: 1 !important; }
.card-list.show-actions .card-list-actions { opacity: 1 !important; }

/* ── Shelf meta row (counts + sort + view toggle) ── */
.shelf-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.shelf-meta-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Meta filter links (Year, Country, Author) ── */
.meta-filter-link {
  cursor: pointer;
  border-bottom: 1px dashed var(--ink-soft);
  transition: color .15s, border-color .15s;
}
.meta-filter-link:hover { color: var(--rose-deep); border-bottom-color: var(--rose); }

/* ── Star rating clickable ── */
.card .card-stars,
.card-list .card-stars { cursor: pointer !important; }
.card .card-stars:hover,
.card-list .card-stars:hover { opacity: .7 !important; }

/* ── Mobile: always show edit/delete buttons ── */
@media (hover: none) {
  .card-actions { opacity: 1 !important; }
  .card-list-actions { opacity: 1 !important; }
}

/* ── Mobile tabs: emoji only ── */
@media (max-width: 600px) {
  .tab .tab-text { display: none !important; }
  .tab { flex: 1 !important; justify-content: center !important; padding: .55rem .25rem !important; font-size: 1.15rem !important; gap: 0 !important; }
  .tab-row { padding: 0 !important; overflow-x: visible !important; max-width: 100% !important; }
}

/* ── Mobile data tab ── */
@media (max-width: 768px) {
  .data-section { padding: 0 0 .5rem; }
  .import-steps { padding: .5rem .65rem; gap: 6px; margin-bottom: .5rem; }
  .import-step { gap: 8px; font-size: .86rem; }
  .import-step span { flex-wrap: wrap !important; gap: 4px !important; }
  .btn-download-template.inline { margin-left: 0 !important; }
  .data-section-title { font-size: 1.05rem; }
  .data-section-desc { font-size: .82rem; margin-bottom: .6rem; }
  .data-divider { margin: .4rem 0; }
  .btn-import { padding: .55rem 1.25rem; }
}

/* ── Mobile list card ── */
@media (max-width: 768px) {
  .card-list { padding: .65rem .75rem; }
  .card-list-index { font-size: .68rem; }
  .card-list-title { font-size: .9rem; }
}

/* ── Shelf title (Anime / Drama / Books) ── */
.shelf-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: .75rem;
}

/* ── Login Overlay ── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-overlay[hidden] { display: none; }

.login-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.login-logo {
  margin-bottom: 0.75rem;
  opacity: 0.9;
}

.login-title {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  font-weight: 400;
  color: var(--ink);
  margin: 0 0 0.25rem;
  letter-spacing: 0.01em;
}

.login-subtitle {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.login-input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--ink);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.login-input:focus {
  border-color: var(--rose);
}

.login-btn {
  width: 100%;
  padding: 0.65rem;
  background: var(--rose);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  letter-spacing: 0.02em;
}
.login-btn:hover  { background: var(--rose-deep); }
.login-btn:disabled { opacity: 0.6; cursor: default; }

.login-error {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--rose-deep);
  margin: 0.5rem 0 0;
  min-height: 1.2em;
  text-align: center;
}

/* end of styles */

/* ── Flatpickr custom theme ── */

/* Force wrapper and input to full width */
.flatpickr-wrapper {
  width: 100%;
  display: block;
}
.flatpickr-input {
  width: 100% !important;
  box-sizing: border-box !important;
  padding: .55rem .85rem !important;
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  background: var(--surface-input) !important;
  font-family: var(--font-sans) !important;
  font-size: .9rem !important;
  color: var(--ink) !important;
  outline: none !important;
  cursor: pointer;
}
.flatpickr-input:focus {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 3px rgba(196,149,122,.15) !important;
}
@media (max-width: 600px) {
  .flatpickr-input { font-size: 16px !important; padding: .42rem .75rem !important; }
}

.flatpickr-calendar {
  font-family: var(--font-sans);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(61,53,48,.12);
}
.flatpickr-month {
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px 10px 0 0;
}
.flatpickr-current-month {
  font-family: var(--font-serif);
  color: var(--ink);
}
.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: var(--surface);
  color: var(--ink);
}
.flatpickr-weekday {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: .75rem;
}
.flatpickr-day {
  border-radius: 8px;
  color: var(--ink);
}
.flatpickr-day:hover {
  background: var(--surface-2);
  border-color: var(--border);
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--rose);
  border-color: var(--rose);
  color: #fff;
}
.flatpickr-day.today {
  border-color: var(--rose);
  color: var(--rose);
}
.flatpickr-day.today:hover {
  background: var(--surface-2);
  color: var(--rose);
}
.numInputWrapper:hover { background: var(--surface-2); }
.flatpickr-prev-month svg,
.flatpickr-next-month svg { fill: var(--ink-soft); }
.flatpickr-prev-month:hover svg,
.flatpickr-next-month:hover svg { fill: var(--rose); }

/* ── Dashboard sub-tabs ── */
#view-mode-row {
  max-width: 860px;
  margin: 0 auto;
  padding: .55rem 1.5rem .35rem;
  gap: 5px;
  justify-content: center;
}
.mode-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: .28rem .85rem;
  font-family: var(--font-sans);
  font-size: .8rem;
  color: var(--ink-mid);
  cursor: pointer;
  transition: all .15s;
}
.mode-btn.active {
  background: var(--rose-wash);
  border-color: var(--rose);
  color: var(--rose-deep);
  font-weight: 600;
}
.mode-btn:hover:not(.active) { border-color: var(--rose); color: var(--rose); }
.mode-btn[data-mode="recommend"] { background: var(--blue-wash); border-color: var(--blue-ink); color: var(--blue-ink); }
.mode-btn[data-mode="recommend"]:hover:not(.active) { border-color: var(--blue-ink); color: var(--blue-ink); }

/* ── Dashboard panels ── */
.dash-panel { animation: fadeIn .2s ease; }

/* ── Stat cards ── */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.dash-stat {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: .85rem .75rem;
  text-align: center;
}
.dash-stat-val {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.1;
}
.dash-stat-lbl {
  font-size: .68rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: .25rem;
}

/* ── Chart cards ── */
.dash-charts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .85rem;
}
.dash-chart-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  overflow: hidden;
  min-width: 0;
}
.dash-chart-title {
  font-family: var(--font-sans);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
  margin-bottom: .75rem;
}
.dash-chart-sub {
  font-weight: 400;
  text-transform: none;
  font-size: .7rem;
  color: var(--ink-soft);
  opacity: .7;
  letter-spacing: 0;
  margin-left: 4px;
}
.dash-charts-note {
  font-size: .78rem;
  color: var(--ink-soft);
  margin-bottom: .75rem;
  padding-left: 2px;
}
.dash-charts-note strong { color: var(--ink-mid); font-weight: 500; }

/* Chart SVG */
.dash-chart-card svg { width: 100%; overflow: visible; }
.chart-bar-group .chart-bar { transition: opacity .15s; }

/* Donut */
.donut-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: .75rem; }
.donut-legend-item { display: flex; align-items: center; gap: 5px; font-size: .75rem; color: var(--ink-mid); }
.donut-swatch { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Empty state */
.dash-empty-msg { text-align: center; color: var(--ink-soft); font-size: .85rem; padding: 1.5rem 0; }

/* Mobile */
@media (max-width: 600px) {
  .dash-stats { grid-template-columns: repeat(2, 1fr); }
  .dash-charts { grid-template-columns: 1fr; }
}

/* ── Stat cards ── */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .75rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 400px) {
  .dash-stats { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ── Genre/Tag toggle ── */
.genre-tag-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: .75rem;
  justify-content: center;
}
.genre-tag-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: .25rem .75rem;
  font-family: var(--font-sans);
  font-size: .75rem;
  color: var(--ink-mid);
  cursor: pointer;
  transition: all .15s;
}
.genre-tag-btn.active {
  background: var(--rose-wash);
  border-color: var(--rose);
  color: var(--rose-deep);
  font-weight: 600;
}

/* ── Now view ── */
.now-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.now-header-title { font-size: 1rem; font-weight: 600; color: var(--ink); }
.now-header-count { font-size: .8rem; color: var(--ink-soft); }

.now-section { margin-bottom: 1.5rem; }
.now-section-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.now-section-status {
  font-size: .68rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: auto;
}
.now-section-status--anime { background: var(--rose-wash);  color: var(--rose-deep); }
.now-section-status--drama { background: var(--blue-wash);  color: var(--blue-ink);  }
.now-section-status--book  { background: var(--teal-wash);  color: var(--teal);      }
.now-entry {
  display: flex;
  flex-direction: column;
  padding: .6rem .75rem;
  border-radius: 8px;
  transition: background .12s;
}
.now-entry:hover { background: var(--surface-2); }
.now-entry-top {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: .65rem;
}
.now-entry-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.now-entry-icon--anime { background: var(--rose-wash);  color: var(--rose-deep); }
.now-entry-icon--drama { background: var(--blue-wash);  color: var(--blue-ink);  }
.now-entry-icon--book  { background: var(--teal-wash);  color: var(--teal);      }
.now-entry-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}
.now-entry-title { font-size: .9rem; color: var(--ink); font-weight: 500; }
.now-entry-meta  { font-size: .78rem; color: var(--ink-soft); }
.now-entry-actions {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.now-stepper-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 0 calc(28px + .65rem);
  padding: .5rem 0 .3rem;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.now-stepper-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: none;
  color: var(--ink-mid);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
}
.now-stepper-btn:hover { background: var(--surface-2); color: var(--ink); }
.now-stepper-btn.minus { border-color: var(--ink-soft); background: var(--surface-2); color: var(--ink-mid); }
.now-stepper-btn.minus:hover { background: var(--ink-mid); color: var(--surface); border-color: var(--ink-mid); }
.now-stepper-btn.plus { border-color: var(--rose); background: var(--rose-wash); color: var(--rose-deep); }
.now-stepper-btn.plus:hover { background: var(--rose); color: var(--surface); }
.now-stepper-btn:disabled { opacity: .35; cursor: default; pointer-events: none; }
.now-stepper-track {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}
.now-stepper-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 3px;
  background: var(--rose);
}
.now-stepper-label { flex-shrink: 0; font-size: .75rem; color: var(--ink-mid); white-space: nowrap; }
.now-done-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--sage);
  background: var(--sage-wash);
  color: var(--sage);
  font-size: .8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
}
.now-done-btn:hover { background: var(--sage); color: var(--surface); border-color: var(--sage); }
.now-empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: .9rem;
  padding: 3rem 0;
}
.now-empty--inline { padding: 1rem 0 0; }
.now-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0 1rem;
}
.now-entry--queued { opacity: .88; }
.now-entry--queued .now-entry-title { color: var(--ink-soft); }
.now-del-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--red-border);
  background: var(--red-wash);
  color: var(--red);
  font-size: .8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
}
.now-del-btn:hover { background: var(--red); color: var(--surface); border-color: var(--red); }
.now-start-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--rose);
  background: var(--rose-wash);
  color: var(--rose-deep);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
}
.now-start-btn:hover { background: var(--rose); color: var(--surface); }

/* ── Sync panel ── */
.sync-tabs { display: flex; gap: 6px; margin-bottom: 1.2rem; }
#data-sync .type-row { margin-bottom: 1.2rem; }
.sync-tab { flex: 1; padding: .5rem .5rem; border: 1.5px solid var(--border); border-radius: var(--radius-md); background: var(--surface-input); font-family: var(--font-sans); font-size: .82rem; color: var(--ink-mid); cursor: pointer; transition: all .16s; text-align: center; }
.sync-tab:hover { border-color: var(--border-focus); color: var(--ink); }
.sync-tab.active { background: var(--rose-wash); border-color: var(--rose); color: var(--rose-deep); font-weight: 600; }
.sync-filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; margin-bottom: .3rem; }
.sync-or-sep { font-size: .78rem; color: var(--ink-soft); margin: .2rem 0 .3rem; }
.sync-all-row { margin-bottom: .6rem; }
.sync-filter-label.sync-disabled { opacity: .4; pointer-events: none; }
.sync-filter-group-label { font-size: .82rem; color: var(--ink-soft); flex-basis: 100%; }
.sync-batch-row { display: flex; align-items: baseline; gap: .8rem; margin: -.2rem 0 .8rem; }
.sync-filter-tally { font-size: .8rem; color: var(--ink-soft); margin: 0; }
.sync-batch-label { font-size: .82rem; color: var(--ink-mid); white-space: nowrap; }
.sync-batch-input { width: 52px; padding: 2px 4px; font-size: .82rem; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--ink); text-align: center; }
.sync-filter-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--ink-mid);
  margin-bottom: 0;
  cursor: pointer;
}
.sync-filter-label input[type="checkbox"] { cursor: pointer; }
.sync-preview-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .8rem;
  margin-bottom: .6rem;
  font-size: .85rem;
  color: var(--ink-mid);
}
.sync-select-all-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: .83rem;
  color: var(--ink-mid);
}
.sync-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.sync-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
}
.sync-table th {
  text-align: left;
  padding: 7px 10px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.sync-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.sync-table tr:last-child td { border-bottom: none; }
.sync-table tr:hover td { background: var(--surface-2); }
.sync-row--nomatch td { opacity: .55; }
.sync-title { font-weight: 500; min-width: 160px; max-width: 240px; word-break: break-word; }
.sync-tag {
  display: inline-block;
  font-size: .73rem;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--ink-mid);
  border: 1px solid var(--border);
  margin: 2px 2px 2px 0;
}
.sync-tag--add          { background: var(--sage-wash); color: var(--sage); border-color: var(--sage); }
.sync-tag--remove       { background: var(--rose-wash); color: var(--rose-deep); border-color: var(--rose); text-decoration: line-through; }
.sync-tag--rank-changed { background: var(--amber-wash); color: var(--amber-ink); border-color: var(--amber); }
.sync-none      { color: var(--ink-soft); font-size: .78rem; }
.sync-nomatch   { color: var(--amber-ink); font-size: .78rem; }
.sync-unchanged { color: var(--ink-soft); font-size: .78rem; }
.sync-row--unchanged td { opacity: .45; }
.sync-id        { font-size: .68rem; color: var(--ink-soft); font-weight: 400; }

/* ── Chart horizontal scroll ── */
.chart-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--surface-2);
  padding-bottom: 4px;
}
.chart-scroll::-webkit-scrollbar { height: 6px; }
.chart-scroll::-webkit-scrollbar-track { background: var(--surface-2); border-radius: 3px; }
.chart-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.chart-scroll::-webkit-scrollbar-thumb:hover { background: var(--ink-soft); }

/* ── Theme toggle button ── */
.btn-theme {
  position: absolute;
  top: .8rem;
  right: 1.25rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
  z-index: 10;
}
.btn-theme:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-soft); }

/* ── Dark mode ── */
[data-theme="dark"] {
  --bg:           #1c1917;
  --surface:      #242019;
  --surface-2:    #2e2822;
  --border:       #3d3530;
  --border-focus: #c4957a;
  --ink:          #f0e4d4;
  --ink-mid:      #c4aea0;
  --ink-soft:     #7a6a60;
  --rose-wash:    #3d1f20;
  --sage-wash:    #1a2e1a;
  --amber-wash:   #2e2212;
  --blue-wash:    #1a1e2e;
  --blue-ink:     #8898c8;
  --surface-input: #2e2822;
  --teal-wash:    #1a2e2b;
  --teal:         #5ab0a0;
  --red-wash:     #2e1a1a;
  --red:          #d06060;
  --amber-ink:    #c49a5a;
  --red-border:   #5a2828;
  --log-success:  #4aaa58;

  --rank1-bg: #2e2500; --rank1-ink: #d4a820;
  --rank2-bg: #282828; --rank2-ink: #a8a8a8;
  --rank3-bg: #2a1a0e; --rank3-ink: #c07840;
  --rank4-bg: #1a1e2e; --rank4-ink: #8898c8;
  --rank11-bg: #1e1a2e; --rank11-ink: #a878c8;

  --shadow-card:  0 2px 8px rgba(0,0,0,.3), 0 0 0 1px rgba(0,0,0,.2);
  --shadow-modal: 0 24px 60px rgba(0,0,0,.55);

  --status-progress-bg:  #3a2810;
  --status-progress-ink: #d4a050;
}

/* ── Recommend view ── */
.rec-season-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 1rem;
  gap: 8px;
}
.rec-season-select { justify-self: center; }
.rec-sort-pills { display: flex; gap: 5px; justify-self: end; }
.rec-sort-pill {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px 11px;
  font-size: .75rem;
  font-family: var(--font-sans);
  color: var(--ink-soft);
  cursor: pointer;
}
.rec-sort-pill:hover:not(.active) { background: var(--surface-2); }
.rec-sort-pill.active { background: var(--ink-mid); color: var(--bg); border-color: var(--ink-mid); }
.rec-profile-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem .9rem;
  margin-bottom: 1.1rem;
}
.rec-profile-label { font-size: .8rem; color: var(--ink-soft); margin-bottom: .5rem; }
.rec-profile-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.rec-profile-sublabel { font-size: .75rem; color: var(--ink-soft); min-width: 38px; flex-shrink: 0; }
.rec-profile-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.rec-ptag-none { font-size: .78rem; color: var(--ink-soft); }
.rec-ptag {
  font-family: var(--font-sans);
  font-size: .78rem;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .12s;
}
.rec-ptag--genre { background: var(--blue-wash); color: var(--blue-ink); }
.rec-ptag--tag   { background: var(--sage-wash);  color: var(--sage); }
.rec-ptag--active { border-color: currentColor; font-weight: 600; }
.rec-count { font-size: .8rem; color: var(--ink-soft); margin-bottom: .6rem; }
.rec-filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 2px 4px 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-mid);
}
.rec-filter-clear {
  border: none;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: .8em;
  padding: 2px 5px;
  line-height: 1;
}
.rec-filter-clear:hover { color: var(--ink); }
.rec-card {
  display: grid;
  grid-template-columns: 228px 1fr;
  gap: 0 11px;
  align-items: start;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.rec-rank-inline {
  display: inline-block;
  font-family: var(--font-serif);
  font-size: .72rem;
  font-style: italic;
  color: var(--ink-soft);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  margin-right: 5px;
}
.rec-cover-wrap {
  aspect-ratio: .71 / 1;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}
.rec-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rec-cover-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 1.1rem;
  font-weight: 500;
}
.rec-body { min-width: 0; }
.rec-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.rec-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 1px;
  word-break: break-word;
}
.rec-romaji {
  font-size: .8rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}
.rec-match-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}
.rec-match-bg {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.rec-match-fill { height: 100%; border-radius: 3px; }
.rec-match-pct { font-size: .82rem; font-weight: 500; min-width: 34px; text-align: right; }
.rec-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.rec-tags--tags { margin-bottom: 5px; }
.rec-tag {
  font-size: .78rem;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  color: var(--ink-soft);
}
.rec-tag--genre.rec-tag--hit { background: var(--blue-wash); border-color: var(--blue-ink); color: var(--blue-ink); }
.rec-tag--tag.rec-tag--hit   { background: var(--sage-wash); border-color: var(--sage);     color: var(--sage);     }
.rec-tag--extra-match {
  background: none;
  border: 1px dashed var(--sage);
  color: var(--sage);
}
.rec-desc {
  font-size: .8rem;
  color: var(--ink-soft);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.rec-desc--expanded {
  display: block;
  -webkit-line-clamp: unset;
  -webkit-box-orient: unset;
  overflow: visible;
}
.rec-stats { font-size: .8rem; color: var(--ink-soft); }
.rec-no-tags { font-size: .8rem; color: var(--ink-soft); }
.rec-links { display: flex; gap: 6px; font-size: .76rem; margin-top: 4px; }
.rec-ext-link { color: var(--ink-soft); text-decoration: none; }
.rec-ext-link:hover { color: var(--ink); text-decoration: underline; }
.rec-actions { flex-shrink: 0; }
.btn-rec-add {
  border: 1px solid var(--border);
  background: none;
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  font-size: .75rem;
  font-family: var(--font-sans);
  cursor: pointer;
  color: var(--ink);
  white-space: nowrap;
}
.btn-rec-add:hover:not([disabled]) { background: var(--surface-2); }
.btn-rec-on-shelf { color: var(--ink-soft); border-style: dashed; cursor: default; }
.rec-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1.4rem 0 .5rem;
}
.rec-divider-line { flex: 1; height: 1px; background: var(--border); }
.rec-divider-label { font-size: .72rem; color: var(--ink-soft); white-space: nowrap; }
.rec-empty, .rec-loading {
  text-align: center;
  color: var(--ink-soft);
  padding: 3rem 0;
  font-size: .88rem;
  line-height: 1.8;
}
#rec-show-more { text-align: center; margin: 1.1rem 0; }
.btn-rec-more {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  font-size: .82rem;
  font-family: var(--font-sans);
  color: var(--ink-mid);
  cursor: pointer;
}
.btn-rec-more:hover { background: var(--surface-2); }

@media (max-width: 480px) {
  .rec-card { grid-template-columns: 150px 1fr; gap: 0 8px; }
  .rec-season-row { grid-template-columns: 1fr; justify-items: center; }
  .rec-sort-pills { justify-self: center; }
}
