:root {
  --bg: #f4efe4;
  --card: #fffaf0;
  --ink: #2f2a24;
  --muted: #7a6f62;
  --moss: #4f6b4a;
  --moss-soft: #dfe7d6;
  --bark: #8a6a48;
  --alarm: #c4553d;
  --line: #e4dccb;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1d1a;
    --card: #262823;
    --ink: #ece6da;
    --muted: #a59c8e;
    --moss: #8fb084;
    --moss-soft: #2f3a2c;
    --bark: #c9a77c;
    --alarm: #e07a62;
    --line: #36382f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 560px; margin: 0 auto; padding: 24px 16px 110px; }
h1 { font-size: 30px; margin: 0; letter-spacing: -0.02em; }
.muted { color: var(--muted); margin: 4px 0 0; }
header { margin-bottom: 24px; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

/* record button */
.rec {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  width: 220px; height: 220px; margin: 24px auto 12px;
  border-radius: 50%; border: none;
  background: var(--moss); color: #fff;
  box-shadow: 0 10px 30px rgb(79 107 74 / 0.35);
  transition: transform 0.15s ease, background 0.2s ease;
}
.rec:active { transform: scale(0.97); }
.rec-dot { width: 22px; height: 22px; border-radius: 50%; background: #fff; }
.rec.recording { background: var(--alarm); box-shadow: 0 10px 30px rgb(196 85 61 / 0.4); }
.rec.recording .rec-dot { border-radius: 5px; animation: breathe 1.6s ease-in-out infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-size: 15px; opacity: 0.9; min-height: 1.2em; }
@keyframes breathe { 50% { transform: scale(0.8); opacity: 0.7; } }

.upload { display: block; text-align: center; color: var(--bark); font-size: 15px; text-decoration: underline; cursor: pointer; margin-bottom: 28px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 14px; }
.pile h2, .group h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 10px; }
.pile ul { list-style: none; margin: 0; padding: 0; }
.pile li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.pile li:first-child { border-top: none; }
.pile h2.sub { margin-top: 18px; }
.pile .explain { margin: -4px 0 8px; font-size: 15px; }
.memo-head { display: flex; align-items: center; gap: 10px; }
.memo-when { flex: 1; }
.memo .said { margin: 6px 0 0; font-style: italic; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.memo .made { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.play { flex: none; width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--moss-soft); color: var(--moss); font-size: 13px; line-height: 1; }
.play:focus-visible { outline: 2px solid var(--moss); outline-offset: 2px; }
.memo.fresh { animation: fresh 2.4s ease-out; border-radius: 10px; }
@keyframes fresh { from { background: var(--moss-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .memo.fresh { animation: none; } }
.pill { font-size: 13px; padding: 2px 9px; border-radius: 999px; background: var(--moss-soft); color: var(--moss); }
.pill.failed { background: rgb(196 85 61 / 0.15); color: var(--alarm); }
.ghost { background: none; border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; color: var(--muted); }

/* one toast for every screen, above the tabs */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 14px; width: min(528px, calc(100% - 32px));
  padding: 10px 16px; border-radius: 14px; background: var(--ink); color: var(--bg);
  font-size: 15px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.18); z-index: 10;
}
.toast #toast-text { flex: 1; }
.toast button.link { color: var(--bg); font-weight: 600; }

/* morning */
.payoff-big { font-size: 22px; color: var(--moss); font-weight: 600; }
.group { margin-bottom: 22px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: start; }
.item .title { font-weight: 600; }
.item .detail { grid-column: 1; color: var(--muted); font-size: 15px; }
.item .when { grid-column: 1; font-size: 14px; color: var(--bark); }
.item .actions { grid-column: 2; grid-row: 1 / span 3; display: flex; flex-direction: column; gap: 6px; }
.item .actions button, .item .actions a {
  border: none; border-radius: 10px; padding: 7px 12px; font-size: 14px; text-align: center; text-decoration: none;
  background: var(--moss-soft); color: var(--moss);
}
.item .actions .no { background: transparent; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* weekly review */
.review { border-color: var(--moss); background: color-mix(in srgb, var(--moss-soft) 45%, var(--card)); margin-bottom: 26px; }
.review .headline { font-size: 18px; margin: 0 0 10px; }
.review .one-thing { margin: 0 0 12px; }
.review h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 14px 0 6px; }
.review ul { margin: 0; padding-left: 18px; }
.review li { margin: 4px 0; }
.review .cites { color: var(--muted); font-size: 14px; }

/* search */
.search { display: flex; gap: 8px; margin-bottom: 18px; }
.search input {
  flex: 1; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
}
.search button, #sign-in {
  border: none; border-radius: 14px; padding: 12px 18px; background: var(--moss); color: #fff;
}
#sign-in { width: 100%; margin: 18px 0 10px; }
.said { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* tabs */
nav {
  position: fixed; inset: auto 0 0 0; display: flex; justify-content: center; gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
nav button {
  flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; padding: 6px; border-radius: 12px; font-size: 20px; color: var(--muted);
}
nav button span { font-size: 12px; }
nav button[aria-current="page"] { color: var(--moss); background: var(--moss-soft); }

.small { font-size: 0.85rem; }
.quota { font-size: 0.85rem; }
.meter { display: grid; grid-template-columns: 8.5rem 1fr 6.5rem; gap: 0.5rem; align-items: center; margin: 0.4rem 0; }
.meter .muted { text-align: right; font-size: 0.85rem; }
.meter progress { width: 100%; height: 0.6rem; accent-color: var(--moss); }
#me:empty { display: none; }
#me h2 { margin-top: 0; }
#me .actions { margin-top: 0.8rem; display: flex; flex-wrap: wrap; gap: 8px; }
#me .actions button { border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; background: transparent; }
#me .actions .no { color: #a34a3a; border-color: currentColor; }
.login-error { color: #a34a3a; font-size: 0.9rem; }
.whoami { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted);
  padding: 6px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.whoami #whoami-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whoami .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--moss); flex: none; }
button.link { background: none; border: none; padding: 0; color: var(--moss); text-decoration: underline; font-size: inherit; }

.boot { text-align: center; padding: 30vh 0; }
.how { margin: 22px 0 6px; padding-left: 22px; }
.how li { margin: 10px 0; }
.back { display: inline-block; margin-bottom: 14px; font-size: 15px; }
.trouble p { margin: 0 0 10px; }
.empty p { margin: 0; }
.empty .small { margin-top: 10px; }
h2.section { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 8px 0 10px; }
.results-head { color: var(--muted); font-size: 15px; margin: 0 0 10px; }
.memory-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.memory-head .title { font-weight: 600; }
.memory-head .pill { flex: none; }
.memory .when { font-size: 14px; color: var(--bark); margin-top: 4px; }
#results:not(:empty) { margin-bottom: 18px; }
