:root {
  --bg: #FFF3F6;
  --card: #FFFFFF;
  --text: #2E2230;
  --muted: #7D5F6B;
  --line: #F8DCE5;
  --primary: #FF4D6D;
  --primary-dark: #E63462;
  --menstrual: #E63462;
  --menstrual-bg: #FDE6EC;
  --menstrual-text: #9A1F42;
  --follicular: #FF9F68;
  --follicular-bg: #FFEADD;
  --follicular-text: #9C4A12;
  --ovulation: #FFC145;
  --ovulation-bg: #FFF4D9;
  --ovulation-text: #8A5B00;
  --luteal: #B185DB;
  --luteal-bg: #F1E8FA;
  --luteal-text: #6B3FA0;
  --radius: 22px;
}

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

button, .chip, .tab-btn, .strip-day, .cal-day, .pill, .option-btn, .edit-link, .btn, .btn-ghost {
  outline: none;
}

button:focus, .chip:focus, .tab-btn:focus {
  outline: none;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#root {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 100px;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-logo {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.app-header h1 {
  font-size: 20px;
  margin: 0;
}

.app-header .date {
  font-size: 13px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.phase-info {
  margin: 4px 0 20px;
  text-align: center;
}

.screen-fade {
  animation: screenFadeIn 0.15s ease-out;
}

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

.date-strip {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.date-strip::-webkit-scrollbar {
  display: none;
}

.strip-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
  width: 36px;
  scroll-snap-align: center;
}

.strip-weekday {
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.strip-daynum {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 600;
  color: var(--text);
  background: var(--line);
  border: 2px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.strip-day.today {
  color: var(--text);
}

.strip-day.today .strip-daynum {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.strip-day.selected:not(.today) .strip-daynum {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 800;
}

.phase-day-big {
  font-size: 36px;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.pill-group {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.phase-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin: 0;
}

.phase-badge-menstrual { background: var(--menstrual-bg); color: var(--menstrual-text); }
.phase-badge-follicular { background: var(--follicular-bg); color: var(--follicular-text); }
.phase-badge-ovulation { background: var(--ovulation-bg); color: var(--ovulation-text); }
.phase-badge-luteal { background: var(--luteal-bg); color: var(--luteal-text); }

.countdown-pill {
  display: inline-block;
  background: var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 999px;
  margin: 0;
}

.countdown-pill strong {
  font-weight: 800;
}

.icon-action-row {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin: 4px 0 20px;
}

.icon-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.icon-action-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease-out, filter 0.15s ease;
}

.icon-action:active .icon-action-circle {
  transform: scale(0.96);
}

.icon-action-circle svg {
  width: 26px;
  height: 26px;
}

.icon-action-circle.filled {
  background: var(--primary);
  box-shadow: 0 6px 14px rgba(255, 77, 109, 0.3);
}

.icon-action-circle.outline {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.icon-action-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.card h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #000;
  margin: 0 0 10px;
}

.patterns-card h2 {
  text-transform: none;
  letter-spacing: normal;
  color: #000;
}

.card h3 {
  font-size: 14px;
  margin: 0 0 6px;
}

.pill-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
}

.pill {
  flex: none;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

textarea.note-field {
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
}

.note-label {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 4px;
}

.num-field {
  width: 100%;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 4px;
}

.num-field:focus,
.note-field:focus,
.onboard input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(255, 77, 109, 0.15);
}

.phase-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.phase-row:last-child { border-bottom: none; }

.phase-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex: none;
}

.phase-row-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.phase-row-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 0;
}

.pattern-text {
  font-size: 14px;
  line-height: 1.5;
}

.pattern-muted {
  font-size: 13px;
  color: var(--muted);
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
  background: none;
  border: none;
  padding: 7px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 14px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.tab-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.tab-icon svg {
  width: 100%;
  height: 100%;
}

.tab-btn.active {
  color: var(--primary);
  background: var(--bg);
}

.btn {
  display: block;
  text-align: center;
  padding: 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease-out, filter 0.15s ease, background-color 0.15s ease;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 14px rgba(255, 77, 109, 0.28);
}

.btn-secondary {
  background: var(--card);
  color: var(--primary-dark);
  border: 1.5px solid var(--line);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 13px;
  padding: 6px 0;
  text-decoration: underline;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(40,30,28,0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
  animation: overlayFadeIn 0.15s ease-out;
}

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

.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  animation: slideUp 0.18s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet h2 {
  font-size: 17px;
  margin: 0 0 14px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
}

.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.option-btn {
  padding: 14px 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 14px;
  text-align: center;
  cursor: pointer;
}

.option-btn.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.sheet-footer {
  display: flex;
  gap: 10px;
}

.sheet-footer .btn { flex: 1; }

.onboard {
  padding-top: 40px;
}

.onboard label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 6px;
}

.onboard input {
  width: 100%;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 15px;
  background: var(--card);
  color: var(--text);
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.pulse {
  animation: pulseOpacity 1.2s ease-in-out infinite;
}

@keyframes pulseOpacity {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.calendar-modal {
  position: fixed;
  inset: 0;
  background: #F2F0F2;
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.modal-enter {
  animation: modalEnter 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.calendar-modal-header {
  padding: 16px 16px 10px;
}

.calendar-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}

.back-btn {
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px 4px 0;
  display: flex;
  align-items: center;
  gap: 2px;
  transition: opacity 0.1s ease-out;
}

.back-btn svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.back-btn:active {
  opacity: 0.55;
}

.modal-header-titled {
  display: grid;
  grid-template-columns: 70px 1fr 70px;
  align-items: center;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.calendar-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 24px;
}

.cal-weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  position: sticky;
  top: 0;
  background: #F2F0F2;
  padding: 10px 0;
  z-index: 2;
}

.cal-weekday-row span {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

.cal-month-label {
  font-size: 19px;
  font-weight: 800;
  margin: 20px 0 16px;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 20px;
}

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
  min-height: 56px;
}

.cal-today-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--primary);
  position: absolute;
  top: -13px;
}

.cal-daynum {
  font-size: 14px;
  color: var(--text);
}

.cal-daynum.active {
  color: var(--primary);
  font-weight: 700;
}

.cal-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease-out;
}

.cal-circle.selected {
  background: var(--primary);
  border-color: var(--primary);
}

.cal-day:active .cal-circle {
  transform: scale(0.9);
}

.logpage-header {
  display: grid;
  grid-template-columns: 70px 1fr 70px;
  align-items: center;
}

.logpage-datenav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.logpage-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease-out, background-color 0.15s ease;
}

