/* ===== My Pill — Pink Glitter Theme ===== */

:root {
  --pink-baby: #ffd6e6;
  --pink-cipria: #f7c5d6;
  --pink-antico: #d48ca6;
  --pink-shock: #ff4d94;
  --pink-fuchsia: #ff2e93;
  --pink-deep: #c2185b;
  --pink-soft: #ffe4ec;
  --pink-mist: #fff0f5;
  --gold: #ffd700;
  --white: #ffffff;
  --text: #4a1d33;
  --text-soft: #8b5a72;
  --gray: #e8d8de;
  --shadow: 0 10px 30px rgba(255, 77, 148, 0.18);
  --glow: 0 0 18px rgba(255, 77, 148, 0.45);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, var(--pink-baby) 0%, transparent 50%),
    radial-gradient(circle at 80% 90%, var(--pink-cipria) 0%, transparent 50%),
    linear-gradient(180deg, var(--pink-mist) 0%, var(--pink-soft) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
}

/* Inputs need selection */
input, textarea { user-select: text; -webkit-user-select: text; }

/* prevent iOS auto-zoom on inputs (16px min) */
input, select, textarea, button { font-size: 16px; }

#glitter-bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 430px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-top)) 16px calc(110px + var(--safe-bottom)) 16px;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-overflow-scrolling: touch;
}

.screen[hidden] { display: none; }

/* HEADER */
.app-header { margin-bottom: 18px; }

.brand {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: 30px;
  margin: 0;
  background: linear-gradient(135deg, var(--pink-shock), var(--pink-deep), var(--pink-fuchsia));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-shadow: 0 2px 8px rgba(255, 46, 147, 0.18);
}

.brand-pill {
  display: inline-block;
  width: 28px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink-shock) 0 50%, var(--pink-baby) 50% 100%);
  box-shadow: 0 0 12px var(--pink-shock), inset 0 1px 2px rgba(255,255,255,0.6);
  transform: rotate(-25deg);
  position: relative;
  overflow: hidden;
}
.brand-pill::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, white 0 1px, transparent 2px),
    radial-gradient(circle at 70% 60%, white 0 1px, transparent 2px),
    radial-gradient(circle at 40% 80%, white 0 1px, transparent 2px);
  opacity: 0.9;
  animation: sparkle 2.4s infinite;
}

@keyframes sparkle {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.greeting {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 16px;
  font-weight: 600;
}

.screen-title {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 28px;
  margin: 0;
  color: var(--pink-deep);
}

/* CARDS */
.card {
  background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255,228,236,0.85));
  border: 1px solid rgba(255, 77, 148, 0.22);
  border-radius: 20px;
  padding: 16px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.glitter-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,0.9) 0 1px, transparent 2px),
    radial-gradient(circle at 80% 30%, rgba(255,215,0,0.7) 0 1px, transparent 2px),
    radial-gradient(circle at 30% 75%, rgba(255,77,148,0.5) 0 1px, transparent 2px),
    radial-gradient(circle at 65% 85%, rgba(255,255,255,0.8) 0 1px, transparent 2px),
    radial-gradient(circle at 50% 50%, rgba(255,215,0,0.4) 0 1px, transparent 2px);
  pointer-events: none;
  animation: cardShimmer 4s infinite ease-in-out;
  opacity: 0.6;
}

@keyframes cardShimmer {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.02); }
}

.card-label {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: var(--pink-deep);
  margin-bottom: 10px;
}

.card.danger { border-color: rgba(220, 50, 100, 0.4); }

/* PILL STATUS */
.pill-status {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}

.pill-actions {
  display: flex;
  gap: 10px;
}

/* BUTTONS */
.btn {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 16px 16px;
  min-height: 50px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.18s;
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--pink-shock), var(--pink-fuchsia));
  color: white;
  box-shadow: 0 6px 18px rgba(255, 46, 147, 0.45), inset 0 1px 0 rgba(255,255,255,0.4);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.7);
  color: var(--pink-deep);
  border: 1.5px solid var(--pink-cipria);
}

.btn-danger {
  background: linear-gradient(135deg, #ff5577, #c2185b);
  color: white;
  box-shadow: 0 6px 18px rgba(194, 24, 91, 0.4);
}

.shimmer::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.6) 50%, transparent 70%);
  animation: shimmerSweep 2.6s infinite;
  pointer-events: none;
}
@keyframes shimmerSweep {
  0% { left: -100%; }
  60%, 100% { left: 130%; }
}

.btn-icon {
  background: rgba(255,255,255,0.8);
  border: 1.5px solid var(--pink-cipria);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 24px;
  color: var(--pink-deep);
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.btn-icon:active { transform: scale(0.92); }

/* CYCLE GRID */
.cycle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.cycle-item {
  background: rgba(255,255,255,0.6);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 77, 148, 0.15);
}
.cycle-item-wide { grid-column: 1 / -1; }
.cycle-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-soft);
  font-weight: 700;
  margin-bottom: 4px;
}
.cycle-value {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--pink-deep);
}

