/* ---------------- Tokens ---------------- */
:root {
  --bg: #0a0608;
  --bg-deep: #050304;
  --text: #f4ecef;
  --text-soft: rgba(244, 236, 239, 0.94);
  --text-mute: rgba(244, 236, 239, 0.72);
  --line: rgba(244, 236, 239, 0.34);
  --line-soft: rgba(244, 236, 239, 0.20);
  --glass: rgba(30, 16, 22, 0.60);
  --glass-strong: rgba(22, 12, 17, 0.78);
  --glass-edge: rgba(255, 255, 255, 0.22);
  --highlight: #e83a4a;
  --highlight-deep: #b62235;
  --highlight-soft: rgba(232, 58, 74, 0.22);
  --img-tint: rgba(8, 4, 6, 0.25);
  --img-vignette: rgba(5, 3, 4, 0.62);
  --shadow-sm: rgba(140, 18, 38, 0.52);
  --shadow-md: rgba(140, 18, 38, 0.66);
  --shadow-hi: rgba(232, 58, 74, 0.42);

  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-display: 'Times New Roman', serif;
}
body[data-theme="light"] {
  --bg: #f5e8e4;
  --bg-deep: #ead7d2;
  --text: #180810;
  --text-soft: rgba(24, 8, 16, 0.88);
  --text-mute: rgba(24, 8, 16, 0.58);
  --line: rgba(24, 8, 16, 0.22);
  --line-soft: rgba(24, 8, 16, 0.12);
  --glass: rgba(255, 252, 251, 0.82);
  --glass-strong: rgba(255, 253, 252, 0.94);
  --glass-edge: rgba(255, 255, 255, 0.90);
  --highlight: #c8243e;
  --highlight-deep: #9c1530;
  --highlight-soft: rgba(200, 36, 62, 0.14);
  --img-tint: rgba(245, 232, 228, 0.05);
  --img-vignette: rgba(245, 232, 228, 0.88);
  --shadow-sm: rgba(140, 30, 50, 0.18);
  --shadow-md: rgba(140, 30, 50, 0.28);
  --shadow-hi: rgba(200, 36, 62, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  transition: background 0.6s ease, color 0.6s ease;
}

/* Atmospheric backdrop: blurred flower image, vignette, optional grain */
.backdrop {
  position: fixed; inset: 0;
  z-index: -2;
  background-image: url('assets/flower-light.jpg');
  background-size: 72%;
  background-position: 50% 40%;
  background-repeat: no-repeat;
  filter: blur(10px) saturate(1.05);
  opacity: 0.90;
  transition: filter 0.6s ease, opacity 0.6s ease;
}
body[data-theme="dark"] .backdrop {
  filter: grayscale(1) brightness(0.38) contrast(1.2) blur(10px);
  opacity: 1;
}
body[data-theme="light"] .backdrop {
  filter: blur(7px) saturate(1.25) brightness(1.0);
  opacity: 0.95;
}
.backdrop-tint {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 58% 50% at 50% 44%, transparent 5%, var(--img-vignette) 65%),
    var(--bg);
  pointer-events: none;
  transition: background 0.6s ease;
}
.backdrop-grain {
  position: fixed; inset: 0; z-index: -1;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/></svg>");
}

a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------------- Shell ---------------- */
.stage {
  min-height: 100dvh;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 22px 20px 40px;
  display: flex; flex-direction: column;
  gap: 22px;
  position: relative;
}

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-block { display: flex; align-items: baseline; gap: 10px; }
.brand {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 29px;
  letter-spacing: 0.01em;
  line-height: 1;
}
.brand-tag {
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.icon-btn {
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  color: var(--text);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  transition: transform 0.2s ease, background 0.25s ease, border-color 0.25s ease;
}
.icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--highlight);
  color: var(--highlight);
}
.icon-btn:active { transform: translateY(0) scale(0.96); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.4; }

/* ---------------- Glass card ---------------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 22px;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow:
    0 18px 60px -8px var(--shadow-sm),
    inset 0 1px 0 rgba(255,255,255,0.10);
  position: relative;
  overflow: hidden;
}
.glass::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0) 45%);
  pointer-events: none;
}

/* ---------------- Eyebrow row ---------------- */
.eyebrow-row {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 4px;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-mute);
  display: inline-flex; align-items: center; gap: 10px;
}
.eyebrow::before {
  content: ""; width: 22px; height: 1px;
  background: var(--highlight);
  box-shadow: 0 0 6px var(--highlight);
}
.today-pill {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  opacity: 0.55;
}
.reset-day-btn {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--highlight);
  opacity: 0.85;
  border: 1px solid rgba(232, 58, 74, 0.35);
  border-radius: 8px;
  padding: 2px 7px;
  background: var(--highlight-soft);
  transition: opacity 0.2s, background 0.2s;
  cursor: pointer;
}
.reset-day-btn:hover { opacity: 1; background: rgba(232, 58, 74, 0.28); }
.day-marker { cursor: grab; }
.day-marker.is-dragging { cursor: grabbing; }

