/* Dope Spin Connect. Visual language matches update.dope-spin.com: the same
   wordmark header, kicker + headline heroes, #080808 cards on #030303, and
   brand-blue primary actions. */

:root {
  color-scheme: dark;
  --bg: #030303;
  --text: #f4f4f4;
  --muted: #b8b8b8;
  --brand-blue: #078dfb;
  --panel: #060606;
  --panel-deep: #050505;
  --border: #1f1f1f;
  --border-accent: #123252;
  --input-bg: #0b0b0b;
  --input-border: #2d2d2d;
  /* Status colours shared with update.dope-spin.com. */
  --attention: #ffd60a;
  --success: #34c759;
  --danger: #ff5a52;
  --ok: #6dce8a;
  --warn: #ffd60a;
  --err: #ff8f8f;
  --cta: #078dfb;
  --card: #080808;
  --card-border: #1f1f1f;

  /* Matches the colours the device paints on the SHOOT screen. */
  --shoot-elev: #a7ff6a;
  --shoot-elev-neg: #b56cff;
  --shoot-wind: #2196f3;
  --band-sub: #e53935;
  --band-trans: #fdd835;
  --band-super: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3, h4 {
  margin: 0 0 8px;
}

p, li {
  color: var(--muted);
}

a {
  color: var(--text);
}

strong {
  color: var(--text);
  font-weight: 700;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

.container-narrow {
  max-width: 760px;
}

/* ------------------------------------------------------------ app chrome */

.svg-defs {
  position: absolute;
  overflow: hidden;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 8px 20px;
  background: rgba(5, 5, 5, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid #171717;
}

.nav-logo-link {
  display: inline-flex;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-wordmark {
  color: #ffffff;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1;
}

.tabs {
  display: flex;
  gap: 2px;
  min-width: 0;
}

.tab {
  position: relative;
  border: 0;
  border-radius: 10px;
  min-height: 36px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tab:hover:not(:disabled) {
  color: var(--text);
  background: #111;
}

.tab.is-active {
  color: #ffffff;
  background: #161616;
}

.tab.is-active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -9px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand-blue);
}

.tab:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tab:focus-visible,
.btn:focus-visible,
.chip-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.tab-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--brand-blue);
  vertical-align: 2px;
  box-shadow: 0 0 0 3px rgba(7, 141, 251, 0.18);
}

.device-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 4px 4px 4px 12px;
  border: 1px solid #222;
  border-radius: 999px;
  background: #0b0b0b;
  font-size: 12px;
  color: var(--muted);
}

.device-chip b {
  color: var(--text);
  font-weight: 650;
}

.device-chip-state {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  font-weight: 600;
}

.device-chip-mac {
  display: none;
}

#stripBattery.is-low {
  color: var(--danger);
  font-weight: 700;
}

.chip-btn {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  background: #1a1a1a;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip-btn:hover {
  background: #262626;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--brand-blue);
  cursor: pointer;
  text-decoration: underline;
  text-align: left;
}

/* Page heading, the update site's hero: kicker, headline, one line of why. */
.page-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 0 22px;
}

.page-hero-center {
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 24px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--brand-blue);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.1;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.lede {
  margin: 0;
  font-size: 17px;
  line-height: 1.45;
  max-width: 40em;
}

.page-hero-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.needs {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.needs li {
  padding: 6px 12px;
  border: 1px solid #262626;
  border-radius: 999px;
  background: #0b0b0b;
  color: #dcdcdc;
  font-size: 14px;
}

.alert {
  margin: 18px auto 0;
  max-width: 36rem;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.45;
}

.alert-error {
  border: 1px solid rgba(255, 90, 82, 0.6);
  background: rgba(255, 90, 82, 0.12);
  color: #ffd9d6;
}

/* Green when frames are arriving, amber when the stream has gone quiet. */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #444;
  margin-right: 5px;
  vertical-align: middle;
}

.dot.is-live { background: var(--ok); box-shadow: 0 0 6px rgba(109, 206, 138, 0.8); }
.dot.is-stale { background: var(--warn); }
.dot.is-down { background: var(--err); }

/* ----------------------------------------------------------------- cards */

