/* ════════════════════════════════════════
   KMS Period Tracker — Cute Pink Design
   ════════════════════════════════════════ */

:root {
  --pink-50: #fff0f6;
  --pink-100: #ffe4f0;
  --pink-200: #ffb3d4;
  --pink-300: #ff80b8;
  --pink-400: #ff4d9c;
  --pink-500: #e8287a;
  --pink-600: #c41f63;
  --rose-400: #fb7185;
  --rose-500: #f43f5e;
  --purple-300: #d8b4fe;
  --purple-400: #c084fc;
  --purple-500: #a855f7;
  --lavender: #f3e8ff;

  --bg: #fffafc;
  --card-bg: #ffffff;
  --border: #ffd6e7;
  --text: #4a1942;
  --text-muted: #9d4b8a;
  --shadow: 0 4px 20px rgba(232, 40, 122, 0.12);
  --shadow-lg: 0 8px 40px rgba(232, 40, 122, 0.18);
  --radius: 18px;
  --radius-sm: 10px;
  --font: "Nunito", sans-serif;
  --grad: linear-gradient(135deg, #ff80b8 0%, #e8287a 50%, #a855f7 100%);
  --grad-soft: linear-gradient(135deg, #ffe4f0 0%, #f3e8ff 100%);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
  position: relative;
}

.hidden {
  display: none !important;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--pink-50);
}
::-webkit-scrollbar-thumb {
  background: var(--pink-300);
  border-radius: 8px;
}
@media (max-width: 600px) {
  ::-webkit-scrollbar {
    display: none;
  }
  * {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
}

/* ══════════ AUTH ══════════ */
.auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grad);
  z-index: 1000;
  overflow: hidden;
}

.auth-bubbles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.bubble {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  animation: floatBubble 8s ease-in-out infinite;
}
.b1 {
  width: 200px;
  height: 200px;
  top: -60px;
  left: -60px;
  animation-duration: 7s;
}
.b2 {
  width: 120px;
  height: 120px;
  top: 20%;
  right: -30px;
  animation-duration: 9s;
  animation-delay: 1s;
}
.b3 {
  width: 160px;
  height: 160px;
  bottom: -50px;
  left: 30%;
  animation-duration: 6s;
  animation-delay: 2s;
}
.b4 {
  width: 80px;
  height: 80px;
  bottom: 20%;
  right: 10%;
  animation-duration: 11s;
  animation-delay: 0.5s;
}
.b5 {
  width: 300px;
  height: 300px;
  bottom: -100px;
  right: -100px;
  opacity: 0.08;
  animation-duration: 13s;
}

@keyframes floatBubble {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  33% {
    transform: translateY(-30px) rotate(5deg);
  }
  66% {
    transform: translateY(20px) rotate(-5deg);
  }
}