/* ---------------- Radial flower ---------------- */
.flower-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid; place-items: center;
}
.flower-svg {
  width: 100%; height: 100%;
  overflow: visible;
}

.petal-shape {
  transform-origin: 0 0;
  transform-box: view-box;
  animation: petalGrow 700ms cubic-bezier(.2,.8,.2,1) both;
  animation-delay: var(--d, 0ms);
  transition: filter 0.4s ease, opacity 0.4s ease;
}
@keyframes petalGrow {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.petal-num {
  font-family: var(--font-body);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  fill: var(--text-soft);
  opacity: 0;
  animation: fadeIn 700ms ease forwards;
  animation-delay: var(--d, 0ms);
}
.petal-num.is-active {
  fill: var(--highlight);
  font-weight: 500;
}
.petal-num.is-period { fill: var(--highlight); }
.petal-num.is-past { fill: var(--text-mute); }

.petal-tick {
  fill: var(--line-soft);
  stroke: none;
  opacity: 0;
  transform-origin: 300px 300px;
  transform-box: view-box;
  animation: petalBounceIn 650ms cubic-bezier(.2,.8,.2,1) both;
  animation-delay: var(--d, 0ms);
}
.petal-tick.is-active { fill: var(--highlight); }
.petal-tick.is-period { fill: var(--highlight); }
.petal-tick.is-past   { fill: var(--line-soft); }

@keyframes petalBounceIn {
  0%   { opacity: 0; transform: scale(0.72); }
  62%  { opacity: 1; transform: scale(1.07); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.ring-arc {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.2;
  opacity: 0;
  animation: fadeIn 500ms ease forwards;
  animation-delay: 30ms;
}
.ring-arc-active {
  fill: none;
  stroke: var(--highlight);
  stroke-width: 1.8;
  stroke-linecap: round;
  filter: drop-shadow(0 0 5px var(--highlight));
  opacity: 0;
  animation: fadeIn 500ms ease forwards;
  animation-delay: 80ms;
}

.moon-icon {
  opacity: 0;
  animation: fadeIn 900ms ease forwards;
  animation-delay: var(--d, 0ms);
}
.moon-icon.is-current { filter: drop-shadow(0 0 4px var(--highlight)); }

/* Day marker dot — pulses on active */
.day-marker {
  fill: var(--highlight);
  filter: drop-shadow(0 0 6px var(--highlight)) drop-shadow(0 0 12px var(--highlight));
  animation: pulse 2.4s ease-in-out infinite;
  touch-action: none;
}
@keyframes pulse { 0%,100% { opacity: 1; r: 5; } 50% { opacity: 0.65; r: 6.5; } }
.day-marker-today {
  fill: var(--text-mute);
  opacity: 0.5;
}

/* Center hub */
.hub {
  position: absolute;
  width: 38%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--glass-strong);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    0 12px 40px var(--shadow-sm);
  cursor: pointer;
  perspective: 900px;
  transition: transform 0.3s cubic-bezier(.2,.8,.2,1);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.hub:hover { transform: scale(1.01); }
.hub:active { transform: scale(0.99); }
.hub-inner {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(.4,.15,.2,1);
}
.hub.is-flipped .hub-inner { transform: rotateY(180deg); }
.hub-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: space-evenly;
  text-align: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.hub-back {
  transform: rotateY(180deg);
  justify-content: center;
  gap: 8px;
}
.hub-day {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(46px, 12vw, 64px);
  line-height: 0.0;
  letter-spacing: -0.02em;
}
.hub-day-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.hub-phase {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--highlight);
}
.hub-phase.muted { color: var(--text-soft); }
.hub-back-date {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(22px, 6vw, 30px);
  color: var(--highlight);
  line-height: 1;
}

/* ---------------- Hormone peek button ---------------- */
.hormone-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hormone-peek-row {
  display: flex;
  justify-content: flex-end;
}
.hormone-peek-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--text-mute);
  transition: color 0.25s ease, border-color 0.25s ease;
}
.hormone-peek-btn svg { width: 13px; height: 13px; stroke-width: 1.5; }
.hormone-peek-btn.is-active {
  color: var(--highlight);
  border-color: var(--highlight);
}

