
:root {
  --paper: #f3eee4;
  --card: #fffdf8;
  --ink: #221c14;
  --muted: #6c6257;
  --line: #e4d8c6;
  --sage: #2f6f5e;
  --sage-dark: #1f4d41;
  --peach: #c45c26;
  --again: #b42318;
  --hard: #b54708;
  --good: #2f6f5e;
  --easy: #1d4e89;
  --shadow: 0 12px 40px rgba(34, 28, 20, 0.08);
  --radius: 18px;
  --sans: "Avenir Next", "Segoe UI", ui-rounded, system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 500px at 10% -10%, #efe4cf 0%, transparent 50%),
    radial-gradient(900px 400px at 100% 0%, #e4efe8 0%, transparent 46%),
    var(--paper);
  color: var(--ink);
  line-height: 1.45;
}

a { color: var(--sage-dark); }
a:hover { color: var(--peach); }

.wrap { width: min(980px, calc(100% - 32px)); margin: 0 auto; padding: 20px 0 64px; }
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 28px;
}
.brand { display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.brand strong { font-family: var(--serif); font-size: 1.55rem; letter-spacing: -0.02em; }
.brand span { color: var(--muted); font-size: 0.82rem; }
.nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.who { color: var(--muted); font-size: 0.92rem; }

h1, h2, h3 { font-family: var(--serif); letter-spacing: -0.02em; margin: 0 0 10px; }
h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); }
p { margin: 0 0 12px; color: var(--muted); }
.lede { font-size: 1.05rem; max-width: 42rem; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card.interactive { text-decoration: none; color: inherit; display: block; transition: transform .15s ease, border-color .15s ease; }
.card.interactive:hover { transform: translateY(-2px); border-color: #cfc0a8; }
.kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; color: var(--muted); margin-bottom: 6px; }
.signin-as {
  margin-top: 6px;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ink);
}
.signin-as code, .field-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: #efe8dc;
  padding: 1px 6px;
  border-radius: 6px;
}
.field-hint { font-size: 0.85rem; color: var(--muted); margin: 0 0 4px; }
.due { display: inline-flex; align-items: center; gap: 6px; background: #eaf4ef; color: var(--sage-dark); border-radius: 999px; padding: 4px 10px; font-size: .85rem; font-weight: 650; }
.due.zero { background: #efe8dc; color: var(--muted); }
.meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

label { display: block; font-weight: 650; margin: 12px 0 6px; }
input, textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid #d7cbb8; background: #fff; color: var(--ink);
  font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 3px solid #cfe3da; border-color: var(--sage); }

.btn, button.btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 11px 16px; border-radius: 12px;
  background: var(--sage); color: #fff; font: inherit; font-weight: 700;
  text-decoration: none; min-height: 46px;
}
.btn:hover { background: var(--sage-dark); }
.btn.secondary { background: #efe6d6; color: var(--ink); }
.btn.secondary:hover { background: #e4d8c4; }
.btn.ghost { background: transparent; color: var(--sage-dark); }
.btn.danger { background: #b42318; }
.btn.danger:hover { background: #8f1b13; }
.btn.wide { width: 100%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.flash { border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.flash.error { background: #fdecea; color: #7a150f; }
.flash.ok { background: #e8f5ee; color: #1c4a3c; }
.flash.warn { background: #fff4e5; color: #7a3e06; }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th { text-align: left; color: var(--muted); font-weight: 650; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; }
td, th { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }

.study-card {
  min-height: 280px; display: flex; flex-direction: column; justify-content: center;
  text-align: center; padding: 32px 20px; cursor: pointer; user-select: none;
}
.study-card .prompt { font-family: var(--serif); font-size: clamp(2rem, 7vw, 3.2rem); line-height: 1.15; }
.study-card .answer { font-size: clamp(1.4rem, 4vw, 2rem); margin-top: 16px; }
.study-card .notes { margin-top: 10px; color: var(--muted); }
.study-pic {
  display: block;
  width: 256px;
  max-width: 72%;
  height: auto;
  object-fit: contain;
  margin: 16px auto 0;
  border-radius: 14px;
  background: #efe8dc;
}
.study-pic[hidden] { display: none; }
.hint { text-align: center; color: var(--muted); margin: 8px 0 18px; }
.ratings { display: none; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ratings.is-open { display: grid; }
@media (min-width: 640px) { .ratings { grid-template-columns: repeat(4, 1fr); } }
.rate { min-height: 64px; border: 0; border-radius: 14px; color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.rate[data-r="again"] { background: var(--again); }
.rate[data-r="hard"] { background: var(--hard); }
.rate[data-r="good"] { background: var(--good); }
.rate[data-r="easy"] { background: var(--easy); }
.progress { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; color: var(--muted); }
.audio-row { display: flex; justify-content: center; margin: 8px 0 16px; }
.dir-toggle { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 8px 12px; font: inherit; cursor: pointer;
}
.chip.on { background: var(--sage); color: #fff; border-color: var(--sage); }

.check-list { display: grid; gap: 8px; }
.check-list label { display: flex; gap: 10px; align-items: center; font-weight: 550; margin: 0; }
.check-list input { width: auto; }

.badge { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: .78rem; font-weight: 700; }
.badge.ok { background: #e8f5ee; color: #1c4a3c; }
.badge.miss { background: #efe8dc; color: #6c6257; }
.badge.off { background: #fdecea; color: #7a150f; }

.empty { text-align: center; padding: 36px 12px; }
.footer-note { margin-top: 28px; font-size: .85rem; color: var(--muted); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); }

@media (max-width: 640px) {
  .site-header { flex-direction: column; align-items: stretch; }
  .nav { justify-content: flex-start; }
  td .actions { flex-direction: column; }
}