.card {
  padding: 20px;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.card-accent {
  border-color: var(--border-accent);
}

.card-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-head h2 {
  font-size: 21px;
  line-height: 1.25;
  margin: 0;
  color: #ffffff;
}

.head-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-desc {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.step-label {
  margin: 0;
  color: var(--brand-blue);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.instruction-card,
.action-card {
  padding: 20px;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: var(--card);
}

.action-card {
  border-color: var(--border-accent);
}

.tiny {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.latest {
  color: var(--brand-blue);
  font-weight: 700;
}

.steps {
  margin: 8px 0 0 18px;
}

/* ---------------------------------------------------------- form control */

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

textarea,
select,
input[type="text"],
input[type="number"] {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}

textarea {
  min-height: 200px;
  resize: vertical;
  line-height: 1.45;
}

textarea:focus,
select:focus,
input:focus {
  outline: 2px solid rgba(7, 141, 251, 0.55);
  outline-offset: 1px;
}

input.is-invalid {
  border-color: var(--err);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid #3a3a3a;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  background: #1a1a1a;
  color: #ffffff;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover:not(:disabled) {
  background: #2b2b2b;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  border: none;
  background-color: var(--brand-blue);
  color: #fff;
  font-weight: 700;
  padding: 10px 22px;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  background-color: var(--brand-blue);
  box-shadow: none;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 1;
  color: #7a7a7a;
  background-color: #1a1a1a;
}

/* The update site's big action: Connect, Update, Done. */
.btn-xl {
  width: 100%;
  min-height: 54px;
  padding: 14px 28px;
  border-radius: 14px;
  font-size: 18px;
}

.btn-danger {
  border-color: rgba(255, 90, 82, 0.45);
  background: rgba(255, 90, 82, 0.08);
  color: #ffd9d6;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(255, 90, 82, 0.16);
}

.btn-ghost {
  border-color: #2e2e2e;
  background: transparent;
  font-weight: 600;
}

.btn-ghost.is-current {
  border-color: rgba(7, 141, 251, 0.7);
  background: rgba(7, 141, 251, 0.12);
  color: #d9efff;
}

.btn-sm {
  min-height: 34px;
  padding: 6px 14px;
  font-size: 13px;
}

.connect-btn {
  position: relative;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 30px;
  color: #fff;
  background-color: var(--cta);
  border: none;
  border-radius: 9999px;
  font-family: inherit;
}

.connect-btn:hover:not(:disabled) {
  filter: brightness(1.06);
}

.connect-btn:disabled {
  color: rgba(0, 0, 0, 0.38);
  background-color: rgba(0, 0, 0, 0.12);
  cursor: not-allowed;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.row-actions-end {
  justify-content: flex-end;
}

.status-line {
  min-height: 1.25em;
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.status-ok { color: var(--ok); }
.status-err { color: var(--err); }
.status-warn { color: var(--warn); }

.meta-line {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.port-token {
  display: inline-block;
  padding: 0.12em 0.45em;
  border-radius: 999px;
  border: 1px solid rgba(7, 141, 251, 0.7);
  background: rgba(7, 141, 251, 0.16);
  color: #d9efff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
  font-weight: 700;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #2a2a2a;
  background: #111;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.badge-active {
  border-color: rgba(7, 141, 251, 0.7);
  background: rgba(7, 141, 251, 0.16);
  color: #d9efff;
}

.badge-ok { border-color: #2c4c36; background: #0d1a11; color: var(--ok); }
.badge-warn { border-color: #4c4423; background: #1a1708; color: var(--warn); }
.badge-err { border-color: #5a2020; background: #1a0c0c; color: var(--err); }

/* ------------------------------------------------------------------ gate */

.steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
  display: grid;
  gap: 14px;
}

.step-card {
  counter-increment: step;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: var(--card);
}

.step-card::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #2e2e2e;
  color: #ffffff;
  font-size: 19px;
  font-weight: 800;
}

.step-card.is-active::before {
  border-color: var(--brand-blue);
  background: var(--brand-blue);
}

.step-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding-top: 8px;
}

.step-body h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.25;
  color: #ffffff;
}

.step-body p {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
}

.step-body .tiny {
  font-size: 13px;
}

/* Status in the update site's tinted box. Hidden while empty. */
.status-box {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  background: #0d0d0d;
  color: #e8e8e8 !important;
  font-size: 15px !important;
  line-height: 1.45;
}

.status-box:empty {
  display: none;
}

.status-box[data-tone="working"] {
  border-color: rgba(7, 141, 251, 0.5);
  background: rgba(7, 141, 251, 0.1);
  color: #d9efff !important;
}

.status-box[data-tone="success"] {
  border-color: rgba(52, 199, 89, 0.55);
  background: rgba(52, 199, 89, 0.12);
  color: #c8f5d3 !important;
  font-weight: 700;
}

.status-box[data-tone="warn"] {
  border-color: rgba(255, 214, 10, 0.5);
  background: rgba(255, 214, 10, 0.08);
  color: #fff3b8 !important;
}

.status-box[data-tone="error"] {
  border-color: rgba(255, 90, 82, 0.6);
  background: rgba(255, 90, 82, 0.12);
  color: #ffd9d6 !important;
}

.picker-hint {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.picker-example {
  margin: 0;
}

.picker-example img {
  display: block;
  width: 100%;
  max-width: 420px;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
}

.callout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 2px solid var(--attention);
  border-radius: 12px;
  background: rgba(255, 214, 10, 0.08);
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--attention) !important;
  font-size: 17px !important;
  font-weight: 800;
}

.callout-title::before {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--attention);
  color: #000000;
  font-size: 15px;
  font-weight: 900;
}

.orientation {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 14px 10px 10px;
  border-radius: 10px;
  background: #000;
}

.orientation-try {
  margin: 0;
  text-align: center;
}

.orientation-try svg {
  display: block;
  width: 100%;
  max-width: 220px;
  margin: 0 auto;
}

.orientation-try figcaption {
  margin-top: 6px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
}

.try-num {
  display: block;
  color: var(--brand-blue);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.orientation-flip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 80px;
  color: var(--attention);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.orientation-flip svg {
  width: 32px;
  height: 32px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
}

.feature {
  padding: 16px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: #060606;
}

.feature h3 {
  margin: 0 0 4px;
  color: #ffffff;
  font-size: 15px;
}

.feature p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.help-card {
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: var(--card);
}

.help-card h3 {
  margin: 18px 0 4px;
  font-size: 15px;
  color: #ffffff;
}

.help-card li {
  margin-bottom: 6px;
  line-height: 1.45;
}

/* Shown instead of a tab's content when the firmware is too old for it. */
.upgrade-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 24px;
  border: 1px solid rgba(7, 141, 251, 0.45);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(7, 141, 251, 0.09), rgba(7, 141, 251, 0.02));
  margin-bottom: 16px;
}

.upgrade-card h2 {
  margin: 0;
  font-size: 22px;
  color: #ffffff;
}

.upgrade-card p {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.upgrade-card .kicker {
  margin: 0;
}

/* -------------------------------------------------------------- live tab */

/* One column of cards, ordered the way the questions get asked: what do I
   dial, what happens at the target, what about every other range. */
.live-grid {
  display: grid;
  gap: 16px;
  align-items: start;
}

/* The dial is a mirror of the device, so it stays recognisable, but the holds
   moved out of it: on a laptop the answer should be readable across a room. */
.hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

.hero-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.hero-title {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-blue);
}

.holds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hold {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-deep);
  padding: 14px 16px;
  min-width: 0;
}

.hold-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.hold-value {
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.hold-value .elev { color: var(--shoot-elev); }
.hold-value .elev.is-negative { color: var(--shoot-elev-neg); }
.hold-value .wind { color: var(--shoot-wind); }
.hold-value .is-empty { color: #333; }

.hold-foot {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.hold-dir {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.facts li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-deep);
  font-size: 13px;
}

.facts .fact-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.facts .fact-value {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* 360x360 round LCD, scaled to fit narrow viewports. */
.dial {
  position: relative;
  width: 300px;
  height: 300px;
  max-width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #000;
  border: 6px solid #101010;
  box-shadow: 0 0 0 1px #262626, 0 18px 48px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  flex: none;
}

.dial-arc {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.dial-profile {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 240px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid #2a2a2a;
  background: #0b0b0b;
  font-size: 11px;
  font-weight: 650;
  color: #d9d9d9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The holds used to sit below this; with them promoted out of the dial the
   range gets the middle of the face to itself. */
.dial-range-wrap {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  text-align: center;
}

.dial-caption {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: #8a8a8a;
  text-transform: uppercase;
}

.dial-range {
  font-size: 54px;
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--band-super);
}

.dial-range-unit {
  font-size: 14px;
  color: #8a8a8a;
  margin-left: 2px;
}

.dial-band {
  min-height: 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.dial-wind {
  position: absolute;
  bottom: 40px;
  left: 0;
  right: 0;
  text-align: center;
}

.dial-wind-speed {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dial-wind-heading {
  font-size: 12px;
  color: #8a8a8a;
  font-variant-numeric: tabular-nums;
}

.dial-note {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 0 40px;
}

/* Sits inside a chart card next to the real charts, so it borrows their height
   and lets the card supply the frame. */
.sparkline {
  width: 100%;
  height: 150px;
  border-radius: 10px;
  background: var(--panel-deep);
}

/* Downrange facts as tiles rather than a key/value list, so no single number
   has to be hunted for and the label can carry a plain-language hint. */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-deep);
  padding: 10px 12px;
  min-width: 0;
}

.stat-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.stat-value .unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 3px;
}

.stat-hint {
  font-size: 11px;
  color: var(--muted);
}

/* Sentences, not a table: each line is a whole thought about one mistake. */
.cost-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cost-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-deep);
  font-size: 13px;
}

.cost-what {
  color: var(--text);
  min-width: 0;
}

.cost-much {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cost-much.is-muted {
  font-weight: 400;
  color: var(--muted);
}

.bands-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.bands-row h3 {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-blue);
}

.bands-row .kv {
  max-width: 340px;
}

.info-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-card h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-blue);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ------------------------------------------------------------- charts */

.live-charts {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-items: start;
  margin-top: 12px;
}

/* Collapsible reference rows. The summary line is written to be worth reading
   on its own, so the panel only has to be opened to chase a specific number. */
.live-folds {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.fold {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}

.fold > summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  list-style: none;
}

.fold > summary::-webkit-details-marker {
  display: none;
}

.fold > summary:hover {
  background: var(--panel-deep);
}

.fold-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-blue);
  white-space: nowrap;
}

