/*
 * "Paperback" — warm, literary design language.
 * Palette, radii, shadows and motion follow Readwise's cream-and-cocoa system;
 * accept and error colours are Radix Colors grass and tomato steps.
 */

:root {
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Surfaces & ink */
  --paper: #fdf7ef;
  --band: #f9f0e0;
  --card: #fffdf9;
  --card-alt: #f5ecdf;
  --ink: #2c2418;
  --ink-strong: #1a1308;
  --muted: #6b5e4a;
  --soft: #9b8d75;
  --hairline: #e5d9c4;
  --input-border: #d4c4a8;

  /* Accent */
  --accent: #c94a17;
  --accent-fill: #c94a17;
  --accent-fill-hover: #ad3c0f;
  --on-accent: #ffffff;
  --accent-soft: #ffe4d4;
  --focus: #ff7a45;

  /* Radix grass / tomato (steps 3, 11) */
  --accept-soft: #e9f6e9;
  --accept: #2a7e3b;
  --on-state: #ffffff;
  --danger-soft: #feebe7;
  --danger: #d13415;
  --wild: #9a6d0c;

  /* Wheel */
  --wheel-rim: #2c2418;
  --wheel-peg: #f5ecdf;
  --wheel-hub: #fffdf9;
  --wheel-empty: #f5ecdf;
  --wheel-shadow: rgba(60, 40, 15, 0.28);
  --plank: #d9c3a0;
  --plank-edge: #b89b70;

  /* Radii */
  --r-sm: 6px;
  --r-input: 8px;
  --r-lg: 14px;
  --r-card: 16px;
  --r-pill: 9999px;

  /* Warm, cocoa-tinted shadows */
  --shadow-ambient: 0 1px 2px rgba(60, 40, 15, 0.05);
  --shadow-card: 0 1px 2px rgba(60, 40, 15, 0.04), 0 4px 12px rgba(60, 40, 15, 0.05);
  --shadow-hover: 0 10px 24px rgba(60, 40, 15, 0.1);
  --shadow-book: 18px 24px 40px rgba(60, 40, 15, 0.28);
  --shadow-modal: 0 24px 60px rgba(60, 40, 15, 0.18);

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-warm: cubic-bezier(0.32, 0.72, 0, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1a1510;
    --band: #211b15;
    --card: #231d16;
    --card-alt: #2b241b;
    --ink: #f3ead9;
    --ink-strong: #fff8ec;
    --muted: #b7a88f;
    --soft: #8a7c66;
    --hairline: #3a3126;
    --input-border: #4a3f31;

    --accent: #ff8a5c;
    --accent-fill: #ff7a45;
    --accent-fill-hover: #ff9466;
    --on-accent: #1a1308;
    --accent-soft: #3d2519;
    --focus: #ff8a5c;

    --accept-soft: #1b2a1e;
    --accept: #71d083;
    --on-state: #1a1308;
    --danger-soft: #391714;
    --danger: #ff977d;
    --wild: #f2c14e;

    --wheel-rim: #120e0a;
    --wheel-peg: #f3ead9;
    --wheel-hub: #2b241b;
    --wheel-empty: #2b241b;
    --wheel-shadow: rgba(0, 0, 0, 0.5);
    --plank: #5a4630;
    --plank-edge: #3d2f20;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-hover: 0 10px 24px rgba(0, 0, 0, 0.35);
    --shadow-book: 18px 24px 40px rgba(0, 0, 0, 0.55);
    --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.5);

    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 480px at 50% -160px, var(--band), transparent 70%),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--ink-strong);
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "SOFT" 50;
  letter-spacing: -0.012em;
  line-height: 1.15;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.icon {
  flex-shrink: 0;
}

.muted {
  color: var(--muted);
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Masthead ---------- */

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 24px 8px;
}

.wordmark {
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.022em;
  font-variation-settings: "SOFT" 50, "opsz" 144;
}

.tagline {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
}

.tagline em {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 16px;
}

.whoami {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.member-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.member {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 4px 4px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  background: var(--card);
  cursor: pointer;
  font-weight: 500;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease), transform 150ms var(--ease);
}

