/* AnonBookRec — library checkout-card aesthetic.
   System stacks only: the CSP forbids external fonts. */

:root {
  --paper: #f5f4ef;
  --card: #fbfaf6;
  --field: #ffffff;
  --ink: #22262b;
  --ink-soft: #5c6067;
  --rule: #d9d5c9;
  --cloth: #2e5e4e;   /* bookcloth green: primary actions */
  --cloth-dark: #234a3d;
  --stamp: #b3543f;   /* stamp red: destructive, warnings */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Owner-picked page colours ("simple user-specific styling").
   Light themes swap the accent; dark themes swap the whole palette.
   Note: --cloth is the primary-button fill, --cloth-dark doubles as its
   hover fill and as accent *text*, so dark themes give it a light value. */
body[data-theme="ink"] { --cloth: #31456e; --cloth-dark: #253552; }
body[data-theme="plum"] { --cloth: #5e2e52; --cloth-dark: #472340; }
body[data-theme="amber"] { --cloth: #8a5a19; --cloth-dark: #6d4713; }
body[data-theme="night"] {
  --paper: #1c1e21; --card: #25282c; --field: #2d3136;
  --ink: #e8e6e1; --ink-soft: #a0a49e; --rule: #3a3e43;
  --cloth: #3f7a5e; --cloth-dark: #82c0a0; --stamp: #d07a63;
}
body[data-theme="midnight"] {
  --paper: #141927; --card: #1c2333; --field: #232c40;
  --ink: #e4e8f2; --ink-soft: #9aa3b8; --rule: #303a52;
  --cloth: #3d5a99; --cloth-dark: #92abe0; --stamp: #d07a63;
}
body[data-theme="noir"] {
  --paper: #121212; --card: #1b1b1b; --field: #242424;
  --ink: #eae6df; --ink-soft: #9c968c; --rule: #333333;
  --cloth: #8a5a19; --cloth-dark: #d0a44c; --stamp: #c4614a;
}
body[data-theme="garnet"] {
  --paper: #1d1418; --card: #271b20; --field: #302228;
  --ink: #efe6e9; --ink-soft: #ab9aa1; --rule: #40303a;
  --cloth: #8a3a4d; --cloth-dark: #d693a2; --stamp: #d0a44c;
}

/* Animated themes: palette + a fixed, pointer-transparent decor layer behind
   the content. Pure CSS (the CSP allows no external assets); motion is slow
   and ambient, and switches off under prefers-reduced-motion. */
body[data-theme="forest"] {
  --paper: #17211a; --card: #1f2c23; --field: #273529;
  --ink: #e6ede5; --ink-soft: #9fb2a2; --rule: #35443a;
  --cloth: #4d8a5f; --cloth-dark: #8cc79d; --stamp: #cf7f56;
}
body[data-theme="cosmos"] {
  --paper: #0b0e1a; --card: #151a30; --field: #1c2140;
  --ink: #e6e9f7; --ink-soft: #98a0c2; --rule: #262c50;
  --cloth: #4f46a0; --cloth-dark: #a29be8; --stamp: #d07a63;
}
body[data-theme="prism"] {
  --paper: #f4f5f7; --card: #fdfdfe; --field: #ffffff;
  --ink: #23262d; --ink-soft: #6a6f7a; --rule: #dcdfe6;
  --cloth: #3b4dbb; --cloth-dark: #2e3c94; --stamp: #b3543f;
}

body[data-theme="forest"]::before,
body[data-theme="cosmos"]::before,
body[data-theme="cosmos"]::after,
body[data-theme="prism"]::before {
  content: "";
  position: fixed;
  inset: -5%;
  z-index: -1;
  pointer-events: none;
}

/* Forest: sunlight drifting through a canopy */
body[data-theme="forest"]::before {
  background:
    radial-gradient(42rem 30rem at 18% 8%, rgba(140, 199, 157, 0.16), transparent 60%),
    radial-gradient(52rem 36rem at 82% 28%, rgba(77, 138, 95, 0.14), transparent 65%),
    radial-gradient(38rem 30rem at 45% 95%, rgba(196, 179, 92, 0.08), transparent 60%);
  animation: canopy-drift 36s ease-in-out infinite alternate;
}
@keyframes canopy-drift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1.02); opacity: 0.85; }
  50% { opacity: 1; }
  to { transform: translate3d(1.5%, 1.2%, 0) scale(1.07); opacity: 0.9; }
}

/* Cosmos: nebula wash + two twinkling star layers */
body[data-theme="cosmos"]::before {
  background:
    radial-gradient(45rem 32rem at 75% 15%, rgba(103, 76, 180, 0.22), transparent 65%),
    radial-gradient(38rem 30rem at 15% 75%, rgba(52, 89, 166, 0.18), transparent 60%),
    radial-gradient(30rem 24rem at 50% 45%, rgba(166, 84, 122, 0.10), transparent 60%);
  animation: nebula-drift 48s ease-in-out infinite alternate;
}
@keyframes nebula-drift {
  from { transform: translate3d(-2%, -1%, 0) rotate(-0.5deg); }
  to { transform: translate3d(2%, 1.5%, 0) rotate(0.5deg); }
}
body[data-theme="cosmos"]::after {
  width: 2px;
  height: 2px;
  inset: auto;
  top: 0;
  left: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow:
    3vw 12vh 0 0 #fff, 9vw 78vh 0 1px #cdd3ff, 14vw 34vh 0 0 #fff,
    18vw 88vh 0 0 #aeb6ff, 22vw 8vh 0 1px #fff, 27vw 55vh 0 0 #e8ebff,
    31vw 28vh 0 0 #fff, 36vw 70vh 0 1px #cdd3ff, 41vw 15vh 0 0 #fff,
    45vw 92vh 0 0 #aeb6ff, 49vw 42vh 0 1px #fff, 54vw 63vh 0 0 #e8ebff,
    58vw 20vh 0 0 #fff, 63vw 81vh 0 0 #cdd3ff, 67vw 36vh 0 1px #fff,
    71vw 5vh 0 0 #aeb6ff, 76vw 59vh 0 0 #fff, 80vw 26vh 0 1px #e8ebff,
    85vw 74vh 0 0 #fff, 89vw 46vh 0 0 #cdd3ff, 93vw 11vh 0 1px #fff,
    97vw 66vh 0 0 #aeb6ff, 6vw 50vh 0 0 #e8ebff, 33vw 96vh 0 0 #fff,
    52vw 3vh 0 0 #cdd3ff, 69vw 90vh 0 1px #fff, 88vw 84vh 0 0 #e8ebff,
    12vw 64vh 0 0 #fff, 79vw 40vh 0 0 #aeb6ff, 24vw 72vh 0 1px #fff;
  animation: twinkle 5s ease-in-out infinite alternate;
}
@keyframes twinkle {
  from { opacity: 0.35; }
  45% { opacity: 0.9; }
  60% { opacity: 0.55; }
  to { opacity: 1; }
}

/* Prism: a faint geometric lattice, panning very slowly */
body[data-theme="prism"]::before {
  background:
    repeating-linear-gradient(60deg,
      rgba(59, 77, 187, 0.05) 0 2px, transparent 2px 26px),
    repeating-linear-gradient(-60deg,
      rgba(59, 77, 187, 0.05) 0 2px, transparent 2px 26px),
    repeating-linear-gradient(0deg,
      rgba(179, 84, 63, 0.03) 0 2px, transparent 2px 26px);
  animation: lattice-pan 60s linear infinite;
}
@keyframes lattice-pan {
  from { background-position: 0 0, 0 0, 0 0; }
  to { background-position: 52px 90px, -52px 90px, 0 -52px; }
}

/* Manuscript: vellum, oxblood, and gold leaf — a static material theme */
body[data-theme="manuscript"] {
  --paper: #ede3cc; --card: #f6eeda; --field: #fbf6e8;
  --ink: #372c1f; --ink-soft: #7a6a52; --rule: #d6c8a6;
  --cloth: #7c2f2f; --cloth-dark: #5e2222; --stamp: #a8842c;
}

/* Blueprint: drafting paper, white ink on deep blue — static */
body[data-theme="blueprint"] {
  --paper: #14294a; --card: #1b3459; --field: #224069;
  --ink: #e8eefc; --ink-soft: #9fb4d8; --rule: #2e4a77;
  --cloth: #2f6fc4; --cloth-dark: #9cc0f0; --stamp: #d07a63;
}
body[data-theme="blueprint"]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(232, 238, 252, 0.05) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(232, 238, 252, 0.05) 0 1px, transparent 1px 28px);
}

