/*
  Books shared style. Two halves:
  1. A verbatim copy of MobileApp/internal/house-style/house.css (the house style of the internal sites).
     Copy it again from there when it changes; do not edit it here.
  2. The Books layer: fonts, eyebrows, pills, empty states. It uses the --qw-* colours only.
  It lives at /shared/kit.css because the server lets signed-out people load this one path (the sign-in page).
*/

/* ===== 1. house.css (verbatim) ===== */
/*
  One look for every internal site: burgundy and gold on cream, the same as the app.
  Each site imports this file first, then its own stylesheet for what only it has.
  Site stylesheets use these --qw-* colors and never write a color of their own.
*/
:root {
  color-scheme: light dark;

  --qw-bg: #faf7f2;
  --qw-surface: #ffffff;
  --qw-surface-2: #f4efe7;
  --qw-line: #e5ded4;
  --qw-line-strong: #cdc2b4;
  --qw-ink: #1d1b19;
  --qw-muted: #5f5953;
  --qw-faint: #8a827a;

  --qw-accent: #7a1f2b;
  --qw-accent-hover: #611722;
  --qw-accent-soft: #f6e8ea;
  --qw-accent-line: #dcb6bc;
  --qw-on-accent: #ffffff;

  --qw-gold: #946512;
  --qw-gold-soft: #f8eed8;
  --qw-good: #1f6b45;
  --qw-good-soft: #e3f1e8;
  --qw-bad: #b42318;
  --qw-bad-soft: #fbe7e4;
  --qw-warn: #8a5a08;
  --qw-warn-soft: #fbf0d6;
  --qw-info: #2f5f8a;
  --qw-info-soft: #e6eef6;
  --qw-focus: #c08a2c;

  --qw-shadow: 0 1px 2px rgba(40, 24, 14, 0.05), 0 8px 24px rgba(40, 24, 14, 0.06);
  --qw-shadow-lift: 0 16px 40px rgba(40, 24, 14, 0.14);
  --qw-backdrop: rgba(29, 27, 25, 0.45);

  --qw-radius: 12px;
  --qw-radius-sm: 8px;
  --qw-radius-pill: 999px;
  --qw-page-width: 1200px;
  --qw-header-height: 60px;

  --qw-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --qw-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  font-family: var(--qw-font);
  font-synthesis: none;
  accent-color: var(--qw-accent);
  color: var(--qw-ink);
  background: var(--qw-bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --qw-bg: #1a1816;
    --qw-surface: #24211e;
    --qw-surface-2: #2d2926;
    --qw-line: #3a3530;
    --qw-line-strong: #4f4841;
    --qw-ink: #f2eee8;
    --qw-muted: #b5aea6;
    --qw-faint: #8c857d;

    --qw-accent: #e0a3ab;
    --qw-accent-hover: #ecbcc2;
    --qw-accent-soft: #3a2327;
    --qw-accent-line: #74414a;
    --qw-on-accent: #2a1014;

    --qw-gold: #e2b968;
    --qw-gold-soft: #3a2f1b;
    --qw-good: #86d3a6;
    --qw-good-soft: #1c3226;
    --qw-bad: #f4a29a;
    --qw-bad-soft: #3e201d;
    --qw-warn: #e8c46e;
    --qw-warn-soft: #3a2f17;
    --qw-info: #9cc2e6;
    --qw-info-soft: #1d2a37;
    --qw-focus: #e2b968;

    --qw-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --qw-shadow-lift: 0 16px 40px rgba(0, 0, 0, 0.45);
    --qw-backdrop: rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--qw-bg); color: var(--qw-ink); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--qw-accent); }
a:hover { color: var(--qw-accent-hover); }
:focus-visible { outline: 3px solid var(--qw-focus); outline-offset: 2px; }
code, kbd, pre { font-family: var(--qw-mono); font-size: 0.9em; }
::selection { background: var(--qw-accent-soft); }

