/* =========================================================================
   MEDIJEWEL - Sage & Gold design system
   Exact palette / type / shadows / radii / motion from the brand spec.
   ========================================================================= */

/* ----- Font-size control (the Settings slider drives --font-scale) ------- */
:root { --font-scale: 1; }
html { font-size: calc(16px * var(--font-scale)); -webkit-text-size-adjust: 100%; }

/* =========================== THEME TOKENS ================================ */
.device {
  /* Core palette */
  --cream: #f2f4f1;
  --forest: #2c3a30;
  --sage: #7e9b7e;
  --gold: #c9a66b;
  /* Supporting */
  --cream-soft: #fafbf9;
  --cream-deep: #e7eae3;
  --forest-soft: #3a4a3e;
  --forest-muted: #36453b;
  --sage-light: #a9bca9;
  --sage-pale: #dce4dc;
  --sage-dark: #4c644d;
  --gold-soft: #d9bd8a;
  --gold-deep: #a98a4f;
  --gold-grad: linear-gradient(135deg, #d9bd8a 0%, #c9a66b 45%, #b08f54 100%);

  /* Semantic (light default) */
  --bg: var(--cream);
  --bg-alt: var(--cream-deep);
  --surface: var(--cream-soft);
  --surface-2: #ffffff;
  --text: var(--forest);
  --text-muted: var(--forest-muted);
  --text-dim: var(--sage-dark);
  --border: var(--sage-light);
  --hairline: rgba(126, 155, 126, 0.28);
  --fill-hover: var(--sage-pale);
  --accent: var(--gold);
  --on-accent: var(--forest);

  /* States */
  --danger: #b4543f;
  --danger-bg: #f6e7e2;
  --success: #4c644d;
  --success-bg: #e3ece1;
  --warn: #a98a4f;

  /* Radii */
  --r-pill: 999px;
  --r-card: 16px;
  --r-lg: 32px;
  --r-sm: 10px;

  /* Shadows (forest-tinted, soft) */
  --sh-soft: 0 2px 8px -4px rgba(44,58,48,.12), 0 14px 36px -22px rgba(44,58,48,.24);
  --sh-card: 0 1px 2px rgba(44,58,48,.04), 0 12px 28px -16px rgba(44,58,48,.18), 0 28px 56px -32px rgba(44,58,48,.22);
  --sh-lift: 0 4px 10px -6px rgba(44,58,48,.14), 0 24px 50px -22px rgba(44,58,48,.28), 0 44px 80px -40px rgba(44,58,48,.30);
  --sh-product: 0 30px 60px -30px rgba(44,58,48,.40), 0 70px 120px -60px rgba(44,58,48,.45);

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 150ms;
  --t-mid: 240ms;
  --t-slow: 300ms;

  /* Type families */
  --serif: "Cormorant", Georgia, "Times New Roman", serif;
  --sans: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Hebrew swaps the font pairing. */
.device[dir="rtl"] {
  --serif: "Frank Ruhl Libre", Georgia, serif;
  --sans: "Heebo", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ----------------------------- DARK MODE -------------------------------- */
.device[data-theme="dark"] {
  --bg: var(--forest);
  --bg-alt: #243029;
  --surface: var(--forest-soft);
  --surface-2: #43564a;
  --text: var(--cream);
  --text-muted: #cdd6cb;
  --text-dim: var(--sage-light);
  --border: rgba(169, 188, 169, 0.28);
  --hairline: rgba(217, 189, 138, 0.22);
  --fill-hover: rgba(126, 155, 126, 0.18);
  --on-accent: var(--forest);
  --danger: #e08c78;
  --danger-bg: rgba(180, 84, 63, 0.18);
  --success: #a9bca9;
  --success-bg: rgba(126, 155, 126, 0.18);
  --sh-soft: 0 2px 8px -4px rgba(0,0,0,.4), 0 14px 36px -22px rgba(0,0,0,.55);
  --sh-card: 0 1px 2px rgba(0,0,0,.3), 0 12px 28px -16px rgba(0,0,0,.5), 0 28px 56px -32px rgba(0,0,0,.55);
  --sh-lift: 0 4px 10px -6px rgba(0,0,0,.4), 0 24px 50px -22px rgba(0,0,0,.55), 0 44px 80px -40px rgba(0,0,0,.6);
}

/* ============================== RESET =================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
*::-webkit-scrollbar { width: 0; height: 0; }
* { scrollbar-width: none; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: #20271f;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
input, select, textarea { font: inherit; color: inherit; }
input:focus-visible, button:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--gold-deep);
  outline-offset: 3px;
  border-radius: 6px;
}
img, svg { display: block; max-width: 100%; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }

/* ===================== DEVICE FRAME (desktop preview) =================== */
body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
}
.device {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  transition: background var(--t-slow) var(--ease);
}
/* Soft device chrome only when there is room around it (desktop preview). */
@media (min-width: 540px) and (min-height: 760px) {
  body { background: radial-gradient(120% 100% at 50% 0%, #2f3d33 0%, #20271f 60%, #171c16 100%); }
  .device {
    height: min(932px, 94dvh);
    border-radius: 44px;
    box-shadow: var(--sh-product), 0 0 0 11px #11150f, 0 0 0 13px #2a342b;
  }
}

.app {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  transition: background var(--t-slow) var(--ease), color var(--t-slow) var(--ease);
}
/* Quiet film grain over flat fills. */
.app::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0.025;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
.device[data-theme="dark"] .app::after { mix-blend-mode: screen; opacity: 0.04; }

/* ============================ TYPOGRAPHY ================================ */
h1, h2, h3, h4, .serif {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--text);
}
.device[dir="rtl"] h1,
.device[dir="rtl"] h2,
.device[dir="rtl"] h3,
.device[dir="rtl"] h4,
.device[dir="rtl"] .serif { font-weight: 500; letter-spacing: 0; line-height: 1.12; }

h1 { font-size: 2.6rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.45rem; }
p { line-height: 1.7; color: var(--text-muted); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--sans);
  text-transform: uppercase;
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  color: var(--sage-dark);
}
.device[data-theme="dark"] .eyebrow { color: var(--gold-soft); }
.eyebrow::before {
  content: "";
  width: 1.6em;
  height: 1px;
  background: var(--gold);
}
.device[dir="rtl"] .eyebrow { text-transform: none; letter-spacing: 0.12em; }

.gold-text {
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Thin gold hairline divider */
.hairline {
  height: 1px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.55;
  margin: 1.4rem 0;
}

/* ============================== BUTTONS ================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  padding: 0.95em 1.6em;
  border-radius: var(--r-pill);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
  will-change: transform;
  user-select: none;
}
.btn:active { transform: translateY(0) scale(0.985); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn-block { width: 100%; }
.btn-lg { padding: 1.05em 1.8em; font-size: 1rem; }

.btn-gold {
  background: var(--gold);
  color: var(--forest);
  box-shadow: 0 2px 8px -4px rgba(201,166,107,.5), 0 14px 30px -18px rgba(201,166,107,.6);
}
.btn-gold:hover { background: var(--gold-deep); transform: translateY(-2px); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--sage);
}
.btn-ghost:hover { background: var(--fill-hover); transform: translateY(-2px); }

.btn-ghost-light {
  background: transparent;
  color: var(--cream);
  border: 1px solid rgba(242,244,241,.32);
}
.btn-ghost-light:hover {
  background: rgba(242,244,241,.08);
  border-color: var(--gold);
  color: var(--gold-soft);
  transform: translateY(-2px);
}
.btn-text {
  padding: 0.5em 0.6em;
  color: var(--text-dim);
  font-weight: 500;
}
.btn-text:hover { color: var(--gold-deep); }
.btn-danger { color: var(--danger); border: 1px solid var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-bg); transform: translateY(-2px); }

/* Chips / pills */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.5em 0.95em;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--t-fast) var(--ease);
}
.chip:hover { border-color: var(--gold); transform: translateY(-1px); }
.chip[aria-pressed="true"], .chip.is-on {
  background: var(--gold);
  color: var(--forest);
  border-color: var(--gold);
}
.chip-sm { padding: 0.42em 0.7em; font-size: 0.78rem; }
.day-chip {
  width: 2.4em; height: 2.4em; padding: 0; justify-content: center; border-radius: 50%;
}

/* ============================== FORMS ================================== */
.field { margin-bottom: 1.05rem; }
.field > label, .label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 0.45rem;
}
.input, .select, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 0.95em 1.05em;
  color: var(--text);
  font-size: 0.98rem;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--sage-light); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,166,107,.18);
  outline: none;
}
.textarea { resize: none; min-height: 6.5em; line-height: 1.6; }
.field.has-error .input, .field.has-error .textarea, .field.has-error .select { border-color: var(--danger); }
.field.is-valid .input { border-color: var(--sage); }
.input-wrap { position: relative; }
.input-affix {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0.85em;
  display: flex;
  align-items: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.input-affix button { color: var(--text-dim); padding: 0.3em; }
.input-affix button:hover { color: var(--gold-deep); }

.help { font-size: 0.78rem; margin-top: 0.4rem; line-height: 1.5; }
.help.error { color: var(--danger); }
.help.ok { color: var(--success); }

/* Live validation checklist */
.checklist { display: grid; gap: 0.35rem; margin-top: 0.55rem; }
.checklist li {
  display: flex; align-items: center; gap: 0.55em;
  font-size: 0.8rem; color: var(--text-dim);
  transition: color var(--t-fast) var(--ease);
}
.checklist li .tick {
  width: 1.25em; height: 1.25em; border-radius: 50%;
  border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 0.7em;
  transition: all var(--t-fast) var(--ease);
}
.checklist li.ok { color: var(--success); }
.checklist li.ok .tick { background: var(--success); border-color: var(--success); color: #fff; }

/* Toggle / switch */
.switch {
  position: relative; width: 3.1em; height: 1.8em; flex: none;
  border-radius: var(--r-pill); background: var(--sage-pale);
  border: 1px solid var(--border);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 50%; inset-inline-start: 0.18em;
  width: 1.35em; height: 1.35em; border-radius: 50%;
  background: var(--surface-2); box-shadow: 0 1px 4px rgba(44,58,48,.3);
  transform: translateY(-50%);
  transition: inset-inline-start var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.switch[aria-checked="true"] { background: var(--gold); border-color: var(--gold); }
.switch[aria-checked="true"]::after { inset-inline-start: calc(100% - 1.53em); }
.device[dir="rtl"] .switch::after { inset-inline-start: auto; inset-inline-end: 0.18em; }
.device[dir="rtl"] .switch[aria-checked="true"]::after { inset-inline-end: calc(100% - 1.53em); }

.row {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.95rem 0;
}
.row + .row { border-top: 1px solid var(--hairline); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 500; font-size: 0.96rem; color: var(--text); }
.row-sub { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.15rem; line-height: 1.4; }

/* Checkbox */
.check {
  display: flex; align-items: flex-start; gap: 0.75em;
  padding: 0.6em 0; cursor: pointer;
}
.check .box {
  width: 1.4em; height: 1.4em; flex: none; margin-top: 0.1em;
  border: 1.5px solid var(--border); border-radius: 6px;
  display: grid; place-items: center; color: #fff; font-size: 0.85em;
  transition: all var(--t-fast) var(--ease);
}
.check[aria-checked="true"] .box { background: var(--gold); border-color: var(--gold); color: var(--forest); }
.check .check-text { font-size: 0.9rem; line-height: 1.55; color: var(--text-muted); }
.check .check-text a { color: var(--gold-deep); text-decoration: underline; text-underline-offset: 3px; }

/* ============================== CARDS ================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 1.2rem;
  box-shadow: var(--sh-soft);
}
.card-lift { transition: transform var(--t-mid) var(--ease), box-shadow var(--t-mid) var(--ease); }
.card-lift:hover { transform: translateY(-6px); box-shadow: var(--sh-card); }
.card-flat { box-shadow: none; }

/* ============================== TOP BAR ================================ */
.topbar {
  position: relative; z-index: 30;
  display: flex; align-items: center; gap: 0.6rem;
  padding: calc(env(safe-area-inset-top, 0px) + 0.7rem) 1.1rem 0.7rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hairline);
}
.topbar .spacer { flex: 1; }
.brandmark { display: flex; align-items: center; gap: 0.55rem; }
.brandmark .logo { height: 2.7rem; flex: none; display: flex; align-items: center; }
.brandmark .logo .brand-logo { height: 2.7rem; width: auto; }

/* The brand logo artwork is black on transparent: keep it as-is on light
   (cream) surfaces, recolor to cream on dark/forest surfaces. */
.brand-logo { object-fit: contain; display: block; }
.device[data-theme="dark"] .brand-logo { filter: brightness(0) invert(1); }
.splash .brand-logo { filter: brightness(0) invert(1); } /* splash bg is always forest */
.brandmark .wordmark { display: flex; flex-direction: column; line-height: 1; }
.brandmark .wordmark .name { font-family: var(--serif); font-size: 1.15rem; letter-spacing: 0.02em; }
.brandmark .wordmark .sub {
  font-size: 0.5rem; letter-spacing: 0.34em; text-transform: uppercase;
  color: var(--text-dim); margin-top: 0.25em; font-weight: 500;
}
.device[dir="rtl"] .brandmark .wordmark .sub { letter-spacing: 0.12em; text-transform: none; }

.icon-btn {
  width: 2.5rem; height: 2.5rem; flex: none;
  display: grid; place-items: center; border-radius: 50%;
  color: var(--text-muted);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--fill-hover); color: var(--text); }
.lang-switch {
  display: inline-flex; align-items: center; border: 1px solid var(--border);
  border-radius: var(--r-pill); overflow: hidden; font-size: 0.74rem; font-weight: 600;
}
.lang-switch button { padding: 0.45em 0.8em; color: var(--text-dim); transition: all var(--t-fast) var(--ease); }
.lang-switch button.is-on { background: var(--forest); color: var(--cream); }
.device[data-theme="dark"] .lang-switch button.is-on { background: var(--gold); color: var(--forest); }

/* ============================ SCREEN AREA ============================== */
.screen-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.3rem 1.1rem calc(env(safe-area-inset-bottom, 0px) + 1.6rem);
}
.has-tabbar .screen-scroll { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 5.6rem); }

