*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --period: #D94E63;
  --period-bg: rgba(217,78,99,0.14);
  --fertile: #E8976B;
  --fertile-color: #D4864F;
  --fertile-bg: rgba(232,151,107,0.13);
  --safe: #6BA5A0;
  --safe-bg: rgba(107,165,160,0.10);
  --text: #4A3728;
  --text-mid: #8B7E74;
  --text-light: #B5A595;
  --text-lighter: #C4B5A5;
  --card: rgba(255,255,255,0.88);
  --radius: 14px;
  --radius-lg: 24px;
}

body {
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  background: url('6-mobile.jpg') no-repeat center center fixed;
  background-size: cover;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  overflow-x: hidden;
}


.container { max-width: 420px; width: 100%; position: relative; z-index: 1; background: rgba(255,255,255,0.4); border-radius: var(--radius-lg); padding: 20px 16px; backdrop-filter: blur(12px); }

.header { text-align: center; margin-bottom: 20px; }
.header-title { display: flex; align-items: center; justify-content: center; gap: 10px; }
.header-title .icon { font-size: 28px; }
.header-title h1 { font-size: 28px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.header p { font-size: 12px; color: var(--text-light); margin-top: 4px; letter-spacing: 2.5px; text-transform: uppercase; font-weight: 500; }

.sync-status {
  text-align: center; font-size: 11px; color: var(--text-lighter);
  margin-bottom: 16px; transition: all 0.3s;
}
.sync-status:empty { margin-bottom: 0; }
.sync-status.ok { color: var(--safe); }
.sync-status.err { color: var(--period); }

.status-card {
  background: var(--card); backdrop-filter: blur(20px); border-radius: var(--radius-lg);
  padding: 16px 8px 20px; display: flex; flex-direction: column; align-items: center;
  margin-top: 20px; margin-bottom: 20px; box-shadow: 0 2px 24px rgba(74,55,40,0.05);
}
.status-date {
  font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 12px;
}
.status-date .sub { font-size: 11px; font-weight: 500; color: var(--text-light); margin-left: 6px; }
.status-cols {
  display: grid; grid-template-columns: 1fr 1fr 1fr; width: 100%;
}
.status-col {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 4px 0; position: relative;
}
.status-col:not(:last-child)::after {
  content: ''; position: absolute; right: 0; top: 15%; height: 70%;
  width: 1px; background: #E8DDD4;
}
.status-col .val { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1.2; }
.status-col .val.fertility-low { color: var(--safe); font-size: 18px; }
.status-col .val.fertility-med { color: var(--fertile-color); font-size: 18px; }
.status-col .val.fertility-high { color: var(--period); font-size: 18px; }
.status-col .lbl { font-size: 11px; color: var(--text-light); font-weight: 500; margin-top: 4px; line-height: 1.3; }

.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; padding: 0 4px; }
.month-nav button {
  width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,0.65); color: var(--text-mid); font-size: 22px; font-weight: 300;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
  box-shadow: 0 1px 6px rgba(74,55,40,0.05);
}
.month-nav button:hover { background: rgba(255,255,255,0.9); }
.month-label { text-align: center; }
.month-label .name { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.3px; display: block; }
.month-label .year { font-size: 12px; color: var(--text-light); font-weight: 500; }

.day-names, .calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 0 2px;
}
.day-names { margin-bottom: 6px; }
.day-names span {
  text-align: center; font-size: 11px; font-weight: 700; color: var(--text-lighter);
  text-transform: uppercase; letter-spacing: 0.5px; padding: 4px 0;
}
.calendar-grid { margin-bottom: 20px; overflow: visible; }

.day-cell {
  aspect-ratio: 1; border-radius: var(--radius); border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative; padding: 0; font-family: inherit; background: transparent; overflow: visible;
  font-size: 16px; color: var(--text-mid); font-weight: 500;
}
.day-cell.empty { cursor: default; }
.day-cell .indicator { font-size: 7px; margin-top: 1px; line-height: 1; letter-spacing: -1px; }
.day-cell .cycle-day {
  position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  font-size: 9px; color: var(--text-lighter); font-weight: 600; line-height: 1;
}