/* CALENDAR */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0;
}
.cal-month-label {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--pink-deep);
  text-transform: capitalize;
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: 800;
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.cal-day {
  aspect-ratio: 1;
  min-height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  padding: 0;
  touch-action: manipulation;
}
.cal-day.other-month { opacity: 0.25; }
.cal-day .day-num { font-size: 14px; line-height: 1; z-index: 2; position: relative; }

.cal-day .day-disc {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--gray);
  z-index: 1;
}

.cal-day.taken .day-disc {
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9), transparent 40%),
    linear-gradient(135deg, var(--pink-shock), var(--pink-fuchsia));
  box-shadow: 0 4px 12px rgba(255, 46, 147, 0.5), inset 0 0 8px rgba(255,255,255,0.4);
}
.cal-day.taken .day-disc::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-image:
    radial-gradient(circle at 20% 30%, white 0 1px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(255,215,0,0.9) 0 1px, transparent 2px),
    radial-gradient(circle at 50% 80%, white 0 1px, transparent 2px);
  animation: sparkle 2s infinite;
}
.cal-day.taken .day-num { color: white; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }

.cal-day.skipped .day-disc {
  background: white;
  border: 2px solid var(--pink-cipria);
}

.cal-day.today .day-disc {
  outline: 2.5px dashed var(--pink-shock);
  outline-offset: 2px;
  animation: todayGlow 1.6s infinite ease-in-out;
}
@keyframes todayGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 77, 148, 0); outline-color: var(--pink-shock); }
  50% { box-shadow: 0 0 14px rgba(255, 77, 148, 0.7); outline-color: var(--gold); }
}

.cal-day .moon {
  position: absolute;
  top: 2px;
  right: 6px;
  font-size: 12px;
  z-index: 3;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.cal-day .day-stars {
  position: absolute;
  bottom: -2px;
  left: 0; right: 0;
  text-align: center;
  font-size: 8px;
  letter-spacing: -1px;
  color: var(--pink-shock);
  z-index: 3;
  line-height: 1;
}

.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 600;
}
.legend > div { display: flex; align-items: center; gap: 8px; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.dot.taken { background: linear-gradient(135deg, var(--pink-shock), var(--pink-fuchsia)); box-shadow: 0 0 6px var(--pink-shock); }
.dot.skipped { background: white; border: 2px solid var(--pink-cipria); }
.dot.empty { background: var(--gray); }
.dot.moon-legend { background: var(--pink-shock); position: relative; }
.dot.moon-legend::after { content:'🌙'; position:absolute; top:-8px; right:-8px; font-size:12px; }

/* SETTINGS */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field.row {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}
.field-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--pink-deep);
  text-transform: uppercase;
}
.field input[type="text"], .field input[type="time"] {
  background: white;
  border: 1.5px solid var(--pink-cipria);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  color: var(--text);
  width: 100%;
}
.field input[type="text"]:focus, .field input[type="time"]:focus {
  outline: 2px solid var(--pink-shock);
  border-color: var(--pink-shock);
}
.field input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--pink-shock);
}

.muted { color: var(--text-soft); font-size: 14px; margin: 0 0 10px; }

/* BOTTOM NAV */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-around;
  padding: 10px 8px calc(10px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(255, 228, 236, 0.85), rgba(247, 197, 214, 0.95));
  border-top: 1px solid rgba(255, 77, 148, 0.3);
  backdrop-filter: blur(10px);
  max-width: 430px;
  margin: 0 auto;
}
.glitter-nav { position: fixed; }
.nav-btn {
  flex: 1;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  min-height: 56px;
  cursor: pointer;
  color: var(--text-soft);
  font-weight: 700;
  font-size: 11px;
  border-radius: 12px;
  transition: background 0.2s;
  touch-action: manipulation;
}
.nav-btn .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 1px 2px rgba(194, 24, 91, 0.35));
  transition: transform 0.2s;
}
.nav-btn .nav-icon svg {
  width: 100%;
  height: 100%;
}
.nav-btn.active .nav-icon {
  transform: scale(1.15);
  filter: drop-shadow(0 0 8px rgba(255, 77, 148, 0.85)) drop-shadow(0 2px 3px rgba(194,24,91,0.3));
  animation: navPulse 1.8s infinite ease-in-out;
}
@keyframes navPulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 77, 148, 0.7)) drop-shadow(0 2px 3px rgba(194,24,91,0.3)); }
  50% { filter: drop-shadow(0 0 14px rgba(255, 215, 0, 0.8)) drop-shadow(0 2px 3px rgba(194,24,91,0.3)); }
}
.nav-btn.active {
  color: var(--pink-deep);
  background: rgba(255,255,255,0.6);
  box-shadow: 0 4px 12px rgba(255, 77, 148, 0.25);
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(74, 29, 51, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.2s;
  backdrop-filter: blur(4px);
}
.modal-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: linear-gradient(180deg, var(--pink-mist), white);
  width: 100%;
  max-width: 430px;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 24px 24px 0 0;
  padding: 18px 18px;
  padding-bottom: calc(24px + var(--safe-bottom));
  box-shadow: 0 -10px 30px rgba(255, 46, 147, 0.3);
  animation: slideUp 0.3s ease-out;
  position: relative;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  margin: 0;
  color: var(--pink-deep);
  text-transform: capitalize;
}

