/* ============================================================================
   RYTHM LEADERBOARD - VISUAL SYSTEM (v2)
   Inspired by Rythm Health's share-view aesthetic: light cream background,
   soft layered shadows, generous rounded corners, restrained type.
   ============================================================================ */

:root {
  /* surfaces */
  --bg:               #f7f7f5;
  --surface:          #ffffff;
  --surface-soft:     #fafaf9;
  --surface-input:    #ffffff;

  /* lines & ink */
  --line:             rgba(0, 0, 0, 0.06);
  --line-strong:      rgba(0, 0, 0, 0.10);
  --ink:              #0c0d10;
  --ink-soft:         #3d434f;
  --ink-muted:        #6a7180;
  --ink-faint:        #99a0ad;

  /* status colors */
  --st-optimal:       #135e6b;
  --st-optimal-soft: #cfeef3;
  --st-average:       #5d6573;
  --st-average-soft: #e2e4e8;
  --st-out:           #8c2c2c;
  --st-out-soft:     #f4d8d8;

  /* category accents (icon bg) */
  --cat-hormone:      #b29ed6;
  --cat-metabolic:    #5fb87a;
  --cat-heart:        #e8a9b5;

  /* shadows (layered, soft) */
  --shadow-card:
    0 1px 1px rgba(0,0,0,0.04),
    0 1px 4px rgba(0,0,0,0.04),
    0 4px 8px rgba(0,0,0,0.04),
    0 8px 24px rgba(0,0,0,0.04);
  --shadow-inner-card:
    0 1px 2px rgba(0,0,0,0.04),
    0 2px 8px rgba(0,0,0,0.03);

  /* type */
  --font:             'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  /* spacing tokens */
  --radius-lg:        24px;
  --radius-md:        16px;
  --radius-sm:        12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input { font-family: inherit; }

.hidden { display: none !important; }

/* ============================================================================
   HEADER
   ============================================================================ */
.site-header {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  display: grid; place-items: center;
}
.brand-name { font-weight: 600; }
.brand-sep { color: var(--ink-faint); font-weight: 400; }
.brand-tag { color: var(--ink-muted); font-weight: 400; }

.header-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-muted);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}
.status-dot.online  { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15); }
.status-dot.offline { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15); }

/* ============================================================================
   LAYOUT
   ============================================================================ */
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ============================================================================
   HERO
   ============================================================================ */
.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  align-items: center;
  gap: 32px;
  padding: 32px 8px;
}
.hero-title {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.025em;
}
.hero-sub {
  margin-top: 16px;
  color: var(--ink-soft);
  font-size: 16px;
  max-width: 480px;
  line-height: 1.55;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px 8px;
}
.stat { padding: 0 16px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: none; }
.stat-num {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
  letter-spacing: 0.01em;
}

/* ============================================================================
   CARDS
   ============================================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card-header {
  padding: 20px 28px 4px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.card-title {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.card-sub {
  font-size: 13px;
  color: var(--ink-muted);
}

/* ============================================================================
   SUBMIT FORM
   ============================================================================ */
.submit-body { padding: 20px 28px 28px; }

.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.text-input {
  width: 100%;
  background: var(--surface-input);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input::placeholder { color: var(--ink-faint); }
.text-input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}
.field-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-muted);
}

.submit-footer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.privacy-note {
  font-size: 12px;
  color: var(--ink-muted);
  max-width: 520px;
  line-height: 1.5;
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--ink);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: #000;
  transform: translateY(-1px);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* link-style button (text-only, underlined on hover) */
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.link-btn:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* ============================================================================
   MANUAL PASTE MODE
   ============================================================================ */
.manual-toggle-row {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  display: flex;
  justify-content: center;
}

.manual-section {
  margin-top: 20px;
  padding: 22px;
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
}

.manual-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.manual-title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.manual-sub {
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 4px;
  max-width: 540px;
  line-height: 1.5;
}

.manual-steps {
  margin: 0 0 16px 22px;
  padding: 0;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.75;
}
.manual-steps li { padding-left: 4px; }

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--ink-soft);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  line-height: 1.3;
  vertical-align: middle;
}

