/* ==========================================================================
   Clinkup — forest green + lime, dark by design.
   Mobile-first: every rule targets a phone, with a couple of min-width
   bumps for tablets and desktops. Safe-area insets keep the chrome clear
   of the iPhone notch and home indicator.
   ========================================================================== */

:root {
  /* Brand palette, carried over from the Android app's theme. */
  --lime:        #8bc34a;
  --lime-dim:    #6f9f3a;
  --lime-soft:   #c8e6a0;
  --cream:       #f4ecdb;
  --bg:          #08231c;
  --surface:     #0e2a23;
  --surface-hi:  #173a31;
  --ink:         #e8efe3;
  --ink-muted:   #aec1b3;
  --outline:     #3a5249;
  --on-lime:     #06210b;

  --danger:      #ef5350;
  --danger-dim:  #7f2420;
  --warn:        #ffb74d;
  --info:        #4fc3f7;

  --radius:      16px;
  --radius-sm:   10px;
  --radius-pill: 999px;

  --gap:         16px;
  --tabbar-h:    58px;

  --shadow: 0 2px 8px rgb(0 0 0 / 0.35);
  --shadow-lg: 0 12px 32px rgb(0 0 0 / 0.45);

  /* Safe areas: 0 on anything that isn't a notched iPhone. */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;   /* iOS: don't reflow text on rotate */
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  /* Stop the whole page rubber-banding on iOS while inner lists scroll. */
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 1em; }
a  { color: var(--lime); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--lime); color: var(--on-lime);
  padding: .75rem 1rem; border-radius: 0 0 var(--radius-sm) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* Visible keyboard focus everywhere; pointer users never see it. */
:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- top bar -------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap);
  padding: calc(var(--safe-top) + 10px) calc(var(--safe-right) + var(--gap))
           10px calc(var(--safe-left) + var(--gap));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--outline);
}

.brand { display: flex; align-items: center; gap: .55rem; color: var(--cream); }
.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--cream); color: var(--bg);
  font-weight: 800; font-size: 1.15rem;
}
.brand-word { font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; }
.brand-up { color: var(--lime); }

.topbar-actions { display: flex; align-items: center; gap: .35rem; }
.inline { display: inline; margin: 0; }

.icon-btn {
  display: grid; place-items: center;
  min-width: 44px; min-height: 44px;   /* Apple's minimum touch target */
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-muted);
  font-size: 1.15rem; cursor: pointer;
}
.icon-btn:hover, .icon-btn:active { background: var(--surface-hi); color: var(--ink); text-decoration: none; }

/* --- layout --------------------------------------------------------------- */

main {
  padding: var(--gap) calc(var(--safe-right) + var(--gap))
           var(--gap) calc(var(--safe-left) + var(--gap));
  max-width: 760px;
  margin: 0 auto;
}
/* Clear the fixed tab bar plus the home indicator. */
main.has-tabbar { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px); }

.page { display: block; }
.page-narrow { max-width: 420px; margin: 0 auto; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap); margin-bottom: var(--gap); flex-wrap: wrap;
}
.page-head h1 { margin: 0; }

.section { margin: 0 0 28px; }
.section-title {
  display: flex; align-items: center; gap: .5rem;
  font-size: .78rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-muted); margin: 0 0 10px;
}
.section-title .count {
  background: var(--surface-hi); color: var(--lime-soft);
  border-radius: var(--radius-pill); padding: 1px 8px; font-size: .78rem; letter-spacing: 0;
}

.stack { display: flex; flex-direction: column; gap: 12px; }

/* --- cards ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: var(--gap);
}
.card + .card { margin-top: 12px; }
.card-link { display: block; color: inherit; }
.card-link:hover { text-decoration: none; border-color: var(--lime-dim); background: var(--surface-hi); }

.card-row {
  display: flex; align-items: center; gap: 12px;
}
.card-body { flex: 1; min-width: 0; }
.card-title { font-weight: 700; margin: 0; }
.card-sub { color: var(--ink-muted); font-size: .88rem; margin: 2px 0 0; }

/* Truncate long names instead of letting them blow out the row. */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- avatars -------------------------------------------------------------- */