.member:hover {
  border-color: var(--input-border);
  transform: translateY(-1px);
}

.member[aria-pressed="true"] {
  border-color: var(--member-color);
  box-shadow: 0 0 0 2px var(--member-color);
  font-weight: 600;
}

/* ---------- Avatars ---------- */

.avatar {
  --size: 28px;
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--member-color, var(--soft));
  color: #fff8ec;
  font-size: calc(var(--size) * 0.42);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
}

.avatar.sm {
  --size: 20px;
}

.avatar.lg {
  --size: 32px;
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  gap: 24px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 24px 24px;
  grid-template-columns: minmax(250px, 1fr) minmax(360px, 1.3fr) minmax(290px, 1fr);
  /* Book talk sits under "Now reading", using the space beside the taller wheel. */
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "hero wheel suggest"
    "chat wheel suggest"
    "shelf shelf shelf";
  align-items: start;
}

.hero { grid-area: hero; }
.chat { grid-area: chat; }
.wheel-card { grid-area: wheel; }
.suggest { grid-area: suggest; }
.shelf-card { grid-area: shelf; }

.card {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  background: var(--card);
  box-shadow: var(--shadow-card);
}

.card h2 {
  font-size: 22px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ---------- Covers ---------- */

.cover {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 2px 4px 4px 2px;
  background: var(--card-alt);
}

.cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8%;
  overflow: hidden;
  text-align: center;
  font-family: var(--font-display);
  line-height: 1.15;
  color: #fff8ec;
  background: linear-gradient(160deg, #c95a1c, #7a3210);
  container-type: inline-size;
}

.cover-placeholder span {
  font-size: max(7px, 13cqi);
  overflow-wrap: anywhere;
}

/* Too small to read a title; a plain coloured cover looks better. */
.thumb.cover-placeholder span {
  display: none;
}

.thumb {
  width: 40px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(60, 40, 15, 0.25);
}

/* ---------- Now reading ---------- */

.hero {
  background: var(--card-alt);
}

.current-book {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  margin-top: 16px;
}

/* A paperback seen at an angle: spine shading and stacked page edges. */
.book {
  position: relative;
  width: min(190px, 70%);
  transform: perspective(900px) rotateY(-14deg);
  transform-origin: left center;
  transition: transform 380ms var(--ease-warm);
  box-shadow:
    1px 1px 0 #fffaf0, 2px 2px 0 #d9ccb4,
    3px 3px 0 #fffaf0, 4px 4px 0 #d9ccb4,
    5px 5px 0 #fffaf0, 6px 6px 0 #cdbfa5,
    var(--shadow-book);
  border-radius: 2px 4px 4px 2px;
}

.book:hover {
  transform: perspective(900px) rotateY(-4deg);
}

.book::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.3) 0, rgba(255, 255, 255, 0.2) 2.5%, rgba(0, 0, 0, 0.1) 5%, transparent 11%);
  pointer-events: none;
}

.current-book.fresh .book {
  animation: arrive 900ms var(--ease-warm);
}

@keyframes arrive {
  from { opacity: 0; transform: perspective(900px) rotateY(-70deg) translateY(12px); }
  to { opacity: 1; transform: perspective(900px) rotateY(-14deg); }
}

.current-details {
  width: 100%;
  text-align: center;
}

.current-title {
  font-size: 28px;
  letter-spacing: -0.02em;
  font-variation-settings: "SOFT" 50, "opsz" 72;
}

.current-author {
  margin-top: 6px;
  color: var(--muted);
  font-size: 16px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 3px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
}

.chip.plain {
  padding-left: 10px;
}

.ol-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 500;
}

/* ---------- Reading schedule ruler ---------- */

.tracker:not(:empty) {
  width: 100%;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
}

.tracker-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.tracker-summary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.tracker-summary strong {
  color: var(--ink-strong);
  font-weight: 600;
}

