/* ============================================================
   לוח גמילה אישי — Cannabis Quit Dashboard
   Nature palette: forest / earth / cream
   RTL Hebrew, system-friendly, no external runtime deps.
   ============================================================ */

:root {
  /* Nature palette — light mode */
  --forest-deep:   #1f4029;
  --forest:        #2d5a3d;
  --forest-mid:    #4a7041;
  --leaf:          #7fa86c;
  --leaf-light:    #a8c19a;
  --moss:          #b8c9aa;
  --earth-deep:    #5a4632;
  --earth:         #8b6f47;
  --earth-light:   #b89977;
  --cream:         #f4ead5;
  --cream-soft:    #fbf9f4;
  --sand:          #e8dcc4;

  --warn:          #c47238;
  --warn-bg:       #fbe9d8;
  --danger:        #a83b2e;
  --danger-bg:     #f5dbd6;

  /* Semantic */
  --bg:            var(--cream-soft);
  --bg-card:       #ffffff;
  --bg-elevated:   #fffdf7;
  --bg-subtle:     var(--cream);
  --border:        #e6dec8;
  --border-strong: #d3c9aa;
  --text:          #2a2823;
  --text-muted:    #6b6555;
  --text-soft:     #8a8470;
  --accent:        var(--forest);
  --accent-bright: var(--leaf);

  --shadow-sm: 0 2px 6px rgba(31, 64, 41, 0.06);
  --shadow-md: 0 8px 24px rgba(31, 64, 41, 0.08);
  --shadow-lg: 0 16px 48px rgba(31, 64, 41, 0.12);

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 22px;
  --radius-xl: 32px;

  --font-sans: "Heebo", "Assistant", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: "Heebo", "Assistant", system-ui, sans-serif;

  --t-fast: 150ms;
  --t-med:  280ms;
  --t-slow: 520ms;
  --ease:   cubic-bezier(.22, .61, .36, 1);
}

[data-theme="dark"] {
  --bg:            #14211a;
  --bg-card:       #1d2c24;
  --bg-elevated:   #243429;
  --bg-subtle:     #1a2820;
  --border:        #2c3d31;
  --border-strong: #3b5042;
  --text:          #e6e3d5;
  --text-muted:    #a7b0a0;
  --text-soft:     #7b8377;
  --cream:         #2a3a30;
  --cream-soft:    #14211a;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, .35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* ============================================================
   ONBOARDING
   ============================================================ */

.onboarding {
  position: relative;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  overflow: hidden;
}

.onboarding-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(160deg, rgba(251, 249, 244, 0.65) 0%, rgba(244, 234, 213, 0.55) 45%, rgba(236, 221, 190, 0.70) 100%),
    url('../images/hero-path.jpg') center/cover no-repeat;
}

[data-theme="dark"] .onboarding-bg {
  background:
    linear-gradient(160deg, rgba(20, 33, 26, 0.78) 0%, rgba(29, 44, 36, 0.85) 100%),
    url('../images/hero-path.jpg') center/cover no-repeat;
}

.onboarding-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 620px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.onboarding-header { text-align: center; margin-bottom: 24px; }
.logo-leaf {
  display: inline-block;
  font-size: 48px;
  filter: drop-shadow(0 4px 12px rgba(127, 168, 108, 0.4));
  animation: gentle-sway 6s var(--ease) infinite alternate;
}
@keyframes gentle-sway {
  0% { transform: rotate(-4deg); }
  100% { transform: rotate(4deg); }
}

.onboarding-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 36px);
  font-weight: 700;
  color: var(--forest-deep);
  margin: 12px 0 8px;
  letter-spacing: -0.02em;
}
[data-theme="dark"] .onboarding-title { color: var(--leaf-light); }

.onboarding-subtitle {
  color: var(--text-muted);
  margin: 0;
  font-size: 15px;
}

.step-indicator {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 24px 0 32px;
}
.step {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 2px solid var(--border-strong);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-soft);
  transition: all var(--t-med) var(--ease);
}
.step.active {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--cream-soft);
  transform: scale(1.1);
}
.step.done {
  background: var(--leaf);
  border-color: var(--leaf);
  color: white;
}

.form-step { display: none; animation: stepFade var(--t-med) var(--ease); }
.form-step.active { display: block; }
@keyframes stepFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--forest-deep);
}
[data-theme="dark"] .step-title { color: var(--leaf-light); }

