/* Caitlin's Bookshop
   Layout concept: an independent bookshop. A painted oxblood shop sign with gold lettering up top,
   covers displayed face-out on wooden ledges, and the owner's opinions written on
   handwritten shelf-talker cards. Warm paper, ink, deep rose, oak. */

:root {
  --paper: #f8f2e9;        /* the shop's walls and pages */
  --paper-deep: #efe3d2;   /* kraft card */
  --card: #fffaf3;
  --ink: #2a1f1c;
  --ink-soft: #6b5953;
  --ink-faint: #9d8a82;
  --rose: #a9506c;         /* the signature: a dusty, grown-up rose, used sparingly */
  --rose-ink: #8a3552;
  --rose-wash: #f2e1e3;
  --fascia: #3a1c22;       /* oxblood shop sign */
  --fascia-edge: #241014;
  --gold: #c9a45c;
  --oak: #9a6a45;
  --oak-dark: #6b4429;
  --oak-light: #c79a6e;
  --sage: #5d7457;
  --sage-wash: #e3ead9;
  --line: #e2d4c3;
  --shadow: 0 1px 2px rgba(42, 31, 28, .08), 0 8px 24px -10px rgba(42, 31, 28, .25);
  --cover-shadow: 0 1px 1px rgba(0, 0, 0, .12), 0 10px 18px -8px rgba(42, 31, 28, .55);

  --display: 'Gloock', 'Iowan Old Style', Georgia, serif;
  --body: 'Literata', 'Iowan Old Style', Georgia, serif;
  --hand: 'Caveat', 'Bradley Hand', 'Segoe Print', cursive;

  --step--1: .84rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.1rem;
  --step-4: clamp(2.3rem, 6vw, 3.6rem);
  --radius: 10px;
  color-scheme: light;
}

/* After hours: the same shop with the lamps on. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1d1716; --paper-deep: #2a201d; --card: #261e1c;
    --ink: #f3e8de; --ink-soft: #c9b6ab; --ink-faint: #8e7b72;
    --rose: #d58aa1; --rose-ink: #e8a9bc; --rose-wash: #3b2129;
    --fascia: #2b1418; --fascia-edge: #140a0c; --gold: #c9a45c;
    --oak: #a77650; --oak-dark: #5a3925; --oak-light: #c79a6e;
    --sage: #9db594; --sage-wash: #27301f;
    --line: #3e322d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -10px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1d1716; --paper-deep: #2a201d; --card: #261e1c;
  --ink: #f3e8de; --ink-soft: #c9b6ab; --ink-faint: #8e7b72;
  --rose: #d58aa1; --rose-ink: #e8a9bc; --rose-wash: #3b2129;
    --fascia: #2b1418; --fascia-edge: #140a0c; --gold: #c9a45c;
  --oak: #a77650; --oak-dark: #5a3925; --oak-light: #c79a6e;
  --sage: #9db594; --sage-wash: #27301f;
  --line: #3e322d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -10px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.55 var(--body);
  min-height: 100vh;
}
img { max-width: 100%; }
a { color: var(--rose-ink); cursor: pointer; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 400; margin: 0; line-height: 1.1; text-wrap: balance; }
button { font: inherit; color: inherit; }
.muted { color: var(--ink-soft); }
.small { font-size: var(--step--1); }
.danger { color: #b3263e !important; }
.ok { color: var(--sage); }
code { background: var(--paper-deep); padding: 0 .3em; border-radius: 4px; font-size: .88em; }
:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }

.eyebrow {
  font: 600 .72rem/1.2 var(--body);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--rose-ink);
  margin: 0;
}

/* ------------------------------------------------------------ shopfront */

.shopfront { text-align: center; }
/* A traditional painted fascia: oxblood board, gold-leaf lettering, a pinstripe inset. */
.fascia {
  background: var(--fascia);
  padding: 14px 16px;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .18), 0 4px 0 var(--fascia-edge);
}
.fascia-board {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 20px 14px;
  border: 1px solid var(--gold);
  outline: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  outline-offset: 4px;
  color: var(--gold);
}
.fascia h1 {
  font-size: var(--step-4);
  letter-spacing: .02em;
  color: var(--gold);
  background: linear-gradient(180deg, #f3dca2 0%, var(--gold) 55%, #9c7a37 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}
.fascia-small {
  margin: 0;
  font: 600 .74rem/1.6 var(--body);
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--gold);
}
.fascia-small:first-child { font-size: .95rem; letter-spacing: .4em; margin-bottom: 4px; }
.shopfront > .tagline { margin: 16px auto 0; padding: 0 16px; color: var(--ink-soft); font-style: italic; font-size: var(--step--1); }

.sync-status { font-size: .78rem; margin: 10px 0 0; color: var(--ink-soft); min-height: 1.2em; }
.sync-status a { color: inherit; }
.sync-status.saved { color: var(--sage); }
.sync-status.lookup { margin-top: 2px; color: var(--ink-soft); font-style: italic; }
.sync-status.off, .sync-status.error { color: #b3263e; font-weight: 600; }
.sync-status .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--rose); animation: pulse 1s infinite; vertical-align: middle; }
@keyframes pulse { 50% { opacity: .25; } }

.nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 22px;
  padding: 12px 16px;
  margin-top: 6px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  z-index: 10;
}
.nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font: 600 .78rem/1 var(--body);
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 8px 2px;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); border-bottom-color: var(--ink); }

/* --------------------------------------------------------------- layout */

.view { max-width: 1160px; margin: 0 auto; padding: 28px 16px 56px; }
.section { margin: 0 0 48px; }
.section-head { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; margin-bottom: 18px; }
.section-head h2 { font-size: var(--step-3); }
.section-head p { margin: 4px 0 0; color: var(--ink-soft); max-width: 60ch; }
.intro { margin: 0 0 26px; }
.intro h2 { font-size: var(--step-3); }
.intro p { color: var(--ink-soft); margin: .4rem 0; max-width: 65ch; }
.section-title { font-family: var(--display); font-size: var(--step-2); margin: 26px 0 12px; }
.small-title { font-size: var(--step-1); margin: 22px 0 8px; }
.hint { font-size: var(--step--1); color: var(--ink-faint); font-style: italic; }
.foot { text-align: center; font-size: .78rem; color: var(--ink-faint); padding: 0 16px 40px; }

/* -------------------------------------------------------------- buttons */

.btn {
  font: 600 .88rem/1 var(--body);
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--rose-ink); border-color: var(--rose-ink); color: #fff; }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { background: var(--paper-deep); color: var(--ink); }
.btn.small { font-size: .78rem; padding: 7px 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.link { background: none; border: 0; color: var(--rose-ink); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.file-btn { display: inline-block; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--card);
}
textarea { width: 100%; resize: vertical; }

/* ------------------------------------------------------- format picker */

.fmt-picker { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; background: var(--card); }
.fmt-picker button {
  border: 0; background: transparent; border-radius: 999px; padding: 6px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--ink-soft);
}
.fmt-picker button[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.ico { width: 1.05em; height: 1.05em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.fmt-badge {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: var(--paper);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.fmt-badge .ico { width: 14px; height: 14px; }
.fmt-inline { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-soft); }

/* ---------------------------------------------------------------- stars */

.stars { display: inline-flex; gap: 1px; vertical-align: -2px; }
.star { position: relative; width: var(--s); height: var(--s); display: inline-block; }
.star svg { width: var(--s); height: var(--s); display: block; }
.star > svg path { fill: var(--line); }
.star .fill { position: absolute; inset: 0 auto 0 0; overflow: hidden; }
.star .fill path { fill: var(--rose); }
.star-picker { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; border-radius: 8px; padding: 2px 4px; touch-action: manipulation; }
.star-val { font-family: var(--hand); font-size: 2rem; color: var(--rose-ink); min-width: 2.4em; line-height: 1; }

/* --------------------------------------------------------------- jackets */

.jacket {
  --j: #7b2d3b;
  position: relative;
  aspect-ratio: 2 / 3;
  max-width: 100%;
  border-radius: 2px 4px 4px 2px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .22) 0 3px, rgba(255, 255, 255, .08) 3px 5px, transparent 5px),
    var(--j);
  box-shadow: var(--cover-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12% 10% 10% 14%;
  color: #fbf3ea;
}
.jacket::after {
  content: ''; position: absolute; inset: 6% 6% 6% 9%;
  border: 1px solid rgba(251, 243, 234, .35);
  pointer-events: none;
}
.jacket-title { font-family: var(--display); font-size: clamp(.7rem, 1.1vw + .3rem, 1.05rem); line-height: 1.1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; }
.jacket-author { font-size: .58rem; letter-spacing: .14em; text-transform: uppercase; opacity: .85; }
.jacket img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }

/* ---------------------------------------------------------- the counter */