.auth-card {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 28px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  display: none;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 10;
  animation: slideUp 0.4s ease;
  max-height: 90vh;
  overflow-y: auto;
}
.auth-card.active {
  display: flex;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.auth-logo {
  font-size: 3rem;
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

.auth-title {
  font-size: 1.6rem;
  font-weight: 900;
  text-align: center;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: -8px;
}

.auth-error {
  color: #c41f63;
  font-size: 0.85rem;
  min-height: 18px;
  text-align: center;
  font-weight: 600;
}

/* Field-level hint and error */
.field-hint {
  font-size: 0.76rem;
  color: #b07aa1;
  line-height: 1.5;
  margin-top: 3px;
}
.field-hint code {
  background: #fce7f3;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--pink-600);
}
.field-error {
  font-size: 0.78rem;
  color: #be123c;
  font-weight: 700;
  margin-top: 3px;
  min-height: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.field-error:empty {
  display: none;
}
input.input-invalid {
  border-color: #fda4af !important;
  background: #fff1f2 !important;
}
input.input-valid {
  border-color: #6ee7b7 !important;
  background: #f0fdf4 !important;
}

.auth-switch {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.auth-switch a {
  color: var(--pink-500);
  font-weight: 700;
  text-decoration: none;
}
.auth-switch a:hover {
  text-decoration: underline;
}

.lang-toggle-auth {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}

/* ══════════ FORM ELEMENTS ══════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}
.form-group input,
.form-group textarea,
.form-group select {
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--pink-50);
  transition: all 0.2s;
  outline: none;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box !important;
  appearance: none;
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--pink-400);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 77, 156, 0.1);
}
.form-group textarea {
  resize: vertical;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ══════════ BUTTONS ══════════ */
.btn-primary {
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 13px 28px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(232, 40, 122, 0.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(232, 40, 122, 0.45);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-primary.full-width {
  width: 100%;
}

.btn-secondary {
  background: var(--pink-100);
  color: var(--pink-500);
  border: 2px solid var(--pink-200);
  border-radius: 50px;
  padding: 11px 24px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover {
  background: var(--pink-200);
}

.btn-add {
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 8px 18px;
  font-size: 0.88rem;
  font-family: var(--font);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-add:hover {
  transform: scale(1.05);
}

.lang-btn {
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}
.lang-btn.active,
.lang-btn:hover {
  background: #fff;
  color: var(--pink-500);
}

/* ══════════ APP LAYOUT ══════════ */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  overflow-x: hidden;
}

.topbar {
  background: var(--grad);
  padding: 0 15px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 3px 20px rgba(232, 40, 122, 0.3);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}
@media (max-width: 400px) {
  .app-name {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }
  .topbar {
    padding: 0 10px;
  }
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-logo {
  font-size: 1.5rem;
  animation: rotateFlower 4s linear infinite;
}
@keyframes rotateFlower {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(15deg);
  }
}
.app-name {
  color: #fff;
  font-weight: 900;
  font-size: 1.1rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-btn-app {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}
.lang-btn-app.active,
.lang-btn-app:hover {
  background: #fff;
  color: var(--pink-500);
}

.user-avatar-wrap {
  position: relative;
  cursor: pointer;
}
.user-avatar {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s;
}
.user-avatar:hover {
  background: rgba(255, 255, 255, 0.4);
}

.user-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  min-width: 160px;
  display: none;
  flex-direction: column;
  border: 2px solid var(--border);
}
.user-menu.open {
  display: flex;
}
.user-menu-name {
  font-weight: 800;
  color: var(--pink-500);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  font-size: 0.9rem;
}
.user-menu a {
  display: block;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s;
}
.user-menu a:hover {
  background: var(--pink-50);
}

/* ── NAV ── */
.app-nav {
  display: flex;
  gap: 4px;
  background: #fff;
  padding: 8px;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 62px;
  z-index: 90;
}
@media (max-width: 600px) {
  .app-nav {
    display: none;
  }
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 6px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.nav-tab:hover {
  background: var(--pink-50);
  color: var(--pink-500);
}
.nav-tab.active {
  background: var(--grad-soft);
  color: var(--pink-600);
}
.nav-icon {
  font-size: 1.2rem;
}

/* ── BOTTOM NAV (mobile) ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 2px solid var(--border);
  /* 增加底部安全間距，fallback 為 25px，新設備使用 env */
  padding: 10px 8px calc(25px + env(safe-area-inset-bottom));
  z-index: 200;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  width: 100%;
}
@media (max-width: 600px) {
  .bottom-nav {
    display: flex;
  }
}

.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  padding: 6px 4px;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.2s;
}
.bottom-nav button span:first-child {
  font-size: 1.4rem;
}
.bottom-nav button.active {
  color: var(--pink-500);
  background: var(--pink-50);
}

/* ── MAIN ── */
.app-main {
  flex: 1;
  padding: 16px 16px calc(110px + env(safe-area-inset-bottom));
  width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}
@media (min-width: 601px) {
  .app-main {
    padding-bottom: 24px;
  }
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* ══════════ HOME ══════════ */
.home-hero {
  margin-bottom: 20px;
}

.hero-greeting {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 14px;
}

.hero-cycle-card {
  background: var(--grad);
  border-radius: 24px;
  padding: 24px 22px;
  color: #fff;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.hero-cycle-card::before {
  content: "🌸";
  position: absolute;
  right: -10px;
  top: -10px;
  font-size: 100px;
  opacity: 0.12;
}

.cycle-pill-wrap {
  margin-bottom: 12px;
}
.cycle-status-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50px;
  padding: 5px 18px;
  font-size: 0.88rem;
  font-weight: 800;
}

.hero-next {
  margin-bottom: 16px;
}
.hero-label {
  font-size: 0.82rem;
  opacity: 0.8;
  font-weight: 600;
}
.hero-date {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.5px;
}
.hero-days {
  font-size: 0.92rem;
  opacity: 0.85;
  font-weight: 600;
  margin-top: 2px;
}

.cycle-progress-wrap {
  margin-top: 12px;
}
.cycle-progress-bar {
  height: 10px;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.25);
  position: relative;
  overflow: hidden;
  margin-bottom: 8px;
}
.cycle-progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--progress, 0%);
  background: #fff;
  border-radius: 50px;
  transition: width 1s ease;
}
.cycle-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  opacity: 0.8;
  font-weight: 600;
}

/* STATS */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
  width: 100%;
}
@media (max-width: 400px) {
  .quick-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 320px) {
  .quick-stats {
    grid-template-columns: 1fr;
  }
}
.stat-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
  transition: all 0.2s;
}
.stat-card:hover {
  border-color: var(--pink-300);
  transform: translateY(-2px);
}
.stat-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--pink-500);
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* WARNINGS */
.warnings-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.warning-card {
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  border-left: 5px solid;
  background: #fff;
  box-shadow: var(--shadow);
}
.warning-card.warn-early {
  border-color: #f59e0b;
  background: #fffbeb;
}
.warning-card.warn-late {
  border-color: #f43f5e;
  background: #fff1f2;
}
.warning-card.warn-irreg {
  border-color: #a855f7;
  background: var(--lavender);
}
.warning-title {
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.warning-body {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.warning-tips {
  margin-top: 10px;
}
.warning-tips h4 {
  font-size: 0.88rem;
  font-weight: 800;
  margin-bottom: 6px;
}
.warning-tips ul {
  list-style: none;
}
.warning-tips ul li::before {
  content: "🌿 ";
}
.warning-tips ul li {
  font-size: 0.83rem;
  color: var(--text-muted);
  padding: 2px 0;
  line-height: 1.5;
}

/* QUICK LOG */
.quick-log-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 20px;
}
.quick-log-card h3 {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 12px;
}
.mood-quick-row,
.grid-options-6 {
  display: grid;
  /* 強制維持 6 欄並允許縮小到 0 */
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.grid-options-5 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

@media (max-width: 500px) {
  .mood-quick-row,
  .grid-options-6 {
    /* 保持 6 欄，但大幅縮小間距和字體避免溢出 */
    gap: 4px;
  }
  .grid-options-5 {
    gap: 4px;
  }
  .mood-quick-btn,
  .grid-option-btn {
    padding: 8px 2px;
    min-height: 60px;
  }
  .mood-quick-btn .m-label,
  .grid-option-btn .opt-label {
    font-size: 0.6rem;
    /* 允許文字換行避免撐寬按鈕 */
    white-space: normal;
    word-break: break-word;
    line-height: 1;
  }
  .mood-quick-btn .m-emoji,
  .grid-option-btn .opt-emoji {
    font-size: 1.2rem;
  }
}

.mood-quick-btn,
.grid-option-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--pink-50);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 70px;
}

