:root {
  --bg: #f6f6f6;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e2e2e2;
  --accent: #1a56db;
  --ok: #15803d;
  --warn: #a16207;
  --bad: #b91c1c;
  --badge-ok-bg: #dcfce7;
  --badge-bad-bg: #fee2e2;
  --focus-ring: rgba(26, 86, 219, 0.12);
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 20, 0.04), 0 1px 6px rgba(20, 20, 20, 0.03);
  --shadow-md: 0 4px 16px rgba(20, 20, 20, 0.06), 0 1px 4px rgba(20, 20, 20, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
html[data-theme="dark"] {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --text: #f0f0f0;
  --muted: #9ca3af;
  --border: #2e2e2e;
  --accent: #60a5fa;
  --ok: #4ade80;
  --warn: #facc15;
  --bad: #f87171;
  --badge-ok-bg: rgba(74, 222, 128, 0.15);
  --badge-bad-bg: rgba(248, 113, 113, 0.15);
  --focus-ring: rgba(96, 165, 250, 0.2);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.18), 0 1px 6px rgba(0, 0, 0, 0.14);
  --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.32), 0 1px 4px rgba(0, 0, 0, 0.2);
}
/* ── Named theme presets ── */
html[data-theme="aurora"],
html[data-theme="rose"],
html[data-theme="ocean"],
html[data-theme="forest"],
html[data-theme="amber"],
html[data-theme="nordic"],
html[data-theme="copper"] {
  --text: #f0f0f0;
  --muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.09);
  --ok: #4ade80;
  --warn: #facc15;
  --bad: #f87171;
  --badge-ok-bg: rgba(74, 222, 128, 0.15);
  --badge-bad-bg: rgba(248, 113, 113, 0.15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.18), 0 1px 6px rgba(0, 0, 0, 0.14);
  --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.32), 0 1px 4px rgba(0, 0, 0, 0.2);
}
html[data-theme="sakura"],
html[data-theme="mint"] {
  --text: #1a1a2e;
  --muted: #6b6b78;
  --border: rgba(0, 0, 0, 0.08);
  --ok: #15803d;
  --warn: #a16207;
  --bad: #b91c1c;
  --badge-ok-bg: #dcfce7;
  --badge-bad-bg: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(20, 20, 20, 0.04), 0 1px 6px rgba(20, 20, 20, 0.03);
  --shadow-md: 0 4px 16px rgba(20, 20, 20, 0.06), 0 1px 4px rgba(20, 20, 20, 0.04);
}
html[data-theme] { --focus-ring: color-mix(in srgb, var(--accent) 22%, transparent); }

