/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --accent: #2C5F7A;
  --accent-light: #E8F2F7;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --text: #1C1C1E;
  --text-secondary: #6C6C70;
  --separator: #E5E5EA;
  --destructive: #FF3B30;
  --success: #34C759;
  --radius-card: 12px;
  --radius-btn: 10px;
  --radius-input: 10px;
  --header-height: 56px;
  --max-width: 480px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
}

/* ── View Transitions (MPA cross-document) ───────────────────────────────── */
@view-transition {
  navigation: auto;
}

@keyframes vt-slide-in-from-right {
  from { transform: translateX(100%); }
}
@keyframes vt-slide-out-to-left {
  to { transform: translateX(-30%); opacity: 0; }
}
@keyframes vt-slide-in-from-left {
  from { transform: translateX(-30%); opacity: 0; }
}
@keyframes vt-slide-out-to-right {
  to { transform: translateX(100%); }
}

/* Default: disable browser's default crossfade */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

:root[data-nav-direction="forward"]::view-transition-old(root) {
  animation: 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both vt-slide-out-to-left;
}
:root[data-nav-direction="forward"]::view-transition-new(root) {
  animation: 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both vt-slide-in-from-right;
}
:root[data-nav-direction="backward"]::view-transition-old(root) {
  animation: 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both vt-slide-out-to-right;
}
:root[data-nav-direction="backward"]::view-transition-new(root) {
  animation: 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both vt-slide-in-from-left;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.page-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* ── Edge swipe capture overlay ──────────────────────────────────────────── */
#edge-swipe-zone,
#edge-swipe-zone-right {
  position: fixed;
  top: 0; bottom: 0;
  width: 24px;
  z-index: 9999;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#edge-swipe-zone { left: 0; }
#edge-swipe-zone-right { right: 0; }


.page-content {
  padding: 16px;
  padding-top: calc(var(--header-height) + 16px);
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--header-height);
  background: var(--card);
  border-bottom: 1px solid var(--separator);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  z-index: 100;
}

.header-btn {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-btn);
  padding: 0 8px;
  -webkit-tap-highlight-color: transparent;
}

.header-btn:active { background: var(--separator); }

.header-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 120px);
}

/* ── Home Screen ──────────────────────────────────────────────────────────── */
.page-content--no-header { padding-top: 16px; }

.home-title {
  text-align: center;
  padding: 28px 0 20px;
  font-size: 36px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1px;
}

.home-subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
  margin-bottom: 8px;
}

.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 4px;
}

.home-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--accent);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  min-height: 110px;
  justify-content: center;
  transition: box-shadow 0.2s, background 0.2s, transform 0.2s;
}

.home-card:active { box-shadow: var(--shadow-md); background: var(--bg); transform: scale(0.98); transition: none; }

.home-card--inactive {
  border-color: var(--separator);
  opacity: 0.45;
  pointer-events: none;
}

.home-card-icon { display: flex; align-items: center; justify-content: center; color: var(--text); }
.home-card-label { font-size: 17px; font-weight: 600; letter-spacing: -0.3px; }

/* ── Flash Messages ───────────────────────────────────────────────────────── */
.flash-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.flash {
  padding: 12px 16px;
  border-radius: var(--radius-card);
  font-size: 14px;
  font-weight: 500;
}

