:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #15171a;
  --muted: #6b7280;
  --border: #e4e6eb;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --warn-bg: #fff7e6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04);
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1b1e24;
    --text: #eceef2;
    --muted: #9aa1ad;
    --border: #2b2f37;
    --accent: #3b82f6;
    --danger: #f87171;
    --ok: #4ade80;
    --warn: #fbbf24;
    --warn-bg: #2a2214;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + 12px)
    calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + 24px)
    calc(env(safe-area-inset-left) + 16px);
}

[hidden] { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 9px; }
h1 { font-size: 1.3rem; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
p { margin: 0 0 12px; }

form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 0.9rem; font-weight: 600; }
input {
  font: inherit;
  font-size: 16px; /* prevents iOS zoom */
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 11px 16px;
  min-height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); width: 100%; margin-bottom: 8px; }
button.link { background: none; border: none; color: var(--accent); padding: 6px 0; min-height: 0; font-weight: 500; }
form button.primary { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row button { flex: 1 1 auto; }

.error { color: var(--danger); font-size: 0.9rem; margin: 0; }
.notice {
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.92rem;
  margin-bottom: 12px;
}
.notice ol { margin: 6px 0 0; padding-left: 20px; }
.notice p { margin: 0; }
.notice.warn { background: var(--warn-bg); border-color: var(--warn); }

.status-card { padding: 14px 16px; }
.status-line { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.status-card p { margin: 4px 0 0 20px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: none; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { color: var(--muted); font-size: 0.85rem; }
.list .empty { color: var(--muted); font-size: 0.92rem; justify-content: center; }

.events .thumb {
  width: 72px; height: 48px; border-radius: 8px; object-fit: cover; flex: none;
  background: var(--bg); border: 1px solid var(--border);
}
.events .thumb.placeholder { display: grid; place-items: center; color: var(--muted); font-size: 1.2rem; }
.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--muted);
  margin-left: 6px; vertical-align: 1px;
}

/* toggle switch */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; inset: 0; cursor: pointer; z-index: 1; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: background 0.2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.2s;
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 0.9rem; font-weight: 500;
  max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
