:root {
  --bg: #F6F6F6;
  --card: #FFFFFF;
  --card-alt: #FAF7F2;
  --divider: rgba(60,50,40,0.10);
  --ink: #1B1714;
  --ink-2: rgba(27,23,20,0.62);
  --ink-3: rgba(27,23,20,0.38);
  --ink-section: rgba(27,23,20,0.42);
  --red: #E72034;
  --red-deep: #B81626;
  --red-soft: #FDE3E6;
  --green: #1E6B3A;
  --green-soft: #E6F0E8;
  --shadow-card: 0 1px 0 rgba(0,0,0,0.02), 0 6px 18px -10px rgba(40,28,20,0.10);
  --shadow-cta: 0 8px 22px -8px rgba(231,32,52,0.55), inset 0 -1px 0 rgba(0,0,0,0.18);
  --shadow-sheet: 0 -20px 40px rgba(20,12,8,0.18);

  --display: "SF Pro Display", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --text: "SF Pro Text", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
.app {
  flex: 1;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* HEADER */
header {
  padding: 22px 20px 22px;
}
.stripe {
  display: block;
  margin: 0 2px 8px;
}
.title-wrap {
  position: relative;
  display: block;
  width: fit-content;
}
.title-hi {
  position: absolute;
  left: -10px;
  top: 14px;
  width: 130px;
  height: 28px;
  background: var(--red-soft);
  z-index: 0;
  border-radius: 2px;
}
h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: var(--display);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink);
}
.subtitle {
  margin-top: 14px;
  font-size: 14px;
  color: var(--ink-2);
  letter-spacing: -0.1px;
}
.subtitle b {
  color: var(--ink);
  font-weight: 700;
}

/* SECTIONS */
.section-label {
  padding: 0 28px 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-section);
}
.card {
  margin: 0 16px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.gap-section { height: 24px; }

/* ROW */
.row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 20px;
  font-size: 17px;
  letter-spacing: -0.4px;
}
.row-label {
  color: var(--ink);
  font-weight: 400;
}
.row-value {
  font-size: 17px;
  letter-spacing: -0.4px;
  color: var(--ink);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.row-value.placeholder { color: var(--ink-3); }
.row-value.set-red { color: var(--red); font-weight: 500; }
.divider {
  height: 0.5px;
  background: var(--divider);
  margin-left: 20px;
}
.row-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 17px;
  margin: 0;
  padding: 0;
  color: transparent;
  z-index: 2;
  cursor: pointer;
}
.row-input::-webkit-date-and-time-value { color: transparent; }

/* STATS */
.stats {
  display: flex;
}
.stat {
  flex: 1;
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.stat-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-2);
}
.stat-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.stat-value.set { color: var(--green); }
.stat-big {
  font-family: var(--display);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -1.4px;
  line-height: 1;
}
.stat-unit {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.2px;
  opacity: 0.85;
}
.stat-divider {
  width: 1px;
  background: var(--divider);
  margin: 14px 0;
}

/* ERROR */
.error {
  height: 44px;
  padding: 12px 24px 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  visibility: hidden;
}
.error.visible { visibility: visible; }
.error-text {
  font-size: 13.5px;
  color: var(--red);
  letter-spacing: -0.1px;
  line-height: 1.35;
}

/* CTA */
.spacer { flex: 1; min-height: 16px; }
.footer {
  padding: 0 20px 8px;
}
.cta {
  width: 100%;
  height: 54px;
  border: 0;
  border-radius: 16px;
  background: var(--red);
  color: #fff;
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  cursor: pointer;
  box-shadow: var(--shadow-cta);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .12s ease, background .15s ease;
}
.cta:active { transform: scale(0.985); }
.cta:disabled {
  background: rgba(27,23,20,0.08);
  color: var(--ink-3);
  box-shadow: none;
  cursor: not-allowed;
}
.cta:disabled .heart-fill { fill: transparent; }
.cta:disabled .heart-stroke { stroke: var(--ink-3); }
.cta-link {
  display: block;
  margin: 18px auto 6px;
  background: none;
  border: 0;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ink-2);
  letter-spacing: -0.1px;
  cursor: pointer;
}