.tracker-cta {
  margin-top: 10px;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.link-btn:hover:not(:disabled) {
  text-decoration: underline;
}

.link-btn:disabled {
  color: var(--soft);
  cursor: not-allowed;
}

.ruler {
  margin-top: 12px;
  user-select: none;
  touch-action: pan-y; /* horizontal drags move your tick; vertical swipes still scroll */
}

.ruler.can-mark {
  cursor: pointer;
}

.ruler.dragging {
  cursor: grabbing;
}

/* Side padding so avatars at 0% and 100% don't hang off the card. */
.ruler-inner {
  position: relative;
  margin: 0 14px;
}

.ruler-labels {
  display: grid;
  margin-bottom: 8px;
  color: var(--soft);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.ruler-labels .current {
  color: var(--accent);
}

.ruler-track {
  position: relative;
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--hairline);
}

.ruler-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent-fill));
  opacity: 0.55;
}

.ruler-divider {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--card-alt);
}

/* Where the club should be today: a pin on the track. */
.ruler-today {
  position: absolute;
  top: -7px;
  bottom: -7px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--ink-strong);
}

.ruler-today::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  border: 5px solid transparent;
  border-top-color: var(--ink-strong);
  transform: translateX(-50%);
}

.ruler-dates {
  position: relative;
  height: 16px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}

.ruler-dates span {
  position: absolute;
  transform: translateX(-50%);
}

.ruler-dates .first {
  transform: none;
}

.ruler-dates .last {
  transform: translateX(-100%);
}

.ruler-members {
  position: relative;
  height: calc(var(--lanes) * 32px + 6px);
  margin-top: 6px;
}

.tick {
  position: absolute;
  top: calc(var(--lane) * 32px + 6px);
  transform: translateX(-50%);
  transition: left 240ms var(--ease-warm);
}

/* A little pointer on top of each avatar marks its exact spot. */
.tick::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  border: 4px solid transparent;
  border-bottom-color: var(--soft);
  transform: translateX(-50%);
}

.tick .avatar {
  --size: 26px;
  box-shadow: 0 0 0 2px var(--card-alt);
}

.tick.mine {
  z-index: 1;
  cursor: grab;
}

.tick.mine::before {
  border-bottom-color: var(--ink-strong);
}

.tick.mine .avatar {
  box-shadow: 0 0 0 2px var(--card-alt), 0 0 0 4px var(--member-color);
}

.tick.ghost {
  opacity: 0.55;
}

.ruler.dragging .tick.mine {
  transition: none;
  cursor: grabbing;
}

.tick:focus-visible {
  outline: none;
}

.tick:focus-visible .avatar {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.tracker-hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Schedule editor ---------- */

.schedule-dialog[open] {
  width: min(520px, calc(100% - 32px));
}

.schedule-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--hairline);
}

.dialog-title h2 {
  margin-top: 2px;
  font-size: 22px;
}

.dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.dialog-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--hairline);
}

.dialog-foot .spacer {
  flex: 1;
}

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 500;
}

.schedule-form input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--r-input);
  background: var(--card);
  color: var(--ink);
}

.schedule-form input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.rows-head,
.schedule-rows li {
  display: grid;
  grid-template-columns: 22px 1fr 150px 30px;
  gap: 8px;
  align-items: center;
}

.rows-head {
  padding-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.rows-head span:first-child {
  grid-column: 2;
}

.schedule-rows li {
  margin-bottom: 6px;
}

.schedule-rows input {
  min-width: 0;
  width: 100%;
}

.row-num {
  color: var(--soft);
  font-size: 12px;
  text-align: right;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.btn-sm {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
}

.btn-danger {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-btn-sm {
  width: 30px;
  height: 30px;
}

.form-error {
  min-height: 1.4em;
  margin-top: 10px;
  color: var(--danger);
  font-size: 13px;
}

@media (max-width: 480px) {
  .rows-head,
  .schedule-rows li {
    grid-template-columns: 18px 1fr 128px 30px;
    gap: 6px;
  }
}

.empty {
  padding: 18px 8px;
  color: var(--muted);
  text-align: center;
}

/* ---------- Wheel ---------- */

.wheel-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wheel-wrap {
  width: min(100%, 440px);
}

#wheel {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  touch-action: pan-y;
}

#wheel.is-grabbable {
  cursor: grab;
  touch-action: none;
}

#wheel.is-dragging {
  cursor: grabbing;
}