.step-hint {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.field {
  display: block;
  margin-bottom: 16px;
}
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="time"],
.field input[type="tel"],
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--leaf);
  box-shadow: 0 0 0 3px rgba(127, 168, 108, 0.25);
}
.field textarea { resize: vertical; min-height: 80px; font-family: inherit; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field.checkbox { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.field.checkbox input { width: 20px; height: 20px; accent-color: var(--forest); }

fieldset.field { border: none; padding: 0; }
fieldset.field legend { margin-bottom: 8px; padding: 0; }

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  position: relative;
  cursor: pointer;
}
.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.chip span {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-strong);
  font-size: 14px;
  transition: all var(--t-fast) var(--ease);
}
.chip input:checked + span {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--cream-soft);
}
.chip:hover span { border-color: var(--leaf); }

.time-range {
  display: flex;
  align-items: center;
  gap: 10px;
}
.time-range input { flex: 1; }

.form-nav {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  justify-content: space-between;
}

.disclaimer {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-soft);
  text-align: center;
  line-height: 1.6;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--forest) 0%, var(--forest-mid) 100%);
  color: var(--cream-soft);
  box-shadow: 0 4px 14px rgba(45, 90, 61, 0.30);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(45, 90, 61, 0.35); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--forest);
  border: 1.5px solid var(--border-strong);
}
[data-theme="dark"] .btn-ghost { color: var(--leaf-light); }
.btn-ghost:hover { background: var(--bg-subtle); border-color: var(--leaf); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #8b2f24; }

.btn-call {
  background: var(--forest-deep);
  color: var(--cream-soft);
  font-size: 16px;
}
.btn-call.urgent { background: var(--danger); }
.btn-call.personal {
  background: linear-gradient(135deg, var(--leaf), var(--forest-mid));
  box-shadow: 0 4px 14px rgba(127, 168, 108, 0.35);
}
.btn-call.personal:hover { transform: translateY(-1px); }

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  font-size: 20px;
  transition: all var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--moss); transform: scale(1.05); }

.lang-btn {
  font-size: 13px;
  font-weight: 700;
  color: var(--forest-deep);
  letter-spacing: 0.04em;
  font-family: var(--font-sans);
}
[data-theme="dark"] .lang-btn { color: var(--leaf-light); }

.link-button {
  background: none;
  border: none;
  color: var(--forest);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font: inherit;
}
[data-theme="dark"] .link-button { color: var(--leaf-light); }

.file-import { position: relative; }
.file-import input { display: none; }

/* Theme icons: show one, hide one */
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark,
html:not([data-theme="dark"]) .theme-icon-dark { display: none; }

/* ============================================================
   DASHBOARD
   ============================================================ */

.dash-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  background: rgba(251, 249, 244, 0.78);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .dash-header { background: rgba(20, 33, 26, 0.78); }

.dash-header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--forest-deep);
}
[data-theme="dark"] .brand { color: var(--leaf-light); }
.brand-leaf { font-size: 22px; }

.header-actions { display: flex; gap: 8px; }

.dash-grid {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
  padding-bottom: 120px;
  position: relative;
}

/* Subtle nature accents — leaf decorations */
.dash-grid::before,
.dash-grid::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.06;
}
.dash-grid::before {
  top: 100px;
  inset-inline-end: -60px;
  width: 240px; height: 240px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><path d='M50,10 C30,20 20,40 25,65 C30,85 50,90 60,75 C70,55 60,30 50,10 Z M50,30 L50,80' fill='none' stroke='%232d5a3d' stroke-width='2'/></svg>");
  transform: rotate(-15deg);
}
.dash-grid::after {
  bottom: 40px;
  inset-inline-start: -80px;
  width: 280px; height: 280px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><path d='M30,90 C40,70 45,50 50,30 C55,50 60,70 70,90 M50,30 C45,20 50,10 55,20 M50,30 L50,90' fill='none' stroke='%237fa86c' stroke-width='2'/></svg>");
  transform: rotate(20deg);
}
[data-theme="dark"] .dash-grid::before,
[data-theme="dark"] .dash-grid::after { opacity: 0.10; }

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-med) var(--ease);
  position: relative;
  overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); }