/* ---------------- Status row ---------------- */
.status-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.5s cubic-bezier(.2,.8,.2,1), opacity 0.35s cubic-bezier(.2,.8,.2,1);
}
/* Padding gives the card's border-radius and box-shadow room to render
   without being clipped by overflow:hidden. Negative margin compensates layout. */
.status-row.is-visible {
  max-height: 700px;
  padding: 3px 24px 82px;
  margin: 0 -24px -82px;
  opacity: 1;
  pointer-events: auto;
}

.chip {
  padding: 14px 14px 12px;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.chip-label {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.chip-value {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 32px;
  line-height: 1;
}
.chip-value .unit {
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin-left: 4px;
}
.chip.accent .chip-value { color: var(--highlight); }

/* Hormone card */
.chip-hormone { gap: 8px; cursor: pointer; user-select: none; }

.hormone-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hormone-card-header .chip-label { flex: 1; }

.hormone-chevron-btn {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text-mute);
  flex-shrink: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(.2,.8,.2,1), color 0.2s ease;
}
.hormone-chevron-btn svg { width: 14px; height: 14px; stroke-width: 1.8; }
.hormone-chevron-btn.is-open { transform: rotate(180deg); color: var(--text); }

.hormone-dot-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
}
.hormone-dot-item {
  display: flex;
  flex-direction: column;
}
.hormone-dot-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-soft);
  line-height: 1;
}
.hormone-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.hormone-dot-desc {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.38s ease, opacity 0.28s ease, margin-top 0.28s ease;
  margin-top: 0;
  padding-left: 12px;
}
#hormoneCard.is-open .hormone-dot-desc {
  max-height: 120px;
  opacity: 1;
  margin-top: 5px;
}
.hormone-desc-role {
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-mute);
  letter-spacing: 0.01em;
  font-style: italic;
}
.hormone-desc-text {
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-soft);
  letter-spacing: 0.01em;
  margin-top: 2px;
}

/* ---------------- Phase note ---------------- */
.phase-note {
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.phase-note-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.phase-note-header .phase-note-title { flex: 1; }
.phase-note-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 27px;
  line-height: 1.2;
  margin: 0;
}
.phase-note-title .accent { color: var(--highlight); font-style: normal; }
.phase-note-body {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}
.phase-split {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 0 16px;
  margin-top: 2px;
}
#phaseSplit[hidden] { display: none; }
.phase-split-divider {
  background: var(--glass-border, rgba(255,255,255,0.08));
  align-self: stretch;
}
.phase-split-col { display: flex; flex-direction: column; gap: 8px; }
.phase-split-label {
  font-size: 10px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-weight: 500;
  padding-bottom: 2px;
}
.phase-split-more .phase-split-label { color: var(--highlight); }
.phase-split-less .phase-split-label { color: var(--text-mute); }
.phase-split-list {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 5px;
}
.phase-split-list li {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.45;
  letter-spacing: 0.01em;
  padding-left: 10px;
  position: relative;
}
.phase-split-more .phase-split-list li::before {
  content: '+';
  position: absolute; left: 0;
  color: var(--highlight);
  font-size: 11px;
}
.phase-split-less .phase-split-list li::before {
  content: '–';
  position: absolute; left: 0;
  color: var(--text-mute);
  font-size: 11px;
}

/* ---------------- Phase expand ---------------- */
.phase-note.is-expandable { cursor: pointer; }
.phase-expand-arrow {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--text-mute);
  transition: color 0.2s ease;
  margin-top: 4px;
}
.phase-note.is-expandable:hover .phase-expand-arrow { color: var(--highlight); }
.phase-expand-arrow svg { width: 14px; height: 14px; stroke-width: 1.8; transition: transform 0.35s ease; }
.phase-note.is-expanded .phase-expand-arrow svg { transform: rotate(180deg); }
.phase-empty-expand {
  font-size: 12px; line-height: 1.65; letter-spacing: 0.04em;
  color: var(--text-mute); text-align: center;
  padding: 8px 4px 2px; font-style: italic;
}

