:root {
  color-scheme: light;
  --app-bg: #F7FAFF;
  --card: #FFFFFF;
  --card-soft: rgba(255, 255, 255, 0.78);
  --text: #23304A;
  --heading: #273A7A;
  --metric: #3152D4;
  --muted: #667799;
  --primary: #4F6BFF;
  --primary-soft: rgba(79, 107, 255, 0.12);
  --aqua: #15B8A6;
  --blue: #4F6BFF;
  --violet: #8B5CF6;
  --pink: #F472B6;
  --sun: #FBBF24;
  --coral: #FB7185;
  --line: rgba(17, 24, 39, 0.08);
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.10);
  --green: #10B981;
  --red: #EF4444;
  --orange: #F59E0B;
}

html.dark {
  color-scheme: dark;
  --app-bg: #0E1424;
  --card: #182235;
  --card-soft: rgba(31, 41, 55, 0.78);
  --text: #EEF5FF;
  --heading: #CFE0FF;
  --metric: #9EC5FF;
  --muted: #A6B5D0;
  --primary: #7DA8FF;
  --primary-soft: rgba(125, 168, 255, 0.16);
  --line: rgba(249, 250, 251, 0.10);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% -8%, rgba(79, 107, 255, 0.20), transparent 30%),
    radial-gradient(circle at 92% 4%, rgba(20, 184, 166, 0.16), transparent 28%),
    radial-gradient(circle at 70% 98%, rgba(251, 191, 36, 0.13), transparent 30%),
    var(--app-bg);
  background-attachment: fixed;
  color: var(--text);
  transition: background-color 180ms ease, color 180ms ease;
}

button,
input,
select,
textarea {
  font: inherit;
  min-width: 0;
}

.app-shell {
  min-height: 100vh;
  padding: calc(96px + env(safe-area-inset-top)) 18px calc(88px + env(safe-area-inset-bottom));
}

.topbar {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--app-bg) 84%, transparent), color-mix(in srgb, var(--card) 78%, transparent)),
    color-mix(in srgb, var(--app-bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  box-shadow: 0 8px 26px rgba(17, 24, 39, 0.06);
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  align-items: center;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card) 90%, transparent), color-mix(in srgb, var(--card) 96%, transparent)),
    color-mix(in srgb, var(--card) 88%, transparent);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.nav-btn {
  height: 48px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: transform 160ms ease, color 160ms ease, background-color 160ms ease;
}

.nav-btn[aria-current="page"] {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--aqua));
  box-shadow: 0 10px 22px rgba(79, 107, 255, 0.22);
}

.nav-btn:active {
  transform: scale(0.96);
}

.nav-plus {
  width: 58px;
  height: 58px;
  margin: -18px auto 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--blue) 48%, var(--aqua));
  box-shadow: 0 16px 34px rgba(79, 107, 255, 0.38);
}

.card,
.install-card {
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--card) 92%, #FFFFFF), var(--card)),
    var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.card {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.install-card {
  padding: 28px;
  min-width: 0;
}

.soft-card {
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.42), transparent 34%),
    linear-gradient(145deg, color-mix(in srgb, var(--primary-soft) 52%, var(--card)), color-mix(in srgb, var(--card-soft) 86%, transparent));
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--line));
  border-radius: 22px;
  backdrop-filter: blur(16px);
}

.brand-mark,
.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-mark {
  width: 50px;
  height: 50px;
}

.setup-logo {
  display: block;
  width: min(190px, 62vw);
  height: auto;
}

.topbar-logo {
  display: block;
  width: 58px;
  height: auto;
  margin-bottom: 2px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid color-mix(in srgb, var(--primary) 26%, transparent);
  background: var(--primary-soft);
}

.avatar-fallback {
  width: 44px;
  height: 44px;
}

.field-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  min-width: 0;
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card) 94%, var(--app-bg)), color-mix(in srgb, var(--card) 86%, var(--primary-soft)));
  color: var(--text);
  padding: 13px 14px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.field-textarea {
  min-height: 104px;
  resize: vertical;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.btn-primary,
.btn-secondary,
.btn-danger,
.icon-btn {
  min-height: 48px;
  border-radius: 18px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: transform 160ms ease, opacity 160ms ease, background-color 160ms ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--violet) 52%, var(--aqua));
  color: #fff;
  box-shadow: 0 14px 30px rgba(79, 107, 255, 0.28);
}

.btn-secondary {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 78%, #FFFFFF), color-mix(in srgb, var(--aqua) 12%, var(--card)));
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 14%, transparent);
}