.counter-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 18px; }
.counter-card {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 20px;
  padding: 20px;
  background: var(--paper-deep);
  border-radius: var(--radius);
  position: relative;
}
.counter-card .cover-lg { width: 132px; cursor: pointer; }
.counter-card h3 { font-size: var(--step-2); cursor: pointer; margin-top: 6px; }
.counter-card .byline { margin: 4px 0 12px; color: var(--ink-soft); }
.counter-card .fmt-picker { margin-bottom: 4px; }
@media (max-width: 480px) {
  .counter-card { grid-template-columns: 96px 1fr; gap: 14px; padding: 14px; }
  .counter-card .cover-lg { width: 96px; }
}

/* --------------------------------------------- staff picks & shelf-talkers */

.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(44%, 200px), 1fr)); gap: 34px 26px; }
@media (max-width: 480px) {
  .picks { gap: 28px 14px; }
  .pick-cover { width: 82%; }
  .talker { width: 100%; padding: 12px 10px 10px; }
  .talker-note { font-size: 1.1rem; }
}
.pick { margin: 0; display: flex; flex-direction: column; align-items: center; }
.pick-cover { border: 0; padding: 0; background: none; cursor: pointer; width: 70%; position: relative; transition: transform .25s; }
.pick-cover:hover { transform: translateY(-4px); }
.pick-ledge { width: 100%; height: 12px; margin-top: -2px; background: linear-gradient(180deg, var(--oak-light), var(--oak) 45%, var(--oak-dark)); border-radius: 2px; box-shadow: 0 6px 10px -6px rgba(42, 31, 28, .6); }
.talker {
  position: relative;
  margin-top: 12px;
  width: 92%;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
  transform: rotate(var(--tilt, -1.2deg));
  text-align: left;
}
.talker::before {
  /* the little clip holding the card to the ledge */
  content: ''; position: absolute; top: -9px; left: 50%; width: 26px; height: 14px; transform: translateX(-50%);
  background: linear-gradient(180deg, #e2c27f, var(--gold) 60%, #8e6c2c); border-radius: 2px;
}
.talker-label { font: 600 .62rem/1 var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--rose-ink); }
.talker-note { display: block; font-family: var(--hand); font-size: 1.32rem; line-height: 1.15; margin: 6px 0 8px; color: var(--ink); }
.talker-title { display: block; font-size: .75rem; color: var(--ink-soft); }

/* ------------------------------------------------------- display ledges */

.ledge-wrap { position: relative; }
.ledge {
  display: flex;
  gap: 18px;
  align-items: flex-end;
  overflow-x: auto;
  padding: 10px 6px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--oak) transparent;
}
.ledge-wrap::after {
  content: ''; display: block; height: 14px;
  background: linear-gradient(180deg, var(--oak-light), var(--oak) 40%, var(--oak-dark));
  border-radius: 2px;
  box-shadow: 0 8px 12px -8px rgba(42, 31, 28, .7);
}
.ledge-item { flex: 0 0 auto; width: 118px; border: 0; padding: 0; background: none; cursor: pointer; position: relative; transition: transform .2s; }
.ledge-item:hover { transform: translateY(-5px) rotate(-1deg); }
.ledge-caption { display: flex; justify-content: space-between; gap: 6px; margin-top: 8px; font-size: .72rem; color: var(--ink-soft); }

/* ------------------------------------------------------- the collection */

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.toolbar input[type="search"] { flex: 1 1 220px; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 12px; font-size: .8rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft);
}
.chip[aria-pressed="true"], .chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
span.chip { cursor: default; }
.chip.read { background: var(--sage-wash); border-color: var(--sage); color: var(--sage); font-weight: 600; }

.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 128px), 1fr)); gap: 26px 18px; }
.wall-item { border: 0; padding: 0; background: none; cursor: pointer; text-align: left; position: relative; display: flex; flex-direction: column; gap: 8px; }
.wall-item .jacket { transition: transform .2s, box-shadow .2s; }
.wall-item:hover .jacket { transform: translateY(-4px); }
.wall-meta { display: flex; justify-content: space-between; align-items: center; font-size: .72rem; color: var(--ink-faint); min-height: 1.2em; }
.wall-title { font-size: .8rem; line-height: 1.25; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tbr-item { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.tbr-item .wall-item { width: 100%; }
.more-row { display: flex; justify-content: center; margin-top: 24px; }

.welcome { background: var(--paper-deep); border-radius: var(--radius); padding: 32px clamp(18px, 4vw, 40px); max-width: 720px; }
.welcome h2 { font-size: var(--step-3); }
.welcome p { color: var(--ink-soft); max-width: 55ch; }

/* --------------------------------------------------------- book cards */

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 18px; }
.book-card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 16px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
}
.book-card .jacket { width: 92px; cursor: pointer; }
.book-card-body { min-width: 0; }
.book-card h4 { font-size: var(--step-1); }
.book-card h4[data-action] { cursor: pointer; }
.book-card p { margin: 3px 0; }
.badge { display: inline-block; background: var(--rose-wash); color: var(--rose-ink); border-radius: 999px; padding: 1px 10px; font-size: .74rem; margin: 6px 0 2px !important; }
.owned { color: var(--sage); font-size: .85rem; cursor: pointer; margin-top: 10px !important; font-weight: 600; }
.why { font-family: var(--hand); font-size: 1.2rem; line-height: 1.1; color: var(--rose-ink); margin-top: 8px !important; }