/* Page enter transition */
.fade-slide { animation: fadeSlide var(--t-slow) var(--ease) both; }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn var(--t-mid) var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ========================== BOTTOM TAB BAR ============================= */
.tabbar {
  position: absolute; inset-inline: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around; align-items: stretch;
  padding: 0.45rem 0.6rem calc(env(safe-area-inset-bottom, 0px) + 0.45rem);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--hairline);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  padding: 0.5rem 0.2rem; color: var(--text-dim); border-radius: 14px;
  position: relative; transition: color var(--t-fast) var(--ease);
}
.tab .tab-ic { width: 1.55rem; height: 1.55rem; transition: transform var(--t-mid) var(--ease); }
.tab .tab-label { font-size: 0.64rem; font-weight: 500; letter-spacing: 0.02em; }
.tab.is-on { color: var(--gold-deep); }
.device[data-theme="dark"] .tab.is-on { color: var(--gold-soft); }
.tab.is-on .tab-ic { transform: translateY(-2px); }
.tab.is-on::after {
  content: ""; position: absolute; top: 0.2rem; width: 5px; height: 5px;
  border-radius: 50%; background: var(--gold);
}

/* ============================ COUNTDOWN =============================== */
.countdown {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 0.4rem 0 0.2rem;
}
.countdown .cd-label { margin-bottom: 0.5rem; }
.countdown .cd-time {
  font-family: var(--serif);
  font-size: 4.4rem; line-height: 1; letter-spacing: 0.01em;
  display: inline-flex; align-items: baseline; gap: 0.02em;
  color: var(--text);
  direction: ltr; /* keep HH:MM:SS order correct in RTL */
}
.countdown .cd-time .unit { font-size: 1.1rem; color: var(--text-dim); margin-inline: 0.05em 0.35em; align-self: center; }
.countdown .cd-sub { color: var(--text-dim); font-size: 0.9rem; margin-top: 0.6rem; }
.countdown.is-due .cd-time { color: var(--gold-deep); }

