/* Sterling training app — shared styles (WP0, frozen).
   Feature modules add their own file (static/<blueprint>.css) and reuse these pieces. */
:root {
  --bg: #faf6ef; --card: #ffffff; --ink: #2a2520; --muted: #7a6f63; --line: #e8dfd2;
  --accent: #c8862a; --accent-ink: #ffffff; --accent-soft: #f7ead4;
  --good: #2f855a; --good-soft: #e3f3ea; --bad: #c53030; --bad-soft: #fde8e8;
  --warn: #b7791f; --warn-soft: #fdf3d7; --info: #2b6cb0; --info-soft: #e3eefa;
  --radius: 14px; --gap: 16px; --tap: 48px;
  --shadow: 0 1px 2px rgba(60, 40, 10, .06), 0 4px 14px rgba(60, 40, 10, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191613; --card: #25211c; --ink: #f1ebe2; --muted: #a89d8f; --line: #3a342c;
    --accent: #e0a445; --accent-ink: #1d1608; --accent-soft: #3a2e19;
    --good: #68d391; --good-soft: #1d3327; --bad: #fc8181; --bad-soft: #3d2020;
    --warn: #f6c35c; --warn-soft: #3a3018; --info: #7fb4ea; --info-soft: #1c2c3d;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 10px; }
small, .muted { color: var(--muted); }
.small { font-size: .875rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--gap) 0; }
ul.plain { list-style: none; margin: 0; padding: 0; }

/* ---- frame ---- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 10px var(--gap); padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.topbar .dogname { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--ink); }
.topbar .age { color: var(--muted); font-size: .85rem; }
.topbar .spacer { flex: 1; }
.wrap { max-width: 640px; margin: 0 auto; padding: var(--gap); }
.page-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.page-title h1 { margin: 0; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-size: .9rem; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--muted); font-size: .68rem; font-weight: 600;
}
.tabbar a .ico { font-size: 1.35rem; line-height: 1; filter: grayscale(.6); opacity: .75; }
.tabbar a.on { color: var(--accent); }
.tabbar a.on .ico { filter: none; opacity: 1; }

/* ---- flash ---- */
.flash { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-weight: 600; }
.flash.ok { background: var(--good-soft); color: var(--good); }
.flash.err { background: var(--bad-soft); color: var(--bad); }

/* ---- cards ---- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--gap); margin-bottom: var(--gap); box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.card.alert { border-color: var(--bad); background: var(--bad-soft); }
.card.good { border-color: var(--good); background: var(--good-soft); }
.card.tint { background: var(--accent-soft); border-color: transparent; }
a.card { display: block; text-decoration: none; color: inherit; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
  padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: 600 1rem var(--font); text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-good { background: var(--good); border-color: var(--good); color: #fff; }
.btn-bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { background: transparent; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); font-weight: 600; }
.btn-danger-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--bad); font-weight: 600; font-size: .9rem; cursor: pointer; }
.btn-big { min-height: 64px; font-size: 1.1rem; width: 100%; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .875rem; border-radius: 10px; }
@media (prefers-color-scheme: dark) { .btn-good, .btn-bad { color: #111; } }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > * { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---- forms ---- */
label.field, .field { display: block; margin-bottom: 14px; }
.field > .lbl, .lbl { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field .hint { display: block; color: var(--muted); font-size: .8rem; margin-top: 4px; }
input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=password],
input[type=tel], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: 1rem var(--font);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* chips: radio or checkbox inputs styled as pills */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; inset: 0; }
.chips span, .chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: .9rem; cursor: pointer;
  text-decoration: none; color: var(--ink);
}
.chips input:checked + span, .chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* segmented control: same markup as chips */
.segmented { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span, .segmented a {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 6px;
  font-weight: 600; font-size: .8rem; text-align: center; cursor: pointer; text-decoration: none; color: var(--ink);
  border-right: 1px solid var(--line);
}
.segmented label:last-child span, .segmented a:last-child { border-right: 0; }
.segmented input:checked + span, .segmented a.on { background: var(--accent); color: var(--accent-ink); }

/* number stepper (app.js wires the buttons) */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: var(--tap); height: var(--tap); border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 1.4rem; font-weight: 700; cursor: pointer; }
.stepper input { width: 84px; text-align: center; font-size: 1.25rem; font-weight: 700; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .unit { color: var(--muted); }

/* rating: five radio stars, highest first in the DOM so CSS can fill to the left */
.rating { display: inline-flex; flex-direction: row-reverse; gap: 4px; }
.rating input { position: absolute; opacity: 0; }
.rating label { font-size: 2.1rem; line-height: 1; color: var(--line); cursor: pointer; padding: 2px; }
.rating input:checked ~ label, .rating label:hover, .rating label:hover ~ label { color: var(--accent); }
.rating input:focus-visible + label { outline: 2px solid var(--accent); border-radius: 6px; }
.stars { color: var(--accent); letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: var(--line); }

/* ---- small pieces ---- */
.member { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px 2px 6px; border-radius: 999px;
  font-weight: 600; font-size: .875rem; background: color-mix(in srgb, var(--mc, var(--accent)) 16%, transparent);
  color: var(--ink); white-space: nowrap; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  background: var(--line); color: var(--ink); white-space: nowrap; }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.info { background: var(--info-soft); color: var(--info); }
.stage-not_started { background: var(--line); color: var(--muted); }
.stage-learning { background: var(--info-soft); color: var(--info); }
.stage-practicing { background: var(--warn-soft); color: var(--warn); }
.stage-proofing { background: var(--accent-soft); color: var(--accent); }
.stage-mastered { background: var(--good-soft); color: var(--good); }

.stats { display: flex; gap: 10px; }
.stat { flex: 1; text-align: center; padding: 10px 4px; border-radius: 12px; background: var(--bg); }
.stat b { display: block; font-size: 1.5rem; line-height: 1.1; }
.stat span { font-size: .75rem; color: var(--muted); }
.big-number { font-size: 2.2rem; font-weight: 800; line-height: 1.05; }

.progress { height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; min-width: 0; }
.progress.good > span { background: var(--good); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li, .list > a { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit; }
.list > li:last-child, .list > a:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.list .sub { color: var(--muted); font-size: .85rem; }
.list .chev { color: var(--muted); }

/* vertical bar chart: .bars > .bar[style="--h: 60%"] > i + span */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bars .bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.bars .bar i { display: block; width: 100%; height: var(--h, 0%); min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; }
.bars .bar.bad i { background: var(--bad); }
.bars .bar.good i { background: var(--good); }
.bars .bar span { font-size: .6rem; color: var(--muted); margin-top: 3px; white-space: nowrap; }
/* horizontal bars: .hbar > label + .progress + value */
.hbar { display: grid; grid-template-columns: 96px 1fr 32px; align-items: center; gap: 8px; margin-bottom: 8px; font-size: .875rem; }
.hbar .v { text-align: right; font-weight: 700; }

.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.empty .ico { font-size: 2rem; display: block; margin-bottom: 6px; }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.right { text-align: right; } .center { text-align: center; }
.mt { margin-top: var(--gap); } .mb0 { margin-bottom: 0; }
.steps { margin: 0; padding-left: 22px; } .steps li { margin-bottom: 8px; }
details > summary { cursor: pointer; font-weight: 600; min-height: 36px; }

/* ---- sign in ---- */
.login { max-width: 420px; margin: 0 auto; padding: 32px var(--gap); text-align: center; }
.login .hero { font-size: 4rem; line-height: 1; }
.who { display: grid; gap: 12px; margin-top: 24px; }
.who a { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); text-decoration: none;
  background: var(--card); border: 1px solid var(--line); color: var(--ink); font-size: 1.2rem; font-weight: 700;
  border-left: 8px solid var(--mc, var(--accent)); }
.who a .ico { font-size: 2rem; }
.pin { font-size: 2rem !important; letter-spacing: .5em; text-align: center; font-weight: 700; }