body[data-theme="ocean"] {
  --paper: #0c1b24; --card: #12242f; --field: #18303d;
  --ink: #e2eef2; --ink-soft: #8fa9b4; --rule: #24404d;
  --cloth: #1f7a8c; --cloth-dark: #7cc6d6; --stamp: #d0845c;
}
body[data-theme="ember"] {
  --paper: #1c1512; --card: #261d18; --field: #30251f;
  --ink: #f0e7e0; --ink-soft: #ab9a8d; --rule: #41332b;
  --cloth: #9c4a26; --cloth-dark: #e0916a; --stamp: #d0a44c;
}
body[data-theme="sakura"] {
  --paper: #faf2f3; --card: #fefbfb; --field: #ffffff;
  --ink: #33272b; --ink-soft: #7d6a70; --rule: #e8d5da;
  --cloth: #b0526d; --cloth-dark: #8c3e55; --stamp: #b3543f;
}
body[data-theme="aurora"] {
  --paper: #0d1615; --card: #142020; --field: #1a2b2a;
  --ink: #e2f0ea; --ink-soft: #92aca2; --rule: #263c38;
  --cloth: #2e7d64; --cloth-dark: #7fd4b4; --stamp: #cf7f56;
}

body[data-theme="ocean"]::before,
body[data-theme="ocean"]::after,
body[data-theme="ember"]::before,
body[data-theme="ember"]::after,
body[data-theme="sakura"]::before,
body[data-theme="sakura"]::after,
body[data-theme="aurora"]::before {
  content: "";
  position: fixed;
  inset: -5%;
  z-index: -1;
  pointer-events: none;
}