.search-bar { display: flex; gap: 8px; max-width: 680px; margin: 0 0 28px; }
.search-bar input { flex: 1; min-width: 0; font-size: 1.05rem; padding: 12px 18px; border-radius: 999px; }

.dnf { margin-top: 36px; border-top: 1px solid var(--line); padding-top: 12px; }
.dnf summary { cursor: pointer; font-family: var(--display); font-size: var(--step-1); }

/* -------------------------------------------------------------- modal */

.modal {
  border: 0; border-radius: 14px; padding: 0;
  width: min(820px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(20, 12, 10, .45);
}
.modal::backdrop { background: rgba(30, 20, 18, .55); backdrop-filter: blur(3px); }
.modal-inner { padding: clamp(18px, 4vw, 34px); position: relative; }
.close { position: absolute; top: 12px; right: 12px; border: 1px solid var(--line); background: var(--card); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; z-index: 3; }
.modal-grid { display: grid; grid-template-columns: 210px 1fr; gap: 28px; }
.modal-cover { width: 210px; }
.modal h2 { font-size: var(--step-3); padding-right: 36px; margin-top: 6px; }
.modal .byline { color: var(--ink-soft); margin: 6px 0 2px; font-size: var(--step-1); }
.modal p { margin: 3px 0; }
.status-pill { display: inline-flex; gap: 6px; align-items: center; }
.modal .rating-block { margin: 18px 0 6px; }
.modal-section { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 6px; }
.desc { margin: 18px 0 6px; white-space: pre-line; font-size: .92rem; color: var(--ink-soft); max-height: 12em; overflow: auto; max-width: 70ch; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; font-size: .74rem; color: var(--ink-soft); }
.reads { list-style: none; padding: 0; margin: 0 0 6px; }
.read-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: .86rem; }
.read-row > span { font-weight: 600; min-width: 6em; }
.read-row input, .read-row select { padding: 4px 8px; font-size: .84rem; }
.talker-edit {
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 14px 16px; transform: rotate(-.6deg); margin-top: 10px; max-width: 560px;
}
.talker-edit textarea { border: 0; background: transparent; padding: 0; font-family: var(--hand); font-size: 1.4rem; line-height: 1.2; color: var(--ink); min-height: 4.5em; }
.talker-edit textarea:focus { outline: none; }
.narrator { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; font-size: .86rem; }
.narrator input { flex: 1 1 200px; min-width: 0; }
.modal-cover-col { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.cover-choices { margin-top: 18px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 12px; margin-top: 8px; }
.choice { border: 0; padding: 0; background: none; cursor: pointer; display: flex; flex-direction: column; gap: 4px; font-size: .7rem; color: var(--ink-faint); }
.choice img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; box-shadow: var(--cover-shadow); border-radius: 2px; transition: transform .15s; }
.choice:hover img { transform: translateY(-3px); }
.modal-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; gap: 10px; flex-wrap: wrap; }
.next-series {
  margin-top: 20px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--rose-wash);
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
}
@media (max-width: 600px) {
  .modal-grid { grid-template-columns: 1fr; gap: 18px; }
  .modal-cover { width: 140px; }
}

/* -------------------------------------------------------------- stats */

.year-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.pill { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; cursor: pointer; font: 600 .82rem var(--body); color: var(--ink-soft); }
.pill.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 1px; margin-bottom: 22px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tile { background: var(--card); padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; }
.tile-big { font-family: var(--display); font-size: 2.5rem; line-height: 1; font-variant-numeric: tabular-nums; }
.tile-label { font: 600 .7rem/1.3 var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--rose-ink); margin-top: 6px; }
.tile-sub { font-size: .78rem; color: var(--ink-soft); min-height: 1.2em; }

