:root {
  color-scheme: light;
  --color-ink: #1f2937;
  --color-muted: #596579;
  --color-surface: #ffffff;
  --color-page: #f9fafb;
  --color-border: #e5e7eb;
  --color-header: #111827;
  --color-accent: #4f46e5;
  --color-accent-hover: #4338ca;
  --color-error: #b42318;
  --space-card: 1.25rem;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--color-ink);
  background: var(--color-page);
  line-height: 1.6;
}
button, select, input, textarea { font: inherit; }
a { color: var(--color-accent); }
a:hover { color: var(--color-accent-hover); }
a:focus-visible, button:focus-visible, select:focus-visible,
input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid #818cf8;
  outline-offset: 3px;
}
button { color: inherit; }
.container { width: min(100% - 2rem, 900px); margin-inline: auto; }
.hidden, [hidden] { display: none; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header { color: #fff; background: var(--color-header); padding: 14px 0; }
.site-header .container { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.logo { color: #fff; font-weight: 700; font-size: 1.2rem; text-decoration: none; }
.site-header nav { display: flex; gap: 18px; }
.site-header nav a { color: #e5e7eb; text-decoration: none; }
.site-header nav a:hover { color: #fff; }

.site-footer {
  margin-top: 60px;
  padding: 24px 0;
  color: #d1d5db;
  background: var(--color-header);
  text-align: center;
  font-size: .9rem;
}
.site-footer p { margin: 0; }

.hero { padding: 50px 0 30px; text-align: center; }
.hero[id] { scroll-margin-top: 1rem; }
.hero h1 { margin: 0 0 8px; font-size: clamp(1.8rem, 7vw, 2.2rem); line-height: 1.2; }
.subtitle { max-width: 620px; margin: 0 auto 30px; color: var(--color-muted); }
.mode-toggle {
  display: inline-flex;
  max-width: 100%;
  margin-bottom: 24px;
  padding: 4px;
  border-radius: 999px;
  background: var(--color-border);
}
.mode-btn {
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #374151;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .2s, color .2s;
}
.mode-btn.active, .mode-btn[aria-selected="true"] { color: #fff; background: var(--color-accent); }
.panel { display: none; }
.panel.active:not([hidden]) { display: block; }
.time-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.time-fieldset legend { width: 100%; }
.time-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0;
  font-size: 1.4rem;
}
.time-picker select {
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-ink);
  cursor: pointer;
}
.colon { font-weight: 700; }
.calc-btn {
  display: inline-block;
  min-height: 48px;
  margin: 16px auto 0;
  padding: 12px 32px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--color-accent);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .2s;
}
.calc-btn:hover { color: #fff; background: var(--color-accent-hover); }
.secondary-btn { color: var(--color-accent); border: 2px solid var(--color-accent); background: transparent; }
.secondary-btn:hover { color: #fff; }
.now-note, .results-note, .results-footer { color: var(--color-muted); }
.calculator-error, .form-error { color: var(--color-error); }
.calculator-error { margin: 1rem 0 0; font-weight: 600; }

.calculator-settings {
  max-width: 680px;
  margin: 28px auto 0;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  text-align: left;
}
.calculator-settings summary { cursor: pointer; font-weight: 700; }
.calculator-settings > p { color: var(--color-muted); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
.settings-grid label { display: grid; gap: 6px; font-weight: 600; }
.settings-grid input {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-ink);
  background: var(--color-surface);
}
.field-help { margin: 0 0 10px; color: var(--color-muted); font-size: .85rem; }
.text-btn {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--color-accent);
  border-radius: 8px;
  color: var(--color-accent);
  background: var(--color-surface);
  font-weight: 600;
  cursor: pointer;
}
.text-btn:hover { color: #fff; background: var(--color-accent-hover); }
.duration-time { display: grid; justify-content: center; }
.duration-time > label { margin-top: 10px; font-weight: 600; }

.results { margin-top: 40px; text-align: center; }
.results h2 { margin-bottom: 8px; font-size: 1.25rem; }
.results-note { margin-bottom: 24px; font-size: .9rem; }
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  gap: 14px;
}
.result-card {
  padding: 18px 10px;
  border: 2px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface);
  transition: transform .15s;
}
.result-card:hover { transform: translateY(-3px); }
.result-card .cycles {
  color: var(--color-muted);
  font-size: .8rem;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.result-card .result-type { margin: 0; color: var(--color-muted); font-weight: 600; }
.result-card .time { margin: 4px 0; color: var(--color-ink); font-size: 1.5rem; font-weight: 700; }
.result-card .day-offset, .result-card .duration, .result-card .cycles, .result-card .assumption { margin: 6px 0 0; }
.result-card .day-offset { color: var(--color-accent); font-weight: 600; }
.result-card .duration { font-weight: 700; }
.result-card .assumption { color: var(--color-muted); font-size: .85rem; }
.results-footer { margin-top: 20px; font-size: .9rem; }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.copy-status { color: var(--color-muted); }

.blog-preview { margin-top: 40px; padding: 60px 0; background: var(--color-surface); }
.blog-preview h2 { margin-bottom: 30px; text-align: center; }
.blog-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 20px; }
.blog-card {
  padding: var(--space-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-page);
  transition: box-shadow .2s;
}
.blog-card:hover { box-shadow: 0 6px 20px rgb(0 0 0 / 8%); }
.blog-card h2, .blog-card h3 { margin: 0 0 8px; font-size: 1.1rem; line-height: 1.35; }
.blog-card h2 a, .blog-card h3 a { color: var(--color-ink); text-decoration: none; }
.blog-card p { margin: 0 0 12px; color: var(--color-muted); font-size: .95rem; }
.blog-card > a, .read-more { color: var(--color-accent); font-weight: 600; text-decoration: none; }
.blog-more { margin: 28px 0 0; text-align: center; }

.planning-notes { padding: 42px 0; }
.planning-notes h2, .planning-notes h3 { line-height: 1.35; }
.planning-notes h2 { margin: 0 0 14px; }
.planning-notes h3 { margin: 28px 0 10px; }
.planning-notes p { max-width: 720px; }
.calculator-faq details {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
}
.calculator-faq summary { cursor: pointer; font-weight: 600; }
.calculator-faq details p { margin-bottom: 0; }

.content-page { min-height: 55vh; padding-block: 32px 52px; }
.content-page > h1, .page-intro h1 { margin-top: 0; font-size: clamp(1.9rem, 6vw, 2.5rem); line-height: 1.2; }
.page-intro { margin-bottom: 28px; }
.page-intro p { color: var(--color-muted); }
.breadcrumbs { margin-bottom: 26px; color: var(--color-muted); font-size: .9rem; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.breadcrumbs li + li::before { content: "/"; margin-right: .5rem; color: var(--color-muted); }
.breadcrumbs [aria-current="page"] { color: var(--color-ink); }
.tag-filter, .tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-filter { margin-bottom: 24px; }
.tag-filter a, .tag-list a {
  padding: 5px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-accent);
  background: var(--color-surface);
  font-size: .85rem;
  text-decoration: none;
}
.tag-filter a[aria-current="page"] { color: #fff; border-color: var(--color-accent); background: var(--color-accent); }
.tag-list { margin: 0 0 14px; padding: 0; list-style: none; }
.post-meta { margin: 0 0 10px; color: var(--color-muted); font-size: .9rem; }
.post-article { max-width: 720px; margin-inline: auto; }
.post-header { margin-bottom: 28px; }
.post-header h1 { margin: 0 0 12px; font-size: clamp(2rem, 6vw, 2.8rem); line-height: 1.2; }
.post-description { color: var(--color-muted); font-size: 1.15rem; }
.cycle-figure { margin: 28px 0; }
.cycle-figure img { display: block; width: 100%; height: auto; border-radius: 12px; }
.cycle-figure figcaption { margin-top: 8px; color: var(--color-muted); font-size: .9rem; }
.post-body { font-size: 1.05rem; }
.post-body h2 { margin-top: 2em; font-size: 1.55rem; line-height: 1.3; }
.post-body h3 { margin-top: 1.7em; font-size: 1.25rem; line-height: 1.35; }
.post-body p { margin: 0 0 1.2em; }
.post-body blockquote { margin: 1.5em 0; padding: .25em 1em; border-left: 4px solid var(--color-accent); color: var(--color-muted); }
.post-disclaimer { margin-top: 28px; padding: 14px; border-radius: 8px; background: var(--color-accent-soft); font-size: .9rem; }
.related-posts { margin-top: 44px; }
.related-posts h2 { font-size: 1.5rem; }
.calculator-cta { margin-top: 36px; text-align: center; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 32px; }
.form-success { color: #166534; }
.admin-page { max-width: 780px; }
.admin-section { margin-block: 32px; }
.admin-post { margin-block: 12px; padding: 16px; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-surface); }
.admin-post summary { cursor: pointer; font-weight: 700; }
.admin-form { display: grid; gap: 14px; margin-top: 16px; }
.admin-form label { display: grid; gap: 5px; font-weight: 600; }
.admin-form input, .admin-form textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #9ca3af;
  border-radius: 6px;
  color: var(--color-ink);
  background: var(--color-surface);
}
.admin-form textarea { resize: vertical; }
.admin-form .calc-btn { justify-self: start; margin: 0; }
.danger-btn { min-height: 44px; padding: 8px 14px; border: 1px solid var(--color-error); border-radius: 8px; color: var(--color-error); background: var(--color-surface); cursor: pointer; }
.delete-form { margin-top: 12px; }

@media (max-width: 420px) {
  .container { width: min(100% - 1.25rem, 900px); }
  .site-header .container { align-items: flex-start; }
  .site-header nav { flex-direction: column; gap: 4px; align-items: flex-end; }
  .mode-toggle { display: flex; width: 100%; flex-direction: column; border-radius: 16px; }
  .mode-btn { width: 100%; }
  .time-picker { gap: 5px; }
  .time-picker select { padding-inline: 8px; }
  .blog-preview { padding-block: 42px; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms; animation-duration: .01ms; animation-iteration-count: 1; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --color-ink: #f3f4f6;
    --color-muted: #c2c9d4;
    --color-surface: #1f2937;
    --color-page: #111827;
    --color-border: #4b5563;
    --color-header: #030712;
    --color-accent: #a5b4fc;
    --color-accent-hover: #c7d2fe;
    --color-error: #fca5a5;
  }
  .mode-btn { color: #e5e7eb; }
  .mode-btn.active, .mode-btn[aria-selected="true"] { color: #111827; background: #a5b4fc; }
  .calc-btn { color: #111827; background: #a5b4fc; }
  .calc-btn:hover { color: #111827; background: #c7d2fe; }
  .tag-filter a[aria-current="page"] { color: #111827; background: #a5b4fc; }
  .tag-filter a, .tag-list a { border-color: #6b7280; }
  .form-success { color: #86efac; }
}