.fold-title::before {
  content: "\25B8";
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.fold[open] > summary .fold-title::before {
  transform: rotate(90deg);
}

.fold-sum {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fold > summary + * {
  padding: 0 14px 12px;
}

.fold-empty {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.chart {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  background: var(--panel-deep);
}

.chart-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: none;
  letter-spacing: normal;
}

.chart-actions select {
  padding: 3px 6px;
  font-size: 12px;
  width: auto;
  margin: 0;
}

.chart-label {
  font-size: 11px;
  color: var(--muted);
}

.tiny.is-warn {
  color: var(--band-trans);
}

/* ---------------------------------------------------- compare profiles */

.compare-slots {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px 6px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.compare-chip.is-on {
  border-color: var(--brand-blue);
  background: var(--panel-deep);
}

.compare-chip input {
  width: auto;
  margin: 0;
  accent-color: var(--brand-blue);
}

.compare-chip:has(input:disabled) {
  opacity: 0.45;
  cursor: not-allowed;
}

.compare-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.compare-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 12px 0;
}

.compare-controls .field {
  margin: 0;
  min-width: 150px;
}

.compare-controls .row-actions {
  margin-left: auto;
}

.dope-details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--brand-blue);
}

.dope-tools {
  display: flex;
  justify-content: flex-end;
  margin: 8px 0;
}