.btn-danger {
  background: color-mix(in srgb, var(--red) 14%, transparent);
  color: var(--red);
}

.icon-btn {
  width: 48px;
  color: var(--heading);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--card) 84%, var(--primary-soft)), color-mix(in srgb, var(--card) 90%, var(--sun) 10%));
  border: 1px solid var(--line);
}

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary:not(:disabled):active,
.btn-secondary:not(:disabled):active,
.icon-btn:active {
  transform: translateY(1px) scale(0.98);
}

.install-body {
  background:
    radial-gradient(circle at top left, rgba(79, 107, 255, 0.18), transparent 35%),
    radial-gradient(circle at bottom right, rgba(20, 184, 166, 0.16), transparent 32%),
    var(--app-bg);
}

.install-feedback {
  border-radius: 18px;
  padding: 12px 14px;
  font-weight: 700;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.install-feedback.is-good {
  color: #047857;
  background: rgba(16, 185, 129, 0.14);
}

.install-feedback.is-bad {
  color: #B91C1C;
  background: rgba(239, 68, 68, 0.14);
}

.route-title {
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: 0;
  color: var(--heading);
}

.big-number {
  font-size: 4.25rem;
  line-height: 0.92;
  letter-spacing: 0;
  font-weight: 900;
}

.metric-number {
  font-size: 2.2rem;
  line-height: 1;
  letter-spacing: 0;
  font-weight: 900;
}

.big-number,
.metric-number:not(.status-green):not(.status-red):not(.status-orange) {
  color: var(--metric);
}

.card h1,
.card h2,
.install-card h1,
.install-card h2,
.glass-panel h2,
.modal-card h2 {
  color: var(--heading);
}

.page-hero {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 18px;
  border-radius: 26px;
  border: 1px solid color-mix(in srgb, var(--primary) 16%, var(--line));
  background:
    radial-gradient(circle at 78% 28%, rgba(255, 255, 255, 0.62), transparent 28%),
    linear-gradient(135deg, rgba(79, 107, 255, 0.18), rgba(20, 184, 166, 0.14) 52%, rgba(251, 191, 36, 0.16));
  box-shadow: 0 16px 42px rgba(79, 107, 255, 0.12);
}

.page-hero > :not(.page-hero-illustration) {
  position: relative;
  z-index: 2;
}

.page-hero-illustration {
  position: absolute;
  right: -18px;
  bottom: -34px;
  width: 150px;
  height: 150px;
  object-fit: contain;
  opacity: 0.42;
  transform: rotate(7deg);
  pointer-events: none;
  filter: drop-shadow(0 18px 26px rgba(39, 58, 122, 0.16));
}

html.dark .page-hero-illustration {
  opacity: 0.38;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.34));
}

.accent-card {
  border-color: color-mix(in srgb, var(--primary) 18%, var(--line));
  background:
    radial-gradient(circle at 92% 12%, rgba(244, 114, 182, 0.18), transparent 30%),
    radial-gradient(circle at 2% 90%, rgba(20, 184, 166, 0.18), transparent 34%),
    linear-gradient(145deg, color-mix(in srgb, var(--card) 80%, var(--primary-soft)), var(--card));
}

.dashboard-hero {
  min-height: 178px;
  background:
    radial-gradient(circle at 86% 20%, rgba(251, 191, 36, 0.22), transparent 26%),
    radial-gradient(circle at 18% 12%, rgba(79, 107, 255, 0.20), transparent 34%),
    linear-gradient(145deg, color-mix(in srgb, var(--card) 72%, rgba(20, 184, 166, 0.22)), var(--card));
}

.tip-card {
  background:
    radial-gradient(circle at 92% 22%, rgba(251, 191, 36, 0.22), transparent 28%),
    linear-gradient(145deg, color-mix(in srgb, var(--card) 78%, rgba(244, 114, 182, 0.14)), color-mix(in srgb, var(--card) 86%, rgba(20, 184, 166, 0.12)));
}

.settings-ai-card {
  background:
    radial-gradient(circle at 90% 10%, rgba(139, 92, 246, 0.22), transparent 32%),
    radial-gradient(circle at 5% 92%, rgba(20, 184, 166, 0.18), transparent 36%),
    linear-gradient(145deg, color-mix(in srgb, var(--card) 78%, rgba(79, 107, 255, 0.12)), var(--card));
}

.illustrated-card {
  padding-right: min(34vw, 150px);
}

.card-illustration {
  position: absolute;
  z-index: 0;
  right: -24px;
  bottom: -34px;
  width: 158px;
  height: 158px;
  object-fit: contain;
  opacity: 0.28;
  transform: rotate(6deg);
  pointer-events: none;
  filter: drop-shadow(0 18px 26px rgba(39, 58, 122, 0.14));
}