/* Ocean: a slow swell of light from above, bubbles rising */
body[data-theme="ocean"]::before {
  background:
    radial-gradient(60rem 30rem at 50% -10%, rgba(124, 198, 214, 0.14), transparent 65%),
    radial-gradient(40rem 30rem at 20% 60%, rgba(31, 122, 140, 0.14), transparent 60%),
    radial-gradient(45rem 32rem at 85% 80%, rgba(38, 96, 130, 0.12), transparent 65%);
  animation: ocean-swell 26s ease-in-out infinite alternate;
}
@keyframes ocean-swell {
  from { transform: translate3d(0, -1.2%, 0) scale(1.03); }
  to { transform: translate3d(0, 1.2%, 0) scale(1.0); }
}
body[data-theme="ocean"]::after {
  width: 3px;
  height: 3px;
  inset: auto;
  top: 108vh;
  left: 0;
  border-radius: 50%;
  opacity: 0.5;
  box-shadow:
    8vw -4vh 0 0 rgba(160, 215, 228, 0.5), 21vw -32vh 0 1px rgba(160, 215, 228, 0.35),
    33vw -12vh 0 0 rgba(160, 215, 228, 0.45), 46vw -48vh 0 0 rgba(160, 215, 228, 0.3),
    58vw -21vh 0 1px rgba(160, 215, 228, 0.45), 69vw -60vh 0 0 rgba(160, 215, 228, 0.3),
    78vw -8vh 0 0 rgba(160, 215, 228, 0.5), 88vw -38vh 0 1px rgba(160, 215, 228, 0.35),
    95vw -70vh 0 0 rgba(160, 215, 228, 0.3), 15vw -80vh 0 0 rgba(160, 215, 228, 0.25);
  animation: bubbles-rise 22s linear infinite;
}
@keyframes bubbles-rise {
  from { transform: translateY(0); }
  to { transform: translateY(-215vh); }
}