.flash.success { background: #D1F5DC; color: #1A6B31; }
.flash.error { background: #FFE5E3; color: #8B1A14; }
.flash.info { background: var(--accent-light); color: #1B3D4F; }

/* ── Search & Sort ────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-row .search-input,
.search-row .form-input { flex: 1; width: auto; }

.search-input {
  width: 100%;
  height: 44px;
  padding: 0 16px 0 40px;
  background: var(--card);
  border: 1px solid var(--separator);
  border-radius: var(--radius-input);
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236C6C70' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

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

.sort-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-icon {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.order-toggle-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: var(--card);
  border: 1px solid var(--separator);
  border-radius: var(--radius-input);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.order-toggle-btn:active {
  background: var(--separator);
  color: var(--text);
}

.order-toggle-btn[data-order="asc"] .icon-desc { display: none; }
.order-toggle-btn[data-order="desc"] .icon-asc { display: none; }

.sort-select {
  flex: 1;
  height: 36px;
  padding: 0 12px;
  background: var(--card);
  border: 1px solid var(--separator);
  border-radius: var(--radius-input);
  font-size: 14px;
  color: var(--text);
  outline: none;
  appearance: auto;
}

/* ── Card Typography Scale ─────────────────────────────────────────────────── */
.card-title  { font-size: 18px; font-weight: 600; color: var(--text); }
.card-normal { font-size: 16px; color: var(--text); }
.card-score  { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1; }
.card-small  { font-size: 12px; color: var(--text-secondary); }
.card-heading { font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

/* ── List Cards (Books home) ──────────────────────────────────────────────── */
.list-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Row wrapper for each list entry */
.list-card-row { position: relative; }

.list-card-main {
  display: flex;
  align-items: center;
}

.list-card-main .list-card {
  flex: 1;
  min-width: 0;
}

/* Drag handle — hidden until edit mode */
.drag-handle {
  display: none;
  width: 36px;
  align-self: stretch;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.drag-handle:active { cursor: grabbing; }

/* Edit controls row — hidden until edit mode */
.list-card-edit-row {
  display: none;
  gap: 8px;
  padding: 6px 0 0;
  justify-content: flex-end;
  margin-left: 36px;
}

/* Rename form indent */
.rename-form-wrap {
  padding-top: 6px;
  margin-left: 36px;
}

/* Edit mode overrides */
.list-cards[data-editing="true"] .drag-handle { display: flex; }
.list-cards[data-editing="true"] .list-card-edit-row { display: flex; }
.list-cards[data-editing="true"] .list-card { pointer-events: none; }
.list-cards[data-editing="true"] .list-card:active {
  transform: none;
  box-shadow: var(--shadow);
  background: var(--card);
}

/* Dragging state */
.list-card-row.dragging { z-index: 10; }
.list-card-row.dragging .list-card { box-shadow: var(--shadow-md); }

.list-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--accent);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.2s, background 0.2s, transform 0.2s;
}

.list-card:active { box-shadow: var(--shadow-md); background: var(--bg); transform: scale(0.98); transition: none; }

.list-card-body { flex: 1; min-width: 0; }
.list-card-name { font-size: 18px; font-weight: 600; color: var(--text); }
.list-card-count { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.list-card-actions { display: flex; gap: 4px; margin-left: 8px; }

/* ── Book Cards ───────────────────────────────────────────────────────────── */
.book-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book-card-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.book-card-menu {
  width: 48px;
}

.book-card-menu .menu-dropdown {
  top: calc(100% + 4px);
  right: 0;
}

.book-card-menu-btn {
  width: 48px;
  height: 28px;
  border-radius: 6px;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.book-card-menu-btn:active { background: var(--bg); }

.book-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--accent);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.2s, background 0.2s, transform 0.2s;
}

.book-card:active { box-shadow: var(--shadow-md); background: var(--bg); transform: scale(0.98); transition: none; }

.book-card-cover {
  width: 48px;
  height: 68px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--separator);
}

.book-card-cover-placeholder {
  width: 48px;
  height: 68px;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--separator);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--separator);
}

.book-card-body { flex: 1; min-width: 0; }
.book-card-title { margin-bottom: 2px; word-break: break-word; }
.book-card-author { margin-bottom: 4px; }
.book-card-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }

/* ── Book Detail ──────────────────────────────────────────────────────────── */
.detail-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.detail-cover-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.detail-cover {
  width: 80px;
  height: 114px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--separator);
}

.detail-cover-placeholder {
  width: 80px;
  height: 114px;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--separator);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--separator);
}

.detail-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  word-break: break-word;
}

.detail-author {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.detail-label {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 90px;
  flex-shrink: 0;
}

.detail-value {
  font-size: 16px;
  color: var(--text);
  flex: 1;
}

.detail-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--separator);
}

.detail-rating-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--separator);
}

.detail-rating-stars {
  display: flex;
  gap: 3px;
}

.star-display {
  color: #FFB800;
  font-size: 18px;
  line-height: 1;
}

.star-display--empty {
  color: var(--separator);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

/* ── Reading Cards ────────────────────────────────────────────────────────── */
.reading-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reading-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--accent);
  padding: 16px;
}

.reading-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.reading-stars {
  display: flex;
  gap: 2px;
}

.reading-notes {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  margin-top: 8px;
}

.reading-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-btn);
  font-size: 16px;
  font-weight: 600;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.btn:active { opacity: 0.8; transform: scale(0.98); }

.btn-primary { background: var(--text); color: #fff; }
.btn-secondary { background: var(--separator); color: var(--text); }
.btn-destructive { background: var(--separator); color: var(--text); }
.btn-ghost {
  background: none;
  color: var(--text);
  padding: 0 8px;
  min-height: 36px;
}
.btn-sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 14px;
  border-radius: 8px;
}
.btn-sm-destructive {
  min-height: 36px;
  padding: 0 14px;
  font-size: 14px;
  border-radius: 8px;
  background: none;
  color: var(--destructive);
  border: 1px solid var(--destructive);
}
.btn-sm-destructive:active { background: #FFE5E3; }

.btn-full { width: 100%; }

.btn-group {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
  overflow: hidden;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--separator);
  border-radius: var(--radius-input);
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus { border-color: var(--accent); background: #fff; }

textarea.form-input {
  height: auto;
  min-height: 100px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.5;
}

select.form-input {
  appearance: auto;
  -webkit-appearance: auto;
}

/* ── OL Search ────────────────────────────────────────────────────────────── */
.ol-search-section {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.ol-search-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.ol-results {
  margin-top: 8px;
  border-radius: var(--radius-input);
  overflow: hidden;
  border: 1px solid var(--separator);
}

.ol-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--separator);
  width: 100%;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}

.ol-result-item:last-child { border-bottom: none; }
.ol-result-item:hover { background: var(--bg); }
.ol-result-item:active { background: var(--separator); }

.ol-result-thumb {
  width: 36px;
  height: 50px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--separator);
}