/* ============================ BRACELET ================================ */
.bracelet-stage {
  position: relative;
  display: grid; place-items: center;
  padding: 0.5rem 0 0.2rem;
}
.pearl-ring-bg {
  position: absolute; width: 260px; height: 260px; border-radius: 50%;
  border: 1px dashed var(--hairline);
  animation: spin 90s linear infinite;
}
.pearl-ring-bg::before, .pearl-ring-bg::after {
  content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold-soft); top: -4px; left: 50%; transform: translateX(-50%);
  box-shadow: 0 252px 0 var(--gold-soft);
}
@keyframes spin { to { transform: rotate(360deg); } }
.bracelet-svg { width: 278px; max-width: 100%; height: auto; position: relative; filter: drop-shadow(0 14px 20px rgba(44,58,48,.20)); }
.device[data-theme="dark"] .bracelet-svg { filter: drop-shadow(0 14px 22px rgba(0,0,0,.45)); }
.slot-pulse { animation: slotPulse 2.4s var(--ease) infinite; transform-origin: center; }
@keyframes slotPulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.shimmer { animation: shimmer 4.5s ease-in-out infinite; }
@keyframes shimmer { 0%,100% { opacity: 0.55; } 50% { opacity: 1; } }

/* ====================== SEGMENTED CONTROL ============================= */
.segmented {
  display: flex; background: var(--bg-alt); border-radius: var(--r-pill);
  padding: 0.28rem; gap: 0.2rem; border: 1px solid var(--hairline);
}
.segmented button {
  flex: 1; padding: 0.6em 0.5em; border-radius: var(--r-pill);
  font-size: 0.82rem; font-weight: 500; color: var(--text-dim);
  transition: all var(--t-mid) var(--ease); white-space: nowrap;
}
.segmented button.is-on {
  background: var(--surface-2); color: var(--text); box-shadow: var(--sh-soft);
}