.mood-quick-btn .m-emoji,
.grid-option-btn .opt-emoji {
  font-size: 1.5rem;
}
.mood-quick-btn .m-label,
.grid-option-btn .opt-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.mood-quick-btn.active,
.mood-quick-btn.selected,
.grid-option-btn.active {
  border-color: var(--pink-400);
  background: var(--pink-100);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(255, 105, 180, 0.15);
}

@media (hover: hover) {
  .mood-quick-btn:hover,
  .grid-option-btn:hover {
    border-color: var(--pink-400);
    background: var(--pink-100);
    transform: translateY(-2px);
  }
}

.mood-quick-btn.active .m-label,
.mood-quick-btn.selected .m-label,
.grid-option-btn.active .opt-label {
  color: var(--pink-600);
}
.mt-8 {
  margin-top: 8px;
}

/* SECTION CARDS */
.section-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 20px;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-card h3 {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 14px;
}

/* RECORDS LIST */
.records-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.record-item {
  background: var(--pink-50);
  border: 2px solid var(--pink-100);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.record-item:hover {
  border-color: var(--pink-300);
  background: var(--pink-100);
}
.record-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--grad);
  flex-shrink: 0;
}
.record-info {
  flex: 1;
  min-width: 0; /* 防止溢出 */
  overflow: hidden;
}
.record-date {
  font-weight: 800;
  font-size: 0.95rem;
}
.record-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.record-actions {
  display: flex;
  gap: 6px;
}
.btn-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  border-color: var(--pink-400);
  background: var(--pink-50);
}
.btn-icon.delete:hover {
  border-color: var(--rose-500);
  background: #fff1f2;
}
.empty-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 10px;
}

