/* ReadQuest — calm, single-accent design system */
:root {
  --page: #f4f5f7;
  --surface: #ffffff;
  --ink: #18212f;
  --muted: #5d6676;
  --faint: #8a93a3;
  --line: #e2e5ea;
  --line-strong: #cfd4dc;
  --accent: #1e6b57;
  --accent-ink: #ffffff;
  --accent-soft: #e6f1ed;
  --warn: #9a5b0b;
  --warn-soft: #fbf1e2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --child: #1e6b57;
  --radius: 10px;
  --radius-sm: 7px;
  --font: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --shadow-pop: 0 18px 50px rgba(24, 33, 47, .18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  font-feature-settings: 'tnum' 1;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; line-height: 1.2; }
h2 { font-size: 1.125rem; line-height: 1.3; }
h3 { font-size: 1rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 20px;
  height: 60px; display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.brand-mark { width: 26px; height: 26px; }
.brand-family { color: var(--muted); font-weight: 500; padding-left: 12px; border-left: 1px solid var(--line); }
.topbar-spacer { flex: 1; }
.profile-chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 5px 12px 5px 5px; cursor: pointer; font-weight: 550;
}
.profile-chip:hover { border-color: var(--line-strong); }
.profile-chip .switch { color: var(--muted); font-weight: 450; font-size: .875rem; padding-left: 8px; margin-left: 2px; border-left: 1px solid var(--line); }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--c, var(--accent)); color: #fff; font-weight: 700; font-size: .8rem; flex: none;
}
.avatar.lg { width: 64px; height: 64px; font-size: 1.5rem; }
.avatar.parent { background: var(--ink); }

/* ---------- layout ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 20px 96px; }
.narrow { max-width: 720px; margin: 0 auto; }
.stack > :not(:first-child) { margin-top: 28px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap-row { flex-wrap: wrap; }
.page-head { margin-bottom: -8px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 28px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; border: 0; background: none; cursor: pointer;
  padding: 10px 14px; color: var(--muted); font-weight: 550; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab[aria-current='page'] { color: var(--ink); border-bottom-color: var(--ink); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: .75rem; font-weight: 700; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-pad { padding: 20px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

/* list rows */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list > li { padding: 14px 18px; display: flex; align-items: center; gap: 14px; }
.list > li + li { border-top: 1px solid var(--line); }
.list .title { font-weight: 600; }
.list .meta { color: var(--muted); font-size: .875rem; }
.list button.rowlink { all: unset; cursor: pointer; display: flex; align-items: center; gap: 14px; width: 100%; }
.list button.rowlink:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: #f8f9fa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #185a49; }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: #eef0f3; color: var(--ink); }
.btn.sm { height: 32px; padding: 0 12px; font-size: .875rem; }
.btn.lg { height: 52px; padding: 0 24px; font-size: 1.0625rem; border-radius: var(--radius); }
.btn.block { width: 100%; }