/* Ember: hearth glow breathing at the foot of the page, sparks drifting up */
body[data-theme="ember"]::before {
  background:
    radial-gradient(70rem 32rem at 50% 108%, rgba(224, 122, 58, 0.20), transparent 70%),
    radial-gradient(30rem 18rem at 22% 105%, rgba(208, 164, 76, 0.12), transparent 65%);
  animation: ember-breathe 7s ease-in-out infinite alternate;
}
@keyframes ember-breathe {
  from { opacity: 0.7; transform: scale(1.0); }
  to { opacity: 1; transform: scale(1.04); }
}
body[data-theme="ember"]::after {
  width: 2px;
  height: 2px;
  inset: auto;
  top: 105vh;
  left: 0;
  border-radius: 50%;
  box-shadow:
    18vw -2vh 0 0 rgba(240, 156, 90, 0.8), 42vw -14vh 0 0 rgba(224, 122, 58, 0.6),
    63vw -6vh 0 1px rgba(240, 156, 90, 0.7), 81vw -18vh 0 0 rgba(208, 164, 76, 0.6),
    30vw -26vh 0 0 rgba(224, 122, 58, 0.5), 74vw -32vh 0 0 rgba(240, 156, 90, 0.4);
  animation: sparks-drift 14s linear infinite;
}
@keyframes sparks-drift {
  from { transform: translateY(0) translateX(0); opacity: 1; }
  60% { opacity: 0.7; }
  to { transform: translateY(-120vh) translateX(3vw); opacity: 0; }
}

/* Sakura: blush wash, petals falling with a light sway */
body[data-theme="sakura"]::before {
  background:
    radial-gradient(45rem 30rem at 80% 5%, rgba(238, 176, 192, 0.20), transparent 60%),
    radial-gradient(40rem 30rem at 10% 70%, rgba(244, 198, 208, 0.16), transparent 60%);
}
body[data-theme="sakura"]::after {
  width: 4px;
  height: 4px;
  inset: auto;
  top: -12vh;
  left: 0;
  border-radius: 60% 40% 55% 45%;
  background: transparent;
  box-shadow:
    6vw 4vh 0 0 #f4c6d0, 17vw 42vh 0 1px #eeb0c0, 26vw 16vh 0 0 #f4c6d0,
    37vw 64vh 0 0 #e8a0b4, 48vw 30vh 0 1px #f4c6d0, 57vw 78vh 0 0 #eeb0c0,
    66vw 8vh 0 0 #f4c6d0, 75vw 52vh 0 1px #e8a0b4, 84vw 24vh 0 0 #eeb0c0,
    93vw 70vh 0 0 #f4c6d0, 12vw 88vh 0 0 #eeb0c0, 89vw 92vh 0 0 #e8a0b4;
  animation: petals-fall 30s linear infinite;
}
@keyframes petals-fall {
  0% { transform: translateY(0) translateX(0) rotate(0deg); }
  25% { transform: translateY(30vh) translateX(2vw) rotate(45deg); }
  50% { transform: translateY(60vh) translateX(-1vw) rotate(90deg); }
  75% { transform: translateY(90vh) translateX(2vw) rotate(135deg); }
  100% { transform: translateY(124vh) translateX(0) rotate(180deg); }
}

/* Aurora: curtains of polar light, slowly shifting hue */
body[data-theme="aurora"]::before {
  background:
    linear-gradient(115deg, transparent 30%, rgba(127, 212, 180, 0.14) 45%, transparent 62%),
    linear-gradient(100deg, transparent 40%, rgba(96, 164, 212, 0.12) 55%, transparent 72%),
    linear-gradient(130deg, transparent 25%, rgba(150, 120, 210, 0.08) 42%, transparent 58%),
    radial-gradient(50rem 30rem at 50% -15%, rgba(127, 212, 180, 0.10), transparent 65%);
  animation: aurora-sweep 24s ease-in-out infinite alternate;
}
@keyframes aurora-sweep {
  from { transform: translateX(-3%) skewX(-2deg); filter: hue-rotate(0deg); opacity: 0.8; }
  50% { opacity: 1; }
  to { transform: translateX(3%) skewX(2deg); filter: hue-rotate(40deg); opacity: 0.85; }
}

