/* godex — one stylesheet, no framework; the monoexp.com look (docs/PLAN.md §12) */

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #5f5f5a;
  --border: #e4e4e0;
  --accent: #1c1c1a;
  --accent-text: #fafaf9;
  --tag-bg: #f0f0ed;
  --focus: #2f6fdb;
  --error: #b42318;
  --error-bg: #fdf0ee;
  --ok: #18794e;
  --ok-bg: #edf7f1;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --max: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --surface: #1a1a19;
    --text: #ececea;
    --muted: #a3a39e;
    --border: #2c2c2a;
    --accent: #ececea;
    --accent-text: #121211;
    --tag-bg: #252524;
    --focus: #7aa7f5;
    --error: #f97066;
    --error-bg: #2a1614;
    --ok: #4cc38a;
    --ok-bg: #12241b;
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; width: 100%; }

a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px;
}

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

.skip {
  position: absolute; left: 8px; top: -48px;
  background: var(--surface); padding: 8px 12px; border-radius: 6px; z-index: 1;
}
.skip:focus { top: 8px; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}
.wordmark {
  font: 600 18px/1 var(--mono);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.wordmark span { color: var(--muted); }
nav { display: flex; align-items: center; gap: 16px; min-width: 0; font-size: 15px; }
nav form { margin: 0; }
.who {
  color: var(--muted);
  text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Text */
h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 6vw, 38px);
  line-height: 1.15;
  letter-spacing: -0.03em;
}
.intro, .narrow { padding: 48px 0 56px; }
.narrow { max-width: 400px; }
.intro p { margin: 0 0 14px; color: var(--muted); max-width: 62ch; }
.intro .lede { font-size: 20px; color: var(--text); }
.hint { margin: 16px 0 0; font-size: 15px; color: var(--muted); }
.stack .hint { margin: -8px 0 0; }

.alert, .ok, .note {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 15.5px;
}
.alert { color: var(--error); background: var(--error-bg); }
.ok { color: var(--ok); background: var(--ok-bg); }
.note { background: var(--tag-bg); }
.stack > .alert, .group > .alert { margin: 0; } /* the gap spaces it */

/* Forms */
.stack { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 15px; font-weight: 500; }
input, textarea {
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}
input:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--focus); }
textarea { resize: vertical; }
button {
  font: 500 16px/1 var(--sans);
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 12px 18px;
  cursor: pointer;
}
.stack button { align-self: flex-start; margin-top: 4px; }
button.link {
  font-size: 15px;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 4px 0;
}
button.link:hover { color: var(--text); }

/* Page heading with an action */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 40px 0 24px;
}
.page-head h1 { margin-bottom: 4px; }
.crumbs { margin: 24px 0 -24px; font-size: 15px; color: var(--muted); }
.crumbs a { text-decoration: none; }
.crumbs a::before { content: "← "; }
a.button {
  flex-shrink: 0;
  display: inline-block;
  font: 500 15px/1 var(--sans);
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 11px 16px;
  text-decoration: none;
}
a.button.secondary, button.secondary { color: var(--text); background: var(--surface); border-color: var(--border); }
a.button.secondary:hover, button.secondary:hover { border-color: var(--accent); }

.badge { font-size: 13px; color: var(--muted); white-space: nowrap; }
.shelf-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; color: var(--muted); font-size: 15px; }
.shelf-desc { display: block; margin: 8px 0 0; color: var(--muted); font-size: 15px; }
.empty { padding: 24px 0 56px; color: var(--muted); }

/* Covers: real ones, or the title's initials */
.no-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tag-bg);
  color: var(--muted);
  font: 600 13px/1 var(--mono);
}

