:root {
  color-scheme: light;
  --paper: #fbfaf7;
  --paper-deep: #f4f2ed;
  --ink: #1b1c19;
  --muted: #6d6b65;
  --faint: #9a978f;
  --line: #dfddd7;
  --line-dark: #c9c6be;
  --green: #4f755e;
  --green-deep: #315440;
  --gold: #b79042;
  --danger: #9c4f45;
  --serif: "Lora", ui-serif, Georgia, serif;
  --hand: "Caveat", cursive;
  --sans: InterVariable, Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  font-family: var(--sans);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
}

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

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 0 clamp(24px, 3vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 247, .94);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  transform: rotate(-4deg);
  border-radius: 7px;
  background: var(--green);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
  font-family: var(--sans);
  font-size: .84rem;
}

.brand-mark span { transform: rotate(4deg); }
nav { display: flex; align-items: center; gap: clamp(20px, 3vw, 42px); font-size: .87rem; }
nav a, nav span { color: #474943; text-decoration: none; }
nav a:hover { color: var(--green-deep); text-decoration: underline; text-underline-offset: 4px; }

main {
  width: min(720px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(56px, 7vw, 92px) 0 76px;
}

.eyebrow {
  margin: 0;
  color: var(--green);
  font-family: var(--hand);
  font-size: 20px;
  font-style: normal;
  font-weight: 500;
  line-height: 24px;
  transform: rotate(-1deg);
  transform-origin: left center;
}

h1, h2, h3 { font-family: var(--serif); }
h1 {
  max-width: 30ch;
  margin: 8px 0 0;
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -.9px;
  line-height: 40px;
}

.lead {
  max-width: 58ch;
  margin: 24px 0 43px;
  color: #595852;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
  line-height: 36px;
}

.step-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 15px; }
.step-number {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #eceae5;
  color: #5c5a55;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
}
.step-heading h2 { margin: 0; font-family: var(--serif); font-size: 14px; font-weight: 600; line-height: 20px; }

.device-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.device-card {
  display: block;
  height: 72px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: rgba(255,255,255,.52);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.device-card:hover { transform: translateY(-2px); border-color: var(--line-dark); box-shadow: 0 7px 20px rgba(49, 50, 44, .06); }
.device-card:focus-visible { box-shadow: 0 0 0 3px rgba(79,117,94,.17); }
.device-card[aria-checked="true"] { border-color: var(--green); background: #fff; box-shadow: 0 7px 22px rgba(49,84,64,.08); }
.device-title-row { display: flex; align-items: center; gap: 6px; }
.device-title-row strong { min-width: 0; overflow: hidden; font-family: var(--sans); font-size: 14px; font-weight: 600; line-height: 20px; text-overflow: ellipsis; white-space: nowrap; }
.device-icon { display: grid; flex: 0 0 auto; width: 16px; height: 16px; place-items: center; border-radius: 3px; background: #1f2522; color: #fff; font-size: 8px; font-weight: 800; }
.device-icon-atom { border-radius: 50%; background: #242c4c; font-size: .52rem; }
.device-icon-xiao { background: #4e8071; }
.device-meta { display: block; margin-top: 2px; overflow: hidden; color: #aaa59f; font-family: var(--mono); font-size: 12px; font-weight: 400; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; }

.firmware-section { margin-top: 28px; }
.step-reveal { animation: step-reveal .34s ease-out both; }
@keyframes step-reveal {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.firmware-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.firmware-card {
  display: block;
  height: 72px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.firmware-card:hover { transform: translateY(-2px); border-color: var(--line-dark); box-shadow: 0 7px 20px rgba(49, 50, 44, .06); }
.firmware-card:focus-visible { box-shadow: 0 0 0 3px rgba(79,117,94,.17); }
.firmware-card[aria-checked="true"] { border-color: var(--green); box-shadow: 0 7px 22px rgba(49,84,64,.08); }
.firmware-title { display: block; overflow: hidden; font-family: var(--sans); font-size: 14px; font-weight: 600; line-height: 20px; text-overflow: ellipsis; white-space: nowrap; }
.custom-upload-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 10px 2px 0; }
.custom-upload-row p { margin: 0; color: var(--muted); font-family: var(--serif); font-size: 13px; line-height: 20px; }
.custom-upload-row code { font-family: var(--mono); font-size: 12px; }
.file-select-button { flex: 0 0 auto; padding: 7px 11px; border: 1px solid var(--line-dark); border-radius: 7px; background: #fff; color: var(--ink); cursor: pointer; font-family: var(--sans); font-size: 12px; font-weight: 600; }
.file-select-button:hover { border-color: var(--green); }
.file-select-button:focus-visible { outline: 3px solid rgba(79,117,94,.17); outline-offset: 1px; }

.flash-section { margin-top: 34px; }
.flash-section > .step-heading { gap: 14px; margin-bottom: 20px; }
.flash-section > .step-heading .step-number {
  width: 42px;
  height: 42px;
  background: var(--green);
  color: #fff;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
}
.flash-section > .step-heading h2 { font-size: 20px; line-height: 28px; }
.install-panel {
  margin-top: 0;
  padding: 24px 26px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.release-name { margin: 0; font-family: var(--sans); font-size: 17px; font-weight: 650; line-height: 24px; }
.release-title { margin: 4px 0 0; color: #aaa59f; font-family: var(--mono); font-size: 14px; font-weight: 400; line-height: 20px; }
.release-separator { color: #aaa59f; font-weight: 400; }

.flash-action-row { display: flex; align-items: center; gap: 18px; margin-top: 18px; }
.install-action { flex: 0 0 200px; }
.install-action esp-web-install-button { display: block; }
.release-device {
  flex: 0 1 auto;
  margin: 0;
  color: var(--green-deep);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  white-space: nowrap;
}
.duration-callout { display: flex; min-width: 0; align-items: center; gap: 8px; }
.duration-arrow { flex: 0 0 58px; width: 58px; height: 28px; overflow: visible; fill: none; stroke: #aaa59f; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.4; }
.duration-note { margin: 0; color: #77736d; font-family: var(--hand); font-size: 20px; font-weight: 500; line-height: 24px; white-space: nowrap; }

.install-footnote { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 13px; color: #aaa59f; font-size: 12px; line-height: 18px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.status-dot.ready { background: var(--green); }
.status-dot.missing { background: var(--danger); }
.footnote-separator { color: var(--line-dark); }
.primary-button {
  display: flex;
  width: 100%;
  min-height: 49px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 16px;
  border: 1px solid var(--green-deep);
  border-radius: 7px;
  outline: none;
  background: var(--green-deep);
  color: #fff;
  cursor: pointer;
  font-size: .84rem;
  font-weight: 720;
  transition: background .16s ease, transform .16s ease;
}
.primary-button:hover:not(:disabled) { transform: translateY(-1px); background: #233f30; }
.primary-button:focus-visible { box-shadow: 0 0 0 3px rgba(79,117,94,.2); }
.primary-button:disabled { border-color: var(--green); background: var(--green); color: #fff; cursor: not-allowed; opacity: .55; }
.flash-icon { width: 17px; height: 17px; fill: currentColor; }
.action-note { color: inherit; }
.support-message { margin: 6px 0 0; color: var(--faint); font-size: .69rem; line-height: 1.45; text-align: center; }
.support-message { color: var(--danger); }

.instructions { margin-top: clamp(84px, 12vw, 130px); padding-top: 8px; border-top: 1px solid var(--line); }
.instructions h2 { margin: 0 0 28px; font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.04em; }
.instruction-list { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 22px; margin: 0; padding: 0; list-style: none; }
.instruction-list li { padding-top: 16px; border-top: 1px solid var(--line); }
.instruction-index { display: block; margin-bottom: 14px; color: var(--green); font-family: var(--serif); font-size: .88rem; font-style: italic; }
.instruction-list h3 { margin: 0 0 8px; font-size: 1.03rem; }
.instruction-list p { margin: 0; color: var(--muted); font-family: var(--serif); font-size: .92rem; line-height: 1.55; }

.safety-note { display: flex; gap: 14px; margin-top: 36px; padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.note-mark { display: grid; flex: 0 0 auto; width: 25px; height: 25px; place-items: center; border: 1px solid var(--gold); border-radius: 50%; color: var(--gold); font-family: var(--serif); font-weight: 700; }
.safety-note strong { font-family: var(--serif); font-size: .98rem; }
.safety-note p { margin: 2px 0 0; color: var(--muted); font-size: .78rem; }

footer { display: flex; justify-content: space-between; gap: 30px; padding: 46px clamp(24px, 3vw, 44px); border-top: 1px solid var(--line); background: #f6f4ef; color: var(--muted); font-size: .75rem; }
.footer-brand { color: var(--ink); font-family: var(--serif); font-size: 1.05rem; font-weight: 700; }
footer p { max-width: 320px; margin: 7px 0 0; }
.footer-meta { display: grid; align-content: start; gap: 7px; text-align: right; }

.toast { position: fixed; z-index: 20; right: 24px; bottom: 24px; max-width: min(390px, calc(100% - 48px)); padding: 12px 15px; border: 1px solid var(--line-dark); border-radius: 8px; background: #fff; box-shadow: 0 14px 40px rgba(0,0,0,.1); color: var(--ink); font-size: .8rem; }

@media (max-width: 760px) {
  nav span { display: none; }
  main { padding-top: 72px; }
  .device-grid { grid-template-columns: 1fr; }
  .device-card { height: 72px; }
  .firmware-grid { grid-template-columns: 1fr; }
  .custom-upload-row { align-items: flex-start; flex-direction: column; }
  .flash-action-row { align-items: flex-start; flex-wrap: wrap; }
  .duration-callout { flex: 1 1 240px; }
  .instruction-list { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .site-header { min-height: 60px; padding-inline: 16px; }
  nav { gap: 14px; font-size: .73rem; }
  nav a:nth-child(2) { display: none; }
  main { width: calc(100% - 28px); padding-top: 58px; }
  h1 { font-size: 32px; line-height: 36px; letter-spacing: -.65px; }
  .lead { font-size: 18px; line-height: 31px; }
  .install-panel { padding: 19px; }
  .flash-section > .step-heading .step-number { width: 38px; height: 38px; }
  .flash-action-row { gap: 14px; }
  .install-action { flex-basis: 100%; }
  .release-device { width: 100%; }
  .duration-arrow { flex-basis: 48px; width: 48px; }
  .duration-note { font-size: 20px; white-space: normal; }
  footer { padding: 34px 18px; flex-direction: column; }
  .footer-meta { text-align: left; }
}

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