/* Zyklus-Kalender — eigenes Design: Sanft Rosé + Creme, diskret/privat */

:root {
  --rose: #e11d72;
  --rose-soft: #f48fb6;
  --rose-deep: #b01259;
  --cream: #fff7f1;
  --cream-2: #fdeee4;

  --bg: var(--cream);
  --bg-elev: #ffffff;
  --bg-soft: #fff1f6;
  --text: #3a2630;
  --text-soft: #6e5560;
  --muted: #9a8088;
  --border: #f0d9e2;
  --border-strong: #e6c3d2;

  --accent: var(--rose);
  --accent-contrast: #ffffff;

  --period: #e11d72;
  --period-bg: #fde2ec;
  --pred: #c98aa6;
  --pred-bg: #f6e6ee;
  --fertile: #2e8f7e;
  --fertile-bg: #dff3ee;
  --ovu: #1f7a6c;

  --danger: #c0392b;
  --danger-bg: #fdecea;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 6px 20px rgba(176, 18, 89, 0.08);
  --shadow-soft: 0 2px 8px rgba(176, 18, 89, 0.06);

  --maxw: 760px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #1a1218;
  --bg-elev: #251a21;
  --bg-soft: #2e1f28;
  --text: #f6e9ef;
  --text-soft: #d8bac8;
  --muted: #a98ba0;
  --border: #3a2a34;
  --border-strong: #4a3540;

  --accent: #f06aa0;
  --accent-contrast: #2a0d1c;

  --period: #f06aa0;
  --period-bg: #4a1f33;
  --pred: #b07d96;
  --pred-bg: #3a2531;
  --fertile: #5fd6bf;
  --fertile-bg: #18342f;
  --ovu: #7ce0cd;

  --danger: #ff7a6e;
  --danger-bg: #3a1c19;

  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* App bar */
.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  box-shadow: var(--shadow-soft);
}
.appbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  flex-shrink: 0;
}
.brand-name {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.28); }
.icon-btn:active { transform: scale(0.94); }

/* Theme toggle icon swap */
.ico-moon { display: none; }
[data-theme="dark"] .ico-sun { display: none; }
[data-theme="dark"] .ico-moon { display: inline; }

/* Calendar nav icon buttons use surface style */
.cal-nav .icon-btn {
  background: var(--bg-soft);
  color: var(--accent);
  border: 1px solid var(--border);
}
.cal-nav .icon-btn:hover { background: var(--bg-2, var(--cream-2)); }

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 14px calc(env(safe-area-inset-bottom) + 32px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.privacy-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-soft);
}
.privacy-banner svg { color: var(--accent); flex-shrink: 0; margin-top: 1px; }
.privacy-banner strong { color: var(--text); }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.card-title {
  margin: 0 0 12px;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text);
}

/* Summary stats */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.stat-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-weight: 600;
}
.stat-value {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--accent);
  word-break: break-word;
}
.summary-hint {
  margin: 12px 0 0;
  font-size: 0.86rem;
  color: var(--text-soft);
}

/* Forms */
.entry-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field-wide { grid-column: 1 / -1; }
.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-soft);
}

input[type="date"],
input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(225, 29, 114, 0.18);
}
/* fix date input color in dark mode */
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover { background: var(--rose-deep); }
[data-theme="dark"] .btn-primary:hover { background: #ff7eae; }
.btn-secondary {
  background: var(--bg-soft);
  color: var(--accent);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--cream-2); }
[data-theme="dark"] .btn-secondary:hover { background: var(--bg); }
.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--bg-soft); }
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

/* Settings switch */
.setting-row { margin-bottom: 12px; }
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.2s ease;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px rgba(225, 29, 114, 0.3);
}
.switch-label { font-size: 0.9rem; font-weight: 600; color: var(--text); }

.field-inline {
  flex-direction: row;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
.field-inline label {
  width: 100%;
}
.field-inline input[type="number"] {
  flex: 1 1 120px;
  min-width: 100px;
}
.field-inline .btn { flex-shrink: 0; }

/* Calendar */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.cal-head .card-title { margin: 0; }
.cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.month-label {
  min-width: 150px;
  text-align: center;
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  cursor: pointer;
  font-family: inherit;
}
.month-label:hover { background: var(--cream-2); }
[data-theme="dark"] .month-label:hover { background: var(--bg); }

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.weekdays span {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1.5px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: transform 0.1s ease, border-color 0.12s ease;
  min-width: 0;
}
.cell.is-empty {
  background: transparent;
  cursor: default;
  border-color: transparent;
}
.cell:not(.is-empty):hover { border-color: var(--accent); }
.cell:not(.is-empty):active { transform: scale(0.95); }
.cell.is-today {
  border-color: var(--accent);
  border-width: 2px;
}
.cell .num { line-height: 1; }

.cell.is-period {
  background: var(--period-bg);
  color: var(--period);
}
.cell.is-pred {
  background: var(--pred-bg);
  color: var(--pred);
}
.cell.is-fertile {
  background: var(--fertile-bg);
  color: var(--fertile);
}
.cell.is-ovu {
  background: var(--fertile-bg);
  color: var(--ovu);
  box-shadow: inset 0 0 0 2px var(--ovu);
}
/* period overrides predicted/fertile visual priority via class order in JS */

.cell-mark {
  position: absolute;
  bottom: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.cell.is-period .cell-mark { background: var(--period); }
.cell.is-pred .cell-mark { background: var(--pred); }
.cell.is-fertile .cell-mark { background: var(--fertile); }

.legend {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 0.78rem;
  color: var(--text-soft);
}
.legend li { display: flex; align-items: center; gap: 6px; }
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-period { background: var(--period); }
.dot-pred { background: var(--pred); }
.dot-fertile { background: var(--fertile); }
.dot-ovu { background: var(--ovu); box-shadow: inset 0 0 0 2px var(--fertile-bg); }

/* Entry list */
.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.entry-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  flex-wrap: wrap;
}
.entry-main { flex: 1 1 180px; min-width: 0; }
.entry-date { font-weight: 700; color: var(--text); }
.entry-meta {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.entry-flow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--period-bg);
  color: var(--period);
}
.entry-note { word-break: break-word; }
.entry-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.mini-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-soft);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.mini-btn.edit:hover { border-color: var(--accent); color: var(--accent); }
.mini-btn.del:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.disclaimer {
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
  margin: 4px 0 0;
  line-height: 1.5;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 20, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fade 0.18s ease;
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow);
  animation: pop 0.18s ease;
}
.modal-title { margin: 0 0 8px; font-size: 1.1rem; color: var(--text); }
.modal-body { margin: 0 0 18px; color: var(--text-soft); font-size: 0.92rem; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translateX(-50%) translateY(10px);
  background: var(--text);
  color: var(--bg-elev);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 60;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }

/* Focus visibility */
:focus-visible {
  outline: 3px solid rgba(225, 29, 114, 0.45);
  outline-offset: 2px;
}

/* Mobile */
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .entry-form { grid-template-columns: 1fr; }
  .month-label { min-width: 120px; }
  .brand-name { font-size: 1rem; }
  .entry-actions { width: 100%; }
  .entry-actions .mini-btn { flex: 1; }
}

@media (max-width: 360px) {
  .stats { grid-template-columns: 1fr; }
}

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