.kv {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  font-size: 13px;
}

.kv dt {
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kv dd {
  margin: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 600;
}

.kv dd.is-muted {
  color: var(--muted);
  font-weight: 400;
}

/* ---------------------------------------------------------- profiles tab */

/* Slot list on the left, the thing you picked on the right. Shared by the
   Profiles and COF tabs so the two read the same way. */
.split-layout {
  display: grid;
  /* Wide enough for a profile name to sit beside its "In use" badge. */
  grid-template-columns: minmax(0, 290px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.slot-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* [#n] [name] [badge]
   [  ] [------ detail ------]
   A grid rather than a flex row so the detail line gets the full width instead
   of whatever the "In use" badge leaves behind. */
.slot-btn {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1px 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-deep);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.slot-btn:hover:not(:disabled) {
  border-color: #333;
}

.slot-btn.is-selected {
  border-color: var(--brand-blue);
  background: rgba(7, 141, 251, 0.1);
}

.slot-btn.is-empty {
  color: var(--muted);
  border-style: dashed;
}

.slot-num {
  grid-row: 1;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 700;
  min-width: 1.6em;
}

.slot-name {
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-btn > .badge {
  grid-row: 1;
}

/* Second line: enough of the load, or of the stage, to tell two rows apart
   without opening both. Spans to the right edge under the name. */
.slot-sub {
  grid-row: 2;
  grid-column: 2 / -1;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-deep);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-section > h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-blue);
}

/* A form section that stays shut until it has something in it. Same box as
   .form-section so the open state does not look like a different control. */
.form-fold {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-deep);
}

.form-fold > summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  list-style: none;
}

.form-fold > summary::-webkit-details-marker {
  display: none;
}

.form-fold > summary:hover {
  background: var(--panel);
}

.form-fold-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-blue);
  white-space: nowrap;
}

.form-fold-title::before {
  content: "\25B8";
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.form-fold[open] > summary .form-fold-title::before {
  transform: rotate(90deg);
}

.form-fold-sum {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-fold > summary ~ * {
  margin: 0 14px 12px;
}

/* Same trick for a whole card: the title stays visible, the body only unfolds
   when the occasional job it does is the job at hand. */
.card-summary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.card-summary::-webkit-details-marker {
  display: none;
}

.card-summary h2 {
  font-size: 1.25rem;
  margin: 0;
}

.card-summary h2::before {
  content: "\25B8";
  display: inline-block;
  margin-right: 10px;
  font-size: 0.8em;
  color: var(--muted);
  transition: transform 0.15s ease;
}

details[open] > .card-summary h2::before {
  transform: rotate(90deg);
}

.card-summary-hint {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The action row reads as a footer to the form rather than another section. */
.save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.save-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 12px;
}

.field label {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.field-hint {
  margin: 3px 0 0;
  font-size: 11px;
  color: #7a7a7a;
}

.field-error {
  margin: 3px 0 0;
  font-size: 11px;
  color: var(--err);
}

.mv-temp-rows {
  display: grid;
  gap: 8px;
}

.mv-temp-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}

.icon-btn {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #333;
  background: #121212;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  font-family: inherit;
}

.icon-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: #555;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.switch-row label {
  margin: 0;
  font-weight: 600;
}

.preview-empty {
  padding: 28px 12px;
  text-align: center;
  border: 1px dashed #2a2a2a;
  border-radius: 10px;
  color: var(--muted);
}

/* --------------------------------------------------------------- tables */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-blue);
  font-weight: 700;
  padding: 0 8px 8px 0;
}

/* Lets an ambiguous column say what it means without a legend elsewhere. */
.th-hint {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.data-table td {
  padding: 5px 8px 5px 0;
  vertical-align: middle;
  border-top: 1px solid #141414;
}

.data-table tr.is-invalid td {
  background: rgba(255, 143, 143, 0.06);
}

.table-scroll {
  max-height: 320px;
  overflow: auto;
}

/* ------------------------------------------------------------- cof tab */

.input-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 10px;
  background: #0a0a0a;
  border: 1px solid #1a1a1a;
}

.input-tab {
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
}