/* ══════════ CALENDAR ══════════ */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
}
.cal-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.cal-nav-btn:hover {
  background: var(--pink-100);
  border-color: var(--pink-300);
}
.cal-month-label {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}

.calendar-legend {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.period-dot {
  background: var(--pink-500);
}
.predicted-dot {
  background: var(--pink-200);
  border: 2px dashed var(--pink-400);
}
.safe-dot {
  background: #fef08a; /* Soft yellow */
}
.fertile-dot {
  background: #86efac;
}
.ovulation-dot {
  background: #60a5fa;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day-header {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  padding: 6px 0;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  position: relative;
  border: 2px solid transparent;
}
.cal-day:hover {
  background: var(--pink-100);
  border-color: var(--pink-200);
}
.cal-day.other-month {
  color: #d1b0c8;
}
.cal-day.today {
  border-color: var(--pink-400);
  color: var(--pink-500);
  font-weight: 900;
}
.cal-day.period {
  background: var(--pink-500);
  color: #fff;
}
.cal-day.predicted {
  background: var(--pink-100);
  border-color: var(--pink-300);
  border-style: dashed;
  color: var(--pink-600);
}
.cal-day.safe {
  background: #fef9c3;
  border-color: #fef08a;
}
.cal-day.fertile {
  background: #dcfce7;
  border-color: #86efac;
}
.cal-day.ovulation {
  background: #dbeafe;
  border-color: #93c5fd;
}
.cal-day.has-log::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--pink-400);
}

.calendar-day-detail {
  margin-top: 12px;
  padding: 16px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 60px;
  font-size: 0.88rem;
  color: var(--text-muted);
  width: 100%;
  box-sizing: border-box;
}

/* ══════════ LOG FORM ══════════ */
.log-form-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
}
.log-form-card h2 {
  font-size: 1.3rem;
  font-weight: 900;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 20px;
}

.flow-selector {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}
.flow-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 3px 2px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--pink-50);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 34px;
}
.flow-btn:hover {
  border-color: var(--pink-300);
  background: var(--pink-100);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(255, 105, 180, 0.1);
}
.flow-btn.active {
  border-color: var(--pink-500);
  background: var(--pink-100);
  color: var(--pink-600);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(255, 105, 180, 0.15);
}
.flow-btn span:first-child {
  font-size: 1.1rem;
  line-height: 1;
}
.flow-btn span:last-child {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
}
.flow-btn.active span:last-child {
  color: var(--pink-600);
}

.mood-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.mood-btn {
  padding: 10px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--pink-50);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}
.mood-btn:hover {
  border-color: var(--pink-300);
}
.mood-btn.active {
  border-color: var(--pink-500);
  background: var(--pink-100);
  color: var(--pink-600);
}

.pain-scale {
  display: flex;
  justify-content: space-between;
  padding: 0 11px; /* Center of thumb at 0 and 10 */
  margin-bottom: 6px;
}
.pain-scale span {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  width: 0;
  display: flex;
  justify-content: center;
  white-space: nowrap;
}

.pain-slider {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
  border: none !important; /* Override .form-group input border */
  padding: 0 !important; /* Override .form-group input padding */
  margin: 0;
  cursor: pointer;
  height: 24px;
}

/* Track Styles */
.pain-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 8px;
  background: var(--grad-soft);
  border: 2px solid var(--border);
  border-radius: 50px;
}
.pain-slider::-moz-range-track {
  width: 100%;
  height: 8px;
  background: var(--grad-soft);
  border: 2px solid var(--border);
  border-radius: 50px;
}

/* Thumb Styles */
.pain-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 22px;
  width: 22px;
  border-radius: 50%;
  background: var(--grad);
  margin-top: -9px; /* Centers thumb on 8px track: (8/2) - (22/2) = -7, +2 for border compensation? Try -9 */
  box-shadow: 0 2px 8px rgba(232, 40, 122, 0.4);
  border: 2px solid #fff;
}
.pain-slider::-moz-range-thumb {
  height: 18px; /* Firefox handles border-box differently */
  width: 18px;
  border-radius: 50%;
  background: var(--grad);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(232, 40, 122, 0.4);
}
.pain-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 4px;
}

