/* Watergrade design system — Apple-inspired, mobile-first. */

:root {
  --tint: #12A5DC;
  --tint-deep: #0C7FB8;
  --ink: #1D1D1F;
  --ink-2: #6E6E73;
  --ink-3: #AEAEB2;
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --line: rgba(60, 60, 67, 0.12);
  --ok: #34C759;
  --warn: #FF9F0A;
  --bad: #FF3B30;
  --grade-a: #34C759;
  --grade-b: #8BC34A;
  --grade-c: #FF9F0A;
  --grade-d: #FF6B22;
  --grade-f: #FF3B30;
  --radius: 20px;
  --tabbar-h: 76px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
body.no-tabbar { padding-bottom: 0; }

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 20px 10px;
  background: rgba(245, 247, 250, 0.78);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
}
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.topbar .brand img { width: 26px; height: 26px; border-radius: 7px; }

/* ── Layout ── */
.page { max-width: 560px; margin: 0 auto; padding: 8px 20px 32px; }
.large-title { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; margin: 16px 0 4px; }
.subtitle { color: var(--ink-2); font-size: 15px; line-height: 1.45; margin-bottom: 18px; }
.section-label { font-size: 13px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; margin: 22px 4px 8px; }

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(13, 60, 88, 0.05);
  margin-bottom: 14px;
}
.card h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.card .muted { color: var(--ink-2); font-size: 14px; line-height: 1.5; }

/* ── Buttons ── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border: none; cursor: pointer;
  font: inherit; font-size: 17px; font-weight: 600;
  padding: 15px 20px; border-radius: 14px;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn-primary { background: var(--tint); color: #fff; }
.btn-secondary { background: rgba(18, 165, 220, 0.12); color: var(--tint-deep); }
.btn-plain { background: transparent; color: var(--tint-deep); }
.btn-google { background: var(--ink); color: #fff; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* ── Forms ── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin: 0 2px 6px; }
.field .hint { font-size: 12.5px; color: var(--ink-3); margin: 5px 2px 0; line-height: 1.4; }
.input, select.input {
  width: 100%; font: inherit; font-size: 17px;
  padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  outline: none; appearance: none; -webkit-appearance: none;
}
.input:focus { border-color: var(--tint); box-shadow: 0 0 0 3px rgba(18, 165, 220, 0.18); }

/* Segmented control (yes / no / untested) */
.segmented { display: flex; background: rgba(118, 118, 128, 0.12); border-radius: 11px; padding: 2px; }
.segmented button {
  flex: 1; border: none; background: transparent; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-2);
  padding: 9px 6px; border-radius: 9px; transition: all 0.15s ease;
}
.segmented button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,0.12); }

/* ── Grade badge ── */
.grade-badge {
  width: 128px; height: 128px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 64px; font-weight: 800; color: #fff; letter-spacing: -0.02em;
  margin: 0 auto;
  animation: gradePop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes gradePop { 0% { transform: scale(0.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.grade-a { background: var(--grade-a); box-shadow: 0 10px 30px rgba(52, 199, 89, 0.4); }
.grade-b { background: var(--grade-b); box-shadow: 0 10px 30px rgba(139, 195, 74, 0.4); }
.grade-c { background: var(--grade-c); box-shadow: 0 10px 30px rgba(255, 159, 10, 0.4); }
.grade-d { background: var(--grade-d); box-shadow: 0 10px 30px rgba(255, 107, 34, 0.4); }
.grade-f { background: var(--grade-f); box-shadow: 0 10px 30px rgba(255, 59, 48, 0.4); }
.grade-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  font-size: 21px; font-weight: 800; color: #fff;
}

/* ── Parameter result rows ── */
.param-row { border-bottom: 0.5px solid var(--line); padding: 12px 0; }
.param-row:last-child { border-bottom: none; }
.param-head { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.param-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-fail, .dot-severe { background: var(--bad); }
.dot-untested { background: var(--ink-3); }
.param-msg { flex: 1; font-size: 15px; font-weight: 500; line-height: 1.35; }
.param-chevron { color: var(--ink-3); font-size: 13px; transition: transform 0.2s ease; flex: none; }
.param-row.open .param-chevron { transform: rotate(90deg); }
.param-learn { display: none; margin: 10px 0 2px 21px; font-size: 14px; color: var(--ink-2); line-height: 1.55; }
.param-row.open .param-learn { display: block; }
.param-learn b { color: var(--ink); }
.param-learn p + p { margin-top: 7px; }

/* ── Progress ring ── */
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { transform: rotate(-90deg); }
.ring .track { stroke: rgba(118, 118, 128, 0.16); }
.ring .fill { stroke: var(--tint); stroke-linecap: round; transition: stroke-dashoffset 0.8s cubic-bezier(0.22, 1, 0.36, 1); }

/* ── Badges ── */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge-tile {
  background: var(--card); border-radius: 16px; padding: 14px 8px; text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.badge-tile .emoji { font-size: 30px; display: block; margin-bottom: 6px; }
.badge-tile .bname { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.badge-tile .bdesc { font-size: 11px; color: var(--ink-3); margin-top: 3px; line-height: 1.3; }
.badge-tile.locked { opacity: 0.4; filter: grayscale(1); }

/* ── Journey tiers ── */
.tier {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 0;
}
.tier .ticon {
  width: 48px; height: 48px; border-radius: 14px; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  background: rgba(18, 165, 220, 0.12);
}
.tier.current { outline: 2.5px solid var(--tint); }
.tier.locked { opacity: 0.55; }
.tier.locked .ticon { background: rgba(118, 118, 128, 0.12); }
.tier .tname { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.tier .tdesc { font-size: 13.5px; color: var(--ink-2); line-height: 1.45; margin-top: 3px; }
.tier-connector { width: 3px; height: 22px; background: var(--line); margin-left: 41px; border-radius: 2px; }
.pill {
  display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: 99px; text-transform: uppercase;
}
.pill-tint { background: rgba(18, 165, 220, 0.14); color: var(--tint-deep); }
.pill-done { background: rgba(52, 199, 89, 0.15); color: #1E8E3E; }
.pill-locked { background: rgba(118, 118, 128, 0.12); color: var(--ink-2); }

/* ── Bottom tab bar ── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none; color: var(--ink-3); font-size: 10.5px; font-weight: 600;
  padding: 4px 14px; border-radius: 12px;
}
.tabbar a .ticn { font-size: 23px; line-height: 1; }
.tabbar a.active { color: var(--tint-deep); }

/* ── Misc ── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px); transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 14.5px; font-weight: 600;
  padding: 12px 20px; border-radius: 99px; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.spinner {
  width: 26px; height: 26px; margin: 40px auto; border-radius: 50%;
  border: 3px solid rgba(18, 165, 220, 0.2); border-top-color: var(--tint);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
a { color: var(--tint-deep); }