/* ---------------- Range picker sheet ---------------- */
.rangepick-nav {
  display: flex; align-items: center; justify-content: space-between; padding: 0 2px;
  margin-bottom: 6px;
}
.rangepick-month-label {
  font-family: var(--font-display); font-style: italic; font-weight: 300; font-size: 20px;
}
.rangepick-nav-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; background: var(--glass); border: 1px solid var(--line);
  font-size: 15px; color: var(--text); transition: border-color 0.2s, color 0.2s;
}
.rangepick-nav-btn:hover { border-color: var(--highlight); color: var(--highlight); }
.rangepick-nav-btn:disabled { opacity: 0.3; pointer-events: none; }
.rangepick-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.rangepick-dow {
  font-size: 9px; text-align: center; color: var(--text-mute);
  letter-spacing: 0.1em; padding: 10px 0 8px;
}
.rangepick-day {
  aspect-ratio: 1; display: grid; place-items: center;
  font-size: 16px; border-radius: 7px; cursor: pointer;
  color: var(--text-soft); font-variant-numeric: tabular-nums; user-select: none;
  transition: background 0.12s ease;
}
.rangepick-day:hover:not(.is-future):not(.is-empty) { background: var(--glass); }
.rangepick-day.is-today { outline: 1px solid var(--line); outline-offset: -1px; }
.rangepick-day.is-future { color: var(--text-mute); opacity: 0.3; pointer-events: none; }
.rangepick-day.is-empty { pointer-events: none; }
.rangepick-day.is-start { background: var(--highlight) !important; color: #fff; font-weight: 500; border-radius: 7px 0 0 7px; }
.rangepick-day.is-end   { background: var(--highlight) !important; color: #fff; font-weight: 500; border-radius: 0 7px 7px 0; }
.rangepick-day.is-start.is-end { border-radius: 7px; }
.rangepick-day.in-range { background: var(--highlight-soft); color: var(--highlight); border-radius: 0; }
.rangepick-summary {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-mute); text-align: center; min-height: 16px;
  padding-top: 16px; padding-bottom: 8px;
}
.rangepick-summary.has-range { color: var(--highlight); }

.split-item-desc {
  display: block;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-mute);
  letter-spacing: 0.01em;
  padding-left: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.38s ease, opacity 0.3s ease, margin-top 0.3s ease;
  margin-top: 0;
}
.phase-note.is-expanded .split-item-desc {
  max-height: 80px;
  opacity: 1;
  margin-top: 3px;
}

/* ---------------- Bottom action ---------------- */
.next-period-line {
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 6px 0 2px;
}
.next-period-line .unit { margin-left: 2px; }
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  margin-top: 8px;
}
.history-header[hidden] { display: none; }
.log-action {
  width: 100%;
  padding: 16px 20px;
  border-radius: 999px;
  background: var(--highlight);
  border: 1px solid rgba(255,255,255,0.14);
  color: #fff;
  font-size: 12px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  box-shadow:
    0 14px 40px -10px var(--shadow-hi),
    inset 0 1px 0 rgba(255,255,255,0.18);
  transition: transform 0.2s ease, box-shadow 0.25s ease;
}
.log-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 50px -10px var(--shadow-hi), inset 0 1px 0 rgba(255,255,255,0.25);
}
.log-action:active { transform: translateY(0) scale(0.98); }
.log-action .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px #fff;
  animation: pulseDot 1.6s ease-in-out infinite;
}
@keyframes pulseDot { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(0.8); } }

/* ---------------- Drawer (right slide menu) ---------------- */
.scrim {
  position: fixed; inset: 0;
  background: rgba(30, 4, 10, 0.60);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 50;
}
body.drawer-open .scrim { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0;
  width: min(420px, 92vw);
  height: 100dvh;
  z-index: 60;
  background: var(--glass-strong);
  backdrop-filter: blur(0px) saturate(1.2);
  -webkit-backdrop-filter: blur(0px) saturate(1.2);
  border-left: 1px solid var(--glass-edge);
  box-shadow: none;
  transform: translateX(100%);
  transition: transform 0.45s cubic-bezier(.2,.8,.2,1), box-shadow 0.45s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
body.drawer-open .drawer { transform: translateX(0); box-shadow: -30px 0 80px var(--shadow-md); }

.drawer-head {
  padding: 22px 24px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
}
.drawer-head h2 {
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-size: 22px;
  margin: 0;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px 28px;
  display: flex; flex-direction: column; gap: 22px;
}
.drawer-section h3 {
  margin: 0 0 12px;
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 400;
}
#upcomingSection:not([hidden]) {
  margin-bottom: 8px;
}
.upcoming-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--line-soft);
}
.upcoming-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.upcoming-date {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 18px;
  color: var(--highlight);
}
.drawer-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.drawer-mission {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 13px;
  color: var(--text-main);
}
.drawer-privacy {
  margin: 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-mute);
}