.symptoms-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 440px) {
  .symptoms-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.symptom-btn {
  padding: 9px 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--pink-50);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  gap: 4px;
  align-items: center;
}
.symptom-btn:hover {
  border-color: var(--pink-300);
}
.symptom-btn.active {
  border-color: var(--purple-400);
  background: var(--lavender);
  color: var(--purple-500);
}

.log-form-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}
.form-msg {
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  min-height: 20px;
  margin-top: 8px;
}
.form-msg.success {
  color: var(--pink-500);
}
.form-msg.error {
  color: var(--rose-500);
}

/* ══════════ ANALYTICS ══════════ */
.analytics-header h2 {
  font-size: 1.3rem;
  font-weight: 900;
  margin-bottom: 16px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 500px) {
  .analytics-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.analytics-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 10px;
  text-align: center;
  transition: all 0.2s;
}
.analytics-card:hover {
  border-color: var(--pink-300);
  transform: translateY(-2px);
}
.a-icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
}
.a-val {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--pink-500);
  margin-bottom: 4px;
}
.a-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

.chart-container,
.chart-wrap {
  padding: 10px 0;
  width: 100%;
  overflow-x: hidden;
}
canvas {
  max-width: 100%;
}

.tips-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tip-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--pink-50);
  border: 2px solid var(--pink-100);
  border-radius: var(--radius-sm);
}
.tip-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}
.tip-text {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
}
.tip-text strong {
  color: var(--pink-600);
}

/* ══════════ PROFILE ══════════ */
.profile-card {
  background: var(--grad);
  border-radius: 24px;
  padding: 30px 20px;
  text-align: center;
  color: #fff;
  margin-bottom: 20px;
  box-shadow: var(--shadow-lg);
}
.profile-avatar {
  font-size: 4rem;
  margin-bottom: 10px;
}
.profile-name {
  font-size: 1.5rem;
  font-weight: 900;
}
.profile-email {
  font-size: 0.88rem;
  opacity: 0.8;
  margin-top: 4px;
}

/* ══════════ MODAL ══════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 25, 66, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--border);
  animation: slideUp 0.3s ease;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.modal-box::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.modal-close:hover {
  background: var(--pink-100);
  border-color: var(--pink-400);
}

/* ══════════ TOAST ══════════ */
.toast {
  position: fixed;
  bottom: calc(95px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--grad);
  color: #fff;
  padding: 12px 24px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s,
    bottom 0.3s;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
}
@media (min-width: 601px) {
  .toast {
    bottom: 30px;
  }
}

@media (max-width: 480px) {
  .form-row {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 12px !important;
  }
  .form-group {
    margin-bottom: 0px;
    width: 100% !important;
    padding: 0 !important;
  }
  .form-group input {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
  }
  .log-form-card, .section-card {
    padding: 20px 15px !important;
    overflow: hidden;
  }
  .auth-card {
    padding: 28px 20px;
  }
}
/* ── Cancel Button Helper ── */
.btn-cancel {
  display: none !important;
}
.modal-box .btn-cancel {
  display: inline-block !important;
}
.btn-cancel:hover {
  border-color: var(--rose-400) !important;
  color: var(--rose-500) !important;
  background: #fff1f2 !important;
}
/* ── Admin Table ── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
  font-size: 0.85rem;
}
.admin-table th,
.admin-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  background: var(--pink-50);
  color: var(--pink-700);
  font-weight: 800;
}
.admin-table tr:hover {
  background: var(--pink-50);
}
.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}
.admin-controls {
  margin-bottom: 10px;
}

/* ── Centered Buttons ── */
.btn-center-moved {
  display: block;
  margin: 15px auto 0 !important;
  min-width: 200px;
}
.btn-danger {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.2);
  transition: all 0.2s;
}
.btn-danger:active {
  transform: scale(0.98);
}