/* MODAL */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(15,10,8,0.42);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 520px;
  margin: 0 auto;
  height: 88vh;
  height: 88svh;
  background: var(--bg);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  box-shadow: var(--shadow-sheet);
  z-index: 31;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(.2,.7,.3,1);
}
.sheet.open { transform: translateY(0); }
.grip-wrap { display: flex; justify-content: center; padding: 8px 0 4px; flex-shrink: 0; }
.grip {
  width: 38px; height: 5px; border-radius: 100px;
  background: rgba(27,23,20,0.20);
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 6px;
  flex-shrink: 0;
}
.sheet-title {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0;
}
.sheet-close {
  width: 32px; height: 32px;
  border-radius: 16px;
  border: 0;
  background: rgba(27,23,20,0.08);
  color: rgba(27,23,20,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 20px calc(env(safe-area-inset-bottom) + 28px);
}
.sheet-intro {
  margin: 6px 0 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  letter-spacing: -0.1px;
}
.sheet-intro b { color: var(--ink); font-weight: 700; }

.name-card {
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02), 0 6px 18px -12px rgba(40,28,20,0.18);
}
.name-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-2);
}
.name-code {
  margin-top: 2px;
  display: block;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ink);
  letter-spacing: -0.1px;
}
.copy-btn {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  border: 0;
  background: var(--green);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.copy-btn:active { opacity: 0.8; }
.copy-btn.done { background: var(--green); opacity: 0.7; }

.sheet h3 {
  margin: 22px 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: rgba(27,23,20,0.55);
}

.step-card, .action-card, .info-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 8px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.num-badge {
  width: 24px; height: 24px;
  border-radius: 12px;
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.2px;
  flex-shrink: 0;
}
.num-badge.info {
  background: var(--green);
  font-family: var(--display);
  font-size: 13px;
  font-style: italic;
}
.step-content { min-width: 0; flex: 1; }
.step-title {
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.2px;
  color: var(--ink);
}
.step-body {
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.45;
}
.action-params {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
}
.action-params li {
  display: flex;
  gap: 8px;
}
.action-params li::before {
  content: '›';
  color: var(--ink-3);
  flex-shrink: 0;
}
.info-body {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.5;
}
.info-body b { font-weight: 600; }

.sheet-foot {
  margin: 18px 0 4px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
}
.sheet-foot b { color: var(--ink); }

code, .inline-code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: rgba(27,23,20,0.06);
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--ink);
}

/* INSTALL CARD — iCloud one-tap shortcut install */
.install-card {
  background: var(--green-soft);
  border-radius: 18px;
  padding: 16px 16px 18px;
  margin: 4px 0 18px;
  border: 1px solid rgba(30, 107, 58, 0.18);
}
.install-card .install-label {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--green);
}
.install-card .install-desc {
  font-size: 13.5px;
  color: var(--ink);
  margin: 0 0 14px;
  line-height: 1.45;
}
.install-card .install-desc b { color: var(--green); }
.install-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--green);
  color: #fff;
  text-decoration: none;
  padding: 14px;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.2px;
  box-shadow: 0 6px 16px -6px rgba(30, 107, 58, 0.55), inset 0 -1px 0 rgba(0,0,0,0.15);
  transition: transform 0.12s ease, opacity 0.2s ease;
  border: 0;
  cursor: pointer;
}
.install-btn:active { transform: scale(0.985); opacity: 0.92; }
.install-hint {
  font-size: 12px;
  color: var(--ink-2);
  margin: 10px 4px 0;
  line-height: 1.4;
  text-align: center;
}
.install-hint code { font-size: 11.5px; }

.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 4px 14px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 0.5px;
  background: var(--divider);
}

/* UPDATE TOAST — shown when SW has a new version ready */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  max-width: 488px;
  margin: 0 auto;
  background: var(--ink);
  color: #fff;
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  letter-spacing: -0.1px;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,0.4);
  z-index: 50;
  transform: translateY(calc(100% + env(safe-area-inset-bottom) + 48px));
  transition: transform 0.3s cubic-bezier(.2,.7,.3,1);
}
.toast.visible { transform: translateY(0); }
.toast-text { flex: 1; }
.toast-btn {
  flex: 0 0 auto;
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.toast-btn:active { opacity: 0.85; }
