:root {
  --bg: #0D0F14;
  --card: #161A22;
  --card2: #1C2030;
  --accent: #6C63FF;
  --green: #06D6A0;
  --gold: #FFD166;
  --red: #FF6B6B;
  --teal: #4ECDC4;
  --white: #F0F4FF;
  --gray: #8892A4;
  --light: #C8D0E0;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
@media (min-width: 400px) { html { font-size: 17px; } }
@media (min-width: 500px) { html { font-size: 18px; } }
@media (min-width: 600px) { html { font-size: 19px; } }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--white);
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

/* ── HEADER ───────────────────────────────────────────────────────────────── */
header { text-align: center; margin-bottom: 20px; padding-top: 8px; }
header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 2px; }
.header-version { font-size: 0.7rem; color: var(--accent); margin-bottom: 4px; letter-spacing: 0.05em; }
.current-time { font-size: 0.875rem; color: var(--gray); font-variant-numeric: tabular-nums; }

/* ── NEXT UP COUNTDOWN ────────────────────────────────────────────────────── */
.next-up {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-bottom: 20px;
  border-left: 4px solid var(--accent);
}
.next-up.all-done { border-left-color: var(--green); font-size: 1.125rem; padding: 24px; }
.next-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gray); margin-bottom: 4px; }
.next-time { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; margin-bottom: 4px; }
.next-slot { font-size: 0.875rem; color: var(--light); }

/* ── SLOTS ────────────────────────────────────────────────────────────────── */
.slots { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

.slot {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  border-left: 4px solid transparent;
}
.slot.current { background: var(--card2); border-left-color: currentColor; box-shadow: 0 0 20px rgba(108,99,255,0.08); }
.slot.done { opacity: 0.45; }

.slot-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.slot-emoji { font-size: 1.5rem; flex-shrink: 0; }
.slot-meta { flex: 1; }
.slot-time { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.slot-label { font-size: 0.8rem; color: var(--gray); text-transform: uppercase; letter-spacing: 0.05em; }

.now-badge {
  background: var(--accent); color: #fff; font-size: 0.65rem; font-weight: 800;
  padding: 3px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.08em;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.6; } }

.done-check { font-size: 1.25rem; color: var(--green); font-weight: 700; }

.cond-note {
  font-size: 0.75rem; color: var(--gold); background: rgba(255,209,102,0.08);
  border-radius: 6px; padding: 6px 10px; margin-bottom: 10px;
}

/* ── ITEMS ────────────────────────────────────────────────────────────────── */
.items { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: rgba(255,255,255,0.03); border-radius: 8px; padding: 10px 12px;
  border-left: 3px solid rgba(255,255,255,0.08);
}
.item.conditional { opacity: 0.75; border-left: 3px dashed rgba(255,209,102,0.4); }
.item-name { font-size: 0.9rem; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dose { font-size: 0.75rem; font-weight: 400; color: var(--accent); white-space: nowrap; }
.item-note { font-size: 0.75rem; color: var(--gray); margin-top: 2px; line-height: 1.4; }

/* ── PER-SLOT CALENDAR BUTTON ─────────────────────────────────────────────── */
.btn-slot-cal {
  width: 100%; margin-top: 10px; padding: 8px;
  background: rgba(108,99,255,0.1); border: 1px solid rgba(108,99,255,0.2);
  border-radius: 8px; color: var(--accent); font-family: var(--font);
  font-size: 0.75rem; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.slot-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn-slot-cal { flex: 1; }
.btn-slot-cal:active { transform: scale(0.98); }
.btn-ics { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.1); color: var(--light); }
.slot.done .btn-slot-cal { opacity: 0.5; }

/* ── RULES ────────────────────────────────────────────────────────────────── */
.rules { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 24px; }
.rules h2 { font-size: 0.9rem; font-weight: 700; margin-bottom: 10px; }
.rules ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.rules li { font-size: 0.8rem; color: var(--light); padding-left: 12px; position: relative; line-height: 1.5; }
.rules li::before { content: '\2022'; position: absolute; left: 0; color: var(--gray); }

/* ── ACTIONS ──────────────────────────────────────────────────────────────── */
.actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.btn-cal, .btn-notif {
  width: 100%; padding: 14px; border: none; border-radius: var(--radius);
  font-family: var(--font); font-size: 0.9rem; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-cal { background: var(--accent); color: #fff; }
.btn-cal:active { opacity: 0.8; }
.btn-notif { background: var(--card2); color: var(--light); border: 1px solid rgba(255,255,255,0.08); }
.btn-notif:disabled { cursor: not-allowed; opacity: 0.4; }

/* ── VERSION BOTTOM ────────────────────────────────────────────────────────── */
.version-bottom {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  padding: 24px 0;
  border-top: 1px solid rgba(108,99,255,0.2);
  margin-top: 16px;
  letter-spacing: 0.05em;
}

/* ── MISC ─────────────────────────────────────────────────────────────────── */
::selection { background: rgba(108,99,255,0.3); }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