.card-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--forest-deep);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}
[data-theme="dark"] .card-title { color: var(--leaf-light); }

.card-icon { font-size: 22px; }
.card-subtitle { margin: 0 0 16px; color: var(--text-muted); font-size: 14px; }

/* Grid layout */
.timer-card      { grid-column: span 7; }
.today-card      { grid-column: span 5; }
.my-numbers-card { grid-column: span 12; }
.checkin-card    { grid-column: span 5; }
.charts-card     { grid-column: span 7; }
.timeline-card   { grid-column: span 12; }

@media (max-width: 980px) {
  .timer-card, .today-card, .my-numbers-card, .checkin-card, .charts-card, .timeline-card {
    grid-column: span 12;
  }
}

/* ============================================================
   MY NUMBERS CARD
   ============================================================ */
.my-numbers-card { padding: 24px 28px; }
.mn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.mn-tile {
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid var(--border);
  text-align: right;
}
.mn-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  font-weight: 600;
}
.mn-value {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  color: var(--forest-deep);
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .mn-value { color: var(--leaf-light); }
.mn-unit { font-size: 14px; font-weight: 500; opacity: 0.65; margin-inline-start: 4px; }
.mn-value-text {
  font-size: 24px;
  font-weight: 700;
  color: var(--forest-deep);
}
[data-theme="dark"] .mn-value-text { color: var(--leaf-light); }
.mn-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.mn-note {
  margin-top: 18px;
  padding: 14px 16px;
  background: linear-gradient(90deg, rgba(127, 168, 108, 0.16), transparent);
  border-radius: var(--radius);
  border-right: 3px solid var(--leaf);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

/* Personal contact card in SOS (highlighted) */
.em-card-personal {
  background: linear-gradient(135deg, var(--leaf), var(--forest-mid));
  color: var(--cream-soft);
  border-color: var(--forest);
}
.em-card-personal h3 { color: var(--cream-soft); }
.em-card-personal p  { color: rgba(244, 234, 213, 0.85); }
.em-card-personal:hover {
  background: linear-gradient(135deg, var(--forest-mid), var(--forest));
  transform: translateY(-2px);
}

/* ============================================================
   TIMER CARD
   ============================================================ */

.timer-card {
  background: linear-gradient(140deg, var(--forest) 0%, var(--forest-deep) 60%, #163020 100%);
  color: var(--cream-soft);
  border: none;
  min-height: 280px;
  position: relative;
}
.timer-card .card-title { color: var(--cream-soft); opacity: 0.85; font-size: 14px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; }

.timer-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 60% 50% at 90% 0%, rgba(127, 168, 108, 0.40), transparent 60%),
    radial-gradient(ellipse 50% 60% at 5% 100%, rgba(168, 193, 154, 0.25), transparent 60%),
    linear-gradient(135deg, rgba(31, 64, 41, 0.65) 0%, rgba(45, 90, 61, 0.75) 50%, rgba(22, 48, 32, 0.85) 100%),
    url('../images/canopy.jpg') center/cover no-repeat;
  pointer-events: none;
}

.timer-content { position: relative; z-index: 1; }

.timer-display {
  display: flex;
  gap: 18px;
  margin: 14px 0 12px;
  flex-wrap: wrap;
}
.timer-segment {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 64px;
}
.timer-num {
  font-size: clamp(32px, 6vw, 52px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.timer-unit {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 4px;
  letter-spacing: 0.04em;
}

.reinforcement {
  margin: 18px 0 18px;
  font-size: 16px;
  font-style: italic;
  opacity: 0.92;
  max-width: 540px;
  line-height: 1.55;
}

.timer-stats {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  padding: 14px 0 0;
  border-top: 1px solid rgba(244, 234, 213, 0.18);
  margin-top: 10px;
}
.stat { display: flex; flex-direction: column; }
.stat-num {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 12px; opacity: 0.72; margin-top: 4px; }

.phase-pill {
  display: inline-block;
  margin-top: 18px;
  padding: 6px 14px;
  background: rgba(244, 234, 213, 0.15);
  border: 1px solid rgba(244, 234, 213, 0.30);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}

/* ============================================================
   TODAY CARD
   ============================================================ */

.today-content { display: flex; flex-direction: column; gap: 14px; }
.today-section { padding-block: 4px; }
.today-section .section-label {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.today-section p { margin: 0; font-size: 15px; line-height: 1.6; }
.today-section.warn .section-label { color: var(--warn); }
.today-section.warn p {
  background: var(--warn-bg);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-right: 3px solid var(--warn);
}
[data-theme="dark"] .today-section.warn p { background: rgba(196, 114, 56, 0.18); }

.today-section.action .section-label { color: var(--forest-mid); }
.today-section.action p {
  background: linear-gradient(90deg, rgba(127, 168, 108, 0.18), transparent);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-right: 3px solid var(--leaf);
  font-weight: 500;
}

.today-section.reframe .section-label { color: var(--earth); }
.today-section.reframe p {
  background: rgba(139, 111, 71, 0.08);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-right: 3px solid var(--earth-light);
  font-style: italic;
}

.action-detail { margin-top: 8px; }
.action-detail summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--forest-mid);
  font-weight: 500;
  padding: 4px 0;
  list-style: none;
}
.action-detail summary::-webkit-details-marker { display: none; }
.action-detail summary::before { content: "▸ "; }
.action-detail[open] summary::before { content: "▾ "; }
.action-detail p {
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* ============================================================
   CHECK-IN CARD
   ============================================================ */

.slider-group { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.slider-field { display: flex; flex-direction: column; gap: 6px; }
.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
}
.slider-value {
  font-variant-numeric: tabular-nums;
  background: var(--bg-subtle);
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--forest);
  min-width: 36px;
  text-align: center;
}
[data-theme="dark"] .slider-value { color: var(--leaf-light); }

input[type="range"][data-slider] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  width: 100%;
  height: 22px;
}
input[type="range"][data-slider]::-webkit-slider-runnable-track {
  height: 6px;
  background: linear-gradient(90deg, var(--leaf-light), var(--forest));
  border-radius: 999px;
}
input[type="range"][data-slider]::-moz-range-track {
  height: 6px;
  background: linear-gradient(90deg, var(--leaf-light), var(--forest));
  border-radius: 999px;
}
input[type="range"][data-slider]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 22px;
  width: 22px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 3px solid var(--forest);
  cursor: pointer;
  margin-top: -8px;
  transition: transform var(--t-fast) var(--ease);
  box-shadow: var(--shadow-sm);
}
input[type="range"][data-slider]::-webkit-slider-thumb:active { transform: scale(1.18); }
input[type="range"][data-slider]::-moz-range-thumb {
  height: 22px; width: 22px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 3px solid var(--forest);
}

