:root {
  --bg: #f2f2f7;
  --card: rgba(255, 255, 255, 0.86);
  --card-solid: #ffffff;
  --text: #111114;
  --muted: #74747c;
  --line: rgba(22, 22, 27, 0.08);
  --blue: #0a84ff;
  --blue-2: #0066d8;
  --green: #22b95b;
  --red: #e7423a;
  --orange: #f59a23;
  --shadow: 0 14px 38px rgba(37, 43, 58, 0.08);
}

html[data-theme="dark"] {
  --bg: #08090b;
  --card: rgba(28, 29, 33, 0.88);
  --card-solid: #1c1d21;
  --text: #f7f7f8;
  --muted: #98989f;
  --line: rgba(255, 255, 255, 0.09);
  --blue: #2997ff;
  --blue-2: #0a84ff;
  --green: #30d158;
  --red: #ff5b52;
  --orange: #ffad33;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.26);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  padding: 0 0 calc(28px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; }

.ambient {
  position: fixed;
  z-index: 0;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.12;
  pointer-events: none;
}

.ambient-one { top: -110px; right: -110px; background: var(--blue); }
.ambient-two { top: 42%; left: -190px; background: #8e5cff; }

.shell {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px 18px;
}

.topbar,
.status-head,
.section-heading,
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

h1, h2, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.1; letter-spacing: -0.9px; }
h2 { font-size: 21px; line-height: 1.2; letter-spacing: -0.45px; }

.eyebrow,
.card-label {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
}

.theme-toggle {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 68px;
  height: 34px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--card);
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
}

.theme-toggle::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--card-solid);
  box-shadow: 0 2px 8px rgba(0,0,0,.16);
  transition: transform .25s ease;
}

html[data-theme="dark"] .theme-toggle::before { transform: translateX(34px); }
.theme-toggle span { position: relative; z-index: 1; display: grid; place-items: center; font-size: 14px; }

.glass {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.status-card {
  margin-top: 22px;
  padding: 18px;
  border-radius: 22px;
}

.status-line { display: flex; align-items: center; gap: 9px; font-size: 20px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 5px color-mix(in srgb, var(--muted) 14%, transparent); }
.status-dot.is-active { background: var(--green); box-shadow: 0 0 0 5px color-mix(in srgb, var(--green) 16%, transparent); }
.status-dot.is-inactive { background: var(--red); box-shadow: 0 0 0 5px color-mix(in srgb, var(--red) 16%, transparent); }
.status-dot.is-loading { animation: breathe 1.2s ease-in-out infinite; }

.status-pill {
  align-self: flex-start;
  padding: 7px 10px;
  border-radius: 99px;
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 11%, transparent);
  font-size: 12px;
  font-weight: 750;
}
.status-pill.is-active { color: var(--green); background: color-mix(in srgb, var(--green) 13%, transparent); }
.status-pill.is-inactive { color: var(--red); background: color-mix(in srgb, var(--red) 13%, transparent); }

.metrics {
  display: grid;
  grid-template-columns: 1.1fr .8fr 1fr;
  gap: 1px;
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--line);
}

