/* ALIGN — colors, spacing and type ported from ALIGN/Theme.swift */

:root {
  /* Brand */
  --green: #1B6B37;
  --green-soft: #9CCBAA;
  --green-pale: #CDE6D5;

  /* Surfaces */
  --background: #FFFFFF;
  --card: #EBEBEB;
  --card-inner: #F7F7F7;
  --track: #BDBDBD;
  --silhouette: #C7C7C7;
  --hairline: #D6D6D6;

  /* Posture zones */
  --zone-good: #5FB37A;
  --zone-fair: #D9CE4A;
  --zone-poor: #E39B3C;
  --zone-bad: #E05B54;

  /* Text */
  --ink: #4A4A4A;
  --ink-soft: #5E5E5E;
  --ink-muted: #6E6E6E;
  --ink-faint: #8A8A8A;

  --corner: 22px;
  --card-padding: 18px;
  --gutter: 16px;

  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system,
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  /* On wide screens the app sits on a soft field rather than filling the page. */
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(205, 230, 213, .5), transparent 60%),
    var(--background);
}

button { font: inherit; cursor: pointer; }
a { color: var(--green); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 10px 14px;
  background: var(--green);
  color: #fff;
  border-radius: 0 0 12px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 8px;
}

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

.shell {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--background);
  display: flex;
  flex-direction: column;
}

@media (min-width: 560px) {
  .shell {
    min-height: auto;
    margin: 28px auto 40px;
    border-radius: 30px;
    box-shadow: 0 18px 60px rgba(27, 107, 55, .12), 0 2px 8px rgba(0, 0, 0, .05);
    overflow: hidden;
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 10px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
}

.wordmark {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--green);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #000;
}
.icon-button:hover { background: rgba(0, 0, 0, .06); }

.page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px var(--gutter) calc(28px + env(safe-area-inset-bottom));
}

#cards { display: flex; flex-direction: column; gap: 14px; }

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

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--card-padding);
  background: var(--card);
  border-radius: var(--corner);
}

.card--bare { background: transparent; padding: 0 4px; }

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--green);
  margin: 0;
}

.card-subtitle {
  font-size: 10px;
  font-weight: 500;
  color: rgba(27, 107, 55, .75);
  margin: 2px 0 0;
}

.card-heading { display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- banners */

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px;
  border: 0;
  border-radius: var(--corner);
  text-align: left;
}

.banner--calibrate {
  background: var(--green);
  color: #fff;
}
.banner--calibrate:hover { background: #175c2f; }

.banner--connect {
  background: rgba(205, 230, 213, .6);
  color: var(--green);
  flex-wrap: wrap;
  row-gap: 12px;
  align-items: flex-start;
}

/* Icon and copy share the first row; the buttons take one of their own, so a
   third option doesn't crush the text into a column of single words. */
.banner--connect .banner-copy { flex: 1 1 200px; }
.banner--connect .banner-actions { flex: 1 1 100%; flex-wrap: wrap; }

.banner-copy { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.banner-title { font-size: 15px; font-weight: 700; }
.banner-detail { font-size: 11px; font-weight: 500; opacity: .85; }

.banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
.banner-actions .pill-button { padding: 9px 16px; }

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

.pill-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  background: var(--green);
  color: #fff;
}
.pill-button:hover { background: #175c2f; }
.pill-button:disabled { background: var(--track); cursor: default; }

.pill-button--ghost {
  background: transparent;
  color: var(--green);
  box-shadow: inset 0 0 0 1.4px var(--green);
}
.pill-button--ghost:hover { background: rgba(27, 107, 55, .08); }

.pill-button--wide { width: 100%; padding: 15px; font-size: 16px; font-weight: 700; }

.link-button {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
  text-align: left;
}
.link-button:hover { text-decoration: underline; }
.link-button--danger { color: var(--zone-bad); }

/* ---------------------------------------------------------------- streak */

.streak-row { display: flex; }

.streak-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.streak-day--future { opacity: .35; }

.streak-label { font-size: 11px; font-weight: 500; color: var(--green); }

.streak-dot {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1.6px solid var(--green);
  border-radius: 50%;
  background: transparent;
  color: var(--green);
}
.streak-dot--worn { background: var(--green-soft); }
.streak-dot svg { display: block; }

.streak-note {
  font-size: 11px;
  font-weight: 500;
  color: rgba(27, 107, 55, .8);
  margin: 0;
}

/* ---------------------------------------------------------------- angle */

.gauge { display: flex; flex-direction: column; align-items: center; padding-top: 12px; }
.gauge--idle .gauge-arc { opacity: .35; }
.gauge-arc { width: 100%; max-width: 300px; height: auto; display: block; }
/* Size comes from the SVG's own width/height so the calibration sheet can
   reuse it at 60px. */
.gauge-figure { margin-top: -6px; }

.verdict { display: flex; align-items: flex-start; gap: 8px; }
.verdict-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--track); margin-top: 5px; flex: none; }
.verdict-copy { display: flex; flex-direction: column; gap: 1px; }
.verdict-title { font-size: 15px; font-weight: 700; color: var(--green); }
.verdict-detail { font-size: 11px; font-weight: 500; color: var(--ink-muted); }

