:root {
  --bg: #f4f5f2;
  --card: #ffffff;
  --text: #171a1d;
  --muted: #646b73;
  --line: #dfe2dd;
  --accent: #1f8f55;
  --accent-text: #ffffff;
  --done-bg: #e3f5ea;
  --danger: #b3372c;
  --warn-bg: #fdf0d8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1e2126;
    --text: #eef0f2;
    --muted: #9aa2ab;
    --line: #30353c;
    --accent: #7ee0a1;
    --accent-text: #0d2416;
    --done-bg: #1c3226;
    --danger: #ff8a7e;
    --warn-bg: #3a2f17;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
main {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(48px + env(safe-area-inset-bottom));
}

h1 { font-size: 1.6rem; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 28px 0 10px; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); font-size: 0.9rem; overflow-wrap: anywhere; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}
a.card { display: block; color: inherit; text-decoration: none; }
.card.done { background: var(--done-bg); border-color: transparent; }

button, .button {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
button.ghost, .button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
  font-weight: 500;
}
button.danger { background: transparent; color: var(--danger); border-color: var(--line); font-weight: 500; }
button:disabled { opacity: 0.5; cursor: default; }
button.small, .button.small { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; }

input[type=text], input[type=url], textarea, select {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 10px 0 4px; }
form button[type=submit] { margin-top: 14px; width: 100%; }
input[type=file].hidden { display: none; }

.badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--done-bg);
  color: var(--accent);
}
@media (prefers-color-scheme: light) { .badge { color: #17683e; } }

/* Exercise card */
.exercise { display: flex; gap: 12px; }
.thumb {
  flex: none;
  width: 84px;
  height: 112px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg) center / cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  padding: 4px;
  min-height: 0;
}
button.thumb { color: #fff; font-size: 1.6rem; text-shadow: 0 1px 6px #000; }
.step { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.exercise h3 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.actions { margin-top: 10px; }
.notice { background: var(--warn-bg); border-radius: 10px; padding: 8px 12px; margin-top: 10px; font-size: 0.9rem; }

details { margin-top: 10px; }
summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; padding: 6px 0; }
details.card > summary { color: var(--text); font-weight: 600; font-size: 1rem; padding: 0; }

/* Last 14 days */
.days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; margin-top: 12px; }
.day {
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--line);
  font-size: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.day.some { background: var(--accent); color: var(--accent-text); opacity: 0.55; }
.day.video { opacity: 1; }
.day.today { outline: 2px solid var(--text); outline-offset: 1px; }

video.inline { width: 100%; max-height: 70vh; border-radius: 10px; background: #000; margin: 10px 0; }

progress { width: 100%; margin-top: 8px; accent-color: var(--accent); }

dialog#player, dialog#upgrade, dialog#ask, dialog#feedback {
  border: none;
  border-radius: 14px;
  padding: 12px;
  background: var(--card);
  color: var(--text);
  width: min(94vw, 480px);
}
dialog#player::backdrop, dialog#upgrade::backdrop, dialog#ask::backdrop, dialog#feedback::backdrop { background: rgba(0, 0, 0, 0.75); }
dialog#player video { width: 100%; max-height: 72vh; border-radius: 10px; background: #000; display: block; }
dialog#player button, dialog#upgrade button, dialog#ask button, dialog#feedback button { width: 100%; margin-top: 10px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  max-width: 90vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
#toast.show { opacity: 1; }
[hidden] { display: none !important; }
a.goal-link { color: inherit; text-decoration: none; display: block; padding: 4px 0; }
dialog#upgrade h2, dialog#feedback h2 { margin: 4px 0 10px; font-size: 1.25rem; }
dialog#ask .message { margin: 6px 0 4px; font-size: 1.05rem; }
button.danger-solid { background: var(--danger); border-color: var(--danger); color: var(--bg); }
/* Example text in empty fields must read as a hint, not as something already typed in. */
::placeholder { color: var(--muted); opacity: 0.6; font-style: italic; }
input[type=range] { width: 100%; margin: 12px 0 2px; accent-color: var(--accent); }
details.help { margin-top: 6px; }
details.help p { margin: 10px 0 4px; }
details.help ol { margin: 0; padding-left: 22px; }
details.help li { margin: 2px 0; }