/* phase legend */
.legend { display: flex; flex-direction: column; gap: 2px; }
.legend-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background 0.2s ease;
}
.legend-row.is-current {
  background: var(--highlight-soft);
  border: 1px solid rgba(232,58,74,0.32);
}
.legend-moon {
  width: 22px; height: 22px;
  flex-shrink: 0;
  color: var(--text-soft);
}
.legend-row.is-current .legend-moon { color: var(--highlight); }
.legend-name { flex: 1; font-size: 12px; color: var(--text); }
.legend-row.is-current .legend-name { font-weight: 500; color: var(--highlight); }
.legend-days {
  font-size: 10px; color: var(--text-mute);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

/* history table */
.history { width: 100%; border-collapse: collapse; }
.history th, .history td {
  text-align: left;
  padding: 9px 0;
  font-size: 11px;
  border-bottom: 1px solid var(--line-soft);
}
.history th {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--text-mute);
  font-weight: 400;
  border-bottom: 1px solid var(--line);
}
.history td .date { color: var(--text); font-variant-numeric: tabular-nums; }
.history td .len { color: var(--text-soft); font-variant-numeric: tabular-nums; }
.history td .badge {
  display: inline-block;
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--highlight-soft);
  color: var(--highlight);
  border: 1px solid rgba(232,58,74,0.28);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ghost button */
.ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.ghost:hover { border-color: var(--highlight); color: var(--highlight); }
.ghost svg { width: 14px; height: 14px; }
.ghost-stack { display: flex; flex-direction: column; gap: 8px; }

.file-pick {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  box-sizing: border-box;
}
.file-pick:hover { border-color: var(--highlight); color: var(--highlight); }
.file-pick svg { width: 14px; height: 14px; flex-shrink: 0; }
.file-pick input { display: none; }

.ghost-danger { color: var(--text-soft); }
.ghost-danger:hover { border-color: #c0392b; color: #c0392b; }

/* drawer empty-state get-started button */
.drawer-get-started {
  width: 100%;
  padding: 28px 24px;
  border-radius: 999px;
  border: none;
  background: var(--highlight);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 36px color-mix(in srgb, var(--highlight) 45%, transparent),
              0 6px 18px color-mix(in srgb, var(--highlight) 28%, transparent);
  transition: box-shadow 0.3s ease, transform 0.2s ease, background 0.2s ease;
}
.drawer-get-started:hover {
  background: var(--highlight-deep);
  box-shadow: 0 0 52px color-mix(in srgb, var(--highlight) 55%, transparent),
              0 6px 22px color-mix(in srgb, var(--highlight) 35%, transparent);
  transform: translateY(-1px);
}

/* close button in drawer head: no glass card */
.drawer-head #closeDrawer {
  background: transparent;
  border-color: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* theme toggle */
.theme-toggle {
  display: flex;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}
.theme-toggle button {
  flex: 1;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-soft);
  transition: background 0.25s ease, color 0.25s ease;
}
.theme-toggle button.active {
  background: var(--highlight);
  color: #fff;
}

/* cycle average stat */
.cycle-avg {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.06em;
}

/* cycle/period length steppers */
.stepper-rows { display: flex; flex-direction: column; }
.stepper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.stepper-row:last-child { border-bottom: none; }
.stepper-label { font-size: 12px; color: var(--text); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  transition: border-color 0.2s, color 0.2s;
}
.stepper-btn:hover { border-color: var(--highlight); color: var(--highlight); }
.stepper-val {
  min-width: 52px;
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
  letter-spacing: 0.06em;
}

/* iOS install tip */
.ios-install-tip {
  font-size: 11px;
  line-height: 1.65;
  color: var(--text-mute);
  padding: 10px 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.ios-install-tip strong { color: var(--text-soft); font-weight: 500; }

/* notification sub-label and hint */
.notify-sublabel {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--text-mute);
  margin: 0 0 8px;
}
.notify-hint {
  margin: 6px 0 0;
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.06em;
  line-height: 1.5;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-edge);
  color: var(--text);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  box-shadow: 0 18px 50px var(--shadow-md);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(.2,.8,.2,1);
  z-index: 100;
  display: flex; align-items: center; gap: 10px;
  white-space: nowrap;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--highlight);
  box-shadow: 0 0 6px var(--highlight);
}

/* ---------------- Calendar view ---------------- */
.cal-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 8px;
}
.cal-year-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cal-year-label {
  font-size: 9px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.cal-year-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}
