/* ============================================================
   SnapOut — app styles
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent-ink); text-decoration: none; }

/* ---------- desktop: iPhone frame ---------- */
#frame { height: 100%; position: relative; }

@media (min-width: 760px) {
  body {
    display: flex; align-items: center; justify-content: center; padding: 28px 0; min-height: 100vh;
    background: radial-gradient(1200px 620px at 20% -10%, var(--surface-2), transparent 60%), var(--bg);
  }
  #frame {
    width: 390px; height: 844px; max-height: calc(100vh - 56px);
    border-radius: 54px; border: 11px solid #2a2a2c;
    box-shadow: 0 24px 80px rgba(15, 15, 25, 0.4);
    overflow: hidden; background: var(--bg);
  }
  #frame::after { /* notch */
    content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    width: 120px; height: 24px; border-radius: 999px; background: #2a2a2c; z-index: 60; pointer-events: none;
  }
  #frame .app { padding-top: 34px; }
}

/* ---------- app shell ---------- */
.app { height: 100%; display: flex; flex-direction: column; overflow: hidden; }

.screen {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 18px calc(96px + env(safe-area-inset-bottom, 0px));
}
.screen.no-tabs { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }

.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-around; align-items: stretch;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-3); font-size: 10.5px; font-weight: 500; padding: 4px 0; border-radius: var(--radius-sm);
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.active { color: var(--accent); }

/* ---------- typography ---------- */
h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 16px; font-weight: 600; }
.muted { color: var(--text-2); }
.small { font-size: 13.5px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.screen-title { margin: 8px 2px 14px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.screen-title .sub { color: var(--text-2); font-size: 14.5px; margin-top: 3px; }
.section-label {
  font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-3); margin: 22px 4px 9px;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px;
}
.card.flat { box-shadow: none; }
.card.pad0 { padding: 2px 16px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 20px; border-radius: var(--radius-pill);
  font-weight: 650; font-size: 16px; transition: transform 0.06s ease, opacity 0.15s;
  border: 1px solid transparent; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--border); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 9px 15px; font-size: 14px; }
.link-btn { color: var(--accent); font-weight: 600; font-size: 14.5px; padding: 10px; background: none; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: var(--radius-pill); font-size: 14px; font-weight: 550;
  background: var(--surface-2); color: var(--text-2); border: 1px solid transparent; transition: all 0.12s ease;
}
.chip.on { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-line); font-weight: 650; }

/* day-of-week chips (compact circles) */
.dow-row { display: flex; gap: 6px; justify-content: space-between; }
.dow {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
}
.dow.on { background: var(--accent); color: var(--on-accent); }

/* ---------- segmented ---------- */
.segmented { display: flex; background: var(--surface-2); border-radius: var(--radius-pill); padding: 3px; gap: 2px; }
.segmented button {
  flex: 1; padding: 8px 10px; border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 550; color: var(--text-2); white-space: nowrap;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 700; }

/* ---------- toggle switch ---------- */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3);
  transition: background 0.2s ease; pointer-events: none;
}
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 0.2s ease; pointer-events: none;
}
.switch input:checked ~ .track { background: var(--ok); }
.switch input:checked ~ .knob { transform: translateX(20px); }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.input, select.input, textarea.input {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  outline: none; appearance: none; -webkit-appearance: none;
}
.input:focus { border-color: var(--accent); }
input[type="time"].input { font-variant-numeric: tabular-nums; }

/* range slider */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; background: var(--surface-3); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow), 0 0 0 1px var(--border) inset; cursor: pointer; }

/* ---------- alarms list ---------- */
.big-clock { text-align: center; margin: 6px 0 14px; }
.big-clock .now { font-size: 60px; font-weight: 300; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.big-clock .next { color: var(--text-2); font-size: 14px; margin-top: 8px; }

.alarm-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 4px; border-bottom: 1px solid var(--border);
}
.alarm-row:last-child { border-bottom: none; }
.alarm-row .times { flex: 1; min-width: 0; text-align: left; }
.alarm-row .t { font-size: 34px; font-weight: 350; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.alarm-row.off .t, .alarm-row.off .s { color: var(--text-3); }
.alarm-row .ampm { font-size: 17px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.alarm-row.off .ampm { color: var(--text-3); }
.alarm-row .s { font-size: 13px; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--accent); background: var(--surface-2); font-size: 22px; font-weight: 500; flex: none; }

/* ---------- ring (full-screen alarm) ---------- */
.ring {
  position: absolute; inset: 0; z-index: 70; display: flex; flex-direction: column;
  padding: calc(48px + env(safe-area-inset-top, 0px)) 22px calc(26px + env(safe-area-inset-bottom, 0px));
  color: #fff;
  background: radial-gradient(120% 80% at 50% 0%, var(--ring-bg-1), var(--ring-bg-2) 72%);
  overflow-y: auto;
}
.ring .ring-clock { text-align: center; }
.ring .ring-clock .t { font-size: 52px; font-weight: 300; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.ring .ring-clock .d { color: rgba(255,255,255,0.65); font-size: 14px; margin-top: 6px; font-weight: 500; }
.ring .ring-clock .waking { margin-top: 10px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-2); }

.task {
  margin: 22px 0 14px; text-align: center;
}
.task .cue { font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255,255,255,0.55); }
.task .emoji { font-size: 76px; line-height: 1; margin: 12px 0 10px; display: block; filter: drop-shadow(0 6px 18px rgba(0,0,0,0.4)); }
.task .name { font-size: 27px; font-weight: 800; letter-spacing: -0.01em; }
.task .hint {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.9);
}