.input-tab.is-active {
  background: #1a1a1a;
  color: var(--text);
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 160px;
  padding: 24px 16px;
  border: 1px dashed #3a3a3a;
  border-radius: 12px;
  background: #080808;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: rgba(7, 141, 251, 0.7);
  background: #0a1016;
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-title {
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
}

.dropzone-sub {
  color: var(--muted);
  font-size: 13px;
}

.dropzone-file {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(7, 141, 251, 0.45);
  background: rgba(7, 141, 251, 0.12);
  color: #d9efff;
  font-size: 12px;
  font-weight: 650;
}

.json-details {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-deep);
  padding: 12px 14px;
}

.json-details summary,
.help-card details summary,
.troubleshooting-card summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--text);
  font-size: 14px;
}

.json-details pre {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: #0a0a0a;
  border: 1px solid #1a1a1a;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
  color: #d9efff;
  max-height: 280px;
}

.help-list {
  margin: 12px 0 0;
  padding-left: 1.15em;
  display: grid;
  gap: 10px;
}

.help-list li {
  font-size: 14px;
  line-height: 1.45;
}

/* ------------------------------------------------------------ update tab */

.install-wrap {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.install-button-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}

/* esp-web-tools' generic dialog says nothing useful; the tab shows device-specific text. */
ewt-no-port-picked-dialog {
  display: none !important;
}

.update-banner {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  background: #0d0d0d;
  color: #e8e8e8;
  font-size: 15px;
  text-align: center;
}

.update-banner.is-available {
  border-color: rgba(7, 141, 251, 0.5);
  background: rgba(7, 141, 251, 0.1);
  color: #d9efff;
  font-weight: 650;
}

.update-banner.is-current {
  border-color: rgba(52, 199, 89, 0.55);
  background: rgba(52, 199, 89, 0.1);
  color: #c8f5d3;
}

.update-banner.is-recovery {
  border-color: rgba(255, 214, 10, 0.5);
  background: rgba(255, 214, 10, 0.08);
  color: #fff3b8;
}

.release {
  border-top: 1px solid #141414;
  padding-top: 12px;
}

.release + .release {
  margin-top: 12px;
}

.release-new .release-version {
  color: var(--brand-blue);
}

.release:first-child {
  border-top: 0;
  padding-top: 0;
}

.release-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.release-version {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.release-date {
  font-size: 12px;
  color: #7a7a7a;
}

.release ul {
  margin: 8px 0 0;
  padding-left: 1.15em;
  display: grid;
  gap: 5px;
}

.release li {
  font-size: 13px;
  line-height: 1.45;
}

.changelog-history {
  margin-top: 14px;
}

/* ---------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .split-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Stack the dial above the holds rather than shrinking both. */
  .hero {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }

  .hero-main {
    width: 100%;
  }

  .dial {
    width: min(300px, 88vw);
    height: auto;
  }
}

@media (max-width: 720px) {
  .row-actions-end {
    justify-content: stretch;
  }

  .row-actions-end .btn {
    flex: 1;
  }
}

/* ------------------------------------------------------- shared helpers */

.sr-only,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--brand-blue);
  flex-shrink: 0;
}

.card.is-muted,
.card.is-disabled {
  opacity: 0.75;
}

/* ------------------------------------------------------ matches: device */

.course-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.course-list:empty {
  display: none;
}

.course-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #1c1c1c;
  border-radius: 12px;
  background: #0b0b0b;
}

.course-row.is-editing {
  border-color: rgba(7, 141, 251, 0.6);
  background: rgba(7, 141, 251, 0.06);
}

.course-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.course-name {
  color: #ffffff;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-sub {
  color: var(--muted);
  font-size: 13px;
}

.course-row .row-actions {
  flex-shrink: 0;
  flex-wrap: nowrap;
}

/* --------------------------------------------------------------- settings */

.settings-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.settings-sections .card {
  margin-bottom: 0;
}

#settingsBody {
  margin-bottom: 16px;
}

#settingsStatus {
  margin-bottom: 16px;
}

.setting-list {
  display: flex;
  flex-direction: column;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid #151515;
}

.setting-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.setting-text {
  flex: 1 1 auto;
  min-width: 0;
}

.setting-text label {
  margin: 0;
  font-weight: 600;
}

.setting-text .field-hint {
  margin: 3px 0 0;
}

.setting-row select {
  width: auto;
  min-width: 150px;
}

.number-with-suffix {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.number-with-suffix input {
  width: 84px;
  text-align: right;
}

/* iOS-style switch on a native checkbox, so keyboard and screen readers just work. */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 28px;
  margin: 0;
  border-radius: 999px;
  background: #2a2a2a;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

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

.switch:checked {
  background: var(--brand-blue);
}

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

.switch:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.segmented {
  display: inline-flex;
  flex-shrink: 0;
  padding: 3px;
  border-radius: 10px;
  background: #0d0d0d;
  border: 1px solid #222;
}

.segmented button {
  border: 0;
  border-radius: 8px;
  padding: 6px 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

.segmented button[aria-checked="true"] {
  background: var(--brand-blue);
  color: #ffffff;
}

.segmented button:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 1px;
}

.restore-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid #222;
  border-radius: 12px;
  background: #0b0b0b;
}

