/* ==========================================================================
   Stay on My Side — visual system
   Dark shell, gold = process, coral = activation, purple = stage.
   ========================================================================== */

:root {
  --bg: #08080a;
  --bg-2: #0d0d10;
  --card: #17171b;
  --card-2: #1e1e23;
  --card-3: #26262c;
  --line: #2a2a31;
  --line-soft: #202027;

  --txt: #f4f4f6;
  --txt-2: #b7b7c0;
  --muted: #85858f;
  --faint: #5c5c66;

  --gold: #f0c22e;
  --gold-dim: #8a7124;
  --coral: #f4594c;
  --coral-2: #e8412f;
  --purple: #7c5cff;
  --purple-dim: #4a3799;
  --green: #3fbf87;

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --r-xl: 24px;

  --pad: 20px;
  /* Content row only. iOS tab bars are ~49pt; the safe-area inset is added
     on top of this, so a taller row here makes the bar look detached. */
  --tab-h: 52px;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

/* Class rules would otherwise outrank the UA's [hidden] { display:none }. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* Only inputs should be selectable — everything else behaves like an app. */
body { -webkit-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: text; user-select: text; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
a { color: inherit; text-decoration: none; }

/* ---------- Shell ---------- */

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  /* Phone-shaped on any screen; a no-op on an actual phone. */
  max-width: 520px;
  margin: 0 auto;
}

.screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--sat) + 8px) calc(var(--pad) + var(--sar)) 28px calc(var(--pad) + var(--sal));
  scrollbar-width: none;
}
.screen::-webkit-scrollbar { display: none; }
.screen.has-tabs { padding-bottom: calc(var(--tab-h) + var(--sab) + 24px); }

.view { animation: fade 0.22s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- Tab bar ---------- */

.tabbar {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--line-soft);
  background: rgba(10, 10, 12, 0.92);
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  /* The home-indicator pill sits ~8-13pt above the bottom edge, so the full
     34pt inset reserves more room than a tab bar needs. Trimming 14px sits
     the bar low without crowding the indicator. */
  padding-bottom: max(calc(var(--sab) - 14px), 0px);
  padding-left: var(--sal);
  padding-right: var(--sar);
}
.tabbar button {
  flex: 1;
  height: var(--tab-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--faint);
  transition: color 0.16s var(--ease);
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button span { font-size: 10px; letter-spacing: 0.02em; font-weight: 500; }
.tabbar button.active { color: var(--gold); }
.tabbar button.active svg { filter: drop-shadow(0 0 10px rgba(240, 194, 46, 0.35)); }

/* ---------- Type ---------- */

.h-hero {
  font-size: 40px;
  line-height: 0.94;
  font-weight: 800;
  letter-spacing: -0.025em;
  text-transform: uppercase;
  margin: 6px 0 0;
}
@media (max-width: 360px) { .h-hero { font-size: 34px; } }

.h1 {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin: 0;
  text-align: center;
}
.h2 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  text-align: center;
}
.eyebrow.purple { color: var(--purple); }

.sub {
  font-size: 15px;
  color: var(--txt-2);
  text-align: center;
  margin: 8px 0 0;
  line-height: 1.4;
}
.process {
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
  margin-top: 12px;
}
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.center { text-align: center; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  margin-bottom: 4px;
}
.topbar .slot { width: 44px; display: flex; align-items: center; }
.topbar .slot.right { justify-content: flex-end; }
.iconbtn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  color: var(--txt-2);
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.iconbtn:active { background: var(--card-2); color: var(--txt); }
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn.gold { color: var(--gold); }

/* ---------- Buttons ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 15px 18px;
  border-radius: var(--r);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: transform 0.12s var(--ease), opacity 0.16s var(--ease);
}
.btn:active { transform: scale(0.985); }
.btn svg { width: 19px; height: 19px; flex: none; }

.btn-gold { background: var(--gold); color: #17140a; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-ghost {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--txt);
  letter-spacing: 0.05em;
}
.btn-quiet {
  background: transparent;
  color: var(--muted);
  min-height: 46px;
  font-size: 12.5px;
  letter-spacing: 0.14em;
}
.btn-danger { background: rgba(244, 89, 76, 0.12); border: 1px solid rgba(244, 89, 76, 0.4); color: var(--coral); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

/* Home primary actions */
.action {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  padding: 18px;
  border-radius: var(--r-lg);
  text-align: left;
  transition: transform 0.12s var(--ease);
}
.action:active { transform: scale(0.985); }
.action .ico {
  width: 42px; height: 42px;
  flex: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.14);
}
.action .ico svg { width: 21px; height: 21px; }
.action .txt { min-width: 0; display: block; }
.action .t {
  display: block;
  font-size: 16px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
}
.action .d { display: block; font-size: 12.5px; opacity: 0.75; margin-top: 3px; line-height: 1.3; }