@media (prefers-reduced-motion: reduce) {
  body[data-theme]::before,
  body[data-theme]::after {
    animation: none !important;
  }
}

* { box-sizing: border-box; }

input, textarea {
  appearance: none;
  -webkit-appearance: none;
}

input[type="checkbox"] {
  appearance: none;
  background-color: var(--field);
  margin: 0;
  font: inherit;
  color: currentColor;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 3px;
  transform: translateY(-1px);
  display: grid;
  place-content: center;
}

input[type="checkbox"]::before {
  content: "";
  width: 10px;
  height: 10px;
  transform: scale(0);
  transition: 120ms transform ease-in-out;
}

input[type="checkbox"]:checked::before {
  background-color: var(--cloth);
  transform: scale(1);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

main { width: min(42rem, 100% - 2.5rem); margin: 0 auto; flex: 1; }

/* Header */
.site-header {
  width: min(42rem, 100% - 2.5rem);
  margin: 0 auto;
  padding: 1.4rem 0 0;
}
.wordmark {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.wordmark:hover { color: var(--cloth); }

/* Hero */
.hero { padding: 3.5rem 0 2.5rem; }
.hero.compact { padding: 2.5rem 0 1.5rem; }
.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.9rem, 5.5vw, 2.8rem);
  line-height: 1.15;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
}
.hero p { max-width: 34rem; color: var(--ink-soft); margin: 0 0 1.6rem; }
.returning { font-size: 0.9rem; margin-top: 1rem; }
.returning a { color: var(--cloth); }

/* Buttons */
.button {
  font: 600 0.95rem var(--sans);
  border: 1px solid var(--cloth-dark);
  border-radius: 3px;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  background: var(--card);
  color: var(--cloth-dark);
}
.button.primary { background: var(--cloth); color: #fff; }
.button.primary:hover { background: var(--cloth-dark); }
.button.small { padding: 0.25rem 0.7rem; font-size: 0.8rem; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button.danger { border-color: var(--stamp); color: var(--stamp); background: transparent; }
.button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--cloth);
  outline-offset: 2px;
}

/* The card: ruled list like a library checkout slip */
.shelf {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1.5rem 1.5rem 1.75rem;
  margin-bottom: 3rem;
  box-shadow: 0 1px 0 var(--rule);
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.5rem;
}
.card-head h2 {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}
.card-note {
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.recommend-form { display: flex; gap: 0.6rem; margin: 0.2rem 0; }
/* When the form sits above the list, give the list header breathing room */
.shelf .card-head:not(:first-child) { margin-top: 1.3rem; }
.recommend-form input {
  flex: 1;
  min-width: 0;
  font: 1rem var(--serif);
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--field);
  color: var(--ink);
}