.restore-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 0;
  padding: 0;
  border: 0;
}

/* ----------------------------------------------------------------- truing */

.true-result {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.true-figure {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.true-label {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.true-before {
  color: var(--muted);
  font-size: 22px;
  font-weight: 700;
  text-decoration: line-through;
  text-decoration-color: #555;
}

.true-arrow {
  color: var(--muted);
  font-size: 20px;
}

.true-after {
  color: var(--shoot-elev);
  font-size: 30px;
  font-weight: 800;
}

.data-table tr.is-current td {
  background: rgba(7, 141, 251, 0.1);
  color: #ffffff;
}

/* ----------------------------------------------------------------- update */

.done-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 32px 20px;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: var(--card);
  text-align: center;
}

.done-panel h2 {
  margin: 4px 0 0;
  font-size: 26px;
  color: #ffffff;
}

.done-panel p {
  margin: 0;
  font-size: 16px;
}

.done-panel .btn-xl {
  max-width: 320px;
  margin-top: 8px;
}

.done-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success);
  color: #000000;
  font-size: 34px;
  font-weight: 900;
}

.install-wrap .btn-xl {
  flex: 1;
}

.version-pick {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.version-pick summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.version-pick details[open] summary {
  margin-bottom: 10px;
}

.version-pick .tiny {
  margin: 8px 0 0;
}

/* ------------------------------------------------------------------ modal */

.modal {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid #262626;
  border-radius: 16px;
  background: #0a0a0a;
  color: var(--text);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
}

.modal-body h2 {
  margin: 0;
  color: #ffffff;
}

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  transform: translate(-50%, 12px);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(52, 199, 89, 0.55);
  background: #0d1a11;
  color: #c8f5d3;
  font-size: 14px;
  font-weight: 650;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
}

.toast.is-in {
  animation: toast-in 0.18s ease-out forwards;
}

@keyframes toast-in {
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast.is-in {
    animation: none;
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* --------------------------------------------------------- connect screen */

/* One picture, one sentence. The picture follows data-state on the card:
   first/plug (cable easing in), connecting, flip (cable turning over), error. */
.gate {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 140px);
  padding: 24px 16px 48px;
}

.gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 460px;
  text-align: center;
}

.gate-art {
  width: min(300px, 76vw);
  height: auto;
  overflow: visible;
}

.gate-title {
  margin: 4px 0 0;
  font-size: clamp(26px, 5vw, 34px);
  line-height: 1.15;
}

.gate-lede {
  max-width: 380px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.gate-status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.gate-status.status-err {
  color: #ff6b6b;
}

.gate-status.status-warn {
  color: #f2a93b;
}

.gate-help {
  max-width: 380px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
  text-align: left;
}

.gate-help summary {
  cursor: pointer;
  text-align: center;
}

.gate-help ul {
  margin: 10px 0 0;
  padding-left: 18px;
  line-height: 1.5;
}

.ga-bezel {
  fill: #0b0b0b;
  stroke: #1f1f1f;
  stroke-width: 8;
}

.ga-screen {
  fill: #000;
}

.ga-ring {
  fill: none;
  stroke: #078dfb;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 70 30;
  transform: rotate(-215deg);
  transform-origin: 160px 118px;
  opacity: 0.9;
}

.ga-range {
  fill: #fff;
  font: 700 40px Inter, system-ui, sans-serif;
}

.ga-unit,
.ga-name {
  fill: #8a8a8a;
  font: 600 11px Inter, system-ui, sans-serif;
  letter-spacing: 0.16em;
}

.ga-socket {
  fill: #000;
  stroke: #3a3a3a;
  stroke-width: 2;
}

.ga-cord {
  fill: none;
  stroke: #3a3a3a;
  stroke-width: 12;
  stroke-linecap: round;
}

.ga-tip {
  fill: #9aa0a6;
}

.ga-head {
  fill: #d8d8d8;
}

.ga-mark {
  fill: #078dfb;
}

.ga-flip {
  fill: none;
  stroke: #f2a93b;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.ga-plug-move,
.ga-plug {
  transform-box: fill-box;
  transform-origin: center;
}

/* Plug in: the cable eases up into the socket and back. */
.gate-card[data-state="plug"] .ga-plug-move,
.gate-card[data-state="first"] .ga-plug-move {
  animation: ga-insert 2.6s ease-in-out infinite;
}

@keyframes ga-insert {
  0%,
  15% {
    transform: translateY(28px);
  }
  55%,
  85% {
    transform: translateY(-2px);
  }
  100% {
    transform: translateY(28px);
  }
}

/* Connecting: seated, and the ring sweeps. */
.gate-card[data-state="connecting"] .ga-plug-move {
  transform: translateY(-2px);
}

.gate-card[data-state="connecting"] .ga-ring {
  animation: ga-spin 1.1s linear infinite;
}

@keyframes ga-spin {
  to {
    transform: rotate(145deg);
  }
}

/* Flip: the cable comes out, turns over, and the arrows say so. */
.gate-card[data-state="flip"] .ga-plug-move {
  transform: translateY(30px);
}

.gate-card[data-state="flip"] .ga-plug {
  animation: ga-turn 2.2s ease-in-out infinite;
}

.gate-card[data-state="flip"] .ga-flip {
  opacity: 1;
}

.gate-card[data-state="flip"] .ga-ring {
  stroke: #f2a93b;
}

.gate-card[data-state="flip"] .ga-mark {
  fill: #f2a93b;
}

.gate-card[data-state="flip"] .gate-title {
  color: #f2a93b;
}

@keyframes ga-turn {
  0%,
  20% {
    transform: scaleX(1);
  }
  50%,
  70% {
    transform: scaleX(-1);
  }
  100% {
    transform: scaleX(1);
  }
}

.gate-card[data-state="error"] .ga-ring {
  stroke: #e5484d;
}

@media (prefers-reduced-motion: reduce) {
  .gate-card .ga-plug-move,
  .gate-card .ga-plug,
  .gate-card .ga-ring {
    animation: none !important;
  }
}

/* ----------------------------------------------------------- live screen */

/* The dial plus its live-screen controls, one column in the hero. */
.dial-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: none;
}

/* The device's own pixels, cropped by the dial's round frame. */
.dial-cast {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
}

.dial.is-casting > :not(.dial-cast) {
  visibility: hidden;
}

/* Room for the panel at exactly 1x (2x on Retina), so the browser never
   rescales it again: 360 px inside the 6 px frame. */
.dial.is-casting {
  box-sizing: border-box;
  width: min(372px, 92vw);
  height: auto;
  aspect-ratio: 1;
}

.dial-cast {
  margin: auto;
}

.cast-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 372px;
  max-width: 100%;
}