.text-area {
  width: 100%;
  min-height: 140px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.4;
  resize: vertical;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

/* warn variant for submit-msg (sits between success & error) */
.submit-msg.warn { background: #fff7ed; color: #9a3412; }

/* ============================================================================
   VERIFIED / MANUAL BADGE
   ============================================================================ */
.verify-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  vertical-align: 2px;
}
.verify-badge.manual {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.submit-msg {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.45;
}
.submit-msg.success { background: #ecfdf5; color: #065f46; }
.submit-msg.error   { background: #fef2f2; color: #991b1b; }

/* ============================================================================
   LEADERBOARD
   ============================================================================ */
.leaderboard { padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 8px; }

.lb-empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 14px;
}

.lb-row {
  display: grid;
  grid-template-columns: 56px 1fr auto auto 100px;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface-soft);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.lb-row:hover {
  background: #fff;
  box-shadow: var(--shadow-inner-card);
  border-color: var(--line);
  transform: translateY(-1px);
}
.lb-row.is-mine {
  background: #fffaf2;
  border-color: rgba(245, 158, 11, 0.25);
}

.lb-rank {
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.lb-rank.top-1 { color: #d4a017; font-weight: 700; }
.lb-rank.top-2 { color: #8a8d93; font-weight: 600; }
.lb-rank.top-3 { color: #c47a3d; font-weight: 600; }

.lb-who {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0;
}
.lb-handle {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-meta {
  font-size: 12px;
  color: var(--ink-muted);
}

.lb-mini-bar {
  display: flex;
  height: 6px;
  width: 140px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}
.lb-mini-bar > span { display: block; height: 100%; }
.lb-mini-bar .opt { background: var(--st-optimal); }
.lb-mini-bar .avg { background: var(--st-average); }
.lb-mini-bar .out { background: var(--st-out); }

.lb-score {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 72px;
}

.lb-action {
  font-size: 12px;
  color: var(--ink-muted);
  display: flex; align-items: center; gap: 4px;
  justify-content: flex-end;
}
.lb-row:hover .lb-action { color: var(--ink); }

/* ============================================================================
   DETAIL VIEW
   ============================================================================ */
.detail-view { display: flex; flex-direction: column; gap: 24px; padding: 8px 0; }

.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  width: fit-content;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink-soft);
  transition: all 0.15s;
}
.back-btn:hover { background: #fff; color: var(--ink); box-shadow: var(--shadow-inner-card); }

/* Hero card for the selected person */
.dv-header {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.dv-title { font-size: 28px; font-weight: 500; letter-spacing: -0.02em; }
.dv-sub   { font-size: 14px; color: var(--ink-muted); margin-top: 2px; }
.dv-score-block {
  display: flex; align-items: baseline; gap: 12px;
}
.dv-score-num {
  font-size: 48px; font-weight: 500;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.dv-score-label { font-size: 13px; color: var(--ink-muted); }

.dv-pct-row { display: flex; flex-wrap: wrap; gap: 24px; }
.dv-pct {
  display: flex; align-items: baseline; gap: 8px;
}
.dv-pct-num {
  font-size: 26px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.dv-pct.optimal .dv-pct-num    { color: var(--st-optimal); }
.dv-pct.average .dv-pct-num    { color: var(--st-average); }
.dv-pct.outOfRange .dv-pct-num { color: var(--st-out); }
.dv-pct-label { font-size: 14px; color: var(--ink-soft); }

.dv-cta {
  display: inline-flex; gap: 8px;
  background: var(--surface-soft);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  transition: all 0.15s;
}
.dv-cta:hover { background: #fff; color: var(--ink); box-shadow: var(--shadow-inner-card); }

/* Category section */
.dv-category {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 8px 12px 16px;
}
.dv-cat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 10px;
}
.cat-icon {
  width: 28px; height: 28px;
  border-radius: 999px;
  display: grid; place-items: center;
  color: #fff;
}
.cat-icon.hormone     { background: var(--cat-hormone); }
.cat-icon.metabolic   { background: var(--cat-metabolic); }
.cat-icon.heart       { background: var(--cat-heart); }
.cat-name { font-size: 17px; font-weight: 500; letter-spacing: -0.01em; }

.dv-status-group { margin: 0 4px 12px; }
.dv-status-header {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 16px 12px;
  margin: 0 8px;
  background: rgba(0, 0, 0, 0.025);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-bottom: none;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500;
}
.status-pill.optimal     { color: var(--st-optimal); }
.status-pill.average     { color: var(--st-average); }
.status-pill.outOfRange  { color: var(--st-out); }
.status-pill::before {
  content: ''; width: 10px; height: 10px; border-radius: 50%;
  background: currentColor;
}

.bio-grid {
  margin: 0 8px;
  padding: 8px 12px 16px;
  background: rgba(0, 0, 0, 0.025);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

/* Biomarker card */
.bio-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  box-shadow: var(--shadow-inner-card);
  display: flex; flex-direction: column;
  gap: 14px;
  min-height: 112px;
  justify-content: space-between;
}
.bio-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
}
.bio-name {
  font-size: 14px; font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.005em;
}
.bio-subtitle {
  font-size: 12px; color: var(--ink-muted);
  margin-top: 2px;
}
.bio-value-row {
  display: flex; align-items: baseline; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.bio-value {
  font-size: 14px; font-weight: 500;
  letter-spacing: -0.005em;
}
.bio-unit  {
  font-size: 12px; color: var(--ink-muted);
}

/* Range bar */
.range-bar {
  position: relative;
  height: 10px;
}
.range-bar-track {
  position: absolute; inset: 0;
  height: 8px;
  margin-top: 1px;
  border-radius: 999px;
  overflow: hidden;
}
.range-seg {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 999px;
  opacity: 0.18;
}
.range-seg.active { opacity: 1; }
.range-seg.optimal     { background: var(--st-optimal); }
.range-seg.average     { background: var(--st-average); }
.range-seg.outOfRange  { background: var(--st-out); }

.range-marker {
  position: absolute;
  top: -2px;
  width: 3px;
  height: 14px;
  background: var(--ink);
  border-radius: 999px;
  transform: translateX(-50%);
}

/* ============================================================================
   FOOTER
   ============================================================================ */
.site-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-muted);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; gap: 24px; padding: 16px 0; }
  .hero-stats { padding: 16px 0; }
  .stat { padding: 0 12px; }
  .stat-num { font-size: 24px; }
  .submit-footer { flex-direction: column; align-items: stretch; }
  .submit-footer .btn { width: 100%; justify-content: center; }
  .privacy-note { max-width: none; }
  .lb-row {
    grid-template-columns: 40px 1fr auto;
    gap: 12px;
  }
  .lb-mini-bar, .lb-action { display: none; }
  .lb-score { font-size: 18px; min-width: 56px; }
  .dv-header { flex-direction: column; align-items: flex-start; }
  .dv-pct-num { font-size: 22px; }
  .dv-score-num { font-size: 36px; }
  .site-footer { flex-direction: column; gap: 8px; text-align: center; }
}