/* Header: brand on the left, then nav, then the account on the right. */
.qw-header { position: sticky; top: 0; z-index: 30; border-bottom: 1px solid var(--qw-line); background: var(--qw-surface); }
.qw-header-in { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; width: min(var(--qw-page-width), calc(100% - 32px)); min-height: var(--qw-header-height); margin: 0 auto; }
.qw-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--qw-ink); font-size: 17px; font-weight: 750; letter-spacing: -0.02em; text-decoration: none; }
.qw-brand:hover { color: var(--qw-ink); }
.qw-mark { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: var(--qw-radius-sm); color: var(--qw-on-accent); background: var(--qw-accent); font-size: 15px; font-weight: 750; }
.qw-mark svg { width: 17px; height: 17px; }
.qw-nav { display: flex; flex-wrap: wrap; gap: 4px; }
.qw-nav a, .qw-nav button { padding: 6px 10px; border: 0; border-radius: var(--qw-radius-sm); color: var(--qw-muted); background: none; font-size: 14px; font-weight: 650; text-decoration: none; cursor: pointer; }
.qw-nav a:hover, .qw-nav button:hover { color: var(--qw-ink); background: var(--qw-surface-2); }
.qw-nav [aria-current="page"], .qw-nav [aria-selected="true"], .qw-nav .qw-on { color: var(--qw-accent); background: var(--qw-accent-soft); }
.qw-account { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; min-width: 0; margin-left: auto; color: var(--qw-muted); font-size: 14px; }
.qw-account > span { overflow-wrap: anywhere; }

/* Site menu (site-menu.ts): the brand is a button that lists every internal site. */
qw-site-menu { position: relative; display: inline-flex; }
.qw-site-button { margin-left: -8px; padding: 4px 8px 4px 4px; border: 1px solid transparent; border-radius: var(--qw-radius); background: none; cursor: pointer; }
.qw-site-button:hover { background: var(--qw-surface-2); }
.qw-site-button[aria-expanded="true"] { border-color: var(--qw-accent-line); background: var(--qw-accent-soft); }
.qw-site-chevron { display: inline-flex; color: var(--qw-muted); transition: transform 0.15s; }
.qw-site-chevron svg { width: 14px; height: 14px; }
.qw-site-button[aria-expanded="true"] .qw-site-chevron { transform: rotate(180deg); }
.qw-site-list { position: absolute; top: calc(100% + 6px); left: -8px; z-index: 40; width: min(340px, calc(100vw - 24px)); padding: 8px; border: 1px solid var(--qw-line); border-radius: var(--qw-radius); background: var(--qw-surface); box-shadow: var(--qw-shadow-lift); }
.qw-site-list[hidden] { display: none; }
.qw-site-heading { margin: 0; padding: 8px 12px 6px; color: var(--qw-gold); font-size: 12px; font-weight: 750; letter-spacing: 0.1em; text-transform: uppercase; }
.qw-site-row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 12px; border-radius: var(--qw-radius-sm); color: var(--qw-ink); text-decoration: none; }
.qw-site-row:hover, .qw-site-row:focus-visible { color: var(--qw-ink); background: var(--qw-surface-2); }
.qw-site-row[aria-current="page"] { background: var(--qw-accent-soft); }
.qw-site-row[aria-current="page"] .qw-site-name { color: var(--qw-accent); }
.qw-site-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.qw-site-name { font-size: 14px; font-weight: 650; }
.qw-site-about { color: var(--qw-muted); font-size: 12.5px; overflow-wrap: anywhere; }
.qw-site-check { display: inline-flex; color: var(--qw-accent); }
.qw-site-check svg { width: 16px; height: 16px; }
.qw-site-rule { height: 1px; margin: 6px 4px; border: 0; background: var(--qw-line); }
.qw-mark-quiet { color: var(--qw-muted); background: var(--qw-surface-2); }

/* Page body. */
.qw-page { width: min(var(--qw-page-width), calc(100% - 32px)); margin: 0 auto; padding: 28px 0 80px; }
.qw-page-title { margin: 0 0 6px; font-size: 26px; line-height: 1.2; font-weight: 750; letter-spacing: -0.025em; }
.qw-section-title { margin: 28px 0 8px; font-size: 19px; font-weight: 700; letter-spacing: -0.015em; }
.qw-muted { color: var(--qw-muted); }
.qw-eyebrow { color: var(--qw-gold); font-size: 12px; font-weight: 750; letter-spacing: 0.1em; text-transform: uppercase; }
.qw-card { padding: 20px; border: 1px solid var(--qw-line); border-radius: var(--qw-radius); background: var(--qw-surface); box-shadow: var(--qw-shadow); }

