/* Forma — foundations: tokens, reset, type, controls, navigation. */

:root {
  --paper: #faf5ef;
  --paper-deep: #f2eae0;
  --card: #fffdfa;
  --line: #e6dccd;
  --line-soft: #efe7da;
  --ink: #332d27;
  --ink-soft: #7b7166;
  --ink-faint: #a99e91;
  --rose: #a85d68;
  --rose-deep: #8c4653;
  --rose-tint: #f0dedd;
  --rose-faint: #f7ece9;
  --moss: #68765c;
  --moss-tint: #e6eadc;
  --danger: #a04b3c;

  --font-display: 'Cormorant', 'Iowan Old Style', Georgia, serif;
  --font-body: 'Urbanist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --radius: 22px;
  --radius-sm: 14px;
  --tap: 44px;
  --nav-h: 62px;
  --screen-pad: 20px;
  --shadow-card: 0 1px 2px rgba(51, 45, 39, 0.05), 0 6px 20px -12px rgba(51, 45, 39, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* liquid-glass light field: soft color pools the glass surfaces refract */
body::before {
  content: '';
  position: fixed;
  inset: -10%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(42% 34% at 16% 8%, rgba(198, 122, 138, 0.34), transparent 70%),
    radial-gradient(38% 30% at 88% 16%, rgba(224, 178, 122, 0.26), transparent 70%),
    radial-gradient(46% 38% at 74% 92%, rgba(147, 168, 126, 0.24), transparent 70%),
    radial-gradient(32% 26% at 6% 78%, rgba(186, 148, 198, 0.18), transparent 70%);
}

h1,
h2,
h3,
p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

a {
  color: var(--rose-deep);
  text-decoration: none;
}

input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--rose-deep);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: var(--rose-tint);
}

/* ---------- app frame ---------- */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) var(--screen-pad)
    calc(var(--nav-h) + env(safe-area-inset-bottom) + 44px);
}

.screen:focus {
  outline: none;
}

.tabbar {
  position: fixed;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 14px;
  right: 14px;
  z-index: 40;
  display: flex;
  justify-content: center;
  gap: 4px;
  max-width: 430px;
  margin: 0 auto;
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.34));
  backdrop-filter: blur(24px) saturate(1.7);
  -webkit-backdrop-filter: blur(24px) saturate(1.7);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow:
    0 14px 36px -14px rgba(80, 55, 58, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  padding: 6px 8px;
}

.tab {
  flex: 1;
  max-width: 132px;
  min-height: calc(var(--nav-h) - 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: var(--radius-sm);
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tab-icon {
  width: 24px;
  height: 24px;
}

.tab[aria-current='page'] {
  color: var(--rose-deep);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.5));
  box-shadow:
    0 4px 14px -6px rgba(80, 55, 58, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  border-radius: 22px;
}

.app.workout-active .tabbar {
  display: none;
}

.app.workout-active .screen {
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  max-width: 560px;
}

/* ---------- type ---------- */

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.display {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: 0;
}

.numeral {
  font-family: var(--font-display);
  font-variant-numeric: lining-nums tabular-nums;
  font-weight: 620;
}

.muted {
  color: var(--ink-soft);
}

.small {
  font-size: 13.5px;
}

/* ---------- signature rail ---------- */

.rail {
  display: flex;
  gap: 5px;
}

.rail-seg {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: var(--line-soft);
  position: relative;
  overflow: hidden;
}

.rail-seg.done {
  background: var(--rose);
}

.rail-seg.now {
  background: var(--rose-tint);
  box-shadow: inset 0 0 0 1.5px var(--rose);
}

.rail-seg.moss {
  background: var(--moss);
}

.rail-seg .rail-fill {
  position: absolute;
  inset: 0;
  background: var(--rose);
  transform-origin: left;
}

/* ---------- cards & sections ---------- */

.card {
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0.38));
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  box-shadow:
    0 12px 34px -16px rgba(80, 55, 58, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card,
  .tabbar,
  .modal {
    background: var(--card);
  }

  .rest-overlay {
    background: var(--paper) !important;
  }
}