.logpage-arrow:active {
  transform: scale(0.9);
}

.logpage-arrow svg {
  width: 18px;
  height: 18px;
}

#logPageDateLabel {
  font-size: 15px;
  font-weight: 700;
  min-width: 110px;
  text-align: center;
}

.logpage-body {
  padding-top: 20px;
}

.log-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.log-section-head h3 {
  margin: 0;
}

.edit-link {
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 0;
  transition: opacity 0.1s ease-out;
}

.edit-link:active {
  opacity: 0.55;
}

.edit-option-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  background: var(--card);
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.edit-option-row.dragging {
  background: var(--bg);
  border-radius: 10px;
  z-index: 5;
  position: relative;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.edit-option-remove {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #E5484D;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease-out, filter 0.15s ease;
}

.edit-option-remove:active {
  transform: scale(0.9);
}

.edit-option-remove svg {
  width: 14px;
  height: 14px;
}

.edit-option-label {
  flex: 1;
  color: var(--text);
}

.edit-option-handle {
  color: var(--muted);
  display: flex;
  align-items: center;
  cursor: grab;
  touch-action: none;
  padding: 6px;
  flex: none;
}

.edit-option-handle svg {
  width: 18px;
  height: 18px;
}

.edit-add-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.edit-add-row .num-field {
  margin-bottom: 0;
}

.edit-add-row .btn {
  width: auto;
  flex: none;
  padding: 11px 16px;
}

.log-section {
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
}

.log-section h3 {
  font-size: 16px;
  letter-spacing: 0.01em;
  color: #000;
  margin: 0 0 12px;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: opacity 0.15s ease, background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.chip:active {
  opacity: 0.55;
}

.chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.chip-toggle {
  background: transparent;
  border: 1.5px dashed var(--line);
  color: var(--muted);
  font-weight: 600;
}

.counter-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.counter-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease-out, background-color 0.15s ease;
}

.counter-btn:active {
  transform: scale(0.92);
}

.counter-value {
  font-size: 22px;
  font-weight: 800;
  min-width: 110px;
  text-align: center;
}

.counter-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { filter: brightness(0.95); }
  .btn-secondary:hover { background: var(--bg); }
  .icon-action-circle.outline:hover { background: var(--line); }
  .icon-action-circle.filled:hover { filter: brightness(1.05); }
  .chip:hover:not(.selected) { background: var(--line); }
  .counter-btn:hover { background: var(--line); }
  .tab-btn:hover:not(.active) { color: var(--text); }
  .edit-option-remove:hover { filter: brightness(1.1); }
  .logpage-arrow:hover { background: var(--line); }
  .back-btn:hover,
  .edit-link:hover { opacity: 0.75; }
}
