:root {
  --bg: #0b1220;
  --card: #131c2e;
  --card-2: #1a2540;
  --text: #e8eefc;
  --muted: #8ea0c4;
  --line: #24304d;

  --danger: #ff3b3b;
  --danger-bg: #2a0d12;
  --clear: #22c55e;
  --clear-bg: #0c2318;
  --unknown: #64748b;

  --accent: var(--unknown);
  --accent-bg: #0f1728;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  transition: background-color 0.4s ease;
}

/* цветовая тема по статусу */
body[data-status='danger'] { --accent: var(--danger); --accent-bg: var(--danger-bg); background: #14060a; }
body[data-status='clear']  { --accent: var(--clear);  --accent-bg: var(--clear-bg); }
body[data-status='unknown']{ --accent: var(--unknown);--accent-bg: var(--accent-bg); }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  gap: 14px;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 6px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.2px; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}
.conn { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--unknown); }
.conn.ok .conn-dot { background: var(--clear); }
.conn.stale .conn-dot { background: #f59e0b; }
.conn.down .conn-dot { background: var(--danger); }

/* карточка статуса */
.status-card {
  background: linear-gradient(160deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px 20px 30px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), inset 0 0 0 2px var(--accent-bg);
  position: relative;
  overflow: hidden;
}
.status-card::before {
  content: ''; position: absolute; inset: -2px;
  border-radius: 22px; padding: 2px;
  background: linear-gradient(160deg, transparent, var(--accent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0.5; pointer-events: none;
}
.status-emoji { font-size: 68px; line-height: 1; margin-bottom: 12px; }
.status-label { font-size: 30px; font-weight: 800; letter-spacing: 0.3px; color: var(--accent); }
.status-sub { margin-top: 8px; color: var(--text); opacity: 0.85; font-size: 15px; line-height: 1.4; }
.status-since { margin-top: 12px; color: var(--muted); font-size: 13px; }

body[data-status='danger'] .status-card { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 10px 40px rgba(0,0,0,0.35), inset 0 0 0 2px var(--danger-bg); }
  50% { box-shadow: 0 10px 60px rgba(255, 59, 59, 0.35), inset 0 0 0 2px rgba(255,59,59,0.4); }
}
@media (prefers-reduced-motion: reduce) {
  body[data-status='danger'] .status-card { animation: none; }
}

.hint {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; font-size: 14px; color: var(--muted); line-height: 1.5;
}
.hint b { color: var(--text); }
.hint ol { margin: 8px 0 0; padding-left: 20px; }
.hint li { margin: 4px 0; }

.actions { display: flex; flex-direction: column; gap: 10px; }
.btn {
  appearance: none; border: none; border-radius: 14px;
  padding: 15px 18px; font-size: 16px; font-weight: 700; cursor: pointer;
  transition: transform 0.06s ease, opacity 0.2s ease, background-color 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: #08101f; }
body[data-status='danger'] .btn-primary { color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ok { background: var(--clear-bg); color: var(--clear); border: 1px solid var(--clear); }
.notif-status { margin: 2px 2px 0; font-size: 13px; color: var(--muted); min-height: 16px; }
.notif-status.err { color: var(--danger); }
.notif-status.ok { color: var(--clear); }

.meta {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 6px 16px;
}
.meta-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; font-size: 14px; border-bottom: 1px solid var(--line);
}
.meta-row:last-child { border-bottom: none; }
.meta-row span:first-child { color: var(--muted); }

.history h2 { font-size: 14px; color: var(--muted); font-weight: 600; margin: 4px 2px 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.history ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.history li {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.history .pill { font-weight: 700; font-size: 13px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.history .pill.danger { background: var(--danger-bg); color: var(--danger); }
.history .pill.clear { background: var(--clear-bg); color: var(--clear); }
.history .h-time { color: var(--muted); font-size: 13px; margin-left: auto; }

.foot {
  margin-top: auto; padding-top: 8px;
  display: flex; justify-content: space-between; align-items: center;
  color: var(--muted); font-size: 12px;
}
.link { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 12px; }
.ios-share { font-family: system-ui; }