.card > :not(.card-illustration) {
  position: relative;
  z-index: 1;
}

html.dark .card-illustration {
  opacity: 0.32;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.34));
}

.progress-track {
  height: 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 16%, transparent);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  width: 0;
  background: linear-gradient(90deg, var(--blue), var(--aqua), var(--sun));
  transition: width 700ms cubic-bezier(.2, .8, .2, 1);
}

.kcal-dashboard-card {
  overflow: hidden;
}

.kcal-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.kcal-side {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.kcal-mini-ring {
  width: 92px;
  aspect-ratio: 1;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.34), transparent 28%),
    conic-gradient(var(--ring) var(--pct), color-mix(in srgb, var(--muted) 16%, transparent) 0);
  position: relative;
}

.kcal-mini-ring::before {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: inherit;
  background: var(--card);
}

.kcal-mini-ring span {
  position: relative;
  z-index: 1;
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--text);
}

.kcal-action {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 15px;
  white-space: nowrap;
}

.weekly-card {
  position: relative;
  min-height: 176px;
  overflow: hidden;
}

.weekly-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 88% 12%, rgba(125, 168, 255, 0.18), transparent 34%),
    radial-gradient(circle at 96% 86%, rgba(16, 185, 129, 0.14), transparent 28%),
    linear-gradient(135deg, rgba(251, 191, 36, 0.08), transparent);
  pointer-events: none;
}

.weekly-copy {
  position: relative;
  z-index: 2;
  max-width: 74%;
}

.weekly-graphic {
  position: absolute;
  right: -14px;
  bottom: -10px;
  width: min(42%, 190px);
  height: auto;
  z-index: 1;
  pointer-events: none;
}

.fade-in {
  opacity: 0;
  transform: translateY(10px);
  animation: fadeIn 500ms ease forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.glass-overlay {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 18px 18px calc(104px + env(safe-area-inset-bottom));
  background: rgba(17, 24, 39, 0.28);
  backdrop-filter: blur(8px);
}

.glass-panel {
  width: min(100%, 460px);
  border-radius: 28px;
  padding: 18px;
  background: color-mix(in srgb, var(--card) 76%, transparent);
  border: 1px solid color-mix(in srgb, var(--card) 60%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.action-tile {
  min-height: 112px;
  padding: 15px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 90% 12%, rgba(251, 191, 36, 0.18), transparent 32%),
    linear-gradient(145deg, color-mix(in srgb, var(--card) 72%, var(--primary-soft)), color-mix(in srgb, var(--card) 84%, rgba(20, 184, 166, 0.12)));
  border: 1px solid color-mix(in srgb, var(--primary) 14%, var(--line));
  text-align: left;
  display: grid;
  align-content: space-between;
  color: var(--text);
}

.pill {
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 0.85rem;
  color: color-mix(in srgb, var(--heading) 82%, var(--muted));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--card) 82%, var(--app-bg)), color-mix(in srgb, var(--card) 84%, rgba(251, 191, 36, 0.12)));
  border: 1px solid color-mix(in srgb, var(--primary) 13%, var(--line));
}

.pill.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--aqua));
}

.status-green {
  color: var(--green);
}

.status-red {
  color: var(--red);
}

.status-orange {
  color: var(--orange);
}

.table-row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(72px, 0.8fr) minmax(58px, 0.8fr);
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 10%, var(--line));
  border-radius: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--app-bg) 68%, var(--card)), color-mix(in srgb, var(--card) 86%, rgba(20, 184, 166, 0.10)));
  align-items: center;
  min-width: 0;
}

.list-row {
  border: 1px solid color-mix(in srgb, var(--primary) 10%, var(--line));
  border-radius: 18px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--card) 80%, var(--app-bg)), color-mix(in srgb, var(--card) 86%, rgba(79, 107, 255, 0.10)));
  padding: 12px 14px;
}

.weight-entry-card {
  padding: 20px 16px 18px;
}

.weight-lock-shell {
  position: relative;
  width: min(100%, 460px);
  margin: 6px auto 0;
  padding-top: 42px;
}

.weight-lock-shackle {
  width: min(42vw, 176px);
  height: 86px;
  margin: 0 auto -32px;
  border: 12px solid color-mix(in srgb, var(--primary) 42%, rgba(255, 255, 255, 0.48));
  border-bottom: 0;
  border-radius: 92px 92px 0 0;
  box-shadow:
    inset 0 10px 18px rgba(255, 255, 255, 0.24),
    0 16px 26px rgba(79, 107, 255, 0.14);
}