html[data-theme="aurora"]  { --bg: #0a0a0f; --surface: #1a1a2e; --accent: #7c3aed; }
html[data-theme="rose"]    { --bg: #0f0a0a; --surface: #2a1215; --accent: #ff6b6b; }
html[data-theme="ocean"]   { --bg: #050d1a; --surface: #0a2040; --accent: #00d4ff; }
html[data-theme="forest"]  { --bg: #060b06; --surface: #0f2010; --accent: #39d353; }
html[data-theme="amber"]   { --bg: #0a0800; --surface: #1a1400; --accent: #ffb300; }
html[data-theme="nordic"]  { --bg: #1a1f2e; --surface: #2e3440; --accent: #88c0d0; }
html[data-theme="copper"]  { --bg: #0c0805; --surface: #1f1510; --accent: #b87333; }
html[data-theme="sakura"]  { --bg: #f5f0f2; --surface: #e8dce0; --accent: #c4527a; }
html[data-theme="mint"]    { --bg: #f0faf5; --surface: #ddf2e8; --accent: #0d9488; }

html[data-theme="dark"] .loading-row .spin {
  border-color: rgba(255,255,255,0.15);
  border-top-color: var(--text);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--focus-ring); }
a { color: var(--accent); }

/* ── Auth screen ── */
#login {
  position: fixed; inset: 0; z-index: 100;
  display: flex;
  padding: 20px;
  overflow-y: auto;
  background: var(--bg);
  transition: opacity 0.25s;
}
.login-theme {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 101;
}
#login.out { opacity: 0; pointer-events: none; }

.auth-shell {
  width: 100%;
  max-width: 880px;
  margin: auto;
  display: flex;
  align-items: stretch;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  animation: auth-rise 0.35s ease;
}
@keyframes auth-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-hero {
  flex: 1.1;
  display: flex;
  align-items: center;
  padding: 44px 40px;
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 60%),
    linear-gradient(160deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000));
  color: #fff;
}
.auth-shell { position: relative; z-index: 1; }
.hero-content { position: relative; max-width: 320px; }
.hero-content h2 {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 12px;
}
.hero-content p {
  font-size: 14px;
  line-height: 1.55;
  opacity: 0.88;
  margin-bottom: 22px;
}
.hero-points { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.hero-points li {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 9px;
  opacity: 0.95;
}
.hero-points li::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.8;
  flex-shrink: 0;
}

.auth-box {
  flex: 1;
  width: 100%; max-width: 400px;
  background: var(--surface);
  padding: 40px 36px;
}
@media (max-width: 720px) {
  .auth-shell { flex-direction: column; max-width: 420px; border-radius: 16px; }
  .auth-hero { padding: 28px 28px 24px; }
  .hero-content { max-width: none; }
  .hero-content h2 { font-size: 21px; }
  .hero-points { display: none; }
  .auth-box { padding: 28px 28px 32px; max-width: none; }
}
.auth-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 16px;
}
.auth-box h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.auth-box .sub { font-size: 14px; color: var(--muted); margin-bottom: 20px; }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  flex: 1;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.panel { display: none; }
.panel.active { display: block; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:hover { border-color: color-mix(in srgb, var(--border) 40%, var(--accent)); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-group-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 18px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.btn {
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: filter 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); box-shadow: var(--shadow-md); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn .spin-wrap { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; }
.btn.loading .btn-label { visibility: hidden; }
.btn.loading .spin-wrap { display: flex; }

.err { font-size: 13px; color: var(--bad); margin-top: 12px; min-height: 1.2em; }

.amizone-recover {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border));
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border-radius: 10px;
}
.amizone-recover .field { margin-bottom: 10px; }
.amizone-recover-msg { font-size: 13px; color: var(--warn); font-weight: 600; margin: 0 0 10px; }
.amizone-recover-hint { font-size: 12px; color: var(--muted); margin: 10px 0 0; text-align: center; }

.spin {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App shell ── */
#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
#app.in { opacity: 1; pointer-events: all; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  flex-shrink: 0;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.theme-btn {
  height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.theme-btn:hover { background: var(--bg); border-color: color-mix(in srgb, var(--border) 50%, var(--accent)); }
.theme-icon { width: 14px; height: 14px; display: inline-flex; flex-shrink: 0; }
.theme-icon svg { width: 100%; height: 100%; }

.theme-menu {
  position: fixed;
  z-index: 200;
  width: 196px;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  animation: auth-rise 0.15s ease;
}
.theme-menu[hidden] { display: none; }
.theme-option {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-transform: capitalize;
  text-align: left;
}
.theme-option:hover { background: var(--bg); }
.theme-option.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.swatch-stack { display: inline-flex; flex-shrink: 0; }
.swatch-stack span {
  width: 9px; height: 16px;
  border: 1px solid rgba(127,127,127,0.25);
  margin-left: -4px;
}
.swatch-stack span:first-child { margin-left: 0; border-radius: 3px 0 0 3px; }
.swatch-stack span:last-child { border-radius: 0 3px 3px 0; }

.date-block { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; margin-bottom: 14px; }

.nav-btn {
  width: 36px; height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-btn:hover { background: var(--bg); }
.date-pick {
  height: 36px;
  min-width: 150px;
  padding: 0 14px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}
.date-pick:hover { background: var(--bg); }
.date-pick:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
@media (max-width: 600px) {
  .main-wrap { padding: 14px; }
  .welcome { margin-bottom: 14px; padding-bottom: 12px; }
  .welcome-name { font-size: 26px; }
  .topbar { padding: 12px 14px; }
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .topbar-actions { justify-content: flex-end; }
  .theme-btn { height: 38px; font-size: 12px; padding: 0 12px; }
  .date-block {
    gap: 8px;
    justify-content: space-between;
    width: 100%;
  }
  .nav-btn { width: 40px; height: 40px; font-size: 16px; flex-shrink: 0; }
  .date-pick {
    height: 40px;
    flex: 1;
    min-width: 0;
    font-size: 16px;
  }
  .card { padding: 16px 14px; }
  .class-item { grid-template-columns: 48px 1fr auto; gap: 8px; padding: 12px 4px; margin: 0 -4px; }
  .class-title { font-size: 16px; }
}
@media (max-width: 380px) {
  .class-item { grid-template-columns: 1fr auto; }
  .class-time { grid-column: 1 / -1; order: -1; margin-bottom: 2px; }
}

.main-wrap {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 20px;
}
.welcome {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.welcome-label {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 4px;
}
.welcome-name {
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  letter-spacing: -0.02em;
}
.content {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 800px) {
  .content { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: var(--shadow-sm);
}
.card-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
  gap: 8px;
}
.card-h h2 { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.card-h span { font-size: 12px; color: var(--muted); }

.status-pill {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.status-pill.is-synced {
  color: var(--ok);
  background: var(--badge-ok-bg);
  border-color: transparent;
}

/* Timetable */
.class-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  padding: 12px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  border-bottom: 1px solid var(--border);
  align-items: start;
  transition: background 0.15s ease;
}
.class-item:hover { background: var(--bg); }
.class-item:last-child { border-bottom: none; }
.class-time { font-family: var(--mono); font-size: 13px; line-height: 1.35; }
.class-time .end { color: var(--muted); font-size: 12px; }
.class-code { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.class-title { font-size: 17px; font-weight: 600; line-height: 1.3; color: var(--text); letter-spacing: -0.01em; }
.class-room {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 5px;
  letter-spacing: 0.03em;
}
.class-meta { font-size: 12px; color: var(--muted); margin-top: 6px; opacity: 0.85; }
.class-item.cancelled { opacity: 0.55; }
.class-item.cancelled .class-title { text-decoration: line-through; }

.badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.badge.present { background: var(--badge-ok-bg); color: var(--ok); }
.badge.absent { background: var(--badge-bad-bg); color: var(--bad); }
.badge.cancelled { background: var(--bg); color: var(--muted); }
.badge.unmarked { background: var(--bg); color: var(--muted); }

.empty, .loading-row {
  font-size: 14px;
  color: var(--muted);
  padding: 24px 0;
  text-align: center;
}
.loading-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.loading-row .spin { border-color: rgba(0,0,0,0.12); border-top-color: var(--text); }

.legend { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.5; }

/* Attendance */
.att-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.att-item:last-child { border-bottom: none; }
.att-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.att-code { font-size: 11px; font-weight: 600; color: var(--muted); }
.att-name { font-size: 14px; font-weight: 500; margin-top: 2px; }
.att-pct { font-size: 18px; font-weight: 700; flex-shrink: 0; }
.att-pct.ok { color: var(--ok); }
.att-pct.mid { color: var(--warn); }
.att-pct.low { color: var(--bad); }
.att-counts { font-size: 12px; color: var(--muted); text-align: right; }
.att-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.att-bar > i {
  display: block;
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.att-bar > i.ok { background: var(--ok); }
.att-bar > i.mid { background: var(--warn); }
.att-bar > i.low { background: var(--bad); }

.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 20px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  gap: 12px;
  flex-wrap: wrap;
}
.footer button {
  font-size: 12px;
  font-family: inherit;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}
.footer button:hover { color: var(--bad); }
.footer a { color: var(--muted); text-decoration: underline; }
.footer a:hover { color: var(--accent); }

.legal-note { font-size: 12px; color: var(--muted); margin-top: 16px; text-align: center; }
.legal-note a { color: var(--muted); text-decoration: underline; }
.legal-note a:hover { color: var(--accent); }

/* ── Calendar sync card (main screen, prominent) ── */
.cal-card { margin-bottom: 24px; }
.cal-lead { font-size: 14px; color: var(--muted); margin-bottom: 16px; max-width: 60ch; }
#cal-status {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted);
}
.cal-reminder-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.cal-reminder-row label { font-size: 13px; font-weight: 500; color: var(--text); }
.cal-reminder-row select {
  padding: 8px 12px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.cal-reminder-row select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }

.cal-apple-note { font-size: 12px; color: var(--muted); margin-top: 12px; max-width: 60ch; }
.cal-apple-note a { color: var(--accent); }

.cal-instructions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.cal-instructions[hidden] { display: none; }
.cal-inst-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600;
  margin-bottom: 10px;
}
.cal-inst-head svg { flex-shrink: 0; }
.cal-steps { margin: 0 0 12px 18px; padding: 0; font-size: 14px; color: var(--text); }
.cal-steps li { margin-bottom: 6px; }
.cal-url-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--mono);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.cal-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.cal-link-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
}
.cal-link-btn:hover { filter: brightness(1.08); }
.cal-link-btn.ghost { color: var(--text); background: var(--surface); border-color: var(--border); }
.cal-link-btn.ghost:hover { background: var(--bg); filter: none; }

.cal-synced {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--badge-ok-bg);
}
.cal-synced-icon {
  width: 28px; height: 28px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--surface);
}
.cal-synced-icon svg { width: 16px; height: 16px; }
.cal-synced-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cal-synced-text strong { font-size: 14px; font-weight: 600; color: var(--ok); }
.cal-synced-sub { font-size: 12px; color: var(--muted); }
.cal-last-synced { font-size: 11px; color: var(--muted); opacity: 0.8; }
.cal-manage-btn {
  flex-shrink: 0;
  height: 32px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.cal-manage-btn:hover { background: var(--bg); }
#cal-setup.collapsed { display: none; }
#cal-synced:not([hidden]) ~ #cal-setup:not(.collapsed) { margin-top: 16px; animation: setup-open 0.2s ease; }
@keyframes setup-open { from { opacity: 0; } to { opacity: 1; } }

.cal-testing { margin-top: 16px; }
.cal-testing summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.cal-testdate-hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; max-width: 50ch; }
.cal-testing input {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
.cal-testing .cal-link-btn { height: 32px; padding: 0 12px; font-size: 13px; margin-left: 8px; }
.cal-testdate-status { margin: 8px 0 0; font-size: 12px; color: var(--muted); min-height: 14px; }
.cal-testdate-status.ok { color: var(--ok); }
.cal-testdate-status.bad { color: var(--bad); }

/* ── flatpickr theme (matches app vars, incl. dark) ── */
.flatpickr-calendar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}
.flatpickr-calendar.arrowTop::before, .flatpickr-calendar.arrowTop::after { border-bottom-color: var(--surface); }
.flatpickr-calendar.arrowBottom::before, .flatpickr-calendar.arrowBottom::after { border-top-color: var(--surface); }
.flatpickr-months, .flatpickr-weekdays { background: var(--surface); }
.flatpickr-month, .flatpickr-current-month, .flatpickr-current-month input.cur-year { color: var(--text); fill: var(--text); }
.flatpickr-monthDropdown-months { background: var(--surface); color: var(--text); }
.flatpickr-weekday { color: var(--muted); }
.flatpickr-prev-month, .flatpickr-next-month { fill: var(--text); }
.flatpickr-prev-month svg, .flatpickr-next-month svg { fill: var(--text); }
.flatpickr-prev-month:hover svg, .flatpickr-next-month:hover svg { fill: var(--accent); }
.flatpickr-day { color: var(--text); border-radius: 6px; }
.flatpickr-day:hover { background: var(--bg); border-color: var(--bg); }
.flatpickr-day.today { border-color: var(--accent); }
.flatpickr-day.selected, .flatpickr-day.selected:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.flatpickr-day.flatpickr-disabled, .flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay { color: var(--muted); opacity: 0.5; }
