/* Self-hosted, SIL OFL 1.1 (licences in fonts/): fetching them from Google sent every
   visitor's address there. Both are variable, so one file covers every weight used. */
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/dm-sans-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Azeret Mono";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("fonts/azeret-mono-latin.woff2") format("woff2");
}

:root {
  --paper: #f4f1e8;
  --paper-deep: #e9e3d4;
  --surface: #fffdf8;
  --surface-raised: #ffffff;
  --ink: #1d2525;
  --ink-soft: #626865;
  --line: #ccc6b7;
  --line-strong: #969184;
  --red: #d63c32;
  --red-dark: #a92520;
  --teal: #087f78;
  --teal-soft: #d9efeb;
  --amber: #bd7200;
  --amber-soft: #fff0c9;
  --blue: #376c96;
  --blue-soft: #e2edf5;
  --shadow: 0 12px 32px rgba(37, 35, 29, 0.08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  background:
    repeating-linear-gradient(90deg, transparent 0, transparent 47px, rgba(52, 50, 43, 0.025) 48px),
    var(--paper);
  font-family: "DM Sans", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

button, input { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); text-underline-offset: 3px; }

.topbar {
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(244, 241, 232, 0.94);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: "Azeret Mono", monospace;
  font-weight: 600;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 28px;
  height: 28px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: linear-gradient(to bottom, var(--red) 0 46%, var(--ink) 46% 54%, #fff 54% 100%);
}

.brand-mark span {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
}

.device-label, .eyebrow, .pack-version, .step-number {
  font-family: "Azeret Mono", monospace;
  letter-spacing: 0;
}

.device-label { color: var(--ink-soft); font-size: 12px; }
.shell { width: min(1080px, calc(100% - 40px)); margin: 0 auto; }

.intro {
  min-height: 390px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 56px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.intro-copy { max-width: 610px; }
.eyebrow { margin: 0 0 8px; color: var(--red-dark); font-size: 12px; font-weight: 600; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 18px; font-size: clamp(42px, 7vw, 74px); line-height: 0.98; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 27px; line-height: 1.15; letter-spacing: 0; }
h3 { margin-bottom: 6px; font-size: 17px; letter-spacing: 0; }
.intro-copy > p:not(.eyebrow) { max-width: 590px; color: var(--ink-soft); font-size: 19px; }

.compatibility, .connection {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-soft);
  font-size: 14px;
}

.signal {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(150, 145, 132, 0.14);
}
.signal-ready, .connection.connected .signal { background: var(--teal); box-shadow: 0 0 0 4px rgba(8, 127, 120, 0.14); }

.device-preview { position: relative; min-height: 330px; }

.device-preview img {
  position: absolute;
  width: 270px;
  aspect-ratio: 1;
  border: 10px solid #242a29;
  border-radius: 50%;
  background: #000;
  box-shadow: var(--shadow);
}

.device-preview img:first-child { top: 4px; right: 4px; z-index: 2; }
.device-preview img:last-child { bottom: 0; left: 2px; width: 210px; opacity: 0.9; }

.notice {
  margin: 24px 0;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid #dfa39d;
  border-radius: 6px;
  color: #7f211c;
  background: #fff0ed;
}
.notice svg { width: 20px; flex: 0 0 auto; }

.work-section { padding: 58px 0; border-bottom: 1px solid var(--line); }
.section-heading, .heading-group { display: flex; align-items: flex-start; gap: 18px; }
.section-heading { margin-bottom: 28px; }
.section-heading-split { justify-content: space-between; }
.step-number { color: var(--red); font-size: 16px; font-weight: 600; line-height: 1.3; }

.edition-grid, .region-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.edition-grid.single { grid-template-columns: 1fr; }

.edition-option, .pack-option {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.72);
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.edition-option:hover, .pack-option:hover { border-color: var(--line-strong); }
.edition-option.selected, .pack-option.selected { border-color: var(--red); background: #fff8f5; }
.edition-option input, .pack-option input { position: absolute; opacity: 0; pointer-events: none; }
/* The real radios and checkboxes are invisible, so keyboard focus is drawn on the card. */
.edition-option:has(input:focus-visible), .pack-option:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 2px; }

.edition-option label, .pack-option label {
  min-height: 92px;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  cursor: pointer;
}

.choice-control {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 2px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-raised);
}
.pack-option .choice-control { border-radius: 3px; }
.selected .choice-control { border-color: var(--red); box-shadow: inset 0 0 0 4px var(--surface-raised); background: var(--red); }

.option-copy { min-width: 0; flex: 1; }
.option-title { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; }
.option-copy p { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }

.tag, .pack-state {
  width: fit-content;
  padding: 3px 7px;
  border-radius: 3px;
  color: var(--ink-soft);
  background: var(--paper-deep);
  font-family: "Azeret Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}
.pack-state.current { color: #075d58; background: var(--teal-soft); }
.pack-state.update { color: #7a4a00; background: var(--amber-soft); }
.pack-state.missing { color: #315c7e; background: var(--blue-soft); }

.action-row, .connect-strip, .deploy-bar { display: flex; align-items: center; gap: 18px; }
.flash-row { margin-top: 18px; }
.action-copy, .connect-strip p { margin: 0; color: var(--ink-soft); font-size: 14px; }

.release-notes {
  margin-top: 26px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.release-notes header { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.release-notes h3 { margin: 0; font-size: 18px; }
.release-notes header a { flex: 0 0 auto; font-size: 13px; font-weight: 700; }
.release-notes pre {
  max-height: 260px;
  margin: 14px 0 0;
  padding: 0 18px 0 0;
  overflow: auto;
  color: var(--ink-soft);
  background: transparent;
  font: 14px/1.65 "DM Sans", sans-serif;
  white-space: pre-wrap;
}

.button, .icon-button {
  min-height: 44px;
  border: 1px solid var(--ink);
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--ink);
  background: var(--surface-raised);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.button { padding: 10px 16px; }
.button svg { width: 18px; height: 18px; }
.button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 12px rgba(37, 35, 29, 0.09); }
.button:disabled, .button[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.button-primary { border-color: var(--ink); color: #fff; background: var(--ink); }
.button-primary:hover:not(:disabled) { background: #303a39; }
.button-accent { border-color: var(--red-dark); color: #fff; background: var(--red); }
.button-accent:hover:not(:disabled) { background: var(--red-dark); }
.button-secondary { border-color: var(--line-strong); background: var(--surface); }
.button-quiet { border-color: transparent; background: transparent; }
.button-small { min-height: 44px; padding: 8px 10px; font-size: 13px; }

.status { margin-top: 14px; padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 5px; color: var(--ink); background: var(--surface); font-size: 14px; }
.status > span { min-width: 0; }
.status .button { flex: 0 0 auto; }
.status-ok { border-color: #9fd1c9; border-left-color: var(--teal); background: var(--teal-soft); }
.status-error { border-color: #dfa39d; border-left-color: var(--red); color: #7f211c; background: #fff0ed; }
.status-warn { border-color: #e7c77f; border-left-color: var(--amber); background: var(--amber-soft); }
.status-info { border-left-color: var(--blue); background: var(--blue-soft); }

.install-note { margin-top: 22px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 14px; }
.install-note summary { padding: 16px 0 0; display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 700; cursor: pointer; }
.install-note summary::-webkit-details-marker { display: none; }
.install-note summary svg { width: 18px; }
.install-note p { max-width: 780px; margin: 12px 0 0 27px; }

.connect-strip { min-height: 76px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.pack-toolbar { margin: 34px 0 14px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.pack-toolbar p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.toolbar-actions { display: flex; gap: 4px; }
.region-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pack-option label { min-height: 110px; }
.pack-version { margin-top: 8px; color: var(--ink-soft); font-size: 11px; }
.pack-option.unavailable { opacity: 0.6; }

.deploy-bar { margin-top: 20px; justify-content: space-between; }
.deploy-bar > div { min-width: 0; display: grid; }
.deploy-bar span { color: var(--ink-soft); font-size: 13px; }

.progress { margin-top: 20px; }
.progress-copy { display: flex; justify-content: space-between; gap: 16px; color: var(--ink-soft); font-size: 13px; }
.progress-track { height: 8px; margin-top: 8px; overflow: hidden; border-radius: 2px; background: var(--paper-deep); }
.progress-track > div { width: 0; height: 100%; background: var(--teal); transition: width 140ms linear; }

.custom-pack { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 9px; color: var(--ink-soft); font-size: 13px; }
.custom-pack svg { width: 17px; }
.text-action { padding: 0; border: 0; background: none; color: var(--blue); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.text-action:disabled { color: var(--ink-soft); text-decoration: none; cursor: not-allowed; }

.save-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.save-layout > div { min-height: 190px; padding: 24px; }
.save-layout > div + div { border-left: 1px solid var(--line); }
.save-layout p { min-height: 66px; color: var(--ink-soft); font-size: 14px; }

/* The in-browser backup history. One row per stored capture: what it is on the
   left, what you can do with it on the right. */
#history { display: flex; flex-direction: column; gap: 8px; }
.history-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface);
}
.history-row strong { font-size: 14px; }
.history-row p { margin: 2px 0 0; font-size: 13px; }
.history-actions { display: flex; gap: 8px; flex-shrink: 0; }
.history-actions .button { padding: 8px 14px; font-size: 13px; }
@media (max-width: 620px) {
  .history-row { flex-direction: column; align-items: flex-start; }
}

.activity { margin: 58px 0; overflow: hidden; border: 1px solid #303b3a; border-radius: 6px; color: #eaf2ee; background: #17201f; box-shadow: var(--shadow); }
.activity header { padding: 16px 18px; border-bottom: 1px solid #34403e; display: flex; align-items: center; justify-content: space-between; }
.activity .eyebrow { color: #72c7be; }
.activity h2 { font-size: 18px; }
.activity-actions { display: flex; gap: 4px; }
.activity pre { min-height: 110px; max-height: 280px; margin: 0; padding: 18px; overflow: auto; color: #bfd0ca; font: 12px/1.65 "Azeret Mono", monospace; white-space: pre-wrap; word-break: break-word; }
.icon-button { width: 44px; min-height: 44px; padding: 0; border-color: transparent; color: #bfd0ca; background: transparent; }
.icon-button:hover { background: #26312f; }
.icon-button svg { width: 17px; }

.muted { color: var(--ink-soft); }
footer { min-height: 76px; padding: 18px max(20px, calc((100vw - 1080px) / 2)); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; color: var(--ink-soft); font-size: 13px; }
footer a:last-child { margin-left: auto; }

@media (max-width: 820px) {
  .shell { width: min(100% - 28px, 680px); }
  .intro { min-height: auto; padding: 50px 0 44px; grid-template-columns: 1fr; gap: 28px; }
  .device-preview { min-height: 235px; width: min(100%, 390px); margin: 0 auto; }
  .device-preview img { width: 210px; }
  .device-preview img:last-child { width: 160px; }
  .region-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading-split { align-items: flex-start; }
}

@media (max-width: 560px) {
  .topbar { min-height: 58px; padding: 0 15px; }
  .device-label { display: none; }
  .intro { padding: 34px 0 28px; gap: 18px; }
  .intro-copy > p:not(.eyebrow) { font-size: 17px; }
  .compatibility { font-size: 13px; }
  .device-preview { min-height: 188px; }
  .device-preview img { width: 170px; border-width: 7px; }
  .device-preview img:last-child { width: 125px; }
  h1 { font-size: 38px; }
  h2 { font-size: 23px; }
  .work-section { padding: 42px 0; }
  .section-heading, .heading-group { gap: 11px; }
  .section-heading-split, .pack-toolbar, .deploy-bar, .action-row, .connect-strip { align-items: stretch; flex-direction: column; }
  .connection { margin-left: 29px; }
  .edition-grid, .region-grid, .save-layout { grid-template-columns: 1fr; }
  .save-layout > div + div { border-top: 1px solid var(--line); border-left: 0; }
  .save-layout p { min-height: auto; }
  .toolbar-actions { align-self: stretch; }
  .toolbar-actions .button { flex: 1; }
  .release-notes header { align-items: flex-start; flex-direction: column; gap: 8px; }
  .deploy-bar .button, .connect-strip .button, .flash-row esp-web-install-button, .flash-row .button { width: 100%; }
  .custom-pack { align-items: flex-start; flex-wrap: wrap; }
  .status { flex-direction: column; align-items: flex-start; }
  footer { align-items: flex-start; flex-direction: column; }
  footer a:last-child { margin-left: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .intro-copy > *, .device-preview { animation: reveal 420ms both; }
  .intro-copy > :nth-child(2) { animation-delay: 60ms; }
  .intro-copy > :nth-child(3) { animation-delay: 120ms; }
  .intro-copy > :nth-child(4) { animation-delay: 180ms; }
  .device-preview { animation-delay: 120ms; }
  @keyframes reveal { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
}