/* simulated camera viewport */
.cam {
  position: relative; margin: 6px auto 0; width: 100%; max-width: 320px; aspect-ratio: 3 / 4;
  border-radius: var(--radius-lg); overflow: hidden; background: #0c0c10;
  border: 1px solid rgba(255,255,255,0.14);
  display: flex; align-items: center; justify-content: center;
}
.cam .viewfinder {
  position: absolute; inset: 0;
  background:
    linear-gradient(115deg, rgba(255,255,255,0.05), transparent 40%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0 12px, transparent 12px 24px);
}
.cam .reticle { position: absolute; inset: 26px; border: 2px dashed rgba(255,255,255,0.3); border-radius: 20px; }
.cam .ghost { font-size: 96px; opacity: 0.14; }
.cam .scanline {
  position: absolute; left: 0; right: 0; height: 3px; top: 0;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
  box-shadow: 0 0 16px 3px color-mix(in srgb, var(--accent-2) 70%, transparent);
  animation: scan 1.4s ease-in-out infinite;
}
@keyframes scan { 0% { top: 6%; } 50% { top: 92%; } 100% { top: 6%; } }
.cam .cam-status {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  padding: 7px 16px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(0,0,0,0.5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); white-space: nowrap;
}
.cam.detecting .reticle { border-color: var(--accent-2); }
.cam .check { font-size: 88px; color: var(--ok); animation: pop 0.4s cubic-bezier(0.2,1.4,0.4,1); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ring controls dock */
.ring-controls { margin-top: auto; padding-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.shutter {
  width: 76px; height: 76px; border-radius: 50%; align-self: center; flex: none;
  background: #fff; border: 5px solid rgba(255,255,255,0.35);
  box-shadow: 0 6px 24px rgba(0,0,0,0.4); transition: transform 0.08s ease;
}
.shutter:active { transform: scale(0.92); }
.shutter:disabled { opacity: 0.5; }
.shutter-cap { text-align: center; font-size: 12.5px; color: rgba(255,255,255,0.7); font-weight: 600; margin-top: -2px; }

.ring-btn {
  display: flex; width: 100%; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 18px; border-radius: var(--radius-pill); font-weight: 650; font-size: 15.5px;
  background: rgba(255,255,255,0.14); color: #fff; transition: transform 0.06s ease, opacity 0.15s;
}
.ring-btn:active { transform: scale(0.98); }
.ring-btn:disabled { opacity: 0.5; }
.ring-btn.snooze { background: transparent; color: rgba(255,255,255,0.75); }

.override-link { text-align: center; }
.override-link button { color: rgba(255,255,255,0.55); font-size: 13px; font-weight: 600; padding: 8px; text-decoration: underline; }
.hold-btn {
  position: relative; overflow: hidden;
  background: rgba(255,90,90,0.16); color: #ff8f8f; border: 1px solid rgba(255,120,120,0.4);
}
.hold-btn .fill {
  position: absolute; inset: 0; width: 0%; background: rgba(255,90,90,0.35); pointer-events: none;
  transition: width 0.05s linear;
}
.hold-btn span { position: relative; z-index: 1; }

/* ---------- interstitial ad ---------- */
.ad-wrap { position: absolute; inset: 0; z-index: 120; background: #101015; display: flex; flex-direction: column; color: #fff; animation: fadein 0.2s ease; }
.ad-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-size: 12px; color: rgba(255,255,255,0.6); font-weight: 600; }
.ad-close { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,0.12); color: #fff; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; }
.ad-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; gap: 12px; }
.ad-badge { align-self: center; font-size: 10.5px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; background: rgba(255,255,255,0.14); padding: 4px 10px; border-radius: 6px; }
.ad-art { font-size: 76px; }
.ad-cta { background: #fff; color: #111; padding: 12px 26px; border-radius: 999px; font-weight: 700; margin-top: 8px; }
.ad-remove { padding: 14px 18px calc(20px + env(safe-area-inset-bottom,0px)); text-align: center; }
.ad-remove button { color: var(--accent-2); font-weight: 700; font-size: 14.5px; }

/* ---------- stats ---------- */
.period { margin-bottom: 14px; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 12px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat-tile .v { font-size: 25px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-tile .l { font-size: 12.5px; color: var(--text-2); margin-top: 2px; line-height: 1.3; }
.stat-tile .ic { font-size: 16px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg text { font-family: var(--font); }

/* ---------- settings ---------- */
.set-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px 2px; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: none; }
.set-row .mid { flex: 1; min-width: 0; }
.set-row .t { display: block; font-weight: 550; font-size: 15.5px; }
.set-row .s { display: block; font-size: 12.5px; color: var(--text-2); }
.set-row .chev { color: var(--text-3); font-size: 17px; }
.set-row .avatar { width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; font-size: 17px; background: var(--accent-soft); color: var(--accent-ink); flex: none; }

/* palette swatches */
.pal-row { display: flex; gap: 12px; }
.pal { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 6px; border-radius: var(--radius-sm); border: 2px solid transparent; }
.pal.on { border-color: var(--accent); background: var(--accent-soft); }
.pal .dot { width: 40px; height: 40px; border-radius: 50%; box-shadow: var(--shadow); }
.pal .nm { font-size: 12px; color: var(--text-2); font-weight: 600; }

/* sound picker rows */
.sound-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 2px; border-bottom: 1px solid var(--border); }
.sound-row:last-child { border-bottom: none; }
.sound-row .nm { flex: 1; font-weight: 550; font-size: 15px; }
.sound-row .tick { color: var(--accent); font-size: 18px; width: 20px; }
.sound-row .play { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* ---------- paywall ---------- */
.plan {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 16px; border-radius: var(--radius); margin-bottom: 10px;
  background: var(--surface); border: 2px solid var(--border); box-shadow: var(--shadow);
}
.plan.on { border-color: var(--accent); background: var(--accent-soft); }
.plan .radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text-3); flex: none; }
.plan.on .radio { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 45%, transparent 50%); }
.plan .mid { flex: 1; }
.plan .t { display: block; font-weight: 750; font-size: 16px; }
.plan .s { display: block; font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.plan .price { text-align: right; }
.plan .price b { font-size: 17px; }
.plan .price span { display: block; font-size: 11.5px; color: var(--text-2); }
.plan .badge-pop {
  position: absolute; top: -9px; right: 14px; padding: 3px 11px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 800; letter-spacing: 0.03em;
}
.paywall-hero { text-align: center; padding: 12px 6px 6px; }
.paywall-hero .logo { font-size: 52px; }
.paywall-hero h2 { margin-top: 8px; }
.paywall-hero p { color: var(--text-2); margin-top: 6px; font-size: 14.5px; }
.perk { display: flex; align-items: center; gap: 10px; padding: 8px 2px; font-size: 14.5px; }
.perk .k { color: var(--ok); font-weight: 800; }

/* ---------- onboarding ---------- */
.ob { height: 100%; display: flex; flex-direction: column; padding: 24px 24px calc(26px + env(safe-area-inset-bottom,0px)); }
.ob-hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ob-hero .logo { font-size: 76px; margin-bottom: 14px; }
.ob-hero h1 { font-size: 27px; }
.ob-hero p { color: var(--text-2); margin-top: 12px; font-size: 16px; max-width: 300px; }
.ob-dots { display: flex; gap: 6px; justify-content: center; margin: 18px 0; }
.ob-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); transition: all 0.2s; }
.ob-dots i.on { background: var(--accent); width: 20px; border-radius: 999px; }

