:root {
  --ground: #FBFAF7;
  --card: #FFFFFF;
  --ink: #1E2B2A;
  --ink-2: #3F4A48;
  --muted: #5B6664;
  --line: #E4E0D8;
  --line-2: #EFEBE3;
  --field: #CFCAC0;
  --accent: #1F5F5B;
  --accent-dark: #123C39;
  --accent-soft: #E3EFED;
  --accent-tint: #F6FAF9;
  --sand: #F4F1EA;
  --star: #E8A700;
  --star-off: #D9D4CA;
  --danger: #A23B2C;
  --admin: #26213A;
  --admin-2: #3B3456;
  --admin-soft: #F6F4FA;
  --warn-bg: #FCF1D6;
  --warn-ink: #7A5300;
  --radius: 16px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Source Sans 3', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.45; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid #7FB3AD; outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { padding: 48px; text-align: center; color: var(--muted); }

/* ---------- layout ---------- */
.shell { min-height: 100vh; display: flex; }
.nav { width: 240px; flex: none; background: var(--ink); color: var(--sand); padding: 28px 16px; display: flex; flex-direction: column; gap: 4px; }
.nav.admin { background: var(--admin); }
.brand { font-family: var(--display); font-size: 24px; font-weight: 700; padding: 0 12px; color: #fff; }
.brand-sub { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #BDB4D6; padding: 2px 12px 0; }
.club-pick { margin: 16px 0 20px; padding: 0 4px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #A9BAB7; }
.club-pick select { min-height: 40px; border-radius: 8px; border: 1px solid #3E5452; background: #2A3B39; color: #fff; padding: 0 8px; font-size: 15px; text-transform: none; letter-spacing: 0; }
.club-pick .club-name { color: #fff; font-size: 15px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.nav-link { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-radius: 8px; color: var(--sand); text-decoration: none; font-weight: 600; background: none; border: none; text-align: left; cursor: pointer; width: 100%; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-link.active { background: #2E4442; color: #fff; font-weight: 700; }
.nav.admin .nav-link.active { background: var(--admin-2); }
.nav-sep { height: 1px; background: rgba(255,255,255,.12); margin: 14px 8px; }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--star); color: var(--admin); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.main { flex: 1; min-width: 0; padding: 32px 40px 56px; display: flex; flex-direction: column; gap: 24px; }
.main.narrow > * { max-width: 920px; width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.col-2 { flex: 2 1 520px; min-width: 0; }
.col-1 { flex: 1 1 300px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-title { font-family: var(--display); font-size: 34px; }
.eyebrow { font-size: 13px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }
.sub { color: var(--muted); margin-top: 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.card h2 { font-size: 19px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }

/* ---------- controls ---------- */
.btn { min-height: 44px; padding: 0 20px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); color: #fff; }
.btn-outline { background: #fff; border-color: var(--accent); color: var(--accent); }
.btn-outline:hover:not(:disabled) { background: var(--accent-tint); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover:not(:disabled) { background: var(--accent-tint); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: #FBEDEA; }
.btn-admin { background: var(--admin); color: #fff; }
.btn-admin-outline { background: #fff; border-color: var(--admin); color: var(--admin); }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.icon-btn { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line); background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); }
.icon-btn:hover:not(:disabled) { background: var(--sand); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.link-btn { background: none; border: none; padding: 0; color: var(--accent); font-weight: 700; cursor: pointer; text-decoration: none; }
.link-btn:hover { color: var(--accent-dark); text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.input, .field input, .field select, .field textarea { min-height: 44px; padding: 10px 12px; border: 1px solid var(--field); border-radius: 10px; background: #fff; font-weight: 400; font-size: 16px; width: 100%; }
.field textarea, textarea.input { resize: vertical; min-height: 90px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
.grid-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.req { color: var(--muted); font-weight: 400; }

.switch { width: 56px; height: 32px; flex: none; border: none; border-radius: 999px; background: #A8A296; padding: 3px; display: flex; cursor: pointer; transition: background .15s; }
.switch span { width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: var(--accent); }
.switch.on span { transform: translateX(24px); }
.switch.admin.on { background: var(--admin); }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.toggle-row:first-child { border-top: 1px solid var(--line); }
.toggle-row .t { font-weight: 700; }
.toggle-row .d { font-size: 14px; color: var(--muted); }

.seg { display: inline-flex; background: #EFEBE3; border-radius: 999px; padding: 4px; }
.seg button { min-height: 40px; padding: 0 20px; border: none; border-radius: 999px; background: transparent; font-weight: 700; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.seg.admin { background: #E6E2EE; }
.seg.admin button[aria-pressed="true"] { background: var(--admin); }

table.data td:first-child { min-width: 150px; }
table.data td.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; min-width: 210px; }
.chip { white-space: nowrap; display: inline-flex; align-items: center; font-size: 13px; padding: 4px 10px; border-radius: 999px; font-weight: 700; background: var(--sand); color: var(--ink-2); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.solid { background: var(--accent); color: #fff; }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.danger { background: #FBEDEA; color: var(--danger); }
.chip.outline { background: #fff; border: 1px solid #DDD7CC; font-size: 12px; padding: 3px 8px; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 15px; }
.alert.error { background: #FBEDEA; color: #7D2A1E; }
.alert.ok { background: var(--accent-soft); color: var(--accent-dark); }
.alert.info { background: var(--sand); color: var(--ink-2); }

/* ---------- books ---------- */
.cover { border-radius: 6px; background: #2F4858; color: #F4F1EA; overflow: hidden; display: flex; align-items: flex-end; flex: none; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover .ph { padding: 12px; font-family: var(--display); font-size: 14px; line-height: 1.2; }
.book-title, .card .book-title { font-family: var(--display); font-size: 30px; line-height: 1.15; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 22px; }
.book-grid.wide { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 24px; }
.book-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); }
.book-card:hover { color: var(--ink); }
.book-card:hover .cover { box-shadow: 0 6px 18px rgba(30,43,42,.2); }
.book-card .cover { width: 100%; aspect-ratio: 2 / 3; transition: box-shadow .15s; }
.book-card .t { font-weight: 700; line-height: 1.25; }
.book-card .a { font-size: 14px; color: var(--muted); }
.book-card.boxed { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }

.stars { display: inline-flex; gap: 2px; align-items: center; }
.star-btn { width: 40px; height: 44px; padding: 0; border: none; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.star-btn:hover svg path { filter: brightness(.95); }

/* ---------- comments ---------- */
.comment { display: flex; gap: 12px; }
.comment + .comment { border-top: 1px solid var(--line-2); padding-top: 14px; }
.comment .meta { font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.comment .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { background: var(--accent-tint); border: 1px solid #D4E4E1; border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.avatar { border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- meetings ---------- */
.meet-btn { display: flex; justify-content: space-between; gap: 10px; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; text-align: left; cursor: pointer; width: 100%; }
.meet-btn:hover { background: var(--accent-tint); }
.meet-btn.past { color: var(--muted); }
.meet-open { border: 2px solid var(--accent); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--accent-tint); }
.meet-open .head { display: flex; justify-content: space-between; font-weight: 700; gap: 10px; }
.meet-open ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.meet-row { border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- members ---------- */
.bubble { display: flex; gap: 12px; align-items: flex-start; }
.bubble .b { background: var(--sand); border-radius: 4px 14px 14px 14px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.roster { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.roster li { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; }
.roster li.lead { border: 2px solid var(--accent); }
.roster li.dragging { opacity: .5; }
.roster li.over { box-shadow: 0 -3px 0 var(--accent); }
.roster .grip { cursor: grab; color: #8A8F8D; display: flex; }
.roster .pos { width: 26px; font-weight: 700; color: var(--muted); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; background: var(--ink); padding: 64px 16px; display: flex; flex-direction: column; align-items: center; gap: 28px; }
.auth .logo { font-family: var(--display); font-size: 40px; font-weight: 700; color: var(--sand); }
.auth-card { width: 100%; max-width: 460px; background: var(--ground); border-radius: 20px; padding: 36px; display: flex; flex-direction: column; gap: 18px; }
.auth-card.wide { max-width: 540px; }
.auth-card h1 { font-family: var(--display); font-size: 28px; }
.toggle-box { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }

/* ---------- admin ---------- */
.admin-main { background: #F3F2EF; }
.club-item { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; gap: 12px; align-items: center; }
.club-item.sel { border: 2px solid var(--admin); }
.club-item .pick { flex: 1; min-width: 0; border: none; background: none; text-align: left; padding: 0; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 15px; }
table.data th { text-align: left; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.data td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.req-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.req-card dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 20px; }
.req-card dt { font-size: 13px; color: var(--muted); }
.req-card dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.req-action { background: var(--admin-soft); border-radius: 10px; padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }

.modal-back { position: fixed; inset: 0; background: rgba(38,33,58,.55); display: flex; align-items: flex-start; justify-content: center; padding: 64px 16px; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 580px; background: #fff; border-radius: 20px; padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.modal h2 { font-family: var(--display); font-size: 26px; }
.radio-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.radio-card.sel { border: 2px solid var(--admin); }
.radio-card input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--admin); }

.empty { padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--field); border-radius: 12px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.skeleton { color: var(--muted); padding: 24px 0; }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(92vw, 440px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 15px; }
.toast.error { background: #7D2A1E; }

/* ---------- small screens ---------- */
@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .nav { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; gap: 2px; }
  .brand { padding: 0 8px; font-size: 20px; flex-basis: 100%; }
  .brand-sub { display: none; }
  .club-pick { margin: 6px 0; flex-basis: 100%; }
  .nav-link { width: auto; padding: 10px 12px; }
  .nav-sep { display: none; }
  .main { padding: 20px 16px 48px; }
  .page-title { font-size: 28px; }
  .card { padding: 18px; }
  .auth-card { padding: 24px; }
  .modal { padding: 22px; }
}