/* ============================== OTP =================================== */
.otp { display: flex; gap: 0.6rem; justify-content: center; direction: ltr; }
.otp input {
  width: 3rem; height: 3.6rem; text-align: center; font-size: 1.6rem;
  font-family: var(--serif);
  border: 1.5px solid var(--border); border-radius: var(--r-card);
  background: var(--surface); color: var(--text);
  transition: all var(--t-fast) var(--ease);
}
.otp input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,166,107,.18); outline: none; }
.otp.is-error input { border-color: var(--danger); }
.shake { animation: shake 0.4s var(--ease); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}

/* ============================ CALENDAR =============================== */
.cal { user-select: none; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.8rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.3rem; }
.cal-dow { text-align: center; font-size: 0.66rem; color: var(--text-dim); padding: 0.3rem 0; font-weight: 600; letter-spacing: 0.04em; }
.cal-day {
  aspect-ratio: 1; min-width: 0; display: grid; place-items: center; border-radius: 12px;
  font-size: 0.85rem; color: var(--text); transition: all var(--t-fast) var(--ease);
  position: relative;
}
.cal-day.empty { visibility: hidden; }
.cal-day.disabled { color: var(--sage-light); opacity: 0.45; pointer-events: none; }
.cal-day.available { cursor: pointer; }
.cal-day.available::after {
  content: ""; position: absolute; bottom: 0.32em; width: 4px; height: 4px;
  border-radius: 50%; background: var(--sage);
}
.cal-day.available:hover { background: var(--fill-hover); }
.cal-day.selected { background: var(--gold); color: var(--forest); font-weight: 600; }
.cal-day.selected::after { background: var(--forest); }