.avatar {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-hi);
  border: 1px solid var(--outline);
}
.avatar-fallback {
  display: grid; place-items: center;
  color: var(--lime-soft); font-weight: 700; font-size: .95rem;
}
.avatar.lg { width: 76px; height: 76px; font-size: 1.5rem; }
.avatar.sm { width: 32px; height: 32px; font-size: .75rem; }

/* --- buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 46px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  font: inherit; font-weight: 650; text-align: center;
  cursor: pointer;
  transition: transform .06s ease, background-color .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.975); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn-primary { background: var(--lime); color: var(--on-lime); }
.btn-primary:hover { background: var(--lime-soft); }

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--outline); }
.btn-ghost:hover { background: var(--surface-hi); }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger-dim); }
.btn-danger:hover { background: var(--danger-dim); color: var(--ink); }

.btn-sm { min-height: 38px; padding: 0 14px; font-size: .88rem; }
.btn-block { display: flex; width: 100%; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; }

/* --- forms ---------------------------------------------------------------- */

.field { margin-bottom: 16px; }
.field label, .label {
  display: block; margin-bottom: 6px;
  font-size: .88rem; font-weight: 650; color: var(--ink-muted);
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="url"], textarea, select {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  font: inherit;
  /* 16px minimum stops iOS Safari zooming in when a field takes focus. */
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }

input:focus, textarea:focus, select:focus {
  border-color: var(--lime);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lime) 25%, transparent);
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--ink-muted) 70%, transparent); }

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
                    linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

.hint { font-size: .82rem; color: var(--ink-muted); margin: 6px 0 0; }

/* Bot decoy. Moved off-screen rather than display:none, because some bots skip
   fields that are explicitly hidden. It stays focusable-in-theory but is removed
   from the tab order and from the accessibility tree by aria-hidden. */
.hp-field {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* File picker: the native control is unstyleable, so style the field around it
   and restyle only the button, which every current browser exposes. */
input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--ink-muted);
  border: 1px dashed var(--outline);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
}
input[type="file"]:hover { border-color: var(--lime-dim); }
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-hi);
  color: var(--lime-soft);
  font: inherit;
  font-size: .88rem;
  font-weight: 650;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--lime); color: var(--on-lime); }

.check {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--outline); border-radius: var(--radius-sm);
  cursor: pointer;
}
.check input[type="checkbox"] {
  flex: 0 0 auto; width: 22px; height: 22px; margin: 1px 0 0;
  accent-color: var(--lime);
}
.check span { font-size: .92rem; }

.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1; min-width: 0; }

/* Sport picker: wrapping chips, no experimental layout APIs needed. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* A full sport list wraps to ~230px on a phone — a third of the viewport, pushing
   the actual content below the fold. Filter rows (as opposed to the multi-select
   picker on the profile form) become a single swipeable strip instead. */