/* ---------- forms ---------- */
.field { display: block; }
.field + .field, .field + .field-row, .field-row + .field, .field-row + .field-row { margin-top: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.label .opt { color: var(--faint); font-weight: 450; }
.hint { color: var(--muted); font-size: .825rem; margin-top: 6px; }
.input, select.input, textarea.input {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
}
textarea.input { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.error-text { color: var(--danger); font-size: .875rem; margin-top: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { appearance: none; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; height: 32px; padding: 0 14px; cursor: pointer; font-weight: 550; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.switch-row { display: flex; align-items: flex-start; gap: 14px; cursor: pointer; }
.switch-row input { appearance: none; flex: none; width: 40px; height: 24px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; margin: 2px 0 0; transition: background .15s; }
.switch-row input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch-row input:checked { background: var(--accent); }
.switch-row input:checked::after { transform: translateX(16px); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { appearance: none; width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255,255,255,.0); }
.swatch[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: var(--ink); color: #e9edf3; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .brand { color: #fff; }
.auth-side h1 { font-size: 2.25rem; max-width: 15ch; color: #fff; }
.auth-side p { color: #b9c1cd; max-width: 40ch; margin-top: 14px; font-size: 1.05rem; }
.auth-shelf { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin-top: 40px; }
.auth-shelf span { width: 22px; border-radius: 3px 3px 1px 1px; background: var(--c); opacity: .95; }
.auth-main { display: grid; place-items: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-switch { margin-top: 20px; color: var(--muted); font-size: .925rem; }
.linkbtn { all: unset; color: var(--accent); font-weight: 600; cursor: pointer; }
.linkbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- profile picker ---------- */
.picker { text-align: center; padding-top: 32px; }
.picker h1 { margin-bottom: 8px; }
.people { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin-top: 36px; }
.person {
  appearance: none; border: 1px solid var(--line); background: var(--surface); border-radius: 14px;
  width: 150px; padding: 24px 12px 18px; cursor: pointer; display: grid; justify-items: center; gap: 12px; font-weight: 600;
}
.person:hover { border-color: var(--line-strong); box-shadow: 0 6px 20px rgba(24,33,47,.06); }
.person .sub { color: var(--muted); font-weight: 450; font-size: .825rem; margin-top: -8px; }

/* ---------- the shelf (signature element) ---------- */
.shelf-wrap { padding: 24px 24px 18px; }
.shelf {
  position: relative; display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 10px;
  height: 170px; padding: 0 4px; border-bottom: 3px solid var(--ink);
}
.shelf.sm { height: 56px; gap: 4px; border-bottom-width: 2px; padding: 0; }
.spine {
  position: relative; height: var(--h); min-height: 4px; border-radius: 4px 4px 1px 1px;
  background: var(--child); transform-origin: bottom;
}
.spine::after { /* spine bands */
  content: ''; position: absolute; left: 0; right: 0; top: 14%; height: 6%; min-height: 2px; background: rgba(255,255,255,.28);
}
.shelf.sm .spine::after { display: none; }
.spine.blank { background: transparent; border: 1.5px dashed var(--line-strong); border-bottom: 0; height: 18px; }
.shelf.sm .spine.blank { height: 6px; }
.spine.future { background: transparent; height: 0; }
.spine.today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--child); }
.spine.grow { animation: grow .7s cubic-bezier(.2,.8,.2,1) both; }
@keyframes grow { from { transform: scaleY(.05); } }
.goal-line { position: absolute; left: -4px; right: -4px; bottom: var(--g); border-top: 1.5px dashed var(--muted); pointer-events: none; }
.shelf-legend { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-size: .825rem; color: var(--muted); }
.shelf-legend .key { display: inline-flex; align-items: center; gap: 8px; }
.shelf-legend .key::before { content: ''; width: 18px; border-top: 1.5px dashed var(--muted); }
.shelf-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; margin-top: 8px; padding: 0 4px; text-align: center; font-size: .8rem; color: var(--muted); }
.shelf-days .is-today { color: var(--ink); font-weight: 700; }
.shelf-days small { display: block; color: var(--faint); font-size: .75rem; }

.today-line { font-size: 1.25rem; font-weight: 600; margin-top: 18px; }
.today-line .big { font-size: 2.25rem; font-weight: 700; letter-spacing: -0.02em; margin-right: 4px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 14px; color: var(--muted); }
.facts b { color: var(--ink); font-weight: 650; }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: .925rem; }
.notice.ok { background: var(--accent-soft); color: var(--accent); }

/* progress bar */
.bar { height: 6px; background: #edf0f3; border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; width: var(--p); background: var(--child, var(--accent)); border-radius: inherit; }

.status { display: inline-block; font-size: .75rem; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: #edf0f3; color: var(--muted); }
.status.pending { background: var(--warn-soft); color: var(--warn); }
.status.approved, .status.finished { background: var(--accent-soft); color: var(--accent); }
.status.rejected { background: var(--danger-soft); color: var(--danger); }

.points-num { font-size: 2.5rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.cost { font-weight: 650; white-space: nowrap; }
.delta-pos { color: var(--accent); font-weight: 650; }
.delta-neg { color: var(--danger); font-weight: 650; }

/* parent overview rows */
.reader-row { display: grid; grid-template-columns: minmax(160px, 1.2fr) minmax(140px, 1fr) repeat(3, minmax(80px, .6fr)) auto; gap: 20px; align-items: center; }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-val { font-weight: 650; font-size: 1.05rem; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .925rem; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: .825rem; background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }

/* ---------- dialog ---------- */
dialog {
  border: 0; padding: 0; border-radius: 14px; width: min(480px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop);
}
dialog::backdrop { background: rgba(24, 33, 47, .45); }
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.dlg-body { padding: 18px 20px 4px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 20px 20px; }
.x { all: unset; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 1.4rem; line-height: 1; }
.x:hover { background: #eef0f3; color: var(--ink); }

.pin-input { letter-spacing: .6em; text-align: center; font-size: 1.5rem; height: 56px; font-weight: 700; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 550;
  box-shadow: var(--shadow-pop); opacity: 0; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* mobile action bar */
.fab-bar { display: none; }

.loading { padding: 80px 0; text-align: center; color: var(--muted); }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 20px; }
  .auth-side h1 { font-size: 1.6rem; }
  .auth-shelf { height: 56px; margin-top: 20px; }
  .auth-side .foot { display: none; }
  .reader-row { grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
  .reader-row .name-cell { grid-column: 1 / 3; grid-row: 1; }
  .reader-row .act-cell { grid-column: 3; grid-row: 1; justify-self: end; }
  .reader-row .shelf-cell { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .topbar-inner { padding: 0 16px; }
  .brand-family { display: none; }
  .wrap { padding: 20px 16px 110px; }
  h1 { font-size: 1.5rem; }
  .shelf { height: 130px; gap: 7px; }
  .shelf-days { gap: 7px; }
  .shelf-wrap { padding: 18px 16px 14px; }
  .field-row { grid-template-columns: 1fr; }
  .list > li { padding: 12px 14px; }
  .person { width: calc(50% - 8px); }
  .hide-sm { display: none; }
  .fab-bar {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--page) 70%, rgba(244,245,247,0));
  }
  .hide-mobile-cta { display: none; }
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92vh; }
  th, td { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