/* ============================ STATUS DOTS ============================= */
.badge {
  display: inline-flex; align-items: center; gap: 0.45em;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 0.35em 0.75em; border-radius: var(--r-pill);
}
.badge .dot { width: 0.5em; height: 0.5em; border-radius: 50%; background: currentColor; }
.badge.taken { color: var(--success); background: var(--success-bg); }
.badge.missed { color: var(--danger); background: var(--danger-bg); }
.badge.pending { color: var(--warn); background: rgba(201,166,107,.16); }
.badge.confirmed { color: var(--success); background: var(--success-bg); }

/* ============================ LIST ITEMS ============================= */
.log-item {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.95rem 0; border-top: 1px solid var(--hairline);
}
.log-item:first-child { border-top: 0; }
.log-ic {
  width: 2.6rem; height: 2.6rem; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--bg-alt); color: var(--sage-dark);
}
.device[data-theme="dark"] .log-ic { color: var(--gold-soft); }
.log-main { flex: 1; min-width: 0; }
.log-title { font-weight: 500; font-size: 0.94rem; }
.log-sub { font-size: 0.79rem; color: var(--text-dim); margin-top: 0.12rem; }

/* ============================ EMPTY STATE ============================ */
.empty {
  text-align: center; padding: 2.8rem 1.2rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.9rem;
}
.empty .empty-ic {
  width: 4.4rem; height: 4.4rem; border-radius: 50%;
  display: grid; place-items: center; color: var(--sage);
  background: var(--bg-alt); border: 1px solid var(--hairline);
}
.empty h3 { font-size: 1.3rem; }
.empty p { font-size: 0.88rem; max-width: 17rem; }

