:root {
  --bg: 242 242 247;
  --text: 17 17 17;
  --accent: #0E7AFE;
  --accent-dark: #1364C4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: 15 17 21;
    --text: 234 234 234;
  }
}

body {
  margin: 0;
  background: rgb(var(--bg));
  color: rgb(var(--text));
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  padding: 1rem;
  line-height: 1.3;
  max-width: 580px;
  margin-inline: auto;
  min-height: 100vh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

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

#pageRoot {
  position: relative;
  /* Slightly lift the whole layout when header is stacked (default).
     Use relative positioning (top) so fixed-position modals still cover the full viewport
     and the lift does not affect flex centering/layout calculations. */
  top: -18px;
}

#pageFadeOverlay {
  position: absolute;
  inset: 0;
  background: rgb(var(--bg));
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.65s ease-out;
}

.header {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 0.8rem;
}

.header-logo img {
  height: 104px !important;
  width: auto;
  max-width: 100%;
  display: block;
}

.header-text {
  margin-top: 1.1rem;
}

.fw-version {
  font-size: 1.1rem;
  text-align: center;
  white-space: nowrap;
}

h1 {
  margin-top: 0rem;
  margin-bottom: 0.2rem;
  font-size: 2rem;
  text-align: center;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.flasher-card {
  background: #ffffff;
  border-radius: 28px;
  padding: 1rem;
  margin-top: 1.5rem;
  border: none;
  box-sizing: border-box;
}

.flasher-card.progress-card {
  display: block;
  padding-bottom: 1rem;
  margin-top: 1rem; /* war inline */
}

@media (prefers-color-scheme: dark) {
  .flasher-card {
    background: rgb(28, 28, 30);
    border: none;
  }
}

ol {
  list-style: none;
  counter-reset: step;
  padding-left: 0;
  margin: 0 0 1.1rem 0;
  list-style-position: inside;
  color: rgb(var(--text));
}

ol li {
  counter-increment: step;
  position: relative;
  margin: 0 0 1rem 0;
  padding-left: 2.1rem;
  padding-top: 0.08rem;
  font-size: 1.1rem;
}

ol li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background-color: #1364C4;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 0.5px;
}

.lts-btn {
  padding: 0.85rem 1.5rem;
  border-radius: 14px;
  background-color: #1a1a1a;
  color: #fff !important;
  border: none;
  font-size: 1.1rem;
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  text-align: center;
  display: block;
}

.lts-btn:disabled {
  background-color: #1a1a1a;
  opacity: 0.6;
  cursor: not-allowed;
}

#flashBtn {
  background-color: #0E7AFE;
  width: auto;
  display: inline-block;
}

#flashBtn:disabled {
  background-color: #1364C4;
  opacity: 0.6;
}

@media (prefers-color-scheme: dark) {
  #flashBtn {
    background-color: #0E7AFE;
    color: #fff !important;
  }

  #flashBtn:disabled {
    background-color: #1364C4;
    color: #fff !important;
    opacity: 0.6;
  }

  #connectBtn {
    background-color: rgb(var(--text));
    color: #000 !important;
  }

  #connectBtn:disabled {
    background-color: rgba(234, 234, 234, 0.7);
    color: #000 !important;
  }
}

@media (prefers-color-scheme: dark) {
  /* Browser not supported overlay: match Connect Respooler button styling */
  #notSupHaveLookBtn,
  #notSupHaveLookBtn:hover,
  #notSupHaveLookBtn:active {
    background: rgb(var(--text)) !important;
    color: #000000 !important;
    border: none !important;
    box-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
    text-decoration: none;
  }

  #notSupHaveLookBtn:disabled {
    background: rgba(234, 234, 234, 0.7) !important;
    color: #000000 !important;
  }
}

.note {
  color: #ff8c28;
  font-size: 1.1rem;
  margin-top: 0.55rem;
  text-align: center;
}