.metric { min-width: 0; padding: 12px 10px; background: var(--card-solid); }
.metric span, .metric strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric span { margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.metric strong { font-size: 14px; }

.notice {
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, var(--red) 25%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--red) 9%, transparent);
}
.notice strong { color: var(--red); font-size: 14px; }
.notice p { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.retry-button {
  margin-top: 11px;
  padding: 9px 13px;
  border: 0;
  border-radius: 11px;
  color: white;
  background: var(--blue);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}
.retry-button:disabled { opacity: .55; cursor: default; }

.connect-section { margin-top: 28px; }
.connect-section.is-disabled { opacity: .48; pointer-events: none; filter: grayscale(.3); }
.step-caption { color: var(--blue); font-size: 12px; font-weight: 750; }

.steps {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 13px;
  padding: 12px 14px;
  border-radius: 16px;
  color: var(--muted);
  font-size: 12px;
}
.steps span { display: flex; align-items: center; gap: 7px; }
.steps b, .step-number {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  color: white;
  background: linear-gradient(135deg, var(--blue), #7367ff);
  font-size: 12px;
}
.steps i { color: var(--blue); font-style: normal; }

.device-grid { display: grid; gap: 10px; margin-top: 13px; }
.device-card, .quick-card {
  width: 100%;
  border-radius: 18px;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}
.device-card:active, .quick-card:active, .primary-button:active { transform: scale(.985); }
.device-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  text-align: left;
}
.device-card > span:nth-child(2), .quick-card > span:nth-child(2), .support-card > span:nth-child(2) { display: grid; gap: 3px; }
.device-card strong, .quick-card strong, .support-card strong { font-size: 15px; }
.device-card small, .quick-card small, .support-card small { color: var(--muted); font-size: 12px; }
.device-icon, .happ-mark, .support-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  color: white;
  background: linear-gradient(145deg, #319cff, #6e66ff);
  font-size: 23px;
  font-weight: 800;
}
.phone-icon { font-size: 27px; }
.chevron { color: var(--muted); font-size: 23px; font-weight: 400; }

.quick-card {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 13px;
  text-align: left;
}
.happ-mark { background: linear-gradient(145deg, #7257ff, #0a84ff); }

.support-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 12px;
  border-radius: 17px;
  color: inherit;
  text-decoration: none;
}
.support-icon { width: 42px; height: 42px; color: var(--blue); background: color-mix(in srgb, var(--blue) 13%, transparent); }
.source-note { margin: 18px 10px 0; color: var(--muted); font-size: 11px; line-height: 1.45; text-align: center; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.sheet {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  width: min(100%, 540px);
  max-height: min(88vh, 760px);
  margin: 0 auto;
  padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 25px 25px 0 0;
  background: var(--card-solid);
  box-shadow: 0 -18px 54px rgba(0,0,0,.2);
  animation: sheet-in .22s ease-out;
}

.sheet-handle { width: 42px; height: 5px; margin: 1px auto 13px; border-radius: 99px; background: color-mix(in srgb, var(--muted) 35%, transparent); }
.sheet-header { align-items: flex-start; margin-bottom: 17px; }
.close-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  font-size: 23px;
  cursor: pointer;
}

.sheet-step { display: flex; align-items: flex-start; gap: 11px; margin: 14px 2px 10px; }
.sheet-step strong { font-size: 14px; }
.sheet-step p { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.4; }

.download-list { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; }
.download-list a {
  display: flex;
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}
.download-list a:last-child { border-bottom: 0; }
.download-list b { color: var(--muted); font-size: 20px; font-weight: 400; }
.download-list a.is-recommended { color: var(--blue); background: color-mix(in srgb, var(--blue) 7%, transparent); }

.primary-button {
  width: 100%;
  margin-top: 14px;
  padding: 14px 18px;
  border: 0;
  border-radius: 15px;
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--blue-2));
  box-shadow: 0 10px 25px color-mix(in srgb, var(--blue) 28%, transparent);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.primary-button:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; }

.share-warning { padding: 12px 13px; border-radius: 13px; color: var(--orange); background: color-mix(in srgb, var(--orange) 11%, transparent); font-size: 13px; line-height: 1.45; }
.link-preview { margin-top: 13px; padding: 13px; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); background: var(--bg); font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }

.toast {
  position: fixed;
  z-index: 50;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 16px;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: 0 auto;
  padding: 11px 15px;
  border-radius: 99px;
  color: white;
  background: rgba(20, 20, 23, .92);
  box-shadow: 0 10px 32px rgba(0,0,0,.24);
  font-size: 13px;
  font-weight: 650;
}

[hidden] { display: none !important; }

@keyframes breathe { 50% { opacity: .35; transform: scale(.8); } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }

@media (min-width: 640px) {
  .shell { padding-top: 32px; }
  .device-grid { grid-template-columns: 1fr 1fr; }
  .device-card:last-child { grid-column: 1 / -1; }
}

.tv-code {
  width: 100%;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: none;
  color: var(--text);
  background: var(--bg);
  font: 800 25px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 9px;
  text-align: center;
}
.tv-code:focus { border-color: var(--blue); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 12%, transparent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