/* ---------- misc ---------- */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-height: 40px; }
.topbar .back { display: inline-flex; align-items: center; gap: 3px; color: var(--accent); font-weight: 600; font-size: 15.5px; padding: 6px 8px 6px 0; }
.topbar .title { flex: 1; text-align: center; font-weight: 700; font-size: 16px; }
.topbar .spacer { min-width: 60px; text-align: right; }
.topbar .save { color: var(--accent); font-weight: 700; font-size: 15.5px; padding: 6px 0; }

.notice { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-size: 13px; line-height: 1.5; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty .e { font-size: 40px; margin-bottom: 10px; }
.empty p { font-size: 14.5px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }

/* bottom sheet */
.sheet-wrap { position: absolute; inset: 0; z-index: 100; display: flex; align-items: flex-end; background: var(--overlay); animation: fadein 0.18s ease; }
.sheet {
  width: 100%; max-height: 86%; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-lg); animation: sheetup 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.sheet .grab { width: 40px; height: 4.5px; border-radius: 999px; background: var(--surface-3); margin: 4px auto 14px; }
@keyframes sheetup { from { transform: translateY(60px); opacity: 0.5; } to { transform: none; opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.toast {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(104px + env(safe-area-inset-bottom, 0px));
  background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 200; box-shadow: var(--shadow-lg);
  animation: fadein 0.2s ease; white-space: nowrap; max-width: 88%; overflow: hidden; text-overflow: ellipsis;
}