.cal-months-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.cal-month {
  padding: 12px 12px 10px;
  border-radius: 18px;
}
.cal-month-header {
  font-size: 11px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 8px;
}
.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}
.cal-dow {
  font-size: 8.5px;
  text-align: center;
  color: var(--text-mute);
  padding: 2px 0 5px;
}
.cal-day {
  font-size: 10px;
  text-align: center;
  padding: 3px 1px;
  border-radius: 5px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.cal-day.has-period {
  background: var(--highlight-soft);
  color: var(--highlight);
}
.cal-day.is-period-start {
  background: var(--highlight);
  color: #fff;
  font-weight: 500;
}
.cal-day.is-today {
  outline: 1px solid var(--highlight);
  outline-offset: -1px;
  color: var(--text);
}
.cal-day.is-today.has-period,
.cal-day.is-today.is-period-start { color: #fff; }
.cal-day[data-date] { cursor: pointer; }
.cal-day[data-date]:hover:not(.has-period):not(.is-period-start) {
  background: var(--glass-edge);
  color: var(--text);
}
.cal-day.is-period-start[data-date]:hover { opacity: 0.75; }

/* ---------------- Secondary log link ---------------- */
.log-alt {
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 6px;
  transition: color 0.2s ease;
}
.log-alt:hover { color: var(--highlight); }

/* ---------------- Date input ---------------- */
.date-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 16px;
  letter-spacing: 0.04em;
  outline: none;
  -webkit-appearance: none;
  transition: border-color 0.2s ease;
}
.date-input:focus { border-color: var(--highlight); }
.date-input::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(0.45);
  cursor: pointer;
}
body[data-theme="light"] .date-input::-webkit-calendar-picker-indicator {
  filter: none;
  opacity: 0.45;
}

/* ---------------- Bottom sheets (onboarding + date picker) ---------------- */
.sheet-scrim {
  position: fixed; inset: 0;
  background: rgba(5, 3, 4, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 80;
}
.sheet-scrim.is-open { opacity: 1; pointer-events: auto; }

.bottom-sheet {
  position: fixed;
  bottom: 0; left: 50%;
  width: min(520px, 100%);
  transform: translateX(-50%) translateY(100%);
  z-index: 90;
  background: var(--glass-strong);
  border: 1px solid var(--glass-edge);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 32px 28px max(env(safe-area-inset-bottom, 0px), 40px);
  transition: transform 0.48s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; gap: 14px;
}
.bottom-sheet.is-open { transform: translateX(-50%) translateY(0); }

/* langSheet must sit above onboardSheet when both are open */
#langSheet { z-index: 100; }
#langScrim { z-index: 95; }

/* Onboard calendar step: generous vertical spacing */
#onboardStep1 .sheet-title { margin-top: 52px; margin-bottom: 8px; }
#onboardStep1 .sheet-sub   { margin-bottom: 20px; }
#onboardStep1 .rangepick-nav { margin-top: 0; margin-bottom: 10px; }
#onboardStep1 .rangepick-summary { padding-top: 24px; padding-bottom: 12px; }
#onboardStep1 .log-action  { margin-top: 8px; }
#onboardStep1 .sheet-cancel { margin-top: 10px; margin-bottom: 4px; }

.sheet-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 28px;
  line-height: 1.25;
  text-align: center;
  margin-bottom: 2px;
}
.sheet-sub {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  text-align: center;
  margin-top: 0px;
}
.sheet-cancel {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
  text-align: center;
  width: 100%;
  padding: 8px;
  padding-top: 8px;
  border: none;
  transition: color 0.2s ease;
}
.sheet-cancel:hover { color: var(--text); }

/* ---------------- Onboarding steppers ---------------- */
.onboard-stepper-group {
  display: flex; flex-direction: column; gap: 10px;
  margin: 20px 0 12px;
}
.onboard-stepper-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; gap: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.onboard-stepper-label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 14px; color: var(--text);
}
.onboard-stepper-hint { font-size: 11px; color: var(--text-mute); letter-spacing: 0.04em; }
.onboard-stepper { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.onboard-step-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font-size: 18px; line-height: 1;
  display: grid; place-items: center;
  transition: border-color 0.15s, color 0.15s;
}
.onboard-step-btn:hover { border-color: var(--highlight); color: var(--highlight); }
.onboard-step-btn:disabled { opacity: 0.3; pointer-events: none; }
.onboard-step-val {
  font-size: 20px; font-variant-numeric: tabular-nums;
  min-width: 38px; text-align: center; color: var(--text);
}