/* Typeahead */
.search-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.search-wrap input { width: 100%; }
.suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 10;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: 0 4px 14px rgba(34, 38, 43, 0.12);
  max-height: 19rem;
  overflow-y: auto;
}
.suggestion {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.4rem 0.5rem;
  border-radius: 2px;
  cursor: pointer;
}
.suggestion:hover, .suggestion.active { background: color-mix(in srgb, var(--cloth) 14%, transparent); }
.suggestion-cover {
  width: 2rem;
  height: 2.9rem;
  object-fit: cover;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper);
  flex-shrink: 0;
}
.suggestion-text { display: flex; flex-direction: column; min-width: 0; }
.suggestion-title {
  font-family: var(--serif);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggestion-author { font-size: 0.78rem; color: var(--ink-soft); }

/* Confirmation card */
.confirm-card {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  border: 1px solid var(--cloth);
  border-radius: 4px;
  background: color-mix(in srgb, var(--cloth) 6%, transparent);
  padding: 0.8rem 1rem;
  margin-top: 0.8rem;
}
.confirm-card[hidden] { display: none; }
.confirm-cover {
  width: 3.4rem;
  height: 5rem;
  object-fit: cover;
  border: 1px solid var(--rule);
  border-radius: 2px;
  flex-shrink: 0;
}
.confirm-info { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.confirm-author { font-size: 0.85rem; color: var(--ink-soft); }
.confirm-actions {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

.status { min-height: 1.3rem; font-size: 0.88rem; color: var(--cloth-dark); margin: 0.4rem 0 0; }
.status.error { color: var(--stamp); }

.card-list { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.card-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  padding: 0.65rem 0.1rem;
  border-bottom: 1px solid var(--rule);
}
.rec-title { font-family: var(--serif); font-size: 1.08rem; }
.rec-title.read { color: var(--ink-soft); }
.rec-title.read::after { content: " ✓"; color: var(--cloth); }
.rec-author { font-size: 0.85rem; color: var(--ink-soft); font-style: italic; }
.rec-isbn { font: 0.72rem var(--mono); color: var(--ink-soft); letter-spacing: 0.03em; }
.rec-count {
  margin-left: auto;
  font: 600 0.8rem var(--mono);
  color: var(--cloth-dark);
  white-space: nowrap;
}
.rec-private {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--stamp);
  border: 1px solid var(--stamp);
  border-radius: 2px;
  padding: 0 0.3rem;
}
.rec-controls { display: flex; gap: 0.4rem; width: 100%; justify-content: flex-end; }
.rec-controls .button { font-weight: 500; }
.empty { color: var(--ink-soft); font-style: italic; margin: 1rem 0 0; }

.rec-note {
  width: 100%;
  margin: 0.15rem 0 0;
  padding: 0.1rem 0 0.1rem 0.7rem;
  border-left: 2px solid var(--rule);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.confirm-note {
  margin-top: 0.4rem;
  width: 100%;
  font: 0.85rem var(--sans);
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--field);
  color: var(--ink);
  resize: vertical;
}

/* Unlock (sign back in) — deliberately quiet, tucked under the card */
.unlock-panel {
  margin: -1.5rem 0 2rem;
  font-size: 0.82rem;
}
.unlock-panel summary {
  cursor: pointer;
  color: var(--ink-soft);
  font-style: italic;
  font-family: var(--serif);
  width: fit-content;
}
.unlock-panel summary:hover { color: var(--cloth-dark); }
.unlock-panel[open] {
  border: 1px dashed var(--rule);
  border-radius: 4px;
  padding: 0.7rem 1rem;
}
.unlock-row { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.unlock-row input {
  flex: 1;
  min-width: 0;
  font: 0.85rem var(--mono);
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--field);
  color: var(--ink);
}

/* Owner panel */
.owner-panel {
  border: 1px dashed var(--cloth);
  border-radius: 4px;
  padding: 0.9rem 1.2rem;
  margin-bottom: 1.5rem;
  background: color-mix(in srgb, var(--cloth) 6%, transparent);
  font-size: 0.9rem;
}
.owner-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; margin-bottom: 0.5rem; }
.owner-note { font-family: var(--serif); font-style: italic; }
.settings { margin-top: 0.4rem; }
.settings summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--cloth-dark);
}
.settings-field { margin: 0.7rem 0; }
.settings-field label {
  font-size: 0.8rem;
  color: var(--ink-soft);
  display: block;
  margin-bottom: 0.25rem;
}
.settings-field input, .settings-field textarea, .settings-field select {
  width: 100%;
  font: 0.9rem var(--sans);
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--field);
  color: var(--ink);
  resize: vertical;
}
.settings-profile {
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.2rem 0.8rem 0.6rem;
  margin: 0.8rem 0;
}
.settings-profile legend {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  padding: 0 0.3rem;
}
.settings-profile:disabled { opacity: 0.45; }
.owner-toggle { display: flex; gap: 0.5rem; align-items: center; cursor: pointer; margin-top: 0.7rem; }

