:root {
  --bg: #faf8f6;
  --surface: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --brand: #b45309;
  --brand-soft: #fef3c7;
  --brand-dark: #92400e;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28,25,23,.06), 0 8px 24px rgba(28,25,23,.06);
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --nav: #ffffffcc;
}
html[data-theme="dark"] {
  --bg: #1c1917;
  --surface: #292524;
  --ink: #fafaf9;
  --muted: #a8a29e;
  --line: #44403c;
  --brand: #fbbf24;
  --brand-soft: #78350f;
  --brand-dark: #fde68a;
  --accent: #5eead4;
  --accent-soft: #134e4a;
  --danger: #fca5a5;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  --nav: #292524ee;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #fde68a55, transparent 60%),
    radial-gradient(900px 400px at 100% 0%, #99f6e455, transparent 55%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.5;
}
body.has-tabs { padding-bottom: 92px; }
html[data-theme="dark"] body {
  background:
    radial-gradient(1200px 500px at 10% -10%, #78350f66, transparent 60%),
    radial-gradient(900px 400px at 100% 0%, #134e4a66, transparent 55%),
    var(--bg);
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 0; gap: 1rem;
}
.logo {
  font-family: var(--font); font-size: 1.25rem; font-weight: 600;
  color: var(--ink); letter-spacing: -0.02em; text-decoration: none;
}
.logo span { color: var(--brand); }
.nav-links { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid transparent; border-radius: 999px;
  padding: .55rem 1.1rem; font-weight: 600; font-size: .95rem;
  cursor: pointer; text-decoration: none; background: var(--brand); color: white;
  font-family: inherit;
}
html[data-theme="dark"] .btn { color: #1c1917; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] .btn.secondary { color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink); }
html[data-theme="dark"] .btn.ghost { color: var(--ink); }
.btn.small { padding: .35rem .8rem; font-size: .85rem; }
.who-name { font-size: .9rem; color: var(--muted); }
.desktop-nav { display: none; }
.nav-sec {
  color: var(--muted); font-weight: 600; font-size: .9rem; padding: .2rem .15rem;
}
.nav-sec.active { color: var(--ink); }
.nav-sec:hover { text-decoration: none; color: var(--brand-dark); }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem;
}
.hero { padding: 2rem 0 1.5rem; }
.hero h1, h1 {
  font-family: var(--font); font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.15; letter-spacing: -0.03em; margin: 0 0 .75rem;
}
.sub, .lead, .muted { color: var(--muted); }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
input, textarea, select {
  width: 100%; padding: .7rem .85rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid #fcd34d; border-color: #f59e0b;
}
.field { margin-bottom: 1rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; max-width: 440px; }
.error {
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
  padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem;
}
.success {
  background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0;
  padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem;
}
html[data-theme="dark"] .error { background: #450a0a; color: #fecaca; border-color: #7f1d1d; }
html[data-theme="dark"] .success { background: #064e3b; color: #a7f3d0; border-color: #065f46; }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.chip {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow);
}
.chip b { display: block; font-family: var(--font); font-size: 1.4rem; }
.chip small { color: var(--muted); }
.bar, .progress { height: 8px; background: #f5f5f4; border-radius: 999px; overflow: hidden; margin-top: .4rem; }
html[data-theme="dark"] .bar { background: #44403c; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.chip.warn .bar > i { background: var(--brand); }
.due {
  background: linear-gradient(180deg, #fffbeb, var(--surface));
  border: 1px solid #fde68a; border-radius: var(--radius);
  padding: 1rem 1.25rem; margin: 0 0 1rem; font-family: var(--font);
}
html[data-theme="dark"] .due { background: #292524; border-color: #78350f; }
.timeline { display: flex; flex-direction: column; gap: .75rem; }
.row {
  display: grid; grid-template-columns: 64px 1fr; gap: .75rem; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .85rem 1rem;
}
.row time { color: var(--muted); font-size: .85rem; }
.tag { font-size: .75rem; font-weight: 700; color: var(--accent); }
.note { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.pad, .mama, .mother { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.pad button, .mama button, .mother button {
  min-height: 64px; border-radius: var(--radius); border: 1px solid var(--line);
  font: inherit; font-weight: 700; cursor: pointer; background: var(--surface); color: var(--ink);
}
.pad .l, .pad .r { background: var(--brand-soft); color: var(--brand-dark); border-color: #fde68a; }
.pad .f, .pad .p { background: var(--accent-soft); color: var(--accent); border-color: #99f6e4; }
html[data-theme="dark"] .pad .l, html[data-theme="dark"] .pad .r { border-color: #92400e; }
html[data-theme="dark"] .pad .f, html[data-theme="dark"] .pad .p { border-color: #0f766e; }
.footer {
  margin-top: 4rem; padding: 2rem 0; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .9rem;
}
.footer-inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; }
.cedar { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); }
.cedar:hover { color: var(--brand-dark); text-decoration: none; }
.cedar svg { width: 2rem; height: 2rem; color: #b45309; }
nav.bottom {
  position: fixed; left: 12px; right: 12px; bottom: 12px;
  background: var(--nav); border: 1px solid var(--line); border-radius: 20px;
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px;
  box-shadow: var(--shadow); backdrop-filter: blur(8px);
  z-index: 20;
}
nav.bottom a {
  text-align: center; text-decoration: none; color: var(--muted);
  font-size: 12px; padding: 10px 0; font-weight: 700;
}
nav.bottom a.active { color: var(--ink); }
.rule-group { font-weight: 700; margin: 1.1rem 0 .2rem; }
.rules { list-style: none; padding: 0; margin: 0 0 1rem; max-width: 40rem; }
.rules li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: .75rem;
  align-items: start;
  padding: .7rem 0;
  border-bottom: 1px solid var(--line);
}
.rules .check { margin: 0; }
.rule-when { color: var(--muted); font-size: .85rem; white-space: nowrap; text-align: right; min-width: 7.5rem; padding-top: .15rem; }
.rule-actions { display: flex; gap: .35rem; justify-content: flex-end; }
.rule-edit {
  grid-column: 1 / -1;
  display: grid;
  gap: .65rem;
  max-width: 28rem;
  padding: .35rem 0 .2rem;
}
.rule-edit label { margin: 0; }
.rule-note { display: block; color: var(--muted); font-weight: 500; font-size: .8rem; }
.print-row { margin: .75rem 0 0; }
.rules-form { max-width: 40rem; }
@media (max-width: 520px) {
  .rules li { grid-template-columns: minmax(0, 1fr) auto; }
  .rule-when { white-space: normal; min-width: 0; }
}
.check { display: flex; gap: .5rem; align-items: flex-start; }
.check input { width: auto; }
.import-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.import-list li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.import-row.is-dup { opacity: .85; }
.import-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; margin: .5rem 0 0 1.6rem; }
.import-raw { white-space: pre-wrap; font-size: .85rem; background: var(--surface); border: 1px solid var(--line); padding: .75rem; border-radius: 10px; overflow-x: auto; }
.hero.tight { padding: .75rem 0 .5rem; }
.hero.tight h1 { font-size: 1.7rem; margin-bottom: .25rem; }
.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;
}
.review-form { max-width: none; }
.review-board { display: grid; gap: .75rem; align-items: start; }
.review-raw h2, .review-parsed h2 { margin: 0 0 .4rem; font-size: 1rem; }
.review-log {
  max-height: 32vh; overflow: auto; font-size: .8rem; line-height: 1.35;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .35rem .45rem;
}
.review-line { display: block; padding: .08rem .25rem; border-radius: 4px; white-space: pre-wrap; }
.review-line.is-parsed { background: var(--accent-soft); }
.review-line.is-miss { box-shadow: inset 3px 0 var(--danger); }
.review-line:target, .review-line.is-hit { background: var(--brand-soft); }
.review-list { list-style: none; padding: 0; margin: 0 0 .75rem; }
.review-item { position: relative; padding: .28rem 0 .28rem; border-bottom: 1px solid var(--line); }
.review-item.is-dup { opacity: .72; }
.review-row {
  display: flex; align-items: center; gap: .4rem; min-width: 0; padding-right: 2.4rem;
}
.review-time {
  flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 700; font-size: .85rem;
  color: var(--ink); text-decoration: none;
}
.review-time:hover { text-decoration: none; color: var(--brand-dark); }
.review-tz { margin-left: .2rem; font-size: .65rem; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.review-what {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600; font-size: .92rem; color: var(--ink); text-decoration: none;
}
.review-flags { flex: 0 0 auto; font-size: .7rem; font-weight: 700; color: var(--muted); }
.review-item.is-miss .review-flags { color: var(--danger); }
.review-edit summary {
  position: absolute; top: .32rem; right: 0; cursor: pointer;
  font-size: .78rem; font-weight: 700; color: var(--brand-dark); list-style: none;
}
.review-edit summary::-webkit-details-marker { display: none; }
.review-edit summary::marker { content: ""; }
.review-more { margin: .35rem 0 .15rem 1.6rem; }
.review-comment { margin-bottom: .35rem; }
.review-comment input, .review-fields input, .review-fields select { padding: .4rem .55rem; }
.review-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .5rem; }
.review-actions { display: flex; gap: .5rem; align-items: center; margin-top: .75rem; }
@media (min-width: 800px) {
  .import-grid { grid-template-columns: 1fr 1fr; }
  .review-board {
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    width: min(1180px, calc(100vw - 2.5rem));
    margin-left: calc(50% - min(590px, 50vw - 1.25rem));
  }
  .review-raw { position: sticky; top: .75rem; }
  .review-log { max-height: calc(100vh - 11rem); }
}
h2 { font-family: var(--font); font-size: 1.35rem; margin: 1.5rem 0 .75rem; }
@media (max-width: 640px) {
  .hero { padding: .5rem 0 1rem; }
  .hero h1, h1 { font-size: 1.7rem; }
  .nav { flex-wrap: wrap; gap: .5rem; }
  .pad button, .mama button, .mother button { min-height: 52px; font-size: .9rem; }
  h2 { font-size: 1.15rem; margin: 1rem 0 .5rem; }
  .pad, .mama, .mother { gap: .5rem; }
}
@media (min-width: 800px) {
  body.has-tabs { padding-bottom: 0; }
  nav.bottom { display: none; }
  .desktop-nav { display: inline-flex; gap: 1rem; align-items: center; margin-right: .5rem; }
  .chips { grid-template-columns: repeat(4, 1fr); }
  .pad { grid-template-columns: repeat(4, 1fr); }
  .mama, .mother { grid-template-columns: repeat(4, 1fr); }
  .hero { padding-top: 2.25rem; }
}
.pager {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  margin: 1rem 0 1.5rem; font-weight: 700;
}
.pager a { text-decoration: none; }