/* Home: shelf cards */
.shelves {
  list-style: none;
  margin: 0;
  padding: 0 0 56px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 640px) {
  .shelves { grid-template-columns: 1fr 1fr; }
}
.shelf-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
}
.shelf-card:hover { border-color: var(--accent); }
.covers { display: flex; gap: 8px; height: 84px; margin-bottom: 14px; }
.covers img, .covers .no-cover {
  width: 56px;
  height: 84px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.empty-covers {
  flex: 1;
  border: 1px dashed var(--border);
  border-radius: 4px;
}
.shelf-name { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 2px; }

/* Shelf: filters */
.filters {
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filters summary {
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.summary-state { font-weight: 400; color: var(--muted); }
.filters form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  padding: 4px 16px 16px;
}
.filters label { font-size: 14px; }
select {
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.vibe-filter {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}
.vibe-filter legend { float: left; width: 100%; margin-bottom: 6px; font-size: 14px; font-weight: 500; }
.chip { flex-direction: row; font-weight: 400; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
}
.chip input:checked + span { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.filter-actions { display: flex; align-items: center; gap: 16px; font-size: 15px; }
.filter-actions button { padding: 9px 16px; font-size: 15px; }

/* Shelf: books */
.book-list { list-style: none; margin: 0; padding: 0; }
.book {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.thumb {
  flex-shrink: 0;
  width: 60px;
  height: 90px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.book-text { display: flex; flex-direction: column; min-width: 0; font-size: 15px; color: var(--muted); }
.book-title { font-size: 17px; font-weight: 600; color: var(--text); text-decoration: none; }
.book-title:hover { text-decoration: underline; }
.subtitle { color: var(--text); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tags:empty { display: none; }
.tag {
  font: 12px/1 var(--mono);
  color: var(--muted);
  background: var(--tag-bg);
  padding: 5px 8px;
  border-radius: 6px;
}
.tag.vibe { font-family: var(--sans); font-size: 13px; }
.more { padding: 24px 0 56px; margin: 0; }

/* Add a book */
h2 { margin: 0; font-size: 19px; letter-spacing: -0.01em; }
.add-start {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding-bottom: 56px;
}
@media (min-width: 640px) {
  .add-start { grid-template-columns: 1fr 1fr; }
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.search-again { display: flex; gap: 8px; margin-bottom: 8px; }
.search-again button { padding: 10px 16px; }
.result-action { margin-top: 10px; }
.result-action .button { padding: 8px 12px; font-size: 14px; }
.add-form { padding-bottom: 56px; }
.group {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.group legend { padding: 0 6px; margin-left: -6px; font-weight: 600; }
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row > label { flex: 1 1 160px; }
.row > .narrow-field { flex: 0 1 160px; }
.grow { flex: 1; min-width: 0; }
.optional { font-weight: 400; color: var(--muted); font-size: 13px; }
.form-cover { display: flex; gap: 16px; align-items: flex-start; }
.choices { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.choices-label { font-size: 15px; font-weight: 500; margin-right: 4px; }
.book.chosen {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Book page */
.book-head { display: flex; gap: 20px; padding: 32px 0 16px; }
.big-cover {
  flex-shrink: 0;
  width: 120px;
  height: 180px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.big-cover.no-cover { font-size: 22px; }
.book-head h1 { font-size: clamp(24px, 5vw, 34px); margin-bottom: 4px; color: var(--text); }
.book-head p { margin: 0 0 4px; }
.book-head .series a { color: var(--muted); }
.volumes { display: flex; justify-content: space-between; gap: 16px; padding: 0 0 16px; font-size: 15px; }
.volumes .next { margin-left: auto; }
.vibe-picker { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 10px; }
.vibe-picker legend { font-size: 15px; font-weight: 500; margin-bottom: 8px; }
.add-vibe { max-width: 320px; }
.shared { padding: 40px 0 0; display: flex; flex-direction: column; gap: 16px; }
.shared .hint { margin: -8px 0 0; }
.remove {
  margin: 40px 0 56px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}
.remove .hint { margin: 0; }
.confirm { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.confirm input { width: auto; }
button.danger { background: var(--error); border-color: var(--error); color: #fff; }
input[type=file] { padding: 8px; }

/* Series */
.nav-link { color: var(--muted); text-decoration: none; }
.nav-link:hover { color: var(--text); }
.series-card { flex-direction: row; gap: 14px; }
.series-card .book-text { gap: 2px; }
.series-card .shelf-name { color: var(--text); }
.vol-label { font: 600 12px/1.6 var(--mono); text-transform: uppercase; letter-spacing: 0.04em; }
.progress { margin: 8px 0 0; font-weight: 500; }
.button-note { font-weight: 400; opacity: 0.75; margin-left: 4px; }
.all-series { margin: 8px 0 56px; }
.plain-list { margin: 0; padding-left: 20px; }
.plain-list li { margin: 4px 0; }
.muted { color: var(--muted); }
.book.gap .book-title { color: var(--muted); }
.book.gap { border-bottom-style: dashed; }
.book.not-mine .thumb { opacity: 0.6; }
.tag.status-read { background: var(--ok-bg); color: var(--ok); }

/* Shelf form */
.toggle { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
.toggle input { width: auto; margin-top: 5px; }
.toggle.off { color: var(--muted); }
.narrow-select { max-width: 320px; }
code { font: 14px var(--mono); background: var(--tag-bg); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Vibes */
.lede-small { margin: 0; color: var(--muted); max-width: 62ch; }
.section-title { margin: 32px 0 12px; }
.vibe-list { list-style: none; margin: 0 0 8px; padding: 0; }
.vibe-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.vibe-row.is-hidden .vibe-name, .vibe-row.is-hidden input { opacity: 0.6; }
.vibe-name { font-size: 16px; }
.vibe-meta { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--muted); }
.vibe-edit { display: flex; gap: 8px; flex: 1 1 280px; align-items: center; }
.vibe-edit input { padding: 7px 10px; }
.emoji-field, .row > .emoji-field { flex: 0 0 96px; }
.vibe-edit .emoji-field { flex-basis: 64px; }
.emoji-field input { text-align: center; }
form.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
button.small { padding: 8px 12px; font-size: 14px; }
button.link.danger-link { color: var(--error); }
.usage { white-space: nowrap; }
.add-vibe-form { margin: 24px 0 8px; }

/* Settings */
.settings-section { margin: 0 0 8px; }
form.settings-section { margin-top: 24px; }
.settings-section h3 { margin: 0; font-size: 17px; }
.token-list { list-style: none; margin: 0 0 8px; padding: 0; }
.token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.token-row div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.token-name { font-weight: 500; overflow-wrap: anywhere; }
.token-row .muted { font-size: 14px; }
.secret {
  margin: 16px 0;
  padding: 16px;
  background: var(--ok-bg);
  border: 1px solid var(--ok);
  border-radius: var(--radius);
}
.secret p { margin: 0 0 10px; }
.secret-value { font: 14px var(--mono); }
.sign-out { margin: 40px 0 56px; }
code.keep { white-space: nowrap; word-break: normal; }
@media (max-width: 640px) {
  .who { display: none; }
}
@media (max-width: 480px) {
  nav { gap: 14px; }
  nav form, .nav-admin { display: none; } /* both are on the settings page */
}

/* Admin */
.tabs { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0 0 24px; padding: 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.tabs a { padding: 8px 0 10px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); font-weight: 500; }
.user-actions { flex-wrap: wrap; justify-content: flex-end; gap: 4px 14px; font-size: 14px; }
.token-row .tag { font-size: 12px; vertical-align: 2px; white-space: nowrap; }
@media (max-width: 640px) {
  .token-row:has(.user-actions) { flex-wrap: wrap; gap: 6px; }
  .user-actions { flex-basis: 100%; justify-content: flex-start; }
}
.row-alert { flex-basis: 100%; margin: 0; }
.vibe-meta button.link:disabled { opacity: 0.35; cursor: default; }
.catalog-search { margin: 16px 0 24px; }
.catalog-search input { flex: 1; min-width: 0; }
.catalog-search select { width: auto; }
.merge-form { margin: 24px 0 8px; }
.tabs + .lede-small { margin-bottom: 20px; }
@media (min-width: 640px) {
  .admin-vibes .vibe-meta { flex: 0 0 250px; justify-content: flex-end; }
}
.merge-form h2 { margin: 0; font-size: 18px; }
.history { list-style: none; margin: 0 0 56px; padding: 0; }
.history li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.history p { margin: 0 0 6px; }
.history dl, .facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; font-size: 14px; }
.history dt, .facts dt { color: var(--muted); }
.history dd, .facts dd { margin: 0; overflow-wrap: anywhere; }
.merge-pair { display: grid; grid-template-columns: 1fr; gap: 16px; margin: 0 0 20px; }
.merge-pair h2 { margin: 4px 0 12px; font-size: 18px; }
.merge-pair .vol-label { margin: 0; color: var(--muted); }
@media (min-width: 640px) { .merge-pair { grid-template-columns: 1fr 1fr; } }
.merge-what li { margin: 6px 0; }
.merge-confirm { display: flex; align-items: center; gap: 16px; margin: 24px 0 56px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); }
.site-footer p { margin: 0; padding: 24px 0 32px; font: 13px/1 var(--mono); color: var(--muted); }