@media (max-width: 599px) {
  .chips-scroll {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    /* Bleed to the screen edges so the strip reads as scrollable. */
    margin-inline: calc(-1 * var(--gap));
    padding-inline: var(--gap);
    padding-bottom: 2px;
  }
  .chips-scroll::-webkit-scrollbar { display: none; }
  .chips-scroll .chip { flex: 0 0 auto; scroll-snap-align: start; }
}
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--outline); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--ink);
  font-size: .9rem; cursor: pointer; user-select: none;
}
.chip:hover { border-color: var(--lime-dim); text-decoration: none; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip.is-on, .chip:has(input:checked) {
  background: var(--lime); color: var(--on-lime); border-color: var(--lime); font-weight: 650;
}
.chip:has(input:focus-visible) { outline: 3px solid var(--lime); outline-offset: 2px; }

/* --- place search --------------------------------------------------------- */

.place-field { position: relative; }

.place-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  margin: 0; padding: 4px;
  list-style: none;
  background: var(--surface-hi);
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 260px; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.place-result {
  display: flex; flex-direction: column; gap: 1px;
  padding: 9px 10px; border-radius: 8px;
  cursor: pointer;
  /* Comfortably tappable without being a full 44px row in a long list. */
  min-height: 40px;
}
.place-result:hover, .place-result.is-active { background: var(--lime); color: var(--on-lime); }
.place-name { font-size: .94rem; font-weight: 600; }
.place-detail {
  font-size: .76rem; color: var(--ink-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.place-result:hover .place-detail, .place-result.is-active .place-detail { color: var(--on-lime); opacity: .75; }

/* --- badges & meta -------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--surface-hi); color: var(--lime-soft);
  font-size: .76rem; font-weight: 650; white-space: nowrap;
}
.badge-lime   { background: var(--lime); color: var(--on-lime); }
.badge-win    { background: color-mix(in srgb, var(--lime) 22%, transparent); color: var(--lime); }
.badge-loss   { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.badge-draw   { background: var(--surface-hi); color: var(--ink-muted); }
.badge-warn   { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }

.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.meta-dot { color: var(--ink-muted); font-size: .85rem; }

/* --- stats ---------------------------------------------------------------- */

.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.stat {
  background: var(--surface); border: 1px solid var(--outline);
  border-radius: var(--radius-sm); padding: 12px 6px; text-align: center;
}
.stat-value { font-size: 1.3rem; font-weight: 750; line-height: 1.1; }
.stat-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-muted); margin-top: 3px;
}

.rating-badge {
  display: inline-flex; flex-direction: column; align-items: center;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--surface-hi); min-width: 74px;
}
.rating-value { font-size: 1.25rem; font-weight: 750; color: var(--lime); line-height: 1; }
.rating-tier { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-muted); margin-top: 3px; }

/* --- leaderboard ---------------------------------------------------------- */

.rank-row { display: flex; align-items: center; gap: 12px; padding: 11px var(--gap); }
.rank-row + .rank-row { border-top: 1px solid var(--outline); }
.rank-row.is-me { background: color-mix(in srgb, var(--lime) 10%, transparent); }

.rank-num {
  flex: 0 0 auto; width: 30px; text-align: center;
  font-weight: 750; color: var(--ink-muted); font-variant-numeric: tabular-nums;
}
.rank-1 .rank-num, .rank-2 .rank-num, .rank-3 .rank-num { color: var(--lime); font-size: 1.05rem; }

.list-card { padding: 0; overflow: hidden; }

/* --- swipe deck ----------------------------------------------------------- */

.deck { position: relative; margin: 8px 0 20px; }

.swipe-card {
  background: linear-gradient(160deg, var(--surface-hi), var(--surface));
  border: 1px solid var(--outline);
  border-radius: 22px;
  padding: 26px var(--gap);
  text-align: center;
  box-shadow: var(--shadow-lg);
  /* Let the browser handle vertical scrolling; JS only claims horizontal drags. */
  touch-action: pan-y;
  will-change: transform;
}
.swipe-card.is-gone { transition: transform .28s ease, opacity .28s ease; opacity: 0; }

.swipe-name { font-size: 1.45rem; font-weight: 750; margin: 14px 0 2px; }
.swipe-bio { color: var(--ink-muted); margin: 10px 0 0; font-size: .95rem; }

.swipe-actions { display: flex; gap: 14px; justify-content: center; margin-top: 20px; }
.swipe-btn {
  width: 66px; height: 66px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.6rem; border: 2px solid var(--outline);
  background: var(--surface); cursor: pointer;
  transition: transform .08s ease;
}
.swipe-btn:active { transform: scale(.92); }
.swipe-btn.pass { color: var(--danger); border-color: var(--danger-dim); }
.swipe-btn.like { color: var(--lime); border-color: var(--lime-dim); }

.deck-count { text-align: center; color: var(--ink-muted); font-size: .85rem; margin-top: 14px; }