html.dark .weight-lock-shackle {
  border-color: color-mix(in srgb, var(--primary) 58%, rgba(255, 255, 255, 0.18));
  box-shadow:
    inset 0 10px 18px rgba(255, 255, 255, 0.10),
    0 18px 30px rgba(0, 0, 0, 0.28);
}

.weight-lock-body {
  position: relative;
  overflow: hidden;
  padding: 22px 14px;
  border-radius: 34px;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--line));
  background:
    radial-gradient(circle at 14% 16%, rgba(255, 255, 255, 0.36), transparent 30%),
    radial-gradient(circle at 90% 8%, rgba(251, 191, 36, 0.22), transparent 28%),
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 24%, var(--card)), color-mix(in srgb, var(--aqua) 20%, var(--card)));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    0 22px 46px rgba(79, 107, 255, 0.18);
}

.weight-lock-body::before {
  content: "";
  position: absolute;
  inset: -80px auto auto -80px;
  width: 160px;
  aspect-ratio: 1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  animation: lockFloat 5s ease-in-out infinite;
}

.weight-lock-body::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0 38%, rgba(255, 255, 255, 0.22) 48%, transparent 58% 100%);
  transform: translateX(-130%);
  animation: lockShine 4.6s ease-in-out infinite;
  pointer-events: none;
}

.weight-lock-reels {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.weight-reel {
  position: relative;
  height: 116px;
  min-width: 0;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card) 98%, var(--app-bg)), color-mix(in srgb, var(--card) 74%, var(--primary-soft)));
  color: var(--heading);
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  box-shadow:
    inset 0 14px 22px rgba(255, 255, 255, 0.22),
    inset 0 -18px 22px rgba(79, 107, 255, 0.08),
    0 10px 18px rgba(39, 58, 122, 0.10);
}

.weight-reel::before,
.weight-reel::after {
  content: "";
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  height: 30%;
  pointer-events: none;
}

.weight-reel::before {
  top: 0;
  background: linear-gradient(180deg, var(--card), transparent);
}

.weight-reel::after {
  bottom: 0;
  background: linear-gradient(0deg, var(--card), transparent);
}

.weight-reel:focus-visible {
  outline: 3px solid var(--primary-soft);
  outline-offset: 3px;
}

.weight-reel.is-grabbing {
  cursor: grabbing;
  transform: scale(0.985);
}

.weight-reel-window {
  position: absolute;
  inset: 12px 0;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  align-items: center;
}

.weight-reel.is-ticking .weight-reel-window {
  animation: reelTick 170ms cubic-bezier(.2, .8, .2, 1);
}

.weight-reel-item {
  display: grid;
  place-items: center;
  font-size: 1.18rem;
  font-weight: 900;
  color: var(--muted);
  opacity: 0.34;
  line-height: 1;
}

.weight-reel-item.is-current {
  font-size: clamp(2.25rem, 10vw, 3.15rem);
  color: var(--heading);
  opacity: 1;
  text-shadow: 0 8px 20px rgba(79, 107, 255, 0.16);
}

.weight-lock-comma {
  align-self: center;
  padding: 0 1px;
  font-size: clamp(2rem, 8vw, 2.7rem);
  line-height: 1;
  font-weight: 900;
  color: var(--heading);
  transform: translateY(18px);
}

.weight-lock-marker {
  position: absolute;
  z-index: 1;
  left: 14px;
  right: 14px;
  top: 50%;
  height: 46px;
  border-radius: 18px;
  transform: translateY(-50%);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  background: color-mix(in srgb, var(--primary-soft) 72%, transparent);
  pointer-events: none;
}

.weight-lock-readout {
  margin-top: 5px;
  font-size: clamp(2.4rem, 12vw, 4.2rem);
  line-height: 0.95;
  font-weight: 900;
  color: var(--metric);
}