/* Buttons. */
.qw-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border: 1px solid var(--qw-line-strong); border-radius: var(--qw-radius-sm); color: var(--qw-ink); background: var(--qw-surface); font-size: 14px; font-weight: 650; line-height: 1.2; text-decoration: none; cursor: pointer; }
.qw-btn:hover { color: var(--qw-ink); background: var(--qw-surface-2); }
.qw-btn-primary { border-color: var(--qw-accent); color: var(--qw-on-accent); background: var(--qw-accent); }
.qw-btn-primary:hover { border-color: var(--qw-accent-hover); color: var(--qw-on-accent); background: var(--qw-accent-hover); }
.qw-btn-danger { border-color: var(--qw-bad); color: var(--qw-bad); background: var(--qw-surface); }
.qw-btn-danger:hover { color: var(--qw-bad); background: var(--qw-bad-soft); }
.qw-btn-ghost { border-color: transparent; color: var(--qw-accent); background: transparent; }
.qw-btn-ghost:hover { color: var(--qw-accent-hover); background: var(--qw-accent-soft); }
.qw-btn:disabled, .qw-btn[aria-disabled="true"] { opacity: 0.5; cursor: default; }
.qw-link-button { padding: 0; border: 0; color: var(--qw-accent); background: none; font-weight: 650; text-decoration: underline; cursor: pointer; }

/* Form fields. */
.qw-field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.qw-input, .qw-field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .qw-field select, .qw-field textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--qw-line-strong); border-radius: var(--qw-radius-sm); color: var(--qw-ink); background: var(--qw-surface); font-weight: 400;
}
.qw-input[aria-invalid="true"], .qw-field [aria-invalid="true"] { border-color: var(--qw-bad); }

/* Pills for state: good, bad, warn, and plain. */
.qw-pill { display: inline-flex; align-items: center; gap: 4px; width: fit-content; padding: 2px 9px; border-radius: var(--qw-radius-pill); color: var(--qw-muted); background: var(--qw-surface-2); font-size: 12px; font-weight: 700; white-space: nowrap; }
.qw-pill-good { color: var(--qw-good); background: var(--qw-good-soft); }
.qw-pill-bad { color: var(--qw-bad); background: var(--qw-bad-soft); }
.qw-pill-warn { color: var(--qw-warn); background: var(--qw-warn-soft); }
.qw-pill-accent { color: var(--qw-accent); background: var(--qw-accent-soft); }

/* Messages. */
.qw-error { padding: 10px 14px; border-radius: var(--qw-radius-sm); color: var(--qw-bad); background: var(--qw-bad-soft); font-weight: 600; }
.qw-notice { padding: 10px 14px; border-radius: var(--qw-radius-sm); color: var(--qw-good); background: var(--qw-good-soft); font-weight: 600; }

/* Tables. */
.qw-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.qw-table th { color: var(--qw-muted); font-size: 12px; font-weight: 750; letter-spacing: 0.05em; text-align: left; text-transform: uppercase; }
.qw-table th, .qw-table td { padding: 10px 8px; border-bottom: 1px solid var(--qw-line); vertical-align: top; }

.qw-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* The header wraps to more rows on narrow screens; keep them off its edges. */
@media (max-width: 760px) {
  .qw-header-in { padding: 10px 0; }
}

@media (max-width: 620px) {
  .qw-account { margin-left: 0; }
  .qw-page { padding-top: 20px; }
  .qw-card { padding: 16px; }
}