.section {
  margin-top: 30px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head .eyebrow {
  color: var(--ink);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: 999px;
  font-weight: 650;
  font-size: 16px;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.985);
}

.btn-primary {
  background: linear-gradient(160deg, rgba(200, 118, 133, 0.95), rgba(150, 78, 92, 0.95));
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow:
    0 10px 26px -10px rgba(150, 78, 92, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.btn-primary:hover {
  background: linear-gradient(160deg, rgba(184, 102, 117, 0.98), rgba(134, 66, 80, 0.98));
}

.btn-quiet {
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.3));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--rose-deep);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.btn-quiet:hover {
  border-color: rgba(168, 93, 104, 0.5);
}

.btn-block {
  display: flex;
  width: 100%;
  min-height: 54px;
  font-size: 17px;
}

.btn-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
}

/* ---------- forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-soft);
}

.input {
  min-height: var(--tap);
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 1px 2px rgba(80, 55, 58, 0.06);
  width: 100%;
  font-size: 16px;
}

.input:focus-visible {
  outline-offset: 0;
  border-color: transparent;
}

.switch {
  position: relative;
  width: 52px;
  height: 32px;
  border-radius: 99px;
  background: var(--line);
  transition: background-color 0.18s ease;
  flex: none;
}

.switch[aria-checked='true'] {
  background: var(--rose);
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease;
}

.switch[aria-checked='true']::after {
  transform: translateX(20px);
}

.seg-control {
  display: flex;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.seg-control button {
  flex: 1;
  min-height: 44px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink-soft);
}

.seg-control button[aria-pressed='true'] {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(51, 45, 39, 0.12);
}

/* stepper: − value + */
.stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  overflow: hidden;
}

.stepper button {
  width: 52px;
  min-height: 52px;
  font-size: 24px;
  font-weight: 500;
  color: var(--rose-deep);
  flex: none;
}

.stepper button:active {
  background: var(--rose-faint);
}

.stepper input {
  flex: 1;
  width: 100%;
  min-width: 0;
  border: none;
  text-align: center;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  background: transparent;
  padding: 0;
  -moz-appearance: textfield;
  appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

/* ---------- modal ---------- */

.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(60, 45, 45, 0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.modal {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.6));
  backdrop-filter: blur(28px) saturate(1.6);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  padding: 24px 20px 20px;
  box-shadow:
    0 24px 60px -16px rgba(60, 40, 44, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 640;
  margin-bottom: 8px;
}

.modal p {
  color: var(--ink-soft);
  font-size: 15px;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn {
  flex: 1;
}

/* ---------- chart ---------- */

.chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid {
  stroke: var(--line-soft);
  stroke-width: 1;
}

.chart-tick {
  fill: var(--ink-faint);
  font-size: 9px;
  font-family: var(--font-body);
}

.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line-rose {
  stroke: var(--rose);
}

.chart-line-ink {
  stroke: var(--ink-faint);
}

.chart-dot.chart-line-rose {
  fill: var(--rose);
  stroke: none;
}

.chart-dot.chart-line-ink {
  fill: var(--ink-faint);
  stroke: none;
}

/* ---------- animation & a11y ---------- */

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.screen > * {
  animation: rise-in 0.28s ease both;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- desktop ---------- */

@media (min-width: 860px) {
  .app {
    padding-left: 124px;
  }

  .app.workout-active {
    padding-left: 0;
  }

  .tabbar {
    top: 50%;
    bottom: auto;
    left: 18px;
    right: auto;
    transform: translateY(-50%);
    width: 88px;
    max-width: none;
    margin: 0;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
    padding: 14px 10px;
    border-radius: 32px;
  }

  .tab {
    flex: none;
    max-width: none;
    width: 100%;
    min-height: 64px;
    font-size: 12px;
  }

  .screen {
    max-width: 640px;
    padding-top: 40px;
    padding-bottom: 60px;
  }
}

@media (min-width: 1100px) {
  .screen {
    max-width: 700px;
  }
}