/* ---------------------------------------------------------------- progress */

.range-select {
  align-self: flex-start;
  border: 0;
  background: transparent;
  padding: 0 18px 0 0;
  margin-top: -6px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(27, 107, 55, .85);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%231B6B37' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
  background-size: 9px 6px;
}

.chart { display: flex; gap: 8px; align-items: stretch; margin-top: 6px; }
.chart-plot { flex: 1; min-width: 0; }
.chart-plot svg { width: 100%; height: auto; display: block; }

.chart-bands {
  width: 62px;
  display: flex;
  flex-direction: column;
}
.chart-band {
  flex: 1;
  display: flex;
  align-items: center;
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-muted);
}

.chart-axis { display: flex; padding-right: 70px; }
.chart-axis span { flex: 1; font-size: 10px; font-weight: 500; color: var(--ink-muted); text-align: center; }
.chart-axis span:first-child { text-align: left; }
.chart-axis span:last-child { text-align: right; }

.stat-row { display: flex; gap: 16px; margin-top: 2px; }
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat-value { font-size: 15px; font-weight: 700; color: var(--green); }
.stat-label { font-size: 10px; font-weight: 500; color: var(--ink-faint); }

.empty-note { font-size: 11px; font-weight: 500; color: var(--ink-faint); margin: 0; }

/* ---------------------------------------------------------------- lean */

.lean-arc { width: 100%; height: auto; display: block; margin-top: 6px; }
/* The two halves centre the numbers under the feet of the arch. */
.lean-legend { display: flex; font-size: 11px; font-weight: 500; color: var(--ink-muted); }
.lean-legend span { flex: 1; text-align: center; }

/* ---------------------------------------------------------------- pill selector */

.segmented {
  position: relative;
  display: flex;
  height: 40px;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 2px;
}

.segmented-knob {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: 999px;
  transition: transform .32s cubic-bezier(.2, .8, .3, 1), background-color .2s linear;
  pointer-events: none;
}

.segmented-option {
  position: relative;
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  z-index: 1;
}
.segmented--readonly .segmented-option { cursor: default; }

/* ---------------------------------------------------------------- rows */

.row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 600; }
.row-label { color: var(--ink-soft); }
.row-value { color: var(--green); }
.row-value--bad { color: var(--zone-bad); }

.divider { height: 1px; background: var(--hairline); border: 0; margin: 0; }

.button-pair { display: flex; gap: 10px; margin-top: 4px; }
.button-pair > * { flex: 1; }

.section { display: flex; flex-direction: column; gap: 6px; padding: 6px 4px 0; }
.section-title { font-size: 17px; font-weight: 700; color: var(--green); margin: 0; }
.section-detail { font-size: 13px; font-weight: 500; color: rgba(27, 107, 55, .85); margin: 0; }

/* ---------------------------------------------------------------- overlays */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 30, 24, .35);
  animation: fade .18s ease-out;
}

@media (min-width: 560px) {
  .overlay { align-items: center; padding: 24px; }
}

.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  border-radius: 26px 26px 0 0;
  animation: rise .24s cubic-bezier(.2, .8, .3, 1);
  overflow: hidden;
}

@media (min-width: 560px) {
  .sheet { border-radius: 26px; max-height: 86dvh; }
}