.ol-result-thumb-placeholder {
  width: 36px;
  height: 50px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--separator);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--separator);
  font-size: 18px;
}

.ol-result-body { flex: 1; min-width: 0; }
.ol-result-title { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ol-result-sub { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }

.ol-loading {
  text-align: center;
  padding: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.ol-no-results {
  padding: 12px;
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
}

/* Cover preview in form */
.cover-preview-wrap {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.cover-preview-img {
  width: 60px;
  height: 85px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--separator);
}

.cover-preview-status {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Star Rating ──────────────────────────────────────────────────────────── */
.star-rating {
  display: flex;
  gap: 4px;
}

.star-btn {
  background: none;
  border: none;
  padding: 4px 2px;
  cursor: pointer;
  color: var(--separator);
  transition: color 0.1s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  line-height: 0;
}

.star-btn.filled {
  color: #FFB800;
}

.star-btn.filled svg polygon {
  fill: currentColor;
}

.star-btn:active { transform: scale(0.88); }

/* ── Confirm dialog ───────────────────────────────────────────────────────── */
.confirm-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 600;
  display: flex;
  align-items: flex-end;
}

.confirm-dialog-sheet {
  background: var(--card);
  width: 100%;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.confirm-dialog-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  margin-bottom: 4px;
}

/* ── Menu dropdown ────────────────────────────────────────────────────────── */
.menu-wrapper { position: relative; }

.menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 52px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 200;
  overflow: hidden;
  border: 1px solid var(--separator);
}

.menu-dropdown.open { display: block; }

.menu-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: none;
  border-bottom: 1px solid var(--separator);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.menu-item:last-child { border-bottom: none; }
.menu-item-destructive { color: var(--destructive); }
.menu-item:active { background: var(--bg); }

.menu-item--checkable {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.menu-item-check {
  flex-shrink: 0;
  color: var(--accent);
  visibility: hidden;
}

.menu-item--active .menu-item-check { visibility: visible; }

.menu-section-label {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg);
  border-bottom: 1px solid var(--separator);
}

.menu-divider {
  height: 1px;
  background: var(--separator);
}

.list-view-options .menu-dropdown {
  top: calc(100% + 4px);
  min-width: 180px;
}

/* ── Book group headers ───────────────────────────────────────────────────── */
.book-group-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 16px 4px 6px;
}

.book-group-header--first { padding-top: 0; }

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}

.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 16px; font-weight: 500; margin-bottom: 4px; color: var(--text); }
.empty-state-sub { font-size: 14px; }

.result-count {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 0 4px;
  margin-bottom: 4px;
}

.load-more-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  background: none;
  border: 1.5px solid var(--separator);
  border-radius: var(--radius-card);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}
.load-more-btn:active { opacity: 0.7; }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo h1 {
  font-size: 36px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1px;
}

.login-logo p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── FAB ──────────────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 50%;
  transform: translateX(calc(50% - 16px));
  max-width: calc(var(--max-width) - 32px);
  width: calc(100% - 32px);
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  min-height: 52px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 90;
  text-decoration: none;
  cursor: pointer;
}

@media (min-width: 480px) {
  .fab {
    right: calc(50% - 240px + 16px);
    transform: none;
    width: calc(var(--max-width) - 32px);
  }
}

/* ── Move list inline form ────────────────────────────────────────────────── */
.move-form {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.move-form select { flex: 1; height: 44px; }

/* ── Inline list create form ──────────────────────────────────────────────── */
.create-list-form {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.create-list-form input { flex: 1; }

/* ── Rename inline form ───────────────────────────────────────────────────── */
.rename-form {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}

.rename-form input { flex: 1; height: 36px; font-size: 14px; }

/* ── Status Badge (book cards) ────────────────────────────────────────────── */
.book-status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.2px;
  line-height: 1.6;
}
.book-status-badge--reading { background: var(--accent-light); color: var(--accent); }
.book-status-badge--read { background: #D1F5DC; color: #1A6B31; }
.book-status-badge--abandoned { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--separator); }

/* ── Status Segmented Control (book detail) ───────────────────────────────── */
.status-section {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 20px;
}
.status-section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.segmented {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--separator);
  border-radius: var(--radius-input);
  padding: 3px;
  gap: 3px;
}
.segmented input[type="radio"] { display: none; }
.segmented label {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.segmented input[type="radio"]:checked + label {
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* ── HTMX loading indicator ───────────────────────────────────────────────── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

/* ── Tag chips ────────────────────────────────────────────────────────────── */
.tag-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  padding: 4px 0;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--separator);
  color: var(--text-secondary);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.tag-chip.selected {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.tag-chip--display {
  cursor: default;
}

.tag-chip:active:not(.tag-chip--display) {
  opacity: 0.75;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.tag-add-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.tag-add-row .form-input {
  flex: 1;
}

/* ── Tag management page ─────────────────────────────────────────────────── */
.tag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--separator);
}

.tag-row:last-child { border-bottom: none; }

.tag-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tag-row-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.text-muted { color: var(--text-secondary); font-size: 14px; }
.divider { height: 1px; background: var(--separator); margin: 16px 0; }
.stats-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