/* Title row + settings gear */
.page-head { display: flex; align-items: flex-start; gap: 0.7rem; }
.page-head h1 { flex: 1; min-width: 0; }
.icon-button {
  background: none;
  border: none;
  padding: 0.4rem;
  margin-top: 0.5rem;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 4px;
  line-height: 0;
}
.icon-button:hover { color: var(--cloth-dark); background: color-mix(in srgb, var(--cloth) 10%, transparent); }

/* Settings popup */
.settings-dialog { width: min(26rem, 92vw); }
.dialog-head { display: flex; align-items: center; margin-bottom: 0.6rem; }
.dialog-head h2 { flex: 1; margin: 0; }
.dialog-head .icon-button { margin: 0; }
.settings-dialog .owner-toggle { margin-top: 1rem; }
.settings-dialog .owner-hint {
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin: 0.3rem 0 0 1.6rem;
}
.share-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.dialog-actions { display: flex; gap: 0.5rem; margin-top: 1.2rem; }
.dialog-actions #logout { margin-left: auto; }

.danger-zone {
  margin-top: 1.2rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
}
.danger-hint { margin: 0 0 0.6rem; color: var(--stamp); }

.share-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.qr-wrap { margin-top: 0.8rem; }
.qr-image {
  display: block;
  width: 240px;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: #fff;
}

/* Bio: quiet epigraph under the title */
.page-bio {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 34rem;
  margin: 0.1rem 0 1rem;
  padding-left: 0.9rem;
  border-left: 2px solid var(--cloth);
}

/* Favourite book: small bookplate chip */
.page-fav {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  margin: 0 0 0.6rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--card);
  box-shadow: 0 1px 0 var(--rule);
}
.page-fav[hidden] { display: none; }
.fav-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--cloth-dark);
  white-space: nowrap;
}
.fav-title { font-family: var(--serif); font-style: italic; font-size: 0.98rem; }
.owner-hint { color: var(--ink-soft); font-size: 0.8rem; margin: 0.3rem 0 0 1.6rem; }

/* Key dialog */
.key-dialog {
  width: min(30rem, 90vw);
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
  padding: 1.75rem;
}
.key-dialog::backdrop { background: rgba(34, 38, 43, 0.55); }
.key-dialog h2 { font-family: var(--serif); margin: 0 0 1rem; }
.key-label { font-size: 0.85rem; color: var(--ink-soft); margin: 0.9rem 0 0.3rem; }
.key-row { display: flex; gap: 0.5rem; align-items: center; }
.key-row code {
  flex: 1;
  font: 0.8rem var(--mono);
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.45rem 0.6rem;
  overflow-wrap: anywhere;
}
.key-warning {
  border-left: 3px solid var(--stamp);
  padding: 0.2rem 0 0.2rem 0.8rem;
  margin: 1.1rem 0;
  font-size: 0.85rem;
}
.key-warning p { margin: 0 0 0.6rem; }
.key-confirm {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  cursor: pointer;
}

.site-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.78rem;
  padding: 1.5rem 0;
  font-family: var(--serif);
  font-style: italic;
}

@media (max-width: 480px) {
  /* iOS zooms the page when focusing any control under 16px */
  input, textarea, select { font-size: 16px !important; }
  .recommend-form { flex-direction: column; }
  .confirm-info { flex: 1 1 100%; }
  .rec-count { margin-left: 0; }
  .confirm-card { flex-wrap: wrap; }
  .confirm-actions {
    margin-left: 0;
    flex-direction: row;
    width: 100%;
  }
  .confirm-actions .button { flex: 1; }
  .hero { padding: 2.2rem 0 1.8rem; }
  .shelf { padding: 1.1rem 1rem 1.3rem; }
  .key-dialog { padding: 1.2rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .card-list li { animation: settle 0.25s ease-out; }
  @keyframes settle {
    from { opacity: 0; transform: translateY(-3px); }
    to { opacity: 1; transform: none; }
  }
}