/* ============================== TOASTS =============================== */
.toast-host {
  position: absolute; inset-inline: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 5.6rem);
  z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  pointer-events: none; padding: 0 1rem;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--forest); color: var(--cream);
  padding: 0.85rem 1.15rem; border-radius: var(--r-pill);
  box-shadow: var(--sh-lift); font-size: 0.86rem; max-width: 100%;
  animation: toastIn var(--t-slow) var(--ease) both;
}
.device[data-theme="dark"] .toast { background: var(--surface-2); border: 1px solid var(--hairline); }
.toast .t-ic { color: var(--gold-soft); flex: none; }
.toast.out { animation: toastOut var(--t-mid) var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ============================ BOTTOM SHEET ========================== */
.sheet-host {
  position: absolute; inset: 0; z-index: 90; display: none;
}
.sheet-host.open { display: block; }
.sheet-host.elevated { z-index: 110; } /* review sheet shown above the chat */
.sheet-scrim {
  position: absolute; inset: 0; background: rgba(28,36,30,.5);
  backdrop-filter: blur(2px); animation: fadeIn var(--t-mid) var(--ease) both;
}
.sheet {
  position: absolute; inset-inline: 0; bottom: 0;
  background: var(--bg); border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--sh-lift); max-height: 88%; display: flex; flex-direction: column;
  animation: sheetUp var(--t-slow) var(--ease) both;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet .grab { width: 2.6rem; height: 4px; border-radius: 999px; background: var(--border); margin: 0.7rem auto 0; }
.sheet-head { padding: 0.8rem 1.3rem 0.4rem; display: flex; align-items: center; justify-content: space-between; }
.sheet-body { padding: 0.6rem 1.3rem 1.3rem; overflow-y: auto; }

/* ============================ MISC UTILS ============================ */
.stack > * + * { margin-top: var(--gap, 1rem); }
.muted { color: var(--text-dim); }
.center { text-align: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.tag-x {
  width: 1.6rem; height: 1.6rem; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: var(--text-dim);
  border: 1px solid var(--hairline); transition: all var(--t-fast) var(--ease);
}
.tag-x:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }
.back-btn { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text-dim); font-size: 0.85rem; font-weight: 500; }
.back-btn:hover { color: var(--gold-deep); }
.device[dir="rtl"] .rtl-flip { transform: scaleX(-1); }

.progress-dots { display: flex; gap: 0.4rem; justify-content: center; }
.progress-dots i {
  width: 7px; height: 7px; border-radius: 999px; background: var(--border);
  transition: all var(--t-mid) var(--ease);
}
.progress-dots i.on { width: 22px; background: var(--gold); }

.step-bar { height: 4px; background: var(--bg-alt); border-radius: 999px; overflow: hidden; }
.step-bar > span { display: block; height: 100%; background: var(--gold-grad); border-radius: 999px; transition: width var(--t-slow) var(--ease); }

/* searchable result list */
.result-list { margin-top: 0.6rem; display: grid; gap: 0.4rem; max-height: 16rem; overflow-y: auto; }
.result {
  display: flex; align-items: center; gap: 0.8rem; width: 100%;
  padding: 0.8rem 0.9rem; border: 1px solid var(--hairline); border-radius: var(--r-card);
  background: var(--surface); text-align: start; transition: all var(--t-fast) var(--ease);
}
.result:hover { border-color: var(--gold); transform: translateY(-1px); }
.result .r-main { flex: 1; min-width: 0; }
.result .r-title { font-weight: 500; font-size: 0.92rem; }
.result .r-sub { font-size: 0.76rem; color: var(--text-dim); }
.result .r-add { color: var(--gold-deep); font-weight: 600; font-size: 1.3rem; }

/* dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; inset-inline: 0; top: calc(100% + 0.4rem); z-index: 20;
  background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--r-card);
  box-shadow: var(--sh-card); max-height: 14rem; overflow-y: auto; padding: 0.4rem;
}
.dropdown-menu button {
  display: block; width: 100%; text-align: start; padding: 0.7rem 0.8rem;
  border-radius: 10px; font-size: 0.9rem; color: var(--text); transition: background var(--t-fast) var(--ease);
}
.dropdown-menu button:hover { background: var(--fill-hover); }

/* ============================ SPLASH / GATE ========================= */
.splash {
  position: absolute; inset: 0; z-index: 100;
  background: var(--forest); color: var(--cream);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.4rem; text-align: center;
}
.splash .splash-logo { width: 250px; max-width: 70%; }
.splash .splash-logo .brand-logo { width: 100%; height: auto; }
.splash .s-name { font-family: var(--serif); font-size: 2.4rem; letter-spacing: 0.06em; margin-top: 1.2rem; }
.splash .s-sub { font-size: 0.62rem; letter-spacing: 0.42em; text-transform: uppercase; color: var(--gold-soft); }
.splash.out { animation: fadeOut var(--t-slow) var(--ease) forwards; }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }

/* Onboarding / intro slides */
.intro {
  height: 100%; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 1rem) 1.4rem calc(env(safe-area-inset-bottom, 0px) + 1.4rem);
}
.intro-art {
  flex: 1; display: grid; place-items: center; position: relative; min-height: 0;
}
.intro-copy { text-align: center; padding: 0 0.4rem; }
.intro-copy h2 { font-size: 2.1rem; margin-bottom: 0.7rem; }
.intro-copy p { font-size: 0.95rem; }

/* hero gradient panels (dark sections) */
.hero-dark {
  background: linear-gradient(160deg, var(--forest) 0%, #243029 100%);
  color: var(--cream); border-radius: var(--r-lg); padding: 1.6rem;
  position: relative; overflow: hidden;
}
.hero-dark h2, .hero-dark h3 { color: var(--cream); }
.hero-dark p { color: rgba(242,244,241,.78); }

/* success burst */
.burst { display: grid; place-items: center; padding: 1rem 0; }
.burst .ring {
  width: 5.5rem; height: 5.5rem; border-radius: 50%;
  border: 2px solid var(--gold); display: grid; place-items: center; color: var(--gold-deep);
  animation: burst 0.5s var(--ease) both;
}
@keyframes burst {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* scanning radar */
.radar { width: 11rem; height: 11rem; position: relative; margin: 0 auto; }
.radar .pulse {
  position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--gold);
  animation: radar 2s var(--ease) infinite;
}
.radar .pulse:nth-child(2) { animation-delay: 0.66s; }
.radar .pulse:nth-child(3) { animation-delay: 1.33s; }
.radar .core {
  position: absolute; inset: 38%; border-radius: 50%; background: var(--gold);
  display: grid; place-items: center; color: var(--forest);
}
@keyframes radar {
  0% { transform: scale(0.4); opacity: 0.9; }
  100% { transform: scale(1); opacity: 0; }
}

/* loading skeleton + spinner */
.spinner {
  width: 1.2em; height: 1.2em; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin 0.8s linear infinite; display: inline-block;
}
.skel { background: linear-gradient(90deg, var(--bg-alt), var(--surface), var(--bg-alt)); background-size: 200% 100%; animation: skel 1.3s ease-in-out infinite; border-radius: 8px; }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* nav underline that grows from leading edge */
.ulink { position: relative; }
.ulink::after {
  content: ""; position: absolute; bottom: -2px; inset-inline-start: 0;
  width: 0; height: 1.5px; background: var(--gold);
  transition: width var(--t-mid) var(--ease);
}
.ulink:hover::after { width: 100%; }

/* number bubble */
.snum {
  width: 1.7rem; height: 1.7rem; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 0.8rem; font-weight: 600;
  background: var(--gold); color: var(--forest);
}

/* ====================== AI ASSISTANT (chat) ======================= */
.chat-fab {
  position: absolute; z-index: 50;
  inset-inline-end: 1.05rem; bottom: calc(env(safe-area-inset-bottom, 0px) + 5.3rem);
  width: 3.5rem; height: 3.5rem; border-radius: 50%;
  display: grid; place-items: center; color: var(--forest);
  background: var(--gold-grad);
  box-shadow: 0 6px 16px -6px rgba(201,166,107,.7), 0 14px 30px -14px rgba(44,58,48,.45);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.chat-fab::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1.5px solid var(--gold); opacity: .5; animation: shimmer 4.5s ease-in-out infinite;
}
.chat-fab:hover { transform: translateY(-2px) scale(1.04); }
.chat-fab:active { transform: scale(.96); }

.chat-host { position: absolute; inset: 0; z-index: 95; display: none; }
.chat-host.open { display: block; }
.chat-scrim { position: absolute; inset: 0; background: rgba(28,36,30,.55); backdrop-filter: blur(3px); animation: fadeIn var(--t-mid) var(--ease) both; }
.chat-panel {
  position: absolute; inset-inline: 0; bottom: 0; height: 94%;
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--sh-lift); overflow: hidden;
  animation: sheetUp var(--t-slow) var(--ease) both;
}
.chat-head {
  display: flex; align-items: center; gap: 0.6rem;
  padding: calc(env(safe-area-inset-top, 0px) + 0.85rem) 1rem 0.7rem;
  border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
}
.chat-head .spacer { flex: 1; }
.chat-ava { width: 2.1rem; height: 2.1rem; border-radius: 50%; flex: none; display: grid; place-items: center; color: var(--forest); background: var(--gold-grad); }
.chat-ava.sm { width: 1.7rem; height: 1.7rem; }
.chat-ava.lg { width: 3.4rem; height: 3.4rem; margin: 0 auto; }
.chat-id .ct-name { font-family: var(--serif); font-size: 1.15rem; line-height: 1; }
.chat-id .ct-sub { font-size: 0.66rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-dim); margin-top: 0.2rem; }
.device[dir="rtl"] .chat-id .ct-sub { letter-spacing: 0.08em; text-transform: none; }

