:root {
  --bg: #f2f4f9;
  --card: #ffffff;
  --text: #10131a;
  --muted: #6b7280;
  --accent: #2c6bff;
  --accent-soft: #e8efff;
  --ok: #14a05a;
  --warn: #e0791a;
  --danger: #d93636;
  --line: rgba(16, 19, 26, 0.08);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16, 19, 26, 0.06), 0 8px 24px rgba(16, 19, 26, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b22;
    --text: #eef1f7;
    --muted: #98a0ae;
    --accent: #5b8bff;
    --accent-soft: #1d2740;
    --ok: #35c07a;
    --warn: #f0a04b;
    --danger: #ff6b6b;
    --line: rgba(255, 255, 255, 0.09);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.28);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior-y: contain;
}

#app { max-width: 640px; margin: 0 auto; padding: 18px 16px 28px; }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.topbar h1 { font-size: 28px; line-height: 1.1; margin: 0 0 4px; letter-spacing: -0.02em; }
.topbar p { margin: 0; color: var(--muted); font-size: 13px; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

.icon-btn, .ghost-btn {
  border: 0;
  background: var(--card);
  color: var(--text);
  border-radius: 14px;
  box-shadow: var(--shadow);
  font: inherit;
  cursor: pointer;
}
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; color: var(--accent); }
.ghost-btn { height: 42px; padding: 0 14px; font-size: 14px; font-weight: 600; color: var(--accent); }
.icon-btn:active, .ghost-btn:active { transform: scale(0.96); }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border-radius: 999px; padding: 7px 12px;
  font-size: 13px; box-shadow: var(--shadow); color: var(--text);
}
.chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip--ok .chip__dot { background: var(--ok); }
.chip--warn .chip__dot { background: var(--warn); }
.chip--danger .chip__dot { background: var(--danger); }
.chip--muted { color: var(--muted); }

.content { display: grid; gap: 14px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card__head { padding: 14px 16px 6px; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); }

.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line); }
.card__head + .row { border-top: 0; }
.row__text { flex: 1; min-width: 0; }
.row__name { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* toggle */
.switch { position: relative; width: 52px; height: 32px; border-radius: 999px; border: 0; padding: 0; background: var(--line); cursor: pointer; transition: background 0.18s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.18s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.45; }
.switch.busy { opacity: 0.6; }

.value { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.value small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.badge { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--line); color: var(--muted); }
.badge--ok { background: rgba(20, 160, 90, 0.14); color: var(--ok); }
.badge--warn { background: rgba(224, 121, 26, 0.14); color: var(--warn); }
.badge--off { background: var(--line); color: var(--muted); }

.cover-actions { display: flex; gap: 8px; }
.cover-actions button { border: 0; background: var(--accent-soft); color: var(--accent); font: inherit; font-weight: 600; font-size: 13px; padding: 9px 14px; border-radius: 12px; }
.cover-actions button:active { transform: scale(0.96); }

.notice { margin-top: 14px; font-size: 12.5px; color: var(--muted); background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.notice.hidden { display: none; }
.notice code { background: var(--line); padding: 1px 5px; border-radius: 6px; font-size: 11.5px; }

.foot { margin-top: 16px; text-align: center; font-size: 12px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: rgba(16, 19, 26, 0.9); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13.5px; max-width: 88vw; transition: opacity 0.2s, transform 0.2s; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.skeleton { height: 60px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
