:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1c2233;
  --muted: #5d6579;
  --border: #dfe3ec;
  --accent: #3a5bd9;
  --accent-text: #ffffff;
  --danger: #c63a3a;
  --radius: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141c;
    --surface: #1b2030;
    --text: #e7eaf2;
    --muted: #9aa3b8;
    --border: #2d3447;
    --accent: #7390ff;
    --accent-text: #0d1020;
    --danger: #ff7a7a;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  /* Room for the notch / status bar when launched standalone */
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--accent);
  color: var(--accent-text);
}

.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: grid;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

#notifications {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

#notifications p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
  margin: 0;
}

.badge {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.25);
  font-size: 0.85rem;
}

.form {
  display: grid;
  gap: 12px;
}

.form label {
  display: grid;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--muted);
}

.form .row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

[hidden] {
  display: none !important;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.button {
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.button.secondary {
  background: var(--accent-text);
  color: var(--accent);
}

.button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid currentColor;
}

.button.small {
  padding: 4px 10px;
  font-size: 0.85rem;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.item-body {
  display: grid;
  min-width: 0;
}

.item-body > * {
  overflow-wrap: anywhere;
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Toggle switch */
.switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--border);
  pointer-events: none;
  transition: background 0.15s;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.switch input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