.wildcard-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.wildcard-row[hidden] {
  display: none;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px 0 8px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 150ms var(--ease), color 150ms var(--ease);
}

.switch:hover:not(:disabled) {
  border-color: var(--input-border);
  color: var(--ink);
}

.switch:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.switch-track {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: var(--r-pill);
  background: var(--hairline);
  transition: background-color 240ms var(--ease);
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 1px 2px rgba(60, 40, 15, 0.3);
  transition: transform 240ms var(--ease-warm);
}

.switch[aria-checked="true"] {
  color: var(--ink);
}

.switch[aria-checked="true"] .switch-track {
  background: #1f1810;
  box-shadow: inset 0 0 0 1px #f2c14e;
}

.switch[aria-checked="true"] .switch-thumb {
  background: #f2c14e;
  transform: translateX(12px);
}

.result-desc {
  display: -webkit-box;
  margin-top: 8px;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.result-desc[hidden] {
  display: none;
}

.eyebrow.wild {
  color: var(--wild);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms var(--ease), border-color 150ms var(--ease);
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--input-border);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  background: var(--card);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms var(--ease), transform 150ms var(--ease), box-shadow 150ms var(--ease);
}

.btn-primary {
  border-color: transparent;
  background: var(--accent-fill);
  color: var(--on-accent);
  box-shadow: 0 2px 8px rgba(201, 74, 23, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-fill-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(201, 74, 23, 0.3);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-lg {
  height: 48px;
  padding: 0 32px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
}

.spin-btn,
#spin-btn {
  margin-top: 20px;
}

.hint {
  min-height: 1.5em;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ---------- Result reveal + voting ---------- */

.result {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 20px;
  width: 100%;
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  background: var(--card-alt);
  animation: rise 380ms var(--ease-warm);
}

.result[hidden] {
  display: none;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.result-cover .cover {
  box-shadow: 6px 10px 20px rgba(60, 40, 15, 0.25);
  transform-origin: left center;
  animation: flip-in 700ms var(--ease-warm) both;
}

@keyframes flip-in {
  from { opacity: 0; transform: perspective(800px) rotateY(-80deg); }
  to { opacity: 1; transform: perspective(800px) rotateY(0); }
}

.result-body {
  min-width: 0;
}

.result-title {
  margin: 4px 0 4px;
  font-size: 22px;
}

.vote-group {
  display: inline-flex;
  gap: 4px;
  margin: 14px 0 14px;
  padding: 4px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  background: var(--card);
}

.vote {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}

.vote:hover:not(:disabled) {
  background: var(--band);
}

.vote:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.vote.accept.chosen {
  background: var(--accept);
  color: var(--on-state);
}

.meter {
  display: flex;
  gap: 4px;
  max-width: 220px;
  margin-bottom: 12px;
}

.meter span {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--hairline);
  transition: background-color 240ms var(--ease);
}

.meter span.on {
  background: var(--accept);
}

.voters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 10px;
}

.voter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.voter.waiting .avatar {
  opacity: 0.35;
}

.voter.me {
  color: var(--ink);
  font-weight: 600;
}

.badge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 2px solid var(--card-alt);
  border-radius: 50%;
  color: var(--on-state);
}

.badge.accept { background: var(--accept); }

/* ---------- Suggest ---------- */

.suggest h2 {
  margin-bottom: 16px;
}

.search {
  position: relative;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 13px;
  display: flex;
  color: var(--soft);
  transform: translateY(-50%);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 40px;
  border: 1px solid var(--input-border);
  border-radius: var(--r-input);
  background: var(--card);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}

.search input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  width: max(100%, 320px);
  max-height: 400px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow-modal);
}

.search-results li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--r-input);
  cursor: pointer;
}

.search-results li.active {
  background: var(--accent-soft);
}

.search-results li.taken {
  cursor: default;
  opacity: 0.5;
}

.search-results li.status {
  padding: 12px;
  color: var(--muted);
  cursor: default;
}

