:root {
  --bg: #faf8f4; --card: #fff; --ink: #2c2a26; --muted: #8a857c;
  --line: #e7e2d8; --accent: #4a6b54; --wild: #7a4f86; --error: #b3402f;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: .75rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.1rem; }
.topbar nav { display: flex; gap: 1rem; }
.userbar { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.inline { display: inline-flex; gap: .25rem; }

main { max-width: 820px; margin: 1.5rem auto; padding: 0 1.25rem; }
footer { max-width: 820px; margin: 2rem auto; padding: 0 1.25rem 2rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 1.25rem 1.5rem; margin-bottom: 1.25rem;
}
h1 { font-size: 1.4rem; margin: .2rem 0 .6rem; }
h3 { margin: 0 0 .15rem; }

.row { display: flex; align-items: center; gap: 1rem; }
.spread { justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); font-size: .9rem; }
.notice { background: #fbf3df; border: 1px solid #ecd9a6; padding: .6rem .8rem; border-radius: 8px; }
.error { background: #fbe6e2; border: 1px solid #e7b4ab; color: var(--error);
         padding: .6rem .8rem; border-radius: 8px; margin-bottom: 1rem; }

input, select, button { font: inherit; }
input[type=text], input[type=number], select {
  padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 7px; background: #fff;
}
button {
  padding: .4rem .8rem; border: 1px solid var(--accent); background: var(--accent);
  color: #fff; border-radius: 7px; cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button[disabled] { opacity: .5; cursor: wait; }

.recform, .setupform { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; margin-top: .5rem; }
.recform label, .setupform label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); }
.recform input[type=number] { width: 4rem; }
.setupform input[type=file] { padding: .3rem; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
h2 { font-size: 1.1rem; margin: .2rem 0 .4rem; }

.cards { display: grid; gap: 1rem; }
.rec { border-left: 4px solid var(--accent); }
.rec.wildcard { border-left-color: var(--wild); }
.rec .byline { color: var(--muted); font-size: .9rem; margin-bottom: .4rem; }
.rec .byline .gr { color: var(--accent); }
.rec h3 a { color: inherit; }
.rec h3 a:hover { color: var(--accent); }
.rec .reason { margin: .4rem 0 .8rem; }
.tag { font-size: .75rem; color: var(--wild); }

.actions form { display: flex; gap: .4rem; flex-wrap: wrap; }
.actions button { background: #fff; color: var(--ink); border-color: var(--line); }
.actions button:hover { border-color: var(--accent); }
.actions.done { color: var(--accent); font-weight: 600; }

.profile-text { white-space: pre-wrap; line-height: 1.65; }

table.history { width: 100%; border-collapse: collapse; }
table.history th, table.history td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
table.history th { white-space: nowrap; }
.sortlink { color: var(--ink); font-weight: 600; }
.sortlink:hover { color: var(--accent); text-decoration: none; }
.sortlink.active { color: var(--accent); }

pre { background: #f3efe7; padding: .8rem; border-radius: 8px; overflow-x: auto; font-size: .85rem; }

/* Site-wide enrichment banner */
.banner { background: #eaf2ec; border: 1px solid #bcd6c3; color: #2f5a3c;
          padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; }
.banner.error { background: #fbe6e2; border-color: #e7b4ab; color: var(--error); }
.banner.stale { background: #fbf3df; border-color: #ecd9a6; color: #6b5410; }
#enrich-banner:empty, #profile-status:empty { display: none; }

/* Library / ratings */
table.library { width: 100%; border-collapse: collapse; }
table.library th, table.library td { text-align: left; padding: .4rem .5rem;
  border-bottom: 1px solid var(--line); vertical-align: middle; }
.rateform { margin: 0; }
.rate-ok { color: var(--accent); font-size: .85rem; }

/* Access wall */
main.access { max-width: 420px; margin-top: 4rem; }
.accessform { display: flex; gap: .5rem; margin-top: .5rem; }
.accessform input { flex: 1; }

/* HTMX loading indicator */
.htmx-indicator { display: none; color: var(--muted); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