/* ── Custom Modals ── */
.custom-modal-title {
  font-family: "Pacifico", cursive;
  color: var(--pink-500);
  margin-bottom: 20px;
  text-align: center;
}
.modal-form-group {
  margin-bottom: 20px;
}
.modal-form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--text);
}
.success-anim-wrap {
  text-align: center;
  margin-bottom: 20px;
}
.success-icon-large {
  font-size: 4rem;
  animation: popScale 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popScale {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Chat Modal ── */
.floating-chat {
  position: fixed;
  bottom: calc(95px + env(safe-area-inset-bottom));
  right: 20px;
  width: 60px;
  height: 60px;
  background: var(--grad);
  color: white;
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  cursor: pointer;
  z-index: 900;
  transition: transform 0.2s;
}
@media (min-width: 600px) {
  .floating-chat {
    bottom: 30px;
  }
}
.floating-chat:active {
  transform: scale(0.9);
}
.floating-chat .unread-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: red;
  color: white;
  font-size: 0.7rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.chat-box {
  display: flex;
  flex-direction: column;
  padding: 0;
  height: 80vh;
  max-width: 500px;
}
.chat-header {
  padding: 15px 20px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--pink-50);
  border-radius: var(--radius) var(--radius) 0 0;
}
.chat-header h3 {
  margin: 0;
  color: var(--pink-500);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafafa;
}
.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 15px;
  font-size: 0.9rem;
  line-height: 1.4;
  position: relative;
}
.msg-mine {
  align-self: flex-end;
  background: var(--pink-500);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg-theirs {
  align-self: flex-start;
  background: var(--pink-400); /* Deeper pink */
  border: none;
  color: white;
  border-bottom-left-radius: 4px;
}
.msg-theirs.is-admin {
  background: var(--pink-500); /* Even deeper for admin */
  color: white;
}
.msg-sender-name {
  font-size: 18px !important;
  font-weight: 700;
  margin-bottom: 4px;
  display: block;
}
.msg-emoji-only {
  background: transparent !important;
  border: none !important;
  font-size: 3rem !important;
  padding: 0 !important;
}
.chat-emoji-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 15px;
  background: white;
  border-top: 1px solid var(--border);
}
.emoji-btn {
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.1s;
}
.emoji-btn:active {
  transform: scale(1.3);
}

/* Chat Sidebar/Inbox for Admins */
.chat-inbox {
  display: flex;
  flex-direction: column;
  padding: 10px;
  max-height: 400px;
  overflow-y: auto;
}
.chat-user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  margin-bottom: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.chat-user-item:hover {
  background: var(--pink-50);
  border-color: var(--pink-200);
}
.chat-user-item.has-unread {
  border-left: 4px solid var(--pink-500);
  background: #fffafa;
}
.user-info-brief {
  display: flex;
  flex-direction: column;
}
.user-name-brief {
  font-weight: bold;
  font-size: 1rem;
}
.user-status-brief {
  font-size: 0.75rem;
  color: #888;
}
.user-unread-pill {
  background: var(--pink-500);
  color: white;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: bold;
}
.chat-back-btn {
  font-size: 0.8rem;
  color: var(--pink-500);
  cursor: pointer;
  margin-right: 10px;
  display: none;
}
.is-in-chat .chat-back-btn {
  display: inline-block;
}
.chat-input-area {
  padding: 15px;
  display: flex;
  gap: 10px;
  border-top: 2px solid var(--border);
  background: white;
  border-radius: 0 0 var(--radius) var(--radius);
}
.chat-input-area input {
  flex: 1;
  padding: 10px 15px;
  border-radius: 20px;
  border: 2px solid var(--border);
  outline: none;
}
.chat-input-area input:focus {
  border-color: var(--pink-300);
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
}
.status-online {
  background-color: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}
.status-offline {
  background-color: #ef4444;
}

/* ── Quick Log Styles ── */
.quick-log-section {
  text-align: left;
}
.quick-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  padding-left: 10px;
}
.mt-12 {
  margin-top: 12px;
}
.mt-8 {
  margin-top: 8px;
}

.symptom-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 10px;
}
.symptom-tag-btn {
  padding: 6px 12px;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: white;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.symptom-tag-btn.active {
  background: var(--pink-100);
  border-color: var(--pink-400);
  color: var(--pink-600);
}
.quick-log-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 15px;
  padding: 0 10px;
}
.custom-range {
  width: 100%;
  accent-color: var(--pink-500);
  cursor: pointer;
}
