:root {
  --bg: #f4f6f1;
  --card: #ffffff;
  --text: #1d2a1f;
  --muted: #5f6d61;
  --line: #d9e0d5;
  --brand: #2f6b3a;
  --brand-text: #ffffff;
  --ok-bg: #e3f3e3;
  --ok: #1f6a2b;
  --warn-bg: #fff4d6;
  --warn: #7a5600;
  --err-bg: #fde6e4;
  --err: #a1261b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121712;
    --card: #1b221c;
    --text: #e7ede5;
    --muted: #9fac9f;
    --line: #2e392f;
    --brand: #5aa868;
    --brand-text: #0d130e;
    --ok-bg: #173a1d;
    --ok: #9fdcaa;
    --warn-bg: #3b3013;
    --warn: #f1d27c;
    --err-bg: #43191a;
    --err: #f3a9a2;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 480px; margin: 0 auto; padding: 24px 16px 48px; }
main.wide { max-width: 1000px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}
label { display: block; font-weight: 600; margin: 14px 0 6px; }
label:first-child { margin-top: 0; }
label small { font-weight: 400; color: var(--muted); }
input, textarea {
  width: 100%;
  font: inherit;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { min-height: 70px; resize: vertical; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  padding: 13px 18px;
  cursor: pointer;
  background: var(--brand);
  color: var(--brand-text);
}
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--err); color: var(--card); }
button.small { padding: 6px 10px; font-size: 0.85rem; }
button:disabled { opacity: 0.5; cursor: default; }
.full { width: 100%; margin-top: 20px; }
.msg { border-radius: 10px; padding: 12px 14px; margin-top: 16px; }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.err { background: var(--err-bg); color: var(--err); }
.hidden { display: none !important; }
.closed { text-align: center; padding: 40px 20px; }
.closed .icon { font-size: 3rem; }
.pill {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}
.pill.open { background: var(--ok-bg); color: var(--ok); }
.pill.shut { background: var(--err-bg); color: var(--err); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar select {
  font: inherit; padding: 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.notes { white-space: normal; min-width: 160px; }
th { color: var(--muted); font-weight: 600; }
tr.dup td { background: var(--warn-bg); }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; color: var(--muted); }
.stats b { color: var(--text); }

/* Progress, assigned tree, tree grid */
.progress { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.progress > div { height: 100%; background: var(--brand); width: 0; transition: width .3s; }
.progress-text { font-size: 0.9rem; color: var(--muted); }
.assigned {
  text-align: center;
  background: var(--ok-bg);
  color: var(--ok);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 4px;
}
.assigned .big { font-size: 2.6rem; font-weight: 800; line-height: 1.1; }
.tree-status { font-size: 0.9rem; margin-top: 6px; min-height: 1.3em; }
.tree-status.ok { color: var(--ok); }
.tree-status.warn { color: var(--warn); font-weight: 600; }
.link-btn { background: none; border: 0; color: var(--brand); padding: 6px 0; font-weight: 600; text-decoration: underline; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 5px; }
.grid span {
  text-align: center; font-size: 0.8rem; font-weight: 600; padding: 7px 0; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.grid span.done { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.grid span.dup { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); margin: 10px 0 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; border: 1px solid var(--line); background: var(--bg); }
.legend i.done { background: var(--ok-bg); border-color: transparent; }
.legend i.dup { background: var(--warn-bg); border-color: transparent; }
.session-item { display: block; width: 100%; text-align: left; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 10px; font-weight: 400; }
.session-item .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.session-item b { font-size: 1.05rem; }
.back { background: none; color: var(--brand); padding: 0; margin-bottom: 12px; }
@media (max-width: 600px) {
  body { font-size: 16px; }
  .card { padding: 16px; }
  .row.stack { flex-direction: column; gap: 0; }
}

/* Tap-to-choose buttons (reps, ratings, yes/no) */
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices label {
  margin: 0; font-weight: 600; font-size: 0.95rem;
  padding: 10px 14px; min-width: 48px; text-align: center;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); cursor: pointer;
}
.choices label { position: relative; }
.choices input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.choices input:checked + span { color: var(--brand-text); }
.choices label:has(input:checked) { background: var(--brand); border-color: var(--brand); color: var(--brand-text); }
.choices label:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.group-title {
  margin: 22px 0 0; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
}
.tree-info { font-size: 0.95rem; margin-top: 6px; }
.tree-info b { color: var(--text); }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.choices.scale { display: grid; gap: 6px; }
.choices.scale label { min-width: 0; padding: 12px 0; }

/* Small phones */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (max-width: 380px) {
  h1 { font-size: 1.25rem; }
  main { padding-left: 12px; padding-right: 12px; }
  .card { padding: 14px; }
}