/* "It's a match!" banner */
.match-pop {
  background: linear-gradient(135deg, var(--lime), var(--lime-dim));
  color: var(--on-lime);
  border-radius: var(--radius); padding: var(--gap);
  text-align: center; margin-bottom: var(--gap);
  animation: pop .35s ease;
}
.match-pop h2 { margin: 0 0 4px; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* --- score entry ---------------------------------------------------------- */

.score-entry { display: flex; align-items: flex-end; gap: 12px; }
.score-entry .field { flex: 1; margin: 0; }
.score-entry input { text-align: center; font-size: 1.5rem; font-weight: 700; min-height: 62px; }
.score-vs { padding-bottom: 18px; color: var(--ink-muted); font-weight: 700; }

/* --- tournament bracket --------------------------------------------------- */

/* On a phone the rounds stack vertically, which stays readable at 390px; from
   tablet width up they become side-by-side columns for the classic bracket
   shape, scrolling horizontally when there are many rounds. */
.bracket { display: flex; flex-direction: column; gap: 22px; }

.bracket-round-title {
  font-size: .78rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-muted); margin: 0 0 10px;
}

.bracket-match {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.bracket-match + .bracket-match { margin-top: 10px; }
.bracket-match.is-mine { border-color: var(--lime-dim); }
.bracket-match.is-done { opacity: .82; }

.bracket-side {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 5px 0; font-size: .94rem;
}
.bracket-side + .bracket-side { border-top: 1px dashed var(--outline); }
.bracket-side.is-winner { color: var(--lime); font-weight: 700; }
/* An empty side: a bye, or a place still to be decided. */
.bracket-blank { color: var(--ink-muted); font-style: italic; font-size: .86rem; }

.bracket-score { font-variant-numeric: tabular-nums; color: var(--ink-muted); min-width: 1.5em; text-align: right; }
.bracket-side.is-winner .bracket-score { color: var(--lime); }

.bracket-report { margin-top: 10px; }
.bracket-report summary {
  cursor: pointer; font-size: .85rem; color: var(--lime); min-height: 24px;
}
.bracket-report .score-entry input { min-height: 48px; font-size: 1.15rem; }

@media (min-width: 700px) {
  .bracket {
    flex-direction: row;
    gap: 18px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }
  .bracket-round { flex: 0 0 240px; }
  /* Space matches out so each round lines up roughly with its feeder pair. */
  .bracket-round + .bracket-round { justify-content: space-around; }
}

/* --- flash messages ------------------------------------------------------- */

.flash-stack {
  position: sticky; top: calc(var(--safe-top) + 56px); z-index: 25;
  padding: 0 calc(var(--safe-right) + var(--gap)) 0 calc(var(--safe-left) + var(--gap));
  max-width: 760px; margin: 12px auto 0;
  display: flex; flex-direction: column; gap: 8px;
}
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--outline); background: var(--surface);
  box-shadow: var(--shadow); font-size: .92rem;
  animation: slide-in .2s ease;
  /* Long dev links must wrap rather than overflow the card. */
  overflow-wrap: anywhere;
}
.flash span { flex: 1; }
.flash-success { border-color: var(--lime-dim); background: color-mix(in srgb, var(--lime) 14%, var(--surface)); }
.flash-error   { border-color: var(--danger-dim); background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.flash-info    { border-color: var(--outline); }
.flash-close {
  flex: 0 0 auto; border: 0; background: none; color: var(--ink-muted);
  font-size: 1.25rem; line-height: 1; cursor: pointer; padding: 0 2px; min-width: 28px;
}
@keyframes slide-in { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- empty states --------------------------------------------------------- */

.empty { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 2.6rem; margin-bottom: 10px; }
.empty-title { margin: 0 0 6px; }
.empty-body { color: var(--ink-muted); margin: 0 auto 18px; max-width: 34ch; }

/* --- bottom tab bar ------------------------------------------------------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);     /* sits above the iPhone home indicator */
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--outline);
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--ink-muted); font-size: .68rem; font-weight: 600;
}
.tab:hover { text-decoration: none; }
.tab-icon { font-size: 1.25rem; line-height: 1; }
.tab.is-active { color: var(--lime); }