.cast-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.cast-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 18px;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.cast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555;
  flex: none;
}

.cast-dot.is-on {
  background: #46a758;
}

.cast-dot.is-warn {
  background: #f2a93b;
}

.cast-dot.is-rec {
  background: #e5484d;
  animation: cast-blink 1s infinite;
}

@keyframes cast-blink {
  50% {
    opacity: 0.3;
  }
}

.cast-rec-time {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-deep);
}

.seg-btn {
  padding: 5px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.seg-btn.is-active {
  background: #078dfb;
  color: #fff;
}

.cast-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.cast-actions select {
  font-size: 12px;
}

#castRecord.is-recording {
  border-color: #e5484d;
  color: #e5484d;
}

#rcDialog .field-wide {
  grid-column: 1 / -1;
}

@media (prefers-reduced-motion: reduce) {
  .cast-dot.is-rec {
    animation: none;
  }
}

/* ------------------------------------------------------------ range card */

@media print {
  .rc-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8pt 10pt;
  }

  .sheet-wrist .rc-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 4pt 6pt;
  }

  .rc-stage {
    break-inside: avoid;
  }

  .rc-stage-head {
    margin: 0 0 2pt;
    font-size: 9pt;
    font-weight: 800;
  }

  .rc-stage-head span {
    font-weight: 500;
    color: #444;
  }

  .rc-table {
    font-size: 9pt;
  }

  .sheet-wrist .rc-table {
    font-size: 7.5pt;
  }

  .sheet-wrist .rc-table th,
  .sheet-wrist .rc-table td {
    padding: 1pt 2pt;
  }
}

/* ------------------------------------------------------------- dope card */

.print-sheet {
  display: none;
}

@media print {
  body.is-printing > *:not(#printSheet) {
    display: none !important;
  }

  body.is-printing {
    background: #ffffff;
  }

  body.is-printing .print-sheet {
    display: block;
    color: #000;
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  }

  .sheet-head {
    margin-bottom: 6pt;
  }

  .sheet-title {
    font-size: 15pt;
    font-weight: 800;
  }

  .sheet-sub {
    font-size: 8.5pt;
    color: #333;
  }

  .sheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
    font-variant-numeric: tabular-nums;
  }

  .sheet-table th,
  .sheet-table td {
    padding: 2.5pt 5pt;
    border-bottom: 0.5pt solid #bbb;
    text-align: right;
  }

  .sheet-table th:first-child,
  .sheet-table td:first-child {
    text-align: left;
    font-weight: 700;
  }

  .sheet-table thead th {
    border-bottom: 1pt solid #000;
    font-size: 8.5pt;
    text-transform: uppercase;
  }

  .sheet-table tr.is-trans td,
  .key-trans {
    background: #fff4b3;
  }

  .sheet-table tr.is-sub td,
  .key-sub {
    background: #ffd0cc;
  }

  .sheet-table tr {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .sheet-key i {
    display: inline-block;
    width: 8pt;
    height: 8pt;
    margin: 0 2pt 0 6pt;
    border: 0.5pt solid #999;
    vertical-align: -1pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .sheet-foot {
    margin-top: 6pt;
    font-size: 7pt;
    color: #444;
    line-height: 1.35;
  }

  .sheet-wrist .sheet-title {
    font-size: 11pt;
  }

  .sheet-wrist .sheet-table {
    font-size: 8pt;
  }

  .sheet-wrist .sheet-table th,
  .sheet-wrist .sheet-table td {
    padding: 1pt 3pt;
  }

  .sheet-wrist .sheet-foot {
    display: none;
  }

  /* A narrow column to cut out and tape to a scope cap or stock. */
  .sheet-strip {
    width: 1.6in;
    padding: 4pt;
    border: 0.75pt dashed #888;
  }

  .sheet-strip .sheet-title {
    font-size: 9pt;
  }

  .sheet-strip .sheet-sub,
  .sheet-strip .sheet-foot {
    display: none;
  }

  .sheet-strip .sheet-table {
    font-size: 8pt;
  }

  .sheet-strip .sheet-table th,
  .sheet-strip .sheet-table td {
    padding: 1pt 2pt;
  }
}

/* ------------------------------------------------------- logo + side nav */

.nav-logo-link {
  align-items: baseline;
  gap: 0.5em;
}

/* Same lettering as the wordmark, in brand blue. */
.nav-connect {
  color: var(--brand-blue);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1;
}

/* The menu is a vertical tab list down the left of the app. */
#app:not(.hidden) {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 8px;
  max-width: 1360px;
  margin: 0 auto;
  padding-left: 16px;
}