.modal-section { margin-bottom: 18px; }

.seg {
  display: flex;
  gap: 6px;
  background: rgba(255,255,255,0.5);
  border-radius: 14px;
  padding: 4px;
  border: 1px solid var(--pink-cipria);
}
.seg-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 14px 6px;
  min-height: 48px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
  touch-action: manipulation;
}
.seg-btn.active {
  background: linear-gradient(135deg, var(--pink-shock), var(--pink-fuchsia));
  color: white;
  box-shadow: 0 4px 10px rgba(255, 46, 147, 0.35);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-weight: 700;
  color: var(--text);
}
.toggle input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--pink-shock);
}

.toggle-primary {
  background: linear-gradient(135deg, rgba(255, 77, 148, 0.12), rgba(255, 214, 230, 0.5));
  border: 1.5px solid var(--pink-cipria);
  border-radius: 14px;
  padding: 14px 14px;
  font-size: 16px;
  margin-bottom: 8px;
}
.toggle-primary span { color: var(--pink-deep); font-weight: 800; }

.cycle-extras {
  padding: 4px 4px 0 8px;
  border-left: 3px solid var(--pink-cipria);
  margin-left: 4px;
  animation: slideDown 0.25s ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.toggle-sub {
  padding: 8px 0;
  font-size: 14px;
}
.toggle-sub span { font-weight: 600; }
.toggle-sub .hint {
  font-style: italic;
  font-weight: 400;
  color: var(--text-soft);
  font-size: 12px;
}

.flow-section { margin-top: 12px; }

.stars {
  display: flex;
  gap: 4px;
  margin: 12px 0 8px;
  justify-content: space-between;
}
.star {
  background: transparent;
  border: none;
  font-size: 42px;
  color: var(--pink-cipria);
  cursor: pointer;
  padding: 6px 4px;
  line-height: 1;
  flex: 1;
  min-height: 56px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.05));
  transition: transform 0.15s;
  touch-action: manipulation;
}
.star:active { transform: scale(1.2) rotate(-6deg); }
.star.filled {
  color: var(--pink-shock);
  text-shadow:
    0 0 6px var(--pink-shock),
    0 0 12px rgba(255, 215, 0, 0.6);
  animation: starPop 0.35s;
}
@keyframes starPop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.flow-label {
  font-weight: 700;
  font-size: 14px;
  color: var(--pink-deep);
  min-height: 20px;
}

.modal-actions { margin-top: 6px; }

/* CELEBRATION */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 214, 230, 0.4), transparent 70%);
}
.celebrate[hidden] { display: none; }
#celebrate-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.celebrate-msg {
  font-family: 'Playfair Display', serif;
  font-size: 42px;
  font-weight: 900;
  color: var(--pink-deep);
  text-shadow:
    0 0 20px var(--pink-shock),
    0 0 40px rgba(255, 215, 0, 0.7);
  animation: celebratePop 0.6s ease-out;
  z-index: 2;
}
@keyframes celebratePop {
  0% { transform: scale(0.3) rotate(-15deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* TOAST */
.toast {
  position: fixed;
  bottom: calc(110px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(74, 29, 51, 0.95);
  color: white;
  padding: 12px 20px;
  border-radius: 22px;
  font-weight: 700;
  z-index: 200;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s;
}
.toast[hidden] { display: none; }
@keyframes toastIn {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* small phones (iPhone SE, ~320–360px) */
@media (max-width: 360px) {
  #app { padding: calc(12px + var(--safe-top)) 12px calc(100px + var(--safe-bottom)) 12px; }
  .brand { font-size: 26px; }
  .greeting { font-size: 14px; }
  .pill-status { font-size: 18px; }
  .cycle-value { font-size: 16px; }
  .cycle-label { font-size: 10px; }
  .star { font-size: 36px; min-height: 48px; }
  .btn { font-size: 15px; padding: 14px 12px; }
  .seg-btn { font-size: 12px; padding: 12px 4px; }
  .card { padding: 14px 12px; border-radius: 18px; }
  .cal-day .day-num { font-size: 13px; }
  .nav-label { font-size: 10px; }
  .nav-btn .nav-icon { width: 26px; height: 26px; }
}

/* prevent scroll-jank when modal open */
body.modal-open { overflow: hidden; touch-action: none; }

/* landscape — discourage by keeping vertical UI */
@media (orientation: landscape) and (max-height: 500px) {
  .modal { max-height: 96vh; }
  .app-header { margin-bottom: 12px; }
  .brand { font-size: 24px; }
}

/* dark / high-contrast safety: ensure text readable */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}
