:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f2f3f8;
  --text: #12141c;
  --text-dim: #5b6072;
  --text-faint: #8a8fa3;
  --line: #e3e5ee;
  --accent: #4f46e5;
  --accent-soft: #eef0fe;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --ok: #047857;
  --ok-soft: #d1fae5;
  --danger: #b91c1c;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 18, 32, 0.05), 0 8px 24px rgba(16, 18, 32, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f16;
    --surface: #171a24;
    --surface-2: #1f2330;
    --text: #eef0f6;
    --text-dim: #a3a9bd;
    --text-faint: #767d94;
    --line: #272b38;
    --accent: #8b85ff;
    --accent-soft: #221f45;
    --warn: #fbbf24;
    --warn-soft: #37290c;
    --ok: #34d399;
    --ok-soft: #0d2f24;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

/* The hidden attribute is only display:none in the UA stylesheet, so ANY class
   rule setting display beats it -- .banner and .boot both do. Without this,
   el.hidden = true runs, reports success, and changes nothing on screen, which
   is how a "Calendar access expired" banner survived three separate fixes to
   the state behind it. Make the attribute mean what the JS assumes it means. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px calc(32px + env(safe-area-inset-bottom));
}

/* ---------- boot / toast ---------- */
.boot { display: grid; place-items: center; min-height: 100dvh; }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  z-index: 50;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 40px);
  text-align: center;
}

/* ---------- signed out ---------- */
.hero { text-align: center; padding: 40px 4px 28px; }
.hero-mark {
  width: 64px; height: 64px;
  margin: 0 auto 20px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 20px;
}
.hero-mark svg { width: 34px; height: 34px; }
.hero h1 { font-size: 30px; margin: 0 0 10px; letter-spacing: -0.02em; }
.hero-sub { color: var(--text-dim); margin: 0 auto 26px; max-width: 380px; }
.hero-fine { color: var(--text-faint); font-size: 13px; margin: 16px auto 0; max-width: 320px; }

.steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 14px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.step-n {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.steps strong { display: block; font-size: 15px; }
.steps p { margin: 2px 0 0; color: var(--text-dim); font-size: 14px; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 8px 13px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-google { background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: var(--shadow); padding: 13px 22px; }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--line); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { color: var(--danger); }

/* ---------- topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 2px 20px; }
.who { display: flex; align-items: center; gap: 11px; min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.who-name { margin: 0; font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-meta { margin: 0; font-size: 13px; color: var(--text-faint); }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin: 0 0 12px; }
.card-head .card-title { margin: 0; }

.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 14px 16px; border-radius: var(--radius); margin-bottom: 14px; font-size: 14px;
}
.banner-warn { background: var(--warn-soft); color: var(--warn); }
.banner strong { font-weight: 700; }
.banner .btn { margin-left: auto; background: var(--warn); color: var(--bg); }

/* ---------- notify states ---------- */
.state { display: flex; gap: 13px; align-items: flex-start; }
.state-icon { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; }
.state-ok .state-icon { background: var(--ok-soft); color: var(--ok); }
.state-todo .state-icon { background: var(--accent-soft); color: var(--accent); }
.state-warn .state-icon { background: var(--warn-soft); color: var(--warn); }
.state-title { margin: 0 0 3px; font-weight: 650; font-size: 15px; }
.state-desc { margin: 0; color: var(--text-dim); font-size: 14px; }
.state-actions { margin-top: 14px; display: flex; gap: 9px; flex-wrap: wrap; }

.install-steps { margin: 12px 0 0; padding-left: 20px; color: var(--text-dim); font-size: 14px; }
.install-steps li { margin-bottom: 5px; }
.install-steps b { color: var(--text); }

/* ---------- form ---------- */
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row-between { justify-content: space-between; align-items: center; margin-top: 15px; }
.field { flex: 1 1 150px; display: block; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-faint); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.field input {
  width: 100%;
  font: inherit;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}
.field input[readonly] { color: var(--text-dim); }
.toggle { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text-dim); cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.next-delivery { font-size: 13px; color: var(--text-faint); }
.save-state { font-size: 13px; color: var(--ok); margin: 10px 0 0; min-height: 18px; }

/* ---------- brief ---------- */
.headline { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.headline-sub { font-size: 13px; color: var(--text-faint); margin: 0 0 16px; }
.muted { color: var(--text-faint); font-size: 14px; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-dim); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-allday { background: var(--accent-soft); color: var(--accent); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 13px; padding: 13px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: none; padding-top: 4px; }
.ev-time { flex: none; width: 74px; }
.ev-start { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ev-end { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.ev-main { min-width: 0; flex: 1; }
.ev-title { font-size: 15px; font-weight: 550; margin: 0; overflow-wrap: anywhere; }
.ev-meta { margin: 3px 0 0; font-size: 13px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.ev-meta a { color: var(--accent); text-decoration: none; font-weight: 600; }
.ev-conflict { color: var(--warn); font-weight: 600; }
.gap-row { display: flex; align-items: center; gap: 10px; padding: 7px 0 7px 87px; color: var(--text-faint); font-size: 12px; border-top: 1px solid var(--line); }
.gap-row::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--line); }

.empty { text-align: center; padding: 22px 0; }
.empty-mark { font-size: 30px; }
.empty p { margin: 8px 0 0; color: var(--text-dim); font-size: 14px; }

.footer { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

/* ---------- legal links ---------- */
.legal-links {
  margin: 22px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}
.legal-links a { color: var(--text-faint); text-decoration: none; }
.legal-links a:hover { text-decoration: underline; }