.slider-anchors {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-soft);
  padding-inline: 4px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--t-fast) var(--ease);
}
.check:hover { background: var(--moss); }
.check input { width: 20px; height: 20px; accent-color: var(--forest); }
.check.warn { background: var(--warn-bg); }
.check.warn input { accent-color: var(--warn); }

.saved-msg {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--forest);
  font-weight: 500;
  min-height: 1.2em;
}

/* ============================================================
   CHARTS CARD
   ============================================================ */

.chart-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.chart-tab {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--t-fast) var(--ease);
}
.chart-tab.active {
  background: var(--forest);
  color: var(--cream-soft);
  border-color: var(--forest);
}
.chart-tab:hover:not(.active) { border-color: var(--leaf); color: var(--forest); }

.chart-wrap {
  width: 100%;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 12px;
}
#chartCanvas {
  width: 100%;
  height: auto;
  display: block;
}
.chart-hint { font-size: 13px; color: var(--text-soft); margin-top: 10px; }

/* Avatar by phase (v3) — sits below chart in chart-card */
.avatar-frame {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px;
  background: linear-gradient(160deg, var(--bg-subtle) 0%, var(--bg-card) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.avatar-frame img {
  max-width: 280px;
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(31, 64, 41, 0.10);
  transition: opacity var(--t-slow) var(--ease);
}
.avatar-frame img.fade { opacity: 0; }
.avatar-caption {
  font-size: 15px;
  font-weight: 600;
  color: var(--forest-deep);
  text-align: center;
  margin-top: 4px;
}
[data-theme="dark"] .avatar-caption { color: var(--leaf-light); }

/* ============================================================
   TIMELINE CARD
   ============================================================ */

.timeline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 0;
  position: relative;
}
.timeline-step {
  flex: 1 1 calc(14% - 8px);
  min-width: 130px;
  padding: 14px 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  text-align: center;
  transition: all var(--t-med) var(--ease);
  position: relative;
}
.timeline-step:hover { transform: translateY(-2px); border-color: var(--moss); }
.timeline-step.current {
  background: linear-gradient(140deg, var(--leaf) 0%, var(--forest) 100%);
  color: var(--cream-soft);
  border-color: var(--forest);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.timeline-step.done {
  background: var(--moss);
  border-color: var(--leaf);
}
.timeline-step-num {
  font-size: 11px;
  opacity: 0.75;
  margin-bottom: 4px;
}
.timeline-step-name { font-size: 14px; font-weight: 600; line-height: 1.3; }
.timeline-step-days { font-size: 11px; margin-top: 4px; opacity: 0.85; }

.timeline-detail {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border-right: 4px solid var(--forest);
}
.timeline-detail h3 { margin: 0 0 6px; font-size: 16px; color: var(--forest-deep); }
[data-theme="dark"] .timeline-detail h3 { color: var(--leaf-light); }
.timeline-detail p { margin: 6px 0; font-size: 14px; line-height: 1.6; }
.timeline-detail .label { font-weight: 600; color: var(--text-muted); }

/* ============================================================
   EMERGENCY FAB
   ============================================================ */

.emergency-fab {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  background: linear-gradient(135deg, #c47238 0%, #a83b2e 100%);
  color: white;
  border: none;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(168, 59, 46, 0.40);
  transition: all var(--t-fast) var(--ease);
  animation: gentle-pulse 3s var(--ease) infinite;
}
@keyframes gentle-pulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(168, 59, 46, 0.40); }
  50% { box-shadow: 0 8px 24px rgba(168, 59, 46, 0.55), 0 0 0 8px rgba(196, 114, 56, 0.15); }
}
.emergency-fab:hover { transform: translateY(-2px) scale(1.04); animation-play-state: paused; }
.fab-icon { font-size: 18px; }

@media (max-width: 540px) {
  .fab-label { display: none; }
  .emergency-fab { padding: 14px; }
  .fab-icon { font-size: 22px; }
}

/* ============================================================
   MODALS
   ============================================================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 33, 26, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: backdropFade var(--t-med) var(--ease);
}
@keyframes backdropFade { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  max-width: 600px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: modalRise var(--t-med) var(--ease);
}
@keyframes modalRise {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
  transition: all var(--t-fast) var(--ease);
}
.modal-close:hover { background: var(--moss); }

.modal-title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
  color: var(--forest-deep);
}
[data-theme="dark"] .modal-title { color: var(--leaf-light); }
.modal-subtitle { margin: 0 0 22px; color: var(--text-muted); font-size: 15px; }

/* Emergency modal */
.emergency-modal { max-width: 720px; }
.emergency-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}
@media (max-width: 540px) {
  .emergency-cards { grid-template-columns: 1fr; }
}
.em-card {
  background: var(--bg-subtle);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: right;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.em-card:hover {
  background: var(--moss);
  border-color: var(--leaf);
  transform: translateY(-2px);
}
.em-card h3 { margin: 0 0 4px; font-size: 16px; color: var(--forest-deep); }
[data-theme="dark"] .em-card h3 { color: var(--leaf-light); }
.em-card p { margin: 0; font-size: 13px; color: var(--text-muted); }

.modal-emergency-row {
  display: flex;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.modal-emergency-row .btn { flex: 1; min-width: 140px; }

/* Active emergency modal (breath/postpone/etc.) */
.em-active { max-width: 480px; text-align: center; padding: 40px 28px; }
.em-active h2 { font-size: 22px; color: var(--forest-deep); margin: 0 0 12px; }
[data-theme="dark"] .em-active h2 { color: var(--leaf-light); }
.em-active p { color: var(--text-muted); margin: 0 0 20px; }

.breath-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  margin: 30px auto;
  background: radial-gradient(circle, var(--leaf) 0%, var(--forest) 100%);
  display: grid;
  place-items: center;
  color: var(--cream-soft);
  font-size: 22px;
  font-weight: 600;
  transition: transform 4s var(--ease);
}
.breath-circle.inhale { transform: scale(1.4); }
.breath-circle.hold { transform: scale(1.4); }
.breath-circle.exhale { transform: scale(0.9); }

.countdown-display {
  font-size: 72px;
  font-weight: 800;
  color: var(--forest);
  font-variant-numeric: tabular-nums;
  margin: 30px 0;
  line-height: 1;
}
[data-theme="dark"] .countdown-display { color: var(--leaf-light); }

.grounding-list {
  text-align: right;
  margin: 20px 0;
  padding: 20px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
}
.grounding-list li { margin: 10px 0; font-size: 15px; }

/* Permission-thought pairs */
.thought-pairs { text-align: right; margin: 20px 0; display: flex; flex-direction: column; gap: 12px; }
.thought-pair { background: var(--bg-subtle); border-radius: var(--radius); padding: 14px 16px; }
.thought-row.thought {
  font-size: 15px;
  color: var(--text);
  font-style: italic;
  margin-bottom: 6px;
  opacity: 0.85;
}
.thought-row.counter {
  font-size: 14px;
  color: var(--forest-deep);
  font-weight: 500;
  border-right: 3px solid var(--leaf);
  padding-inline-start: 10px;
}
[data-theme="dark"] .thought-row.counter { color: var(--leaf-light); }

/* Social-pressure scripts */
.scripts-list { text-align: right; margin: 20px 0; display: flex; flex-direction: column; gap: 10px; }
.script-card {
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 14px 16px;
  border-right: 3px solid var(--earth);
}
.script-level {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--earth);
  font-weight: 600;
  margin-bottom: 4px;
}
.script-text { font-size: 15px; color: var(--text); }
.script-tip {
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(127, 168, 108, 0.15);
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: right;
}

