/* Shared design system: iOS-style, RTL, light + dark. */
:root {
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --text: #000000;
  --text-2: rgba(60, 60, 67, 0.62);
  --text-3: rgba(60, 60, 67, 0.32);
  --sep: rgba(60, 60, 67, 0.16);
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, 0.14);
  --orange: #ff9500;
  --orange-soft: rgba(255, 149, 0, 0.14);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --radius-lg: 22px;
  --blur-bg: rgba(242, 242, 247, 0.78);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Heebo", "Arial Hebrew", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elev: #1c1c1e;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.36);
    --text: #ffffff;
    --text-2: rgba(235, 235, 245, 0.6);
    --text-3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.6);
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.2);
    --green: #30d158;
    --green-soft: rgba(48, 209, 88, 0.18);
    --orange: #ff9f0a;
    --orange-soft: rgba(255, 159, 10, 0.18);
    --red: #ff453a;
    --red-soft: rgba(255, 69, 58, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --blur-bg: rgba(0, 0, 0, 0.72);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 17px; line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

/* --- layout ----------------------------------------------------------- */
.page { max-width: 720px; margin: 0 auto; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
.page.wide { max-width: 1120px; }
.nav {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: var(--blur-bg); border-bottom: 0.5px solid var(--sep);
  padding-top: env(safe-area-inset-top);
}
.nav-inner { max-width: 1120px; margin: 0 auto; height: 52px; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.nav-title { font-weight: 600; font-size: 17px; flex: 1; display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6); color: #fff;
}
.large-title { font-size: 34px; font-weight: 700; letter-spacing: -0.4px; margin: 20px 0 6px; }
.subtitle { color: var(--text-2); font-size: 15px; margin: 0 0 18px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 4px 8px; }
.section-head h2 { font-size: 22px; font-weight: 700; margin: 0; }
.caption { color: var(--text-2); font-size: 13px; }
.muted { color: var(--text-2); }
.row-flex { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.grid { display: grid; gap: 12px; }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

/* --- surfaces ----------------------------------------------------------- */
.card { background: var(--bg-elev); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.list { background: var(--bg-elev); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; position: relative; min-height: 56px; }
.list-row + .list-row::before {
  content: ""; position: absolute; top: 0; inset-inline-start: 16px; inset-inline-end: 0;
  border-top: 0.5px solid var(--sep);
}
.list-row.tap { cursor: pointer; }
.list-row.tap:active { background: var(--fill); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

.stat { padding: 16px; }
.stat .num { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; }
.stat .lbl { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.stat.warn .num { color: var(--orange); }
.stat.accent .num { color: var(--accent); }

/* --- app icon ----------------------------------------------------------- */
.app-icon {
  width: 60px; height: 60px; border-radius: 22.5%; flex: none; object-fit: cover;
  background: var(--fill); box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08);
  display: grid; place-items: center; color: var(--text-3); overflow: hidden;
}
.app-icon.lg { width: 112px; height: 112px; }
.app-icon.sm { width: 44px; height: 44px; }

/* --- buttons ------------------------------------------------------------ */
.btn {
  appearance: none; border: 0; cursor: pointer; border-radius: 12px; padding: 13px 20px;
  font-weight: 600; font-size: 17px; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.12s ease, opacity 0.2s ease, background 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.plain { background: var(--fill); color: var(--text); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.small { padding: 7px 14px; font-size: 15px; border-radius: 10px; }
.btn.lg { padding: 16px 22px; border-radius: 14px; }
.icon-btn {
  appearance: none; border: 0; background: var(--fill); color: var(--accent); cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
}
.icon-btn:active { opacity: 0.6; }

/* The App Store "Get" pill and its states. */
.get {
  appearance: none; border: 0; cursor: pointer; min-width: 74px; height: 30px; padding: 0 16px;
  border-radius: 15px; background: var(--fill); color: var(--accent);
  font-weight: 700; font-size: 15px; display: inline-grid; place-items: center; flex: none;
  transition: background 0.2s ease, color 0.2s ease, transform 0.12s ease;
}
.get:active { transform: scale(0.95); }
.get.ready { background: var(--accent); color: #fff; }
.get.busy { background: transparent; cursor: default; min-width: 74px; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--fill-2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.spinner.lg { width: 40px; height: 40px; border-width: 3.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- forms -------------------------------------------------------------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin: 0 4px 6px; }
.input {
  width: 100%; border: 0; outline: none; background: var(--bg-elev); border-radius: 12px;
  padding: 14px 16px; font-size: 17px; box-shadow: inset 0 0 0 1px var(--sep);
  transition: box-shadow 0.15s ease;
}
.input:focus { box-shadow: inset 0 0 0 2px var(--accent); }
textarea.input { min-height: 90px; resize: vertical; }
.sheet .input, .card .input { background: var(--bg); }
.search {
  width: 100%; border: 0; outline: none; background: var(--fill); border-radius: 10px;
  padding: 9px 36px 9px 12px; font-size: 17px; margin: 4px 0 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m14 14-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.error-text { color: var(--red); font-size: 14px; margin: 8px 4px 0; min-height: 1em; }

.seg { display: inline-flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button {
  appearance: none; border: 0; background: transparent; padding: 6px 14px; border-radius: 7px;
  font-size: 14px; font-weight: 500; cursor: pointer; color: var(--text);
}
.seg button.on { background: var(--bg-elev); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); font-weight: 600; }

.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--fill-2); border-radius: 31px; transition: background 0.2s; cursor: pointer; }
.switch span::after {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 27px; height: 27px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); transition: transform 0.2s;
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(-20px); }

/* --- badges -------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: var(--fill); color: var(--text-2); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }

/* --- sheet (modal) ------------------------------------------------------ */
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.2s ease;
}
.sheet {
  background: var(--bg-elev); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 14px 14px 0 0; padding: 8px 20px calc(24px + env(safe-area-inset-bottom));
  animation: up 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--fill-2); margin: 0 auto 12px; }
.sheet h3 { font-size: 20px; margin: 4px 0 16px; text-align: center; }
@media (min-width: 700px) {
  .backdrop { align-items: center; }
  .sheet { border-radius: 18px; padding-bottom: 24px; }
  .sheet .grabber { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* --- toast ---------------------------------------------------------------- */
.toast-host { position: fixed; z-index: 80; left: 0; right: 0; bottom: calc(24px + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: rgba(30, 30, 32, 0.92); color: #fff; padding: 11px 18px; border-radius: 99px;
  font-size: 15px; font-weight: 500; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  animation: up 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.toast.err { background: var(--red); }

/* --- misc ------------------------------------------------------------------ */
.empty { text-align: center; color: var(--text-2); padding: 48px 16px; }
.empty .big { font-size: 44px; margin-bottom: 8px; }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.drop {
  border: 2px dashed var(--fill-2); border-radius: var(--radius); padding: 28px 16px; text-align: center;
  color: var(--text-2); transition: border-color 0.15s, background 0.15s; cursor: pointer;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.progress { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.25s ease; }
.copy-chip { appearance: none; border: 0; background: var(--fill); border-radius: 8px; padding: 4px 8px; cursor: pointer; color: var(--text); }
.copy-chip:active { opacity: 0.6; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 15px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
.fade-in { animation: fade 0.35s ease; }

/* --- hero (join + store) -------------------------------------------------- */
.hero {
  position: relative; overflow: hidden; text-align: center; color: #fff;
  border-radius: 28px; padding: 36px 22px 28px;
  background: linear-gradient(150deg, #0a84ff 0%, #5e5ce6 55%, #8e44ec 100%);
  box-shadow: 0 18px 50px rgba(48, 72, 230, 0.35);
}
.hero-glow {
  position: absolute; inset: -40% -20% auto; height: 120%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.35), transparent 70%);
  opacity: 0.55; transform: translateY(-30%);
}
.hero > * { position: relative; }
.hero-icon { display: inline-block; margin-bottom: 14px; animation: float 4s ease-in-out infinite; }
.hero-icon img, .hero-icon .brand-mark {
  width: 96px; height: 96px; border-radius: 22.5%; display: block;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25), inset 0 0 0 0.5px rgba(255, 255, 255, 0.4);
}
.hero-kicker { font-size: 15px; opacity: 0.85; margin-bottom: 4px; }
.hero-title { font-size: 30px; font-weight: 800; letter-spacing: -0.4px; margin: 0 0 8px; line-height: 1.15; }
.hero-sub { font-size: 16px; opacity: 0.9; margin: 0 auto 20px; max-width: 420px; }
.hero-btn {
  background: #fff; color: #3a4be8; width: 100%; max-width: 360px; font-size: 18px; font-weight: 700;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}
.hero-btn:disabled { opacity: 0.85; }
.hero-fine { font-size: 13px; opacity: 0.8; margin-top: 12px; }
.hero-note {
  display: inline-flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, 0.18);
  padding: 12px 16px; border-radius: 14px; font-weight: 600;
}
.hero-done { background: rgba(255, 255, 255, 0.16); border-radius: 18px; padding: 16px; font-weight: 700; font-size: 18px; }
.hero-done .btn.secondary { background: rgba(255, 255, 255, 0.92); color: #3a4be8; }
.feature { display: grid; gap: 4px; }
.feature-icon {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 6px;
  background: var(--accent-soft); color: var(--accent);
}
.float { animation: float 4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .hero-icon, .float { animation: none; } }

/* Inputs living inside a grouped list (iOS settings style). */
.input.bare { box-shadow: none; background: transparent; padding: 12px 0; }
.input.bare:focus { box-shadow: none; }

/* Stat tiles with an icon chip. */
.stat .stat-icon {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; margin-bottom: 10px;
  background: var(--fill); color: var(--text-2);
}
.stat.accent .stat-icon { background: var(--accent-soft); color: var(--accent); }
.stat.warn .stat-icon { background: var(--orange-soft); color: var(--orange); }
.stat.good .stat-icon { background: var(--green-soft); color: var(--green); }
.stat.good .num { color: var(--green); }

/* "Open in Safari" card for in-app browsers. */
.safari-card { border: 1.5px solid var(--accent-soft); margin: 18px 0; }
.safari-steps { margin: 12px 0 0; padding-inline-start: 1.3em; line-height: 1.75; font-size: 15px; }
.safari-steps b { font-weight: 700; }
.safari-fallback { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 15px; }