.action-activated {
  background: linear-gradient(135deg, var(--coral) 0%, var(--coral-2) 100%);
  color: #fff;
  box-shadow: 0 10px 30px -12px rgba(244, 89, 76, 0.6);
}
.action-secondary { background: var(--card); border: 1px solid var(--line); color: var(--txt); }
.action-secondary .ico { background: var(--card-3); color: var(--txt-2); }

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 16px;
}
.card-flat { background: var(--card); border-radius: var(--r); padding: 14px 16px; }

.note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 14px 16px;
  color: var(--txt-2);
  font-size: 13.5px;
  line-height: 1.45;
}
.note svg { width: 18px; height: 18px; flex: none; color: var(--muted); margin-top: 1px; }

/* ---------- Forms ---------- */

.field { position: relative; }
.field textarea, .field input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  color: var(--txt);
  font-size: 15.5px;
  line-height: 1.45;
  padding: 15px 16px 30px;
  resize: none;
  outline: none;
  transition: border-color 0.16s var(--ease);
  font-family: inherit;
}
.field input { padding-bottom: 15px; }
.field textarea::placeholder, .field input::placeholder { color: var(--faint); }
.field textarea:focus, .field input:focus { border-color: var(--card-3); }
.field .count {
  position: absolute;
  right: 13px;
  bottom: 9px;
  font-size: 11px;
  color: var(--faint);
  pointer-events: none;
}

.label {
  font-size: 14.5px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--txt);
}

/* ---------- Choice grids ---------- */

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }

.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 78px;
  padding: 12px 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--txt-2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  transition: border-color 0.16s var(--ease), color 0.16s var(--ease), background 0.16s var(--ease), transform 0.12s var(--ease);
}
.chip svg { width: 21px; height: 21px; }
.chip:active { transform: scale(0.96); }
.chip.on {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(240, 194, 46, 0.07);
}
.chip.on.purple { border-color: var(--purple); color: var(--purple); background: rgba(124, 92, 255, 0.09); }

/* Inline pill suggestions */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  padding: 9px 13px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--txt-2);
  font-size: 13px;
  text-align: left;
  transition: border-color 0.16s var(--ease), color 0.16s var(--ease);
}
.pill:active { border-color: var(--gold); color: var(--gold); }

/* ---------- Reminder lists ---------- */

.reminders { display: flex; flex-direction: column; gap: 2px; }
.reminder {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 11px 2px;
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--txt);
}
.reminder svg { width: 19px; height: 19px; flex: none; color: var(--gold); margin-top: 1px; }
.reminder.purple svg { color: var(--purple); }
.reminder.green svg { color: var(--green); }

/* ---------- Rows / lists ---------- */

.rows { display: flex; flex-direction: column; gap: 2px; }
.row {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--r-sm);
  text-align: left;
  transition: background 0.16s var(--ease);
}
.row:active { background: var(--card-2); }
.row > svg:first-child { width: 19px; height: 19px; flex: none; color: var(--green); }
.row[data-delete] > svg:first-child { color: var(--coral); }
.row[data-delete] .t { color: var(--coral); }
.row .body { flex: 1; min-width: 0; display: block; }
.row .t { display: block; font-size: 14.5px; line-height: 1.3; }
.row .d { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.row .radio {
  width: 20px; height: 20px; flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--card-3);
  display: flex; align-items: center; justify-content: center;
}
.row .radio svg { display: none; width: 12px; height: 12px; }
.row.on { background: rgba(240, 194, 46, 0.08); }
.row.on .radio { border-color: var(--gold); background: var(--gold); color: #17140a; }
.row.on .radio svg { display: block; }
.row .chev { width: 17px; height: 17px; color: var(--faint); flex: none; }

/* ---------- Yes / No ---------- */

.yn { display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: var(--card); border-radius: var(--r-sm); }
.yn .q { flex: 1; font-size: 13.5px; line-height: 1.3; }
.yn > svg { width: 18px; height: 18px; color: var(--purple); flex: none; }
.yn .opts { display: flex; gap: 6px; flex: none; }
.yn .opt {
  min-width: 46px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--card-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.yn .opt.on { background: var(--purple); color: #fff; }
.yn .opt.on.no { background: var(--card-3); color: var(--txt); }

/* ---------- Tabs (segmented) ---------- */

.segs { display: flex; border-bottom: 1px solid var(--line-soft); margin-bottom: 22px; }
.segs button {
  flex: 1;
  padding: 13px 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.16s var(--ease), border-color 0.16s var(--ease);
}
.segs button.active { color: var(--purple); border-bottom-color: var(--purple); }
.segs.gold button.active { color: var(--gold); border-bottom-color: var(--gold); }

.filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
  flex: none;
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.filters button.active { background: var(--gold); border-color: var(--gold); color: #17140a; font-weight: 600; }

/* ---------- Step dots ---------- */

.dots { display: flex; justify-content: center; gap: 9px; padding: 22px 0 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--card-3); transition: background 0.2s var(--ease); }
.dots i.on { background: var(--gold); }

/* ---------- Stats ---------- */

.stats {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 16px;
  text-align: left;
}
.stats > svg { width: 22px; height: 22px; color: var(--green); flex: none; }
.stats .cols { flex: 1; display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.stats .col { display: block; }
.stats .col .k { display: block; font-size: 11.5px; color: var(--muted); }
.stats .col .v { display: block; font-size: 17px; font-weight: 700; margin-top: 3px; white-space: nowrap; }
.stats .chev { width: 18px; height: 18px; color: var(--faint); flex: none; }

/* ---------- Banner ---------- */

.banner {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--r);
  background: rgba(240, 194, 46, 0.09);
  border: 1px solid rgba(240, 194, 46, 0.28);
  text-align: left;
  color: var(--gold);
}
.banner svg:first-child { width: 19px; height: 19px; flex: none; }
.banner .body { flex: 1; min-width: 0; display: block; }
.banner .t { display: block; font-size: 13.5px; font-weight: 600; }
.banner .d { display: block; font-size: 12px; opacity: 0.72; margin-top: 2px; }
.banner .chev { width: 17px; height: 17px; opacity: 0.6; flex: none; }
.banner.purple { background: rgba(124, 92, 255, 0.1); border-color: rgba(124, 92, 255, 0.3); color: #a894ff; }

/* ---------- Quote ---------- */

.quote { text-align: center; padding: 6px 12px 2px; }
.quote .mark { color: var(--card-3); display: flex; justify-content: center; margin-bottom: 10px; }
.quote .mark svg { width: 26px; height: 26px; }
.quote p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--muted); }

.rule { height: 1px; background: var(--line-soft); margin: 24px 0; }

/* ---------- History entries ---------- */

.entry {
  display: flex;
  gap: 13px;
  width: 100%;
  padding: 15px 16px;
  background: var(--card);
  border-radius: var(--r);
  text-align: left;
  align-items: flex-start;
}
.entry:active { background: var(--card-2); }
.entry .badge {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card-2);
}
.entry .badge svg { width: 17px; height: 17px; }
.entry .badge.act { color: var(--coral); background: rgba(244, 89, 76, 0.12); }
.entry .badge.rep { color: var(--green); background: rgba(63, 191, 135, 0.12); }
.entry .badge.stage { color: var(--purple); background: rgba(124, 92, 255, 0.13); }
.entry .body { flex: 1; min-width: 0; display: block; }
.entry .meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--faint); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.entry .t { display: block; font-size: 14.5px; line-height: 1.35; }
.entry .d { display: block; font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.4; }