.reasons-list {
  text-align: right;
  margin: 20px 0;
  padding: 20px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  list-style: "🌿  ";
  padding-inline-start: 24px;
}
.reasons-list li {
  margin: 12px 0;
  padding-inline-start: 8px;
  font-size: 16px;
  line-height: 1.55;
}

/* Settings */
.settings-section { margin-bottom: 24px; }
.settings-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.settings-section .btn { display: flex; width: 100%; justify-content: flex-start; margin-bottom: 8px; text-align: right; }
.settings-section.danger h3 { color: var(--danger); }
.settings-section .hint { font-size: 12px; color: var(--text-soft); margin: 4px 0 0; }

/* Resources */
.resources-list { display: flex; flex-direction: column; gap: 10px; }
.resource-item {
  padding: 14px 16px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border-right: 3px solid var(--forest);
}
.resource-item h3 { margin: 0 0 4px; font-size: 16px; color: var(--forest-deep); }
[data-theme="dark"] .resource-item h3 { color: var(--leaf-light); }
.resource-item p { margin: 2px 0; font-size: 13px; color: var(--text-muted); }
.resource-item .phone {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 12px;
  background: var(--forest);
  color: var(--cream-soft);
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

:focus-visible {
  outline: 3px solid var(--leaf);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   LOGIN SCREEN — Google Auth gate (v2 cloud)
   ============================================================ */

.login-screen {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px 80px;
  background:
    radial-gradient(circle at 20% 10%, rgba(168, 193, 154, 0.35), transparent 60%),
    radial-gradient(circle at 80% 90%, rgba(184, 153, 119, 0.18), transparent 55%),
    var(--bg);
}

.login-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 30% 80%, rgba(127, 168, 108, 0.22), transparent 60%),
    radial-gradient(ellipse at 70% 20%, rgba(244, 234, 213, 0.6), transparent 55%);
  z-index: 0;
}