/* ---------------- Quote card ---------------- */
.quote-date {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  opacity: 0.7;
  align-self: flex-start;
}
.quote-card {
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.quote-text {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-soft);
  letter-spacing: 0.02em;
  margin: 0;
}
.quote-text::before { content: '\201C'; }
.quote-text::after  { content: '\201D'; }
.quote-meta {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}
.quote-topic {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--highlight);
  opacity: 0.7;
}
.quote-author-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.quote-author {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.quote-role {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-mute);
  opacity: 0.55;
}

/* ---------------- Empty state phase preview ---------------- */
.empty-phase-preview {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.empty-preview-heading {
  display: block;
  margin-bottom: 0;
}
.empty-phases-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.empty-phase-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
}
.empty-phase-swatch {
  width: 3px;
  border-radius: 2px;
  flex-shrink: 0;
  opacity: 0.75;
  align-self: stretch;
  min-height: 28px;
}
.empty-phase-info {
  display: block;
  flex: 1;
  min-width: 0;
}
.empty-phase-name {
  display: block;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.empty-phase-tagline {
  display: block;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
  letter-spacing: 0.01em;
}

/* language pill shared styles */
.drawer-lang-pill {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.drawer-lang-pill:hover { color: var(--highlight); border-color: var(--highlight); }

/* ---------------- Onboarding Step 0 intro animation ---------------- */
.onboard-lang-float {
  position: absolute;
  top: 24px;
  right: 24px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  display: flex;
  align-items: center;
  gap: 5px;
  z-index: 1;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.onboard-lang-float:hover { color: var(--highlight); border-color: var(--highlight); }
.onboard-intro-brand {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 38px;
  text-align: center;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 10px;
  margin-top: 12px;
}
.onboard-intro-sub {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--text-mute);
  text-align: center;
  text-transform: uppercase;
  margin: 0;
}
.onboard-intro-divider {
  width: 36px;
  height: 1px;
  background: var(--line-soft);
  margin: 16px auto 0;
}
.onboard-privacy-line {
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-mute);
  text-align: center;
  letter-spacing: 0.02em;
  margin: 12px 0 0;
  opacity: 0.8;
  animation: onboardDialFadeIn 0.5s ease 0.2s both;
}
.onboard-dial-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: 24px 0 16px;
}
.onboard-dial-container {
  position: relative;
  width: 200px;
  height: 200px;
  display: grid;
  place-items: center;
}
.onboard-dial-svg {
  width: 200px;
  height: 200px;
  filter: drop-shadow(0 0 24px rgba(140, 18, 38, 0.3));
  animation: onboardDialFadeIn 0.8s ease both;
}
.onboard-hub {
  position: absolute;
  width: 38%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--glass-strong);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    0 8px 28px var(--shadow-sm);
  pointer-events: none;
  animation: onboardDialFadeIn 0.8s ease both;
  display: flex;
  align-items: center;
  justify-content: center;
}
.onboard-hub .hub-inner {
  position: relative;
  width: 100%;
  height: 100%;
}
.onboard-hub .hub-face {
  justify-content: center;
  gap: 2px;
}
.onboard-hub-day {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}
.intro-marker {
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.9));
}
.intro-phase-name {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  color: var(--text-soft);
  text-align: center;
  letter-spacing: 0.04em;
  min-height: 24px;
  animation: onboardDialFadeIn 0.6s ease 0.4s both;
}
.intro-phase-body {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-mute);
  text-align: center;
  letter-spacing: 0.02em;
  margin: 0;
  padding: 0 8px;
  min-height: 88px;
  white-space: pre-line;
  animation: onboardDialFadeIn 0.6s ease 0.6s both;
}
@keyframes onboardDialFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.onboard-day-marker {
  fill: var(--highlight);
  filter: drop-shadow(0 0 18px var(--highlight)) drop-shadow(0 0 36px var(--highlight));
  animation: onboardPulse 2.4s ease-in-out infinite;
}
@keyframes onboardPulse {
  0%, 100% { opacity: 1; r: 14; }
  50% { opacity: 0.65; r: 18; }
}

/* ---------------- Export dialog ---------------- */
.export-formats {
  display: flex; flex-direction: column; gap: 6px;
}
.export-fmt-btn {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid var(--glass-edge);
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.export-fmt-btn:hover { border-color: var(--highlight); }
.export-fmt-btn.is-active {
  border-color: var(--highlight);
  background: color-mix(in srgb, var(--highlight) 10%, transparent);
}
.export-fmt-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}
.export-fmt-btn.is-active .export-fmt-name { color: var(--highlight); }
.export-fmt-desc {
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.03em;
}