.progress-wrapper {
  font-size: 1.1rem;
  margin-top: -0.09rem;
  padding-right: 0.27rem;
}

.progress-label {
  text-align: left;
}

.progress-label a {
  color: #0E7AFE;
  text-decoration: underline;
}

.progress-label a:visited {
  color: #0E7AFE;
}

.progress-label a:hover,
.progress-label a:active {
  color: #0E7AFE;
}

.progress-track {
  position: relative;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.progress-bar {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: 0;
  background: #0E7AFE;
  transition: width 0.35s ease-out, background-color 0.35s ease;
}

.progress-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0;
  margin-bottom: 0.4rem;
}

.progress-percent {
  font-size: 1.1rem;
  text-align: right;
  opacity: 1;
}

@media (prefers-color-scheme: dark) {
  .progress-track {
    background: rgba(255, 255, 255, 0.08);
  }
}

.flash-row {
  display: flex;
  align-items: center;
  margin-top: 0;
}

.flash-col-button {
  flex: 0 0 auto;
  min-width: 0;
}

.flash-col-progress {
  flex: 1 1 auto;
  min-width: 0;
}

.flash-divider {
  width: 1px;
  align-self: stretch;
  background: #d1d5db;
  margin: 0 0.8rem;
}

@media (prefers-color-scheme: dark) {
  .flash-divider {
    background: rgba(255, 255, 255, 0.18);
  }
}

.section-divider {
  border: 0;
  border-top: 1px solid #d1d5db;
}

@media (prefers-color-scheme: dark) {
  .section-divider {
    border-top-color: rgba(255, 255, 255, 0.18);
  }
}

.segmented {
  display: flex;
  padding: 0.2rem;
  background: #e5e7eb;
  border-radius: 14px;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  margin-top: 0.8rem;
}

#variantSegment {
  margin-top: 0.65rem; /* war inline */
}

.segmented.is-disabled {
  opacity: 0.6;
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  .segmented {
    background: rgba(255, 255, 255, 0.08);
  }
}

.seg-indicator {
  position: absolute;
  top: 0.25rem;
  left: 0.25rem;
  height: calc(100% - 0.5rem);
  width: calc(50% - 0.25rem);
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  transform: translateX(0%);
  transition: transform 0.25s ease;
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  .seg-indicator {
    background: rgba(255, 255, 255, 0.14);
  }
}

.seg-btn {
  flex: 1 1 0;
  padding: 0.4rem 0.9rem;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  color: rgb(var(--text));
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.seg-btn.is-selected {
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .seg-btn.is-selected {
    font-weight: 600;
  }
}

.seg-btn:focus,
.lts-btn:focus {
  outline: none;
}

/* was inline */
.connect-row {
  margin-top: 0.8rem;
}

/* footer (war inline styles) */
.page-footer {
  text-align: center;
  margin-top: 2rem;
  margin-bottom: 2rem;
  font-size: 1rem;
  color: rgb(var(--text));
}

.page-footer a {
  color: rgb(var(--text));
  text-decoration: underline;
}

.page-footer-links {
  margin-top: 0.6rem;
}

.page-footer-links .github-link {
  margin-right: 1rem;
}

@media (max-width: 450px) {
  body {
    padding-left: 14px;
    padding-right: 14px;
  }

  h1 {
    font-size: 1.9rem;
  }

  .header-logo img {
    height: 86px !important;
    width: auto;
    max-width: 100%;
  }

  .fw-version {
    font-size: 1.0rem;
  }

  ol li {
    font-size: 1.0rem;
    padding-top: 0.15rem;
  }

  .lts-btn {
    font-size: 1.0rem;
  }

  .note {
    font-size: 1.0rem;
  }

  .progress-wrapper {
    font-size: 1.0rem;
  }

  .progress-percent {
    font-size: 1.0rem;
  }

  .seg-btn {
    font-size: 1.0rem;
  }
}

@media (max-height: 820px) {
  .header {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 2rem;
  }

  .header-logo img {
    height: 86px !important;
    width: auto;
    max-width: 45vw;
  }

  .header-text {
    margin-top: 0;
    text-align: left;
  }

  .header-text h1 {
    text-align: left;
  }

  .fw-version {
    text-align: left;
  }
}

@media (max-width: 400px) and (max-height: 820px) {
  .header {
    gap: 1rem;
  }
}

@media (max-width: 450px) and (max-height: 820px) {
  body {
    padding-left: 14px;
    padding-right: 14px;
  }

  .header-logo img {
    height: 74px !important;
    width: auto;
    max-width: 100%;
  }
}

/* When header is side-by-side (small height), don't lift the content. */
@media (max-height: 820px) {
  #pageRoot {
    top: 0;
  }
}