.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px;
  padding: 32px 28px 28px;
  background: var(--bg-card);
  border-radius: 22px;
  box-shadow:
    0 16px 40px -16px rgba(31, 64, 41, 0.25),
    0 4px 12px -2px rgba(31, 64, 41, 0.10);
  text-align: center;
}

.login-pug {
  display: block;
  width: 168px; height: 168px;
  margin: 0 auto 18px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, var(--cream) 0%, var(--moss) 100%);
  box-shadow: 0 8px 22px -8px rgba(31, 64, 41, 0.30);
}

.login-title {
  margin: 0 0 8px;
  font-size: 28px; font-weight: 700;
  color: var(--forest-deep);
  letter-spacing: -0.3px;
}

.login-subtitle {
  margin: 0 0 24px;
  font-size: 15px; line-height: 1.55;
  color: var(--forest);
  opacity: 0.85;
}

.btn-google {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 12px;
  padding: 13px 16px;
  background: #fff; color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 12px;
  font-size: 15px; font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: box-shadow .15s ease, transform .05s ease, background .15s ease;
}
.btn-google:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 3px 0 rgba(60, 64, 67, 0.30), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
}
.btn-google:active { transform: translateY(1px); }
.btn-google:disabled { opacity: .6; cursor: progress; }
.btn-google .g-icon { flex-shrink: 0; }