/* ===== 2. Books layer ===== */
:root {
  --qw-serif: "Literata", Georgia, "Times New Roman", serif;
  --qw-sans: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --qw-font: var(--qw-sans);
  --qw-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: var(--qw-sans);
}
body { font-family: var(--qw-sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, .bk-serif { font-family: var(--qw-serif); font-weight: 600; letter-spacing: -0.01em; }
[hidden] { display: none !important; }

.qw-header { padding-top: var(--safe-top); }
.qw-header-in { width: min(var(--qw-page-width), calc(100% - 32px - var(--safe-left) - var(--safe-right))); }
.qw-brand { font-family: var(--qw-sans); }
.qw-account [data-account] { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bk-eyebrow { display: block; margin: 0 0 6px; color: var(--qw-gold); font-size: 12px; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; }
.bk-title { margin: 0; font-family: var(--qw-serif); font-size: clamp(28px, 4.2vw, 40px); font-weight: 600; line-height: 1.12; letter-spacing: -0.02em; }
.bk-lede { margin: 8px 0 0; color: var(--qw-muted); font-size: 16px; max-width: 60ch; }

.bk-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.bk-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 14px;
  border: 1px solid var(--qw-line-strong); border-radius: var(--qw-radius-pill);
  color: var(--qw-ink); background: var(--qw-surface); font-size: 14px; font-weight: 650; cursor: pointer;
  transition: background-color 0.2s var(--qw-ease), color 0.2s var(--qw-ease), border-color 0.2s var(--qw-ease);
}
.bk-pill:hover { background: var(--qw-surface-2); }
.bk-pill[aria-pressed="true"] { border-color: var(--qw-accent); color: var(--qw-on-accent); background: var(--qw-accent); }
.bk-pill .bk-count { color: inherit; opacity: 0.65; font-weight: 600; }

.bk-empty { display: grid; justify-items: center; gap: 10px; padding: 48px 20px; text-align: center; }
.bk-empty .bk-empty-art {
  display: grid; place-items: center; width: 96px; height: 96px; border-radius: 50%;
  background: var(--qw-gold-soft); border: 1px solid var(--qw-line); font-size: 44px;
}
.bk-empty h2 { margin: 6px 0 0; font-size: 24px; }
.bk-empty p { margin: 0; color: var(--qw-muted); max-width: 42ch; }

/* The old kid-kit names, kept so older markup still works, drawn in the house look. */
button { font: inherit; }
.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px;
  border: 1px solid var(--qw-line-strong); border-radius: var(--qw-radius-pill); color: var(--qw-ink); background: var(--qw-surface);
  font-size: 15px; font-weight: 650; text-decoration: none; cursor: pointer;
  transition: background-color 0.2s var(--qw-ease), transform 0.15s var(--qw-ease), box-shadow 0.2s var(--qw-ease);
}
.btn:hover { background: var(--qw-surface-2); color: var(--qw-ink); }
.btn:active { transform: translateY(1px); }
.btn.go, .btn.blue { border-color: var(--qw-accent); color: var(--qw-on-accent); background: var(--qw-accent); box-shadow: var(--qw-shadow); }
.btn.go:hover, .btn.blue:hover { background: var(--qw-accent-hover); color: var(--qw-on-accent); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--qw-muted); }
.btn.danger { border-color: var(--qw-bad); color: var(--qw-bad); }
.btn:disabled { opacity: 0.45; cursor: default; }
.icon {
  display: inline-grid; place-items: center; flex: none; width: 42px; height: 42px; padding: 0;
  border: 1px solid var(--qw-line); border-radius: 50%; color: var(--qw-ink); background: var(--qw-surface);
  font-size: 18px; text-decoration: none; cursor: pointer; transition: background-color 0.2s var(--qw-ease), transform 0.15s var(--qw-ease);
}
.icon:hover { background: var(--qw-surface-2); color: var(--qw-ink); }
.icon:active { transform: scale(0.96); }
.icon:disabled { opacity: 0.4; cursor: default; }
.icon svg { width: 20px; height: 20px; }

/* A short plain message at the bottom of the screen: errors and notes. */
.toast {
  position: fixed; left: 50%; bottom: calc(110px + var(--safe-bottom)); transform: translateX(-50%); z-index: 60;
  max-width: min(92vw, 520px); padding: 10px 16px; border: 1px solid var(--qw-line); border-radius: var(--qw-radius);
  color: var(--qw-ink); background: var(--qw-surface); box-shadow: var(--qw-shadow-lift);
  font-size: 15px; font-weight: 600; text-align: center; animation: bk-rise 0.3s var(--qw-ease);
}
.toast.error { border-color: var(--qw-bad); color: var(--qw-bad); background: var(--qw-bad-soft); }
@keyframes bk-rise { from { opacity: 0; transform: translate(-50%, 8px); } }

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