.goal { background: var(--paper-deep); border-radius: var(--radius); padding: 14px 20px; margin-bottom: 22px; font-size: .9rem; }
.goal-track { height: 10px; border-radius: 999px; background: var(--card); margin-top: 8px; overflow: hidden; }
.goal-fill { height: 100%; background: var(--rose); border-radius: 999px; transition: width 1s; }
.empty-note { background: var(--paper-deep); border-radius: var(--radius); padding: 12px 18px; margin: 0 0 18px; }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart-card { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 12px; min-width: 0; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card figcaption { font-family: var(--display); font-size: var(--step-1); margin-bottom: 8px; }
@media (max-width: 760px) { .chart-grid { grid-template-columns: 1fr; } }

.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .axis { stroke: var(--ink-faint); stroke-width: 1; }
.chart-svg .tick { fill: var(--ink-soft); font: 11px var(--body); }
.chart-svg .bar { fill: var(--rose); transition: fill .15s; }
.chart-svg .bar.hl { fill: var(--rose-ink); }
.chart-svg .hit { fill: transparent; }
.chart-svg .col:hover .hit { fill: var(--rose-wash); opacity: .5; }
.chart-svg .col:hover .bar { fill: var(--ink); }

.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar-row { display: grid; grid-template-columns: minmax(0, 9em) 1fr auto; gap: 10px; align-items: center; font-size: .85rem; }
.hbar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 10px; background: var(--paper-deep); border-radius: 0 5px 5px 0; }
.hbar-fill { display: block; height: 100%; background: var(--rose); border-radius: 0 5px 5px 0; }
.hbar-row:hover .hbar-fill { background: var(--ink); }
.hbar-val { font-size: .8rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.chart-tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--ink); color: var(--paper); font-size: .8rem; padding: 6px 10px; border-radius: 6px;
  opacity: 0; transition: opacity .12s; max-width: 280px;
}
.chart-tip.show { opacity: 1; }
.cover-row { display: flex; flex-wrap: wrap; gap: 12px; }
.mini-cover { width: 70px; cursor: pointer; }
.highlights { margin-top: 12px; }

/* ----------------------------------------------------------- settings */

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 18px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 22px 22px; }
.panel label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: .88rem; }
.panel label.btn { display: inline-block; margin: 6px 0; }
.progress { height: 6px; background: var(--paper-deep); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress div { height: 100%; width: 0; background: var(--rose); transition: width .3s; }

.import-panel { margin-bottom: 18px; border-color: var(--rose); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 0 12px; }
.map-grid select { width: 100%; }
.table-wrap { overflow-x: auto; }
.preview-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.preview-table th { text-align: left; font: 600 .7rem var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--rose-ink); border-bottom: 1px solid var(--line); padding: 6px 8px; }
.preview-table td { padding: 6px 8px; border-bottom: 1px dashed var(--line); white-space: nowrap; }
.preview-table td:first-child { white-space: normal; min-width: 10em; }

.cloud-panel { margin-bottom: 18px; border-color: var(--rose); }
.cloud-panel.connected { border-color: var(--sage); }
.cloud-panel p { max-width: 70ch; }
.steps { padding-left: 1.3em; display: grid; gap: 14px; max-width: 75ch; }
.steps ul { margin: 6px 0 0; padding-left: 1.1em; font-size: .9rem; }
.cloud-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 0 12px; align-items: end; margin-top: 8px; }
.cloud-form .btn { margin: 10px 0; justify-self: start; }

/* -------------------------------------------------------------- misc */

.loading { padding: 40px 0; color: var(--ink-soft); font-style: italic; display: flex; gap: 10px; align-items: center; }
.loading::before { content: ''; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--rose); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 30px);
  background: var(--ink); color: var(--paper); padding: 11px 20px; border-radius: 999px;
  box-shadow: var(--shadow); opacity: 0; transition: all .3s; z-index: 200;
  max-width: calc(100vw - 32px); text-align: center; font-size: .9rem; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* Phones: keep the sign tidy and the format switch inside its card. */
.counter-card > div:last-child { min-width: 0; }
.fmt-picker { max-width: 100%; }
@media (max-width: 480px) {
  .fascia-board { padding: 12px 10px 10px; }
  .fascia-small { font-size: .6rem; letter-spacing: .2em; }
  .fascia-small:first-child { font-size: .8rem; letter-spacing: .3em; }
  .fmt-picker button { padding: 6px 8px; font-size: .74rem; gap: 4px; }
}

.reread-choice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.reread-choice .btn { display: inline-flex; align-items: center; gap: 6px; }
.taste-now { font-size: 1.05rem; max-width: 60ch; }
.english-fix { margin-top: 16px; padding: 12px 16px; border-radius: var(--radius); background: var(--paper-deep); }
.english-fix p { margin: 0 0 6px; }
.choice span { white-space: normal; line-height: 1.2; }