.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--card-3);
  color: var(--txt-2);
}
.tag.pending { background: rgba(240, 194, 46, 0.16); color: var(--gold); }
.tag.done { background: rgba(63, 191, 135, 0.14); color: var(--green); }

.day-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 18px 4px 8px;
}

/* ---------- Learning card ---------- */

.learn {
  background: linear-gradient(150deg, rgba(63, 191, 135, 0.1), rgba(63, 191, 135, 0.02));
  border: 1px solid rgba(63, 191, 135, 0.22);
  border-radius: var(--r);
  padding: 15px 16px;
}
.learn .t { font-size: 14.5px; line-height: 1.4; }
.learn .d { font-size: 11.5px; color: var(--muted); margin-top: 7px; }

/* ---------- Exposure complete ---------- */

.exposure {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 17px;
  border-radius: var(--r);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.22), rgba(124, 92, 255, 0.08));
  border: 1px solid rgba(124, 92, 255, 0.4);
  text-align: left;
}
.exposure svg { width: 24px; height: 24px; color: var(--purple); flex: none; }
.exposure > span { display: block; min-width: 0; }
.exposure .t { display: block; font-size: 15px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.exposure .d { display: block; font-size: 12px; color: var(--txt-2); margin-top: 4px; line-height: 1.35; }

/* ---------- Empty state ---------- */

.empty { text-align: center; padding: 54px 24px; color: var(--faint); }
.empty svg { width: 34px; height: 34px; margin-bottom: 14px; opacity: 0.5; }
.empty p { margin: 0; font-size: 13.5px; line-height: 1.5; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sab) + var(--tab-h) + 20px);
  transform: translate(-50%, 20px);
  background: var(--card-3);
  color: var(--txt);
  font-size: 13.5px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
  z-index: 90;
  max-width: calc(100vw - 48px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Sheet ---------- */

.sheet-root { position: fixed; inset: 0; z-index: 100; }
.sheet-scrim {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  animation: fadeIn 0.2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 10px calc(var(--pad) + var(--sar)) calc(var(--sab) + 20px) calc(var(--pad) + var(--sal));
  max-height: 86vh;
  overflow-y: auto;
  animation: slideUp 0.26s var(--ease);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet .handle { width: 38px; height: 4px; border-radius: 2px; background: var(--card-3); margin: 0 auto 18px; }

/* ---------- Utility ---------- */

.ico-inline { display: flex; flex: none; }
.ico-inline svg { width: 19px; height: 19px; }

.stack > * + * { margin-top: 12px; }
.stack-sm > * + * { margin-top: 8px; }
.stack-lg > * + * { margin-top: 20px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.grow { flex: 1; }
.hide { display: none !important; }