@keyframes reelTick {
  0% {
    transform: translateY(0) scale(1);
  }
  45% {
    transform: translateY(-11px) scale(0.985);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes lockShine {
  0%, 58% {
    transform: translateX(-130%);
  }
  100% {
    transform: translateX(130%);
  }
}

@keyframes lockFloat {
  0%, 100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(18px, 12px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .weight-lock-body::before,
  .weight-lock-body::after,
  .weight-reel.is-ticking .weight-reel-window {
    animation: none;
  }
}

.modal-backdrop {
  position: fixed;
  z-index: 70;
  inset: 0;
  padding: 18px;
  display: grid;
  place-items: center;
  background: rgba(17, 24, 39, 0.38);
  backdrop-filter: blur(9px);
}

.modal-card {
  width: min(100%, 520px);
  max-height: min(86vh, 760px);
  overflow: auto;
  border-radius: 26px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}

.toast {
  position: fixed;
  z-index: 90;
  left: 16px;
  right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  margin: 0 auto;
  max-width: 440px;
  padding: 13px 15px;
  border-radius: 18px;
  background: var(--text);
  color: var(--app-bg);
  font-weight: 800;
  box-shadow: var(--shadow);
}

.donut {
  width: 156px;
  aspect-ratio: 1;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.30), transparent 26%),
    conic-gradient(var(--primary) var(--pct), color-mix(in srgb, var(--muted) 18%, transparent) 0);
}

.donut::before {
  content: "";
  width: 108px;
  aspect-ratio: 1;
  border-radius: 999px;
  background: var(--card);
}

.scanner-video {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 22px;
  background: #000;
  object-fit: cover;
}

.crop-shell {
  display: grid;
  gap: 18px;
}

.crop-modal {
  max-height: min(92dvh, 760px);
  overscroll-behavior: contain;
}

.crop-stage {
  position: relative;
  width: clamp(220px, min(76vw, 42dvh), 320px);
  max-width: 100%;
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 999px;
  background: #0B1020;
  border: 1px solid var(--line);
  touch-action: none;
  cursor: grab;
}

.crop-stage:active {
  cursor: grabbing;
}

.crop-stage img {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: none;
  transform-origin: center;
  user-select: none;
  will-change: transform;
}

.crop-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 999px rgba(17, 24, 39, 0.05);
}

.crop-guide {
  position: absolute;
  inset: 10px;
  border-radius: 999px;
  pointer-events: none;
  border: 2px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 0 0 1px rgba(17, 24, 39, 0.20);
}

@media (max-width: 420px) {
  .page-hero {
    min-height: 104px;
    padding: 16px;
  }

  .page-hero-illustration {
    right: -42px;
    bottom: -46px;
    width: 132px;
    height: 132px;
    opacity: 0.18;
  }

  .illustrated-card {
    padding-right: 18px;
  }

  .card-illustration {
    right: -54px;
    bottom: -54px;
    width: 136px;
    height: 136px;
    opacity: 0.12;
  }

  .dashboard-hero {
    min-height: 164px;
  }

  .big-number {
    font-size: 3.7rem;
  }

  .weight-entry-card {
    padding: 18px 12px;
  }

  .weight-lock-shell {
    padding-top: 34px;
  }

  .weight-lock-shackle {
    width: 138px;
    height: 72px;
    border-width: 10px;
    margin-bottom: -28px;
  }

  .weight-lock-body {
    padding: 18px 10px;
    border-radius: 28px;
  }

  .weight-lock-reels {
    gap: 5px;
  }

  .weight-reel {
    height: 96px;
    border-radius: 18px;
  }

  .weight-reel-window {
    inset: 10px 0;
  }

  .weight-reel-item {
    font-size: 1rem;
  }

  .weight-reel-item.is-current {
    font-size: clamp(2rem, 12vw, 2.55rem);
  }

  .weight-lock-comma {
    font-size: 2rem;
    transform: translateY(14px);
  }

  .weight-lock-marker {
    left: 10px;
    right: 10px;
    height: 38px;
    border-radius: 15px;
  }

  .modal-card.crop-modal {
    padding: 14px;
    max-height: 94dvh;
  }

  .crop-modal .crop-shell {
    gap: 14px;
  }

  .crop-modal .field-label {
    gap: 10px;
  }

  .crop-stage {
    width: clamp(210px, min(82vw, 40dvh), 300px);
  }

  .crop-guide {
    inset: 8px;
  }

  .weekly-copy {
    max-width: 100%;
  }

  .weekly-graphic {
    width: 150px;
    opacity: .32;
  }

  .kcal-dashboard-grid {
    grid-template-columns: minmax(0, 1fr) 88px;
    gap: 12px;
  }

  .kcal-mini-ring {
    width: 74px;
  }

  .kcal-action {
    min-height: 38px;
    padding: 0 10px;
    font-size: 0.82rem;
  }
}

@media (min-width: 780px) {
  .app-shell {
    max-width: 760px;
    margin: 0 auto;
  }

  .topbar-inner,
  .bottom-nav {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
  }

  .bottom-nav {
    left: 50%;
    right: auto;
    bottom: 0;
    width: min(760px, 100vw);
    transform: translateX(-50%);
  }
}
