/* ── Reset & Variables ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #E91E63;
  --brand-dark: #C2185B;
  --brand-light: #FCE4EC;
  --bg: #FFF5F8;
  --surface: #FFFFFF;
  --surface2: #FFF0F5;
  --border: #F3D5E0;
  --text: #1A1A2E;
  --text-muted: #888;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(233,30,99,.10);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { background: var(--bg); color: var(--text); min-height: 100dvh; overflow-x: hidden; font-size: 16px; line-height: 1.6; word-break: keep-all; }
main { min-width: 0; overflow: hidden; }
button { cursor: pointer; border: none; font-family: inherit; background: none; }
a { text-decoration: none; color: inherit; }
input, select, textarea { font-family: inherit; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ── Layout ────────────────────────────────────────────── */
.layout-container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
@media (max-width: 800px) {
  .layout-container { grid-template-columns: 1fr; padding: 16px 12px 40px; }
  .app-sidebar { display: none; }
}

/* ── Ad containers ─────────────────────────────────────── */
.ad-container { display: block; width: 100%; margin: 0; text-align: center; }
.top-ad { background: #f9f9f9; padding: 8px 0; border-bottom: 1px solid var(--border); }
.middle-ad { margin: 20px 0; }
.bottom-ad { margin-top: 24px; padding: 16px 0; border-top: 1px solid var(--border); }

/* ── Header ────────────────────────────────────────────── */
.main-header {
  background: linear-gradient(135deg, #E91E63 0%, #F06292 50%, #C2185B 100%);
  padding: 20px 20px 24px;
  position: relative;
  overflow: hidden;
}
.main-header::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.main-header::after {
  content: '';
  position: absolute;
  bottom: -20px; left: 10px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}
.header-logo { display: flex; align-items: center; gap: 12px; }
.header-logo-icon {
  font-size: 28px;
  background: rgba(255,255,255,.2);
  border-radius: 12px;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
}
.header-logo h1 { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.header-logo h1 a { color: #fff; }
.header-logo p { font-size: 13px; color: rgba(255,255,255,.8); margin-top: 2px; }
.btn-share {
  background: rgba(255,255,255,.2);
  border: 1.5px solid rgba(255,255,255,.4);
  color: #fff;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
}
.btn-share:hover { background: rgba(255,255,255,.3); }

/* ── Screen toggle ─────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ── Hero ──────────────────────────────────────────────── */
.hero-card {
  background: linear-gradient(135deg, #E91E63, #F48FB1);
  border-radius: var(--radius);
  padding: 28px 24px;
  color: #fff;
  text-align: center;
  margin-bottom: 24px;
}
.hero-title { font-size: 20px; font-weight: 800; margin-bottom: 8px; letter-spacing: -.5px; }
.hero-desc { font-size: 14px; opacity: .85; }

/* ── Form ──────────────────────────────────────────────── */
.form-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.form-row.single { grid-template-columns: 1fr; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface2);
  text-align: center;
}
.form-group input:focus { border-color: var(--brand); outline: none; }
.form-group input::placeholder { color: #bbb; font-weight: 400; }
@media (max-width: 520px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ── Buttons ───────────────────────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius);
  text-align: center;
  transition: background .2s;
  box-shadow: 0 4px 16px rgba(233,30,99,.3);
}
.btn-primary:hover { background: #D81B60; }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.btn-outline {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--surface);
  color: #666;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  text-align: center;
}
.btn-outline:hover { background: var(--surface2); }
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-light);
  margin-bottom: 16px;
}
.btn-back:hover { background: var(--border); }
.btn-share-result {
  display: block;
  width: 100%;
  padding: 14px;
  background: #059669;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius);
  text-align: center;
}
.btn-share-result:hover { background: #047857; }
.result-actions { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }

/* ── Result hero ──────────────────────────────────────── */
.result-hero {
  background: linear-gradient(135deg, #E91E63, #F06292);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  color: #fff;
  margin-bottom: 20px;
}
.result-emoji { font-size: 40px; margin-bottom: 6px; }
.result-date { font-size: 28px; font-weight: 900; line-height: 1.2; }
.result-label { font-size: 15px; font-weight: 600; opacity: .9; margin-top: 4px; }
.result-dday {
  display: inline-block;
  margin-top: 8px;
  background: rgba(255,255,255,.25);
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
}

/* ── Timeline ─────────────────────────────────────────── */
.timeline-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--brand-dark); margin-bottom: 14px; }
.timeline { display: flex; flex-direction: column; }
.tl-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  position: relative;
}
.tl-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 26px;
  bottom: -6px;
  width: 2px;
  background: #E5E7EB;
}
.tl-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
}
.tl-item.period .tl-dot { background: #EF4444; }
.tl-item.safe .tl-dot { background: #22C55E; }
.tl-item.fertile .tl-dot { background: #8B5CF6; }
.tl-item.ovulation .tl-dot { background: #E91E63; box-shadow: 0 0 0 3px rgba(233,30,99,.25); }
.tl-item.next .tl-dot { background: #F59E0B; }
.tl-label { font-size: 14px; font-weight: 700; color: #333; }
.tl-date { font-size: 13px; color: #888; margin-top: 2px; }

/* ── Cycle bar ────────────────────────────────────────── */
.cycle-bar-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.cycle-bar { display: flex; height: 28px; border-radius: 14px; overflow: hidden; }
.cb-seg {
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
  min-width: 4px;
}
.cb-seg span { white-space: nowrap; }
.period-seg { background: #EF4444; }
.safe-seg { background: #86EFAC; }
.fertile-seg { background: #8B5CF6; }
.cb-labels {
  display: flex; justify-content: space-between;
  padding: 6px 2px 0; font-size: 11px; color: #999;
}

/* ── Detail card ──────────────────────────────────────── */
.detail-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f3f3f3;
  font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); font-weight: 500; }
.detail-value { font-weight: 600; color: #333; }
.detail-value.highlight { color: var(--brand); font-weight: 800; }
.detail-value.fertile-text { color: #8B5CF6; font-weight: 700; }

/* ── Forecast ─────────────────────────────────────────── */
.forecast-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.forecast-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #F3F4F6;
}
.forecast-row:last-child { border-bottom: none; }
.fc-month { font-size: 16px; font-weight: 800; color: var(--brand); min-width: 36px; padding-top: 2px; }
.fc-info { display: flex; flex-direction: column; gap: 4px; }
.fc-line { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #555; }
.fc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.period-dot { background: #EF4444; }
.ov-dot { background: #E91E63; }
.fertile-dot { background: #8B5CF6; }

/* ── Notice ───────────────────────────────────────────── */
.notice-card {
  background: #FFF7ED;
  border: 1.5px solid #FED7AA;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.notice-title { font-size: 14px; font-weight: 700; color: #C2410C; margin-bottom: 8px; }
.notice-text { font-size: 13px; color: #9A3412; line-height: 1.7; }

/* ── Guide cards ──────────────────────────────────────── */
.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.guide-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.guide-card h3 { font-size: 15px; font-weight: 700; color: var(--brand-dark); margin-bottom: 10px; }
.guide-card p { font-size: 13px; color: #666; line-height: 1.7; }
@media (max-width: 520px) {
  .guide-grid { grid-template-columns: 1fr; }
}

/* Legend */
.legend-list { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #444; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Footer ────────────────────────────────────────────── */
.main-footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.footer-sub { margin-top: 4px; opacity: .7; font-size: 11px; }

/* ── Toast ─────────────────────────────────────────────── */
.share-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #333;
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  z-index: 9999;
  pointer-events: none;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Sidebar ───────────────────────────────────────────── */
.app-sidebar {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  scrollbar-width: none;
}
.app-sidebar::-webkit-scrollbar { display: none; }
.sidebar-card { background: var(--surface); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.sidebar-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; padding-left: 8px; border-left: 3px solid var(--brand); color: var(--text); }
.sidebar-list { list-style: none; padding: 0; margin: 0; }
.sidebar-list li { margin-bottom: 6px; }
.sidebar-list a { display: flex; align-items: flex-start; text-decoration: none; color: var(--text); padding: 7px 8px; border-radius: 8px; transition: background .15s; }
.sidebar-list a:hover { background: var(--brand-light); }
.link-icon { margin-right: 8px; font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.link-content { min-width: 0; overflow: hidden; flex: 1; }
.link-title { display: block; font-size: 13px; font-weight: 600; color: var(--brand); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-desc { display: block; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