.chat-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 1rem; display: flex; flex-direction: column; gap: 0.7rem; }
.chat-msg { display: flex; align-items: flex-end; gap: 0.5rem; max-width: 100%; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg .chat-col { display: flex; flex-direction: column; gap: 0.3rem; max-width: 82%; }
.chat-bubble {
  padding: 0.7rem 0.95rem; border-radius: 18px; font-size: 0.92rem; line-height: 1.55;
  background: var(--surface); border: 1px solid var(--hairline); color: var(--text);
  border-end-start-radius: 6px; box-shadow: var(--sh-soft);
}
.chat-msg.user .chat-bubble {
  background: var(--gold); color: var(--forest); border-color: var(--gold);
  border-radius: 18px; border-end-end-radius: 6px; border-end-start-radius: 18px;
}
.chat-action {
  display: inline-flex; align-items: center; gap: 0.4em; align-self: flex-start;
  font-size: 0.74rem; font-weight: 600; color: var(--success);
  background: var(--success-bg); padding: 0.3em 0.7em; border-radius: var(--r-pill);
}
.chat-bubble.typing { display: inline-flex; gap: 0.3rem; padding: 0.85rem 1rem; }
.chat-bubble.typing i { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--sage); animation: typing 1.2s infinite ease-in-out; }
.chat-bubble.typing i:nth-child(2) { animation-delay: 0.18s; }
.chat-bubble.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.chat-welcome { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.9rem; padding: 1.5rem 0.5rem; }
.chat-hello { font-family: var(--serif); font-size: 1.4rem; line-height: 1.2; color: var(--text); max-width: 18rem; }
.chat-suggs { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.chat-suggs .chip { cursor: pointer; }

.chat-input {
  display: flex; align-items: flex-end; gap: 0.6rem; padding: 0.7rem 0.9rem;
  border-top: 1px solid var(--hairline); background: var(--bg);
}
.chat-input textarea {
  flex: 1; resize: none; border: 1px solid var(--border); background: var(--surface);
  border-radius: 22px; padding: 0.7em 1em; font-size: 0.95rem; color: var(--text);
  max-height: 120px; line-height: 1.45;
}
.chat-input textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,166,107,.18); }
.chat-send { width: 2.7rem; height: 2.7rem; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: var(--forest); transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.chat-send:hover { background: var(--gold-deep); transform: translateY(-1px); }
.chat-disclaimer { text-align: center; font-size: 0.66rem; color: var(--text-dim); padding: 0 1rem calc(env(safe-area-inset-bottom, 0px) + 0.6rem); }

/* ===================== REDUCED MOTION ============================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}