.row-text {
  min-width: 0;
  flex: 1;
}

.row-text strong {
  display: block;
  overflow: hidden;
  color: var(--ink-strong);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-text span {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.row-text .truncate {
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggest-as {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.suggest-as select {
  padding: 4px 8px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.list-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 24px 0 8px;
  font-size: 17px;
}

.count {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
}

.book-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--hairline);
}

.book-list li:first-child {
  border-top: 0;
}

.book-list li.empty {
  display: block;
}

.book-list .avatar {
  --size: 26px;
}

.pending-tag {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.remove-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--soft);
  cursor: pointer;
}

.remove-btn:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

.remove-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---------- The shelf ---------- */

.shelf-card .card-head {
  justify-content: flex-start;
  align-items: baseline;
}

/* Covers stand on a plank drawn behind the row; `local` keeps it under every book when scrolled. */
.shelf {
  --cover-h: 150px;
  display: flex;
  gap: 28px;
  overflow-x: auto;
  padding: 4px 12px 8px;
  background:
    linear-gradient(var(--plank), var(--plank)) 0 calc(var(--cover-h) + 4px) / 100% 10px no-repeat local,
    linear-gradient(var(--plank-edge), var(--plank-edge)) 0 calc(var(--cover-h) + 14px) / 100% 3px no-repeat local,
    linear-gradient(rgba(60, 40, 15, 0.18), transparent) 0 calc(var(--cover-h) + 17px) / 100% 10px no-repeat local;
}

.shelf li {
  width: 100px;
  flex-shrink: 0;
}

.shelf .cover {
  height: var(--cover-h);
  box-shadow: 3px 0 6px rgba(60, 40, 15, 0.25);
  transition: transform 240ms var(--ease-warm);
}

.shelf li:hover .cover {
  transform: translateY(-6px);
}

.shelf-caption {
  margin-top: 26px;
}

.shelf-caption p:first-child {
  color: var(--ink-strong);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}

.shelf-caption .meta {
  margin-top: 2px;
  font-size: 12px;
}

.shelf li.empty {
  width: auto;
  flex: 1;
  padding-bottom: 36px;
}

/* ---------- Book talk ---------- */

.chat {
  display: flex;
  flex-direction: column;
}

.chat[hidden] {
  display: none;
}

.chat-head {
  margin-bottom: 8px;
}

.chat-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-head .meta em {
  color: var(--ink);
  font-family: var(--font-display);
}

.unread {
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--accent-fill);
  color: var(--on-accent);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.unread[hidden] {
  display: none;
}

.chat-list {
  display: flex;
  flex-direction: column;
  min-height: 96px;
  max-height: 440px;
  margin: 0 -10px;
  padding: 4px 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-empty {
  margin: auto 0;
  padding: 20px 8px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.msg {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  column-gap: 10px;
  align-items: start;
  padding-top: 10px;
}

.msg.grouped {
  padding-top: 2px;
}

.avatar-spacer {
  width: 28px;
}

.msg-body {
  min-width: 0;
}

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.msg-head strong {
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 600;
}

.msg-head time {
  color: var(--soft);
  font-size: 12px;
}

.msg-text {
  margin-top: 1px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.spoiler-wrap {
  position: relative;
  margin-top: 2px;
  border-radius: var(--r-sm);
  background: var(--band);
}

.msg-text.blurred {
  padding: 2px 6px;
  filter: blur(5px);
  user-select: none;
}

.spoiler-btn {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.spoiler-btn span {
  padding: 2px 10px;
  border-radius: var(--r-pill);
  background: var(--card);
  box-shadow: var(--shadow-ambient);
}

.msg-delete {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--soft);
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms var(--ease);
}

.msg:hover .msg-delete,
.msg-delete:focus-visible {
  opacity: 1;
}

.msg-delete:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

@media (hover: none) {
  .msg-delete {
    opacity: 0.6;
  }
}

.composer {
  margin-top: 12px;
  padding: 8px 8px 8px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--r-lg);
  background: var(--card);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}

.composer:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer textarea {
  display: block;
  width: 100%;
  max-height: 180px;
  padding: 4px 0;
  border: 0;
  outline: none;
  background: transparent;
  line-height: 1.5;
  resize: none;
}

.composer textarea:disabled {
  cursor: not-allowed;
}

.composer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.spoiler-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.spoiler-toggle input {
  accent-color: var(--accent-fill);
}

.composer .btn {
  height: 34px;
  margin-left: auto;
  padding: 0 18px;
}

/* ---------- Book talk archive ---------- */

.shelf-book {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.shelf-talk {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.shelf-book:hover .shelf-talk {
  text-decoration: underline;
}

.archive {
  width: min(640px, calc(100% - 32px));
  max-height: min(82vh, 760px);
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-modal);
}

.archive[open] {
  display: flex;
  flex-direction: column;
  animation: rise 380ms var(--ease-warm);
}

.archive::backdrop {
  background: rgba(26, 19, 8, 0.45);
}

.archive-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--hairline);
}

.archive-cover .cover {
  width: 56px;
  box-shadow: 3px 4px 10px rgba(60, 40, 15, 0.25);
}

.archive-info {
  flex: 1;
  min-width: 0;
}

.archive-info h2 {
  margin: 2px 0 4px;
  font-size: 22px;
}

.archive-list {
  flex: 1;
  max-height: none;
  margin: 0;
  padding: 8px 20px 20px;
}

/* ---------- Footer, toast ---------- */

.footer {
  padding: 8px 24px 40px;
  color: var(--soft);
  font-size: 12px;
  text-align: center;
}

.footer a {
  color: inherit;
}

.toast {
  position: fixed;
  z-index: 50;
  bottom: 24px;
  left: 50%;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: var(--r-pill);
  background: var(--ink-strong);
  color: var(--paper);
  box-shadow: var(--shadow-modal);
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 240ms var(--ease), transform 380ms var(--ease-warm);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

/* ---------- Passcode gate ---------- */

.gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.gate[hidden] {
  display: none;
}

.gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(100%, 380px);
  padding: 36px 28px 28px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  background: var(--card);
  box-shadow: var(--shadow-modal);
  text-align: center;
}

.gate-card.shake {
  animation: shake 420ms var(--ease);
}

@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.gate-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.gate-card .wordmark {
  font-size: 32px;
}

.gate-card input {
  width: 100%;
  height: 44px;
  margin-top: 6px;
  padding: 0 14px;
  border: 1px solid var(--input-border);
  border-radius: var(--r-input);
  background: var(--card);
  text-align: center;
}

.gate-card input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.gate-error {
  min-height: 1.5em;
  color: var(--danger);
  font-size: 13px;
}

.app[hidden] {
  display: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: minmax(240px, 0.8fr) 1.2fr;
    grid-template-rows: auto 1fr auto auto;
    grid-template-areas:
      "hero wheel"
      "chat wheel"
      "suggest suggest"
      "shelf shelf";
  }
}

@media (max-width: 760px) {
  .masthead {
    align-items: flex-start;
    padding: 20px 16px 4px;
  }

  .wordmark {
    font-size: 32px;
  }

  .whoami {
    align-items: flex-start;
  }

  .member-picker {
    justify-content: flex-start;
  }

  .layout {
    gap: 16px;
    padding: 16px;
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas:
      "hero"
      "chat"
      "wheel"
      "suggest"
      "shelf";
  }

  .chat-list {
    max-height: 360px;
  }


  .card {
    padding: 18px;
  }

  .current-book {
    flex-direction: row;
    align-items: center;
    gap: 22px;
    margin-top: 12px;
  }

  .book {
    width: 108px;
    flex-shrink: 0;
  }

  .current-details {
    text-align: left;
  }

  .current-title {
    font-size: 22px;
  }

  .chips {
    justify-content: flex-start;
  }

  .result {
    grid-template-columns: 76px 1fr;
    gap: 14px;
    padding: 14px;
  }

  .vote {
    padding: 0 12px;
  }
}

@media (max-width: 420px) {
  .member {
    padding-right: 4px;
  }

  .member .member-name {
    display: none;
  }
}

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