.export-preview-wrap {
  background: color-mix(in srgb, var(--glass-edge) 40%, transparent);
  border: 1px solid var(--glass-edge);
  border-radius: 12px;
  overflow: hidden;
}
.export-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--glass-edge);
}
.export-preview-label {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.export-copy-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
  background: transparent;
  border: 1px solid var(--glass-edge);
  border-radius: 20px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.export-copy-btn:hover { color: var(--highlight); border-color: var(--highlight); }
.export-copy-btn.copied { color: var(--highlight); border-color: var(--highlight); }
.export-preview {
  margin: 0;
  padding: 12px;
  max-height: 160px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 10px;
  line-height: 1.6;
  color: var(--text-mute);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------------- Phase arcs & hormone ring ---------------- */
.phase-arc { pointer-events: none; }
.hormone-fill, .hormone-stroke { pointer-events: none; }

/* ---------------- Language picker ---------------- */
.lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0;
}
.lang-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
  width: 100%;
}
.lang-btn:hover:not(:disabled) { border-color: var(--highlight); color: var(--highlight); }
.lang-btn:disabled { opacity: 0.30; cursor: not-allowed; }
.lang-btn.is-active {
  border-color: var(--highlight);
  color: var(--highlight);
  background: var(--highlight-soft);
}
.lang-flag { font-size: 17px; line-height: 1; flex-shrink: 0; }
.lang-name { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.lang-native { font-size: 12px; }
.lang-english { font-size: 10px; color: var(--text-mute); letter-spacing: 0.06em; }
.lang-btn.is-active .lang-english { color: var(--highlight); opacity: 0.75; }

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

/* ---------------- Dev scrubber ---------------- */
.dev-scrubber {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-edge);
  border-right: none;
  border-radius: 16px 0 0 16px;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: -8px 0 30px var(--shadow-sm);
  transition: opacity 0.3s ease;
  opacity: 0.92;
}
.dev-scrubber:hover { opacity: 1; }
.dev-scrubber.is-hidden { opacity: 0; pointer-events: none; }

.dev-scrubber-label {
  font-size: 8px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--highlight);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
}
.dev-scrubber-day {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 300;
  line-height: 1;
  color: var(--text);
  min-width: 22px;
  text-align: center;
}
.dev-scrubber-total {
  font-size: 9px;
  color: var(--text-mute);
  letter-spacing: 0.06em;
  text-align: center;
}
.dev-scrubber input[type="range"] {
  -webkit-appearance: slider-vertical;
  appearance: slider-vertical;
  writing-mode: vertical-lr;
  direction: rtl;
  width: 20px;
  height: 160px;
  cursor: pointer;
  accent-color: var(--highlight);
  background: transparent;
}

/* ================================================
   RTL OVERRIDES  (Persian / Arabic script)
   ================================================ */
[dir="rtl"] .drawer {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 1px solid var(--glass-edge);
  transform: translateX(-100%);
}
[dir="rtl"] body.drawer-open .drawer {
  transform: translateX(0);
  box-shadow: 30px 0 80px var(--shadow-md);
}

[dir="rtl"] .history th,
[dir="rtl"] .history td { text-align: right; }

[dir="rtl"] .export-fmt-btn { text-align: right; }
[dir="rtl"] .lang-btn { text-align: right; }

[dir="rtl"] .quote-text::before { content: '«'; }
[dir="rtl"] .quote-text::after  { content: '»'; }

[dir="rtl"] .dev-scrubber {
  right: auto;
  left: 0;
  border-right: none;
  border-left: 1px solid var(--glass-edge);
  border-radius: 0 16px 16px 0;
  box-shadow: 8px 0 30px var(--shadow-sm);
}

/* ================================================
   PARTNER VIEW
   ================================================ */
#partnerSheet { max-height: 80dvh; overflow: hidden; display: flex; flex-direction: column; }
.partner-content {
  overflow-y: auto;
  flex: 1;
  display: flex; flex-direction: column; gap: 12px;
  padding-right: 4px;
}
.partner-no-data {
  font-size: 13px; color: var(--text-mute); text-align: center; padding: 20px 0;
}
.partner-phase-badge {
  display: inline-block;
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--highlight); background: var(--highlight-soft);
  padding: 5px 12px; border-radius: 999px;
  align-self: flex-start;
}
.partner-meta {
  font-size: 11px; letter-spacing: 0.08em; color: var(--text-mute);
}
.partner-headline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  font-weight: 300;
  line-height: 1.35;
  color: var(--text);
}
.partner-body {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-soft);
}
.partner-tips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.partner-tips li {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-soft);
  padding-left: 14px;
  position: relative;
}
.partner-tips li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--highlight);
  font-size: 16px;
  line-height: 1.2;
}