/* Six tabs on a 390px phone leaves ~65px each. Tighten the label so it never
   wraps or truncates; the icon carries most of the recognition anyway. */
@media (max-width: 420px) {
  .tab-label { font-size: .62rem; letter-spacing: -.01em; }
  .tab-icon  { font-size: 1.15rem; }
}

/* --- landing page --------------------------------------------------------- */

.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { font-size: 2.1rem; letter-spacing: -.02em; }
.hero .lead { color: var(--ink-muted); font-size: 1.05rem; max-width: 36ch; margin: 0 auto 26px; }

.feature-grid { display: grid; gap: 12px; margin: 28px 0; }
.feature { display: flex; gap: 12px; align-items: flex-start; }
.feature-icon { font-size: 1.5rem; flex: 0 0 auto; }
.feature h3 { margin: 0 0 2px; font-size: 1rem; }
.feature p { margin: 0; color: var(--ink-muted); font-size: .9rem; }

/* --- help / documentation ------------------------------------------------- */

.help-toc {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--outline);
}
.help-toc a {
  padding: 7px 13px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  font-size: .86rem;
}
.help-toc a:hover { border-color: var(--lime-dim); text-decoration: none; background: var(--surface-hi); }

.help-section { margin: 0 0 36px; }
/* Offset for the sticky top bar, so an anchor jump doesn't hide the heading. */
.help-section { scroll-margin-top: 76px; }
.help-section h2 {
  font-size: 1.2rem;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--lime);
  display: inline-block;
}
.help-section h3 { font-size: .98rem; color: var(--lime-soft); margin: 22px 0 8px; }
.help-section p { color: var(--ink); }

.help-list { margin: 0 0 1em; padding-left: 1.2em; }
.help-list li { margin-bottom: .55em; }
.help-list li::marker { color: var(--lime); }

.help-note {
  background: var(--surface);
  border-left: 3px solid var(--lime);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 11px 14px;
  color: var(--ink-muted);
  font-size: .92rem;
}

/* --- tables (admin) ------------------------------------------------------- */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--outline); }
th { color: var(--ink-muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }

details.disclosure { border: 1px solid var(--outline); border-radius: var(--radius-sm); padding: 12px var(--gap); background: var(--surface); }
details.disclosure + details.disclosure { margin-top: 10px; }
details.disclosure summary { cursor: pointer; font-weight: 650; min-height: 24px; }
details.disclosure[open] summary { margin-bottom: 12px; }

.danger-zone { border-color: var(--danger-dim); }

/* --- wider screens -------------------------------------------------------- */

@media (min-width: 600px) {
  h1 { font-size: 1.9rem; }
  .feature-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid { gap: 12px; }
}

@media (min-width: 900px) {
  /* Tab bar moves off the bottom edge and becomes a centred pill. */
  .tabbar {
    left: 50%; right: auto; bottom: 20px;
    transform: translateX(-50%);
    width: min(560px, calc(100% - 40px));
    height: var(--tabbar-h);
    padding-bottom: 0;
    border: 1px solid var(--outline);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-lg);
  }
  main.has-tabbar { padding-bottom: calc(var(--tabbar-h) + 48px); }
}

/* --- touch devices -------------------------------------------------------- */

/* Apple's minimum touch target is 44px. Chips and small buttons sit just under
   that, which is fine for a mouse but fiddly with a thumb — so grow them only
   where the primary pointer is coarse, leaving desktop density unchanged. */
@media (pointer: coarse) {
  .chip     { min-height: 44px; padding: 0 16px; }
  .btn-sm   { min-height: 44px; }
  .brand    { min-height: 44px; }
  .flash-close { min-width: 44px; min-height: 44px; }
}

/* --- respect user preferences --------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .topbar, .tabbar, .flash-stack, .btn { display: none !important; }
  body { background: #fff; color: #000; }
}