/* --- Modal base (shared) --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10000; /* above #pageFadeOverlay (9999) */
}

@media (prefers-color-scheme: dark) {
  .modal-backdrop {
    background: rgba(0,0,0,0.62);
  }
}

/* JS toggles: `backdrop.hidden = false` + `.is-open` */
.modal-backdrop.is-open {
  display: flex;
}

.modal {
  width: min(460px, 100%);
  background: #ffffff;
  border-radius: 29px;
  padding: 1rem 1rem 0.45rem 1rem;
  box-shadow: 0 18px 50px rgba(0,0,0,0.22);
  border: 1px solid #d1d5db; /* match .section-divider */
  position: relative;
  box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
  .modal {
    background: rgb(28,28,30);
    border: 1px solid rgba(255,255,255,0.18);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0.75rem;
  position: relative;
  padding-right: 44px; /* reserve space for close button */
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  line-height: 30px; /* match close button height */
}

.icon-btn {
  border: none;
  background: #e5e7eb;
  color: rgb(var(--text));
  width: 30px;
  height: 30px;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-appearance: none;
  appearance: none;
}

@media (prefers-color-scheme: dark) {
  .icon-btn {
    background: rgba(255,255,255,0.14);
  }
}

/* For the SVG-based close button used in your Web Control modals */
.icon-btn.modal-close {
  padding: 0;
  font-size: 0;
  line-height: 0;
}

.icon-btn.modal-close svg {
  width: 16px;
  height: 16px;
  display: block;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  transform: none;
  z-index: 20;
  pointer-events: auto;
}

/* Description paragraph style (used in modals) */
.modal-desc {
  margin: 0 0 14px 0;
  color: rgb(var(--text) / 0.65);
  font-size: 1.05rem;
  line-height: 1.25;
}

/* Small action buttons (mirrors Web Control) */
.mini-btn {
  border: none;
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  font-size: 1.0rem;
  font-weight: 600;
  cursor: pointer;
  background: #e5e7eb;
  color: rgb(var(--text));
  -webkit-appearance: none;
  appearance: none;
}

@media (prefers-color-scheme: dark) {
  .mini-btn {
    background: rgba(255,255,255,0.14);
  }
}

.mini-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mini-btn.compact {
  height: 26px;
  padding: 0 0.75rem;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  white-space: nowrap;
}

/* --- Driver help popup specifics --- */
.driver-help-port-list {
  margin: 0;
  padding-left: 18px;
  color: rgb(var(--text) / 0.85);
  line-height: 1.35;
}

.driver-help-links-title {
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 1.1rem; /* match .lts-btn */
}

.driver-help-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.driver-help-hint {
  margin-top: 14px;
}


.driver-help-link {
  text-decoration: none;
  color: rgb(var(--text));
}

.driver-help-link:visited {
  color: rgb(var(--text));
}

@media (max-width: 450px) {
  .modal-title {
    font-size: 1.1rem;
  }
  .modal-desc {
    font-size: 1.0rem;
  }
  .driver-help-links-title {
    font-size: 1.0rem; /* match .lts-btn on small screens */
  }
}