.day-cell.period { background: var(--period-bg); color: var(--period); font-weight: 700; }
.day-cell.period .indicator { font-size: 8px; color: var(--period); }
.day-cell.fertile { background: var(--fertile-bg); color: var(--fertile-color); font-weight: 600; }
.day-cell.fertile .indicator { color: var(--fertile-color); font-size: 5px; }
.day-cell.ovulation { background: var(--fertile-bg); color: var(--fertile-color); font-weight: 700; }
.day-cell.ovulation .indicator { color: var(--fertile-color); font-size: 9px; }
.day-cell.today { box-shadow: inset 0 0 0 2px var(--text-lighter); }
.day-cell .today-label {
  position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%);
  font-size: 7px; line-height: 1; text-transform: uppercase;
  letter-spacing: 0.1px; padding: 2px 5px; border-radius: 4px;
  color: var(--text-light); background: transparent;
  white-space: nowrap; z-index: 2;
}
.day-cell.today.selected .today-label {
  background: var(--text-light); color: #fff;
}
.day-cell.today.selected.period .today-label {
  background: var(--period); color: #fff;
}
.day-cell.today.selected.fertile .today-label,
.day-cell.today.selected.ovulation .today-label {
  background: var(--fertile); color: #fff;
}
.day-cell.today.selected.safe-day .today-label {
  background: var(--safe); color: #fff;
}
.day-cell.today:not(.selected) .today-label {
  background: var(--text-mid); color: #fff;
}
.day-cell.today.period { box-shadow: inset 0 0 0 2px var(--period); }
.day-cell.today.fertile, .day-cell.today.ovulation { box-shadow: inset 0 0 0 2px var(--fertile-color); }

.day-cell.selected { transform: scale(1.1); color: #fff !important; }
.day-cell.selected.period { background: var(--period); box-shadow: 0 4px 16px rgba(217,78,99,0.3); }
.day-cell.selected.fertile, .day-cell.selected.ovulation { background: var(--fertile); box-shadow: 0 4px 16px rgba(232,151,107,0.3); }
.day-cell.selected.safe-day { background: var(--safe); box-shadow: 0 4px 16px rgba(107,165,160,0.3); }
.day-cell.selected:not(.period):not(.fertile):not(.ovulation):not(.safe-day) { background: #D4C5B9; box-shadow: 0 4px 16px rgba(180,165,149,0.3); }

.detail-card {
  background: var(--card); backdrop-filter: blur(20px); border-radius: 16px;
  padding: 16px 20px; margin-bottom: 20px; box-shadow: 0 2px 16px rgba(74,55,40,0.04);
  border-left: 4px solid var(--text-lighter);
  animation: slideIn 0.2s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.detail-card.period-detail { border-left-color: var(--period); }
.detail-card.fertile-detail { border-left-color: var(--fertile); }
.detail-card.safe-detail { border-left-color: var(--safe); }
.detail-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.detail-date { font-size: 15px; font-weight: 700; color: var(--text); }
.detail-badge { font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 20px; }
.detail-text { font-size: 13px; color: var(--text-mid); line-height: 1.5; }

.legend {
  display: flex; gap: 16px; justify-content: center; padding: 14px 16px;
  background: rgba(255,255,255,0.45); border-radius: 16px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-label { font-size: 11px; color: var(--text-mid); font-weight: 600; }

.settings-toggle {
  display: block; margin: 0 auto 16px; padding: 10px 24px; border: none; cursor: pointer;
  background: rgba(255,255,255,0.6); border-radius: 20px; font-family: inherit;
  font-size: 13px; font-weight: 600; color: var(--text-mid); transition: all 0.2s;
  box-shadow: 0 1px 8px rgba(74,55,40,0.04);
}
.settings-toggle:hover { background: rgba(255,255,255,0.85); }

.settings-panel {
  background: var(--card); backdrop-filter: blur(20px); border-radius: var(--radius-lg);
  padding: 24px; margin-bottom: 20px; box-shadow: 0 2px 24px rgba(74,55,40,0.05);
  display: none;
}
.settings-panel.open { display: block; animation: slideIn 0.2s ease; }
.settings-panel h3 { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 16px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.setting-row label { font-size: 13px; color: var(--text-mid); font-weight: 600; }
.setting-row input {
  width: 70px; padding: 6px 10px; border: 2px solid #E8DDD4; border-radius: 10px;
  font-family: inherit; font-size: 14px; font-weight: 700; color: var(--text);
  text-align: center; outline: none; transition: border-color 0.2s;
}
.setting-row input:focus { border-color: var(--period); }

.period-list { margin-top: 16px; }
.period-list h4 { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.period-entry {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: rgba(217,78,99,0.06); border-radius: 10px; margin-bottom: 6px;
}
.period-entry span { font-size: 13px; color: var(--text-mid); font-weight: 600; }
.period-entry button {
  background: none; border: none; cursor: pointer; font-size: 16px; color: var(--period);
  padding: 2px 6px; border-radius: 6px; transition: background 0.2s;
}
.period-entry button:hover { background: rgba(217,78,99,0.1); }

.add-period { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.add-period .date-range { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.add-period .date-range span { font-size: 12px; color: var(--text-light); font-weight: 600; flex-shrink: 0; }
.add-period input {
  flex: 1; padding: 8px 10px; border: 2px solid #E8DDD4; border-radius: 10px;
  font-family: inherit; font-size: 13px; color: var(--text); outline: none; min-width: 0;
}
.add-period input:focus { border-color: var(--period); }
.add-period button {
  padding: 8px 16px; background: var(--period); color: #fff; border: none;
  border-radius: 10px; font-family: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: opacity 0.2s;
}
.add-period button:hover { opacity: 0.85; }

.export-row { display: flex; gap: 8px; margin-top: 16px; }
.export-row button {
  flex: 1; padding: 10px; border: 2px solid #E8DDD4; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,0.5); font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--text-mid); transition: all 0.2s;
}
.export-row button:hover { background: rgba(255,255,255,0.9); border-color: var(--text-lighter); }

/* Recording mode */
.record-btn {
  display: block; width: 100%; padding: 12px 24px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--period), #E86B8A); color: #fff;
  border-radius: 16px; font-family: inherit; font-size: 14px; font-weight: 700;
  margin-bottom: 16px; transition: all 0.2s;
  box-shadow: 0 2px 12px rgba(217,78,99,0.2);
}
.record-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.record-btn.done-btn {
  background: linear-gradient(135deg, var(--safe), #5AA08A);
  box-shadow: 0 2px 12px rgba(107,165,160,0.2);
}

.calendar-grid.recording {
  background: rgba(217,78,99,0.04);
  border-radius: var(--radius-lg);
  padding: 8px;
  border: 2px dashed rgba(217,78,99,0.2);
}

.recording-banner {
  text-align: center; font-size: 13px; font-weight: 600; color: var(--period);
  margin-bottom: 10px; padding: 8px; background: rgba(217,78,99,0.06);
  border-radius: 10px;
}

.day-cell .actual-check {
  position: absolute; top: 2px; right: 2px;
  font-size: 10px; line-height: 1; color: var(--period);
}

.day-cell.actual-marked {
  background: rgba(217,78,99,0.18);
  color: var(--period);
  font-weight: 700;
}

.day-cell .actual-dot {
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--period);
}

.auto-calc-info {
  font-size: 12px; color: var(--text-light); margin-bottom: 14px;
  padding: 8px 12px; background: rgba(107,165,160,0.08); border-radius: 10px;
}

@media (min-width: 768px) {
  body { background-image: url('6-desktop.jpg'); }
}