#app > .container {
  width: 100%;
}

.tabs {
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 68px;
  align-self: start;
  margin-top: 34px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
}

.tab {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 11px;
  text-align: left;
  font-size: 15px;
}

.tab-icon {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.tab.is-active {
  color: var(--brand-blue);
  background: rgba(7, 141, 251, 0.13);
  box-shadow: inset 3px 0 0 var(--brand-blue);
}

.tab.is-active:hover:not(:disabled) {
  color: var(--brand-blue);
  background: rgba(7, 141, 251, 0.18);
}

.tab.is-active .tab-icon {
  opacity: 1;
}

.tab.is-active::after {
  content: none;
}

.tab .tab-dot {
  margin-left: auto;
}

/* ---------------------------------------------------------- page sections */

/* Every page: title, a row of section tabs, a one-line note, then the section. */
[data-subhidden] {
  display: none !important;
}

.subtabs {
  display: flex;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin: -4px 0 14px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  overflow-x: auto;
  scrollbar-width: none;
}

.subtabs::-webkit-scrollbar {
  display: none;
}

.subtab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.subtab:hover {
  color: var(--text);
  background: #111;
}

.subtab.is-active,
.subtab.is-active:hover {
  color: #ffffff;
  background: #1b1b1b;
  box-shadow: inset 0 -2px 0 var(--brand-blue);
}

.subtab:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.section-note {
  max-width: 46em;
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.5;
}

/* An old firmware notice takes the page; section tabs would lead nowhere. */
.upgrade-card:not(.hidden) ~ .subtabs,
.upgrade-card:not(.hidden) ~ .section-note {
  display: none;
}

#compareCard:not(.hidden) ~ .compare-empty {
  display: none;
}

.compare-empty {
  margin: 0;
  font-size: 15px;
}

/* Firmware update is the third section of Settings. While an install or a
   repair holds the screen, there is nowhere else to go. */
.is-locked #panel-update .subtabs {
  display: none;
}

#panel-update > .card,
#panel-update > .done-panel,
#panel-update > .update-banner {
  max-width: 760px;
}

/* ---------------------------------------------------- header responsive */

@media (max-width: 1080px) {
  .device-chip-state #stripState {
    display: none;
  }
}

@media (max-width: 900px) {
  .settings-sections {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .site-header {
    padding: 8px 12px;
  }

  .device-chip {
    margin-left: auto;
  }

  /* No room for a side column: the tab list becomes a row under the header
     that scrolls sideways rather than wrapping. */
  #app:not(.hidden) {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-left: 0;
  }

  .tabs {
    flex-direction: row;
    top: 52px;
    z-index: 90;
    margin: 0;
    padding: 6px 8px;
    border-width: 0 0 1px;
    border-color: #171717;
    border-radius: 0;
    background: rgba(5, 5, 5, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    width: auto;
    flex-shrink: 0;
    min-height: 38px;
    gap: 8px;
    padding: 0 12px;
    font-size: 14px;
  }

  .tab.is-active {
    box-shadow: inset 0 -2px 0 var(--brand-blue);
  }

  .page-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-hero-center {
    align-items: center;
  }
}

@media (max-width: 560px) {
  .step-card {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 16px;
  }

  .step-card::before {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .step-body {
    padding-top: 0;
  }

  .orientation {
    grid-template-columns: 1fr;
  }

  .orientation-flip {
    flex-direction: row;
    max-width: none;
    justify-content: center;
  }

  .feature-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Switches stay beside their label; wider controls drop underneath. */
  .setting-row:has(select),
  .setting-row:has(.segmented) {
    flex-wrap: wrap;
  }

  .course-row {
    flex-direction: column;
    align-items: stretch;
  }

  .device-chip-meta:first-of-type {
    display: none;
  }
}

#panel-update {
  margin-inline: 0;
}
