:root {
  --bg: #fbf7f2;
  --bg-accent: #f6e7ee;
  --surface: #ffffff;
  --text: #2b2330;
  --muted: #7d7285;
  --border: #ece3e8;
  --accent: #b5487a;
  --accent-strong: #933565;
  --accent-soft: #fbe9f1;
  --danger: #c0392b;
  --shadow: 0 10px 30px -12px rgba(80, 40, 70, 0.25);
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #19151c;
    --bg-accent: #2a1d27;
    --surface: #241e28;
    --text: #f3ecf4;
    --muted: #a99db0;
    --border: #3a3040;
    --accent: #e27aa9;
    --accent-strong: #f09cc1;
    --accent-soft: #3a2433;
    --danger: #ef6b5b;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 15% 0%, var(--bg-accent), transparent 45%), var(--bg);
  background-attachment: fixed;
  line-height: 1.5;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
a { color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px;
}
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.brand-icon { display: inline-block; margin-right: 4px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-actions form { margin: 0; }

.container { max-width: 1100px; margin: 0 auto; padding: 8px 16px 48px; }

.footer { padding: 0 16px 32px; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

/* ---------- Sections & cards ---------- */
.section-title { font-size: 1.1rem; margin: 28px 0 14px; }
.section-title-muted { color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.card {
  display: block;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { transform: translateY(-3px); }
.card-past { opacity: 0.7; }
.card-title { font-size: 1.2rem; overflow-wrap: anywhere; }
.card-date { margin: 4px 0 16px; color: var(--muted); font-size: 0.9rem; }

/* ---------- Countdown tiles ---------- */
.tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
}
.tile-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.tile-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.countdown-caption { margin: 10px 0 0; color: var(--muted); font-size: 0.9rem; }

.countdown-big .tiles { justify-content: center; gap: 12px; }
.countdown-big .tile { min-width: 96px; padding: 18px 20px; border-radius: 16px; }
.countdown-big .tile-value { font-size: clamp(2rem, 7vw, 3.5rem); overflow-wrap: anywhere; }
.countdown-big .tile-label { font-size: 0.85rem; }
.countdown-big .countdown-caption { text-align: center; font-size: 1.05rem; }

/* ---------- Detail page ---------- */
.back-link { display: inline-block; margin: 8px 0 16px; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--text); }

.hero, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.hero { padding: 40px 24px; text-align: center; }
.hero-title { font-size: clamp(1.8rem, 5vw, 2.6rem); overflow-wrap: anywhere; }
.hero-date { color: var(--muted); margin: 6px 0 24px; }
.hero-actions { display: flex; gap: 10px; justify-content: center; margin-top: 32px; }

.unit-picker {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
  color: var(--muted);
}

/* ---------- Forms ---------- */
.panel { max-width: 460px; margin: 24px auto; padding: 32px 24px; }
.panel h1 { font-size: 1.5rem; margin-bottom: 20px; overflow-wrap: anywhere; }
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; }
.optional { color: var(--muted); font-weight: 400; }
.help { color: var(--muted); }
.error, .errorlist { color: var(--danger); margin: 0; padding: 0; list-style: none; }

input, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.unit-picker select { width: auto; padding: 8px 12px; font-weight: 600; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.switch { margin: 20px 0 0; text-align: center; color: var(--muted); }
.switch a { color: var(--accent); font-weight: 600; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 72px 16px; }
.empty-icon { font-size: 3rem; margin: 0; }
.empty h1 { margin: 12px 0 8px; }
.empty p { color: var(--muted); margin: 0 0 24px; }