.login-disclaimer {
  margin: 20px 0 8px;
  font-size: 13px; line-height: 1.5;
  color: var(--earth-deep);
}
.login-disclaimer a {
  color: var(--danger);
  text-decoration: none;
  font-weight: 600;
  margin: 0 4px;
}
.login-disclaimer a:hover { text-decoration: underline; }

.login-privacy {
  margin: 8px 0 0;
  font-size: 12px; line-height: 1.5;
  color: var(--earth);
  opacity: 0.75;
}

/* ============================================================
   USER MENU — Avatar + dropdown (post-login header)
   ============================================================ */

.user-menu { position: relative; }

/* Global floating user menu — fixed top-start on every screen */
.user-menu-global {
  position: fixed;
  top: 16px;
  inset-inline-start: 16px;
  z-index: 90;
}

.user-avatar-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  padding: 0;
  background: var(--bg-card);
  border: 2px solid var(--moss);
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 4px 12px -2px rgba(31, 64, 41, 0.18);
  transition: border-color .15s ease, transform .05s ease, box-shadow .15s ease;
}
.user-avatar-btn:hover { border-color: var(--leaf); box-shadow: 0 0 0 4px rgba(127, 168, 108, 0.15); }
.user-avatar-btn:active { transform: scale(0.96); }
.user-avatar-img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.user-avatar-fallback {
  font-size: 18px;
  color: var(--forest);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  /* Anchor to the same edge as the avatar (top-start) so menu opens into the viewport */
  inset-inline-start: 0;
  min-width: 240px;
  background: var(--bg-card);
  border-radius: 14px;
  box-shadow:
    0 12px 32px -10px rgba(31, 64, 41, 0.22),
    0 4px 10px -4px rgba(31, 64, 41, 0.12);
  border: 1px solid rgba(127, 168, 108, 0.20);
  padding: 6px;
  z-index: 90;
  animation: usermenuIn 0.14s ease-out;
}

@keyframes usermenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.user-menu-header {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--bg-subtle);
  margin-bottom: 4px;
}
.user-menu-name {
  font-weight: 600; font-size: 14px;
  color: var(--forest-deep);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-menu-email {
  font-size: 12px;
  color: var(--earth);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}

.user-menu-item {
  display: block;
  width: 100%;
  text-align: start;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font: inherit; font-size: 14px;
  color: var(--forest);
  cursor: pointer;
}
.user-menu-item:hover { background: var(--bg-subtle); }
.user-menu-item:focus-visible { background: var(--bg-subtle); outline: 2px solid var(--leaf); outline-offset: -2px; }
.user-menu-item-danger { color: var(--danger); }
.user-menu-item-danger:hover { background: var(--danger-bg); }

.user-menu-sep {
  border: none;
  border-top: 1px solid var(--bg-subtle);
  margin: 4px 6px;
}

/* ============================================================
   BRAND FOOTER — Made by Joujik (global, all screens)
   ============================================================ */

.brand-footer {
  position: relative;
  padding: 18px 16px 14px;
  text-align: center;
  /* Slight separation from content */
  margin-top: 28px;
  border-top: 1px solid rgba(127, 168, 108, 0.15);
  /* Don't render over fixed SOS button on small screens */
  padding-inline-end: 92px;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.brand-footer-link {
  display: inline-flex; align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--earth-deep);
  text-decoration: none;
  opacity: 0.75;
  transition: opacity .15s ease;
}
.brand-footer-link:hover { opacity: 1; text-decoration: underline; }
.brand-footer-mark {
  width: 24px; height: 24px;
  object-fit: contain;
  display: block;
}
.brand-footer-text {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 500;
}

/* On the login screen, footer floats at the very bottom for visual anchor */
body:has(#login:not(.hidden)) .brand-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  margin-top: 0;
  background: rgba(244, 234, 213, 0.85);
}