.sheet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px var(--gutter);
  border-bottom: 1px solid var(--hairline);
}
.sheet-title { font-size: 16px; font-weight: 700; color: var(--green); margin: 0; }

.sheet-body {
  overflow-y: auto;
  padding: 14px var(--gutter) calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sheet-body--centered { align-items: center; text-align: center; gap: 20px; padding-top: 24px; }

@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { transform: translateY(24px); opacity: .6 } }

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

/* ---------------------------------------------------------------- calibration */

.calibration-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: rgba(205, 230, 213, .55);
}

.calibration-stage-art {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translateY(10px);
}

.calibration-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  /* Sits in the opening of the arch rather than over the figure's head. */
  transform: translateY(-8px);
  font-size: 56px;
  font-weight: 800;
  color: var(--green);
}

.calibration-copy { display: flex; flex-direction: column; gap: 8px; padding: 0 12px; }
.calibration-title { font-size: 21px; font-weight: 700; color: var(--green); margin: 0; }
.calibration-detail { font-size: 14px; font-weight: 500; color: var(--ink-soft); margin: 0; }

.calibration-status { font-size: 11px; font-weight: 600; color: var(--zone-bad); margin: 0; }

.stage-actions { width: 100%; padding: 0 12px; }

/* ---------------------------------------------------------------- profiles */

.topbar-actions { display: flex; align-items: center; gap: 4px; }

body.signed-out .topbar-actions { display: none; }

.profile-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
}
.profile-chip:hover { background: rgba(0, 0, 0, .06); }
.profile-chip .avatar { width: 30px; height: 30px; font-size: 12px; }

.profile-chip-name {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green-pale);
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  flex: none;
}

/* ---------------------------------------------------------------- sign in */

.signin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  padding: 20px 4px 40px;
}

.signin-art { display: flex; flex-direction: column; align-items: center; }

.signin-copy { display: flex; flex-direction: column; gap: 8px; }

.signin-title { font-size: 24px; font-weight: 800; color: var(--green); margin: 0; }

.signin-detail {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  margin: 0 auto;
  max-width: 36ch;
}

.signin-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
}

.field-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--green);
  margin-top: 8px;
}

.field {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--hairline);
  border-radius: 14px;
  background: var(--card-inner);
  font: inherit;
  font-size: 15px;
  color: var(--ink);
}
.field::placeholder { color: var(--ink-faint); }
.field:focus { border-color: var(--green); outline: none; }

.field-error {
  min-height: 1.2em;
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--zone-bad);
}

.signin-form .pill-button--wide { margin-top: 6px; }

.signin-existing { width: 100%; display: flex; flex-direction: column; gap: 10px; }

.signin-divider { font-size: 11px; font-weight: 600; color: var(--ink-faint); margin: 0; }

.profile-list { display: flex; flex-direction: column; gap: 8px; }

.profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 18px;
  background: var(--card);
  text-align: left;
}
.profile-row:hover { background: #e2e2e2; }

.profile-row-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.profile-row-name { font-size: 14px; font-weight: 700; color: var(--green); }
.profile-row-detail { font-size: 11px; font-weight: 500; color: var(--ink-muted); }

/* ---------------------------------------------------------------- address box */

.endpoint-row { display: flex; gap: 8px; align-items: center; width: 100%; }
.endpoint-row .field { font-size: 12px; padding: 9px 12px; }
.endpoint-row .pill-button { flex: none; white-space: nowrap; }

/* Six characters of hex, read off the board and typed in. Monospaced and
   widely tracked so a B and an 8 can't be mistaken for one another, and capped
   in width so it reads as a code rather than a text box. */
.field--code {
  flex: 0 1 9.5em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px !important;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
}

/* ---------------------------------------------------------------- misc */

.hint { font-size: 11px; font-weight: 500; color: var(--ink-muted); margin: 0; }
.hint--warn { color: var(--zone-bad); }

.inline-icon { display: inline-block; vertical-align: -2px; margin-right: 4px; }

/* Icons that stand alone rather than leading a line of text. */
.streak-dot .inline-icon,
.calibration-overlay .inline-icon,
.banner .inline-icon:last-child { margin-right: 0; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
