:root {
  color-scheme: light;
  --bg: #f5f2ed;
  --surface: #fffdf9;
  --surface-soft: #eee9e2;
  --ink: #211d1a;
  --muted: #6f6862;
  --border: #dcd4cb;
  --border-strong: #c6bbb0;
  --brand: #d94b23;
  --brand-hover: #bf3f1d;
  --brand-orange: #f7941d;
  --success: #18784d;
  --danger: #b22f2b;
  --focus: #1666c5;
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --duration-fast: 150ms;
  --duration-normal: 200ms;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select { font: inherit; }

button,
select,
input[type="range"],
.upload-button { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
.upload-button:has(input:focus-visible),
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  padding: 10px max(24px, calc((100vw - 1440px) / 2));
  color: #fffaf4;
  background: #171311;
  border-bottom: 3px solid var(--brand-orange);
}

.identity {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 66px;
  height: 46px;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #2b2420;
}

.brand-mark img { display: block; width: 56px; height: auto; }
.identity strong { display: block; font-size: 18px; line-height: 1.1; letter-spacing: -.01em; }
.identity small { display: block; margin-top: 3px; color: #c9beb4; font-size: 12px; }

.topbar-status {
  display: flex;
  align-items: center;
  gap: 18px;
  color: #cfc4ba;
  font-size: 13px;
}

.connection {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #4a4039;
  border-radius: var(--radius-sm);
  background: #211c19;
}

.connection i { width: 8px; height: 8px; border-radius: 50%; background: #d58a3a; }
.connection.is-connected i { background: #4bd38a; }
.connection.is-disconnected i { background: #e46b5e; }

.page-shell {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  align-items: end;
  gap: 64px;
  padding: 0 0 38px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 750;
}

.intro h1 {
  margin: 0;
  font-family: "Segoe UI Variable Display", "Segoe UI", Arial, sans-serif;
  font-size: clamp(38px, 5vw, 68px);
  font-weight: 760;
  line-height: .98;
  letter-spacing: -.045em;
}

.intro h1 span { color: var(--brand); }
.intro > p { max-width: 560px; margin: 0 0 4px; color: var(--muted); font-size: 16px; line-height: 1.65; }

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(520px, 1.28fr);
  align-items: start;
  gap: 24px;
}

.editor { display: grid; gap: 18px; }
.monitor-column { position: sticky; top: 96px; display: grid; gap: 18px; }

.panel {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 1px 1px rgba(45, 31, 21, .04);
}

.panel-heading,
.monitor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.panel-heading { justify-content: flex-start; }
.panel-heading .step {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius-xs);
  color: #fff;
  background: var(--brand);
  font-weight: 760;
}

h2 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: -.015em; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.field { margin-top: 20px; }
.field > label,
.label-row label,
.url-label { display: block; color: #3e3833; font-size: 13px; font-weight: 680; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.label-row > span,
.optional { color: var(--muted); font-size: 11px; font-weight: 500; }

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: 46px;
  margin-top: 8px;
  padding: 10px 12px;
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

input[type="text"]:hover,
input[type="number"]:hover,
select:hover { border-color: #a99c90; }

input[type="text"]:focus,
input[type="number"]:focus,
select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 13%, transparent); }

.range-field output { color: var(--brand); font-size: 13px; font-weight: 760; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; margin: 16px 0 0; accent-color: var(--brand); }

.coordinates { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.upload-row { display: flex; align-items: center; gap: 12px; margin-top: 9px; }
.upload-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 9px 14px;
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 680;
}

.upload-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
#photo-status { flex: 1; color: var(--muted); font-size: 13px; }
.text-danger { min-height: 40px; padding: 7px 8px; color: var(--danger); border: 0; background: transparent; font-size: 13px; font-weight: 680; }
.text-danger:disabled { color: #a9a29c; cursor: not-allowed; }
.help { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.monitor-panel { padding: 24px; }
.monitor-heading .eyebrow { margin-bottom: 5px; }
.air-status {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 720;
}

.air-status.is-live { color: #fff; border-color: var(--success); background: var(--success); }

.preview-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-top: 20px;
  overflow: hidden;
  border: 1px solid #bcb3aa;
  border-radius: var(--radius-sm);
  background-color: #ded9d2;
  background-image:
    linear-gradient(45deg, #f2efea 25%, transparent 25%),
    linear-gradient(-45deg, #f2efea 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f2efea 75%),
    linear-gradient(-45deg, transparent 75%, #f2efea 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

#preview-frame { position: absolute; inset: 0; overflow: hidden; }
#preview { display: block; width: 1920px; height: 1080px; border: 0; background: transparent; transform-origin: top left; pointer-events: none; }
.preview-label {
  position: absolute;
  left: 12px;
  bottom: 10px;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  color: #534b45;
  background: rgba(255, 253, 249, .86);
  font-size: 11px;
  font-weight: 650;
}

.preview-meta { display: flex; justify-content: space-between; gap: 16px; margin: 10px 2px 20px; color: var(--muted); font-size: 12px; }
.actions { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 10px; }
.actions button,
.link-copy button {
  min-height: 46px;
  border-radius: var(--radius-sm);
  font-weight: 720;
  transition: background var(--duration-fast), border-color var(--duration-fast), transform var(--duration-fast);
}

.actions button:active,
.link-copy button:active { transform: translateY(1px); }
.primary { color: #fff; border: 1px solid var(--brand); background: var(--brand); }
.primary:hover { border-color: var(--brand-hover); background: var(--brand-hover); }
.secondary { color: var(--ink); border: 1px solid var(--border-strong); background: var(--surface-soft); }
.secondary:hover { border-color: #a99c90; background: #e7e0d8; }
.actions button span { margin-right: 6px; font-size: 11px; }
.feedback { min-height: 20px; margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.feedback.is-error { color: var(--danger); }

.connection-panel .panel-heading { margin-bottom: 20px; }
.url-label { margin: 16px 0 7px; }
.link-copy { display: flex; align-items: center; gap: 12px; }
.link-copy code { min-width: 0; flex: 1; overflow-wrap: anywhere; color: #5b2c1f; font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.link-copy button { min-width: 82px; padding: 8px 12px; color: var(--brand); border: 1px solid #dfa58e; background: #fff3ed; }
.link-copy button:hover { border-color: var(--brand); background: #ffe9df; }
.instructions { margin: 22px 0 0; padding: 18px 0 0 22px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; line-height: 1.65; }
.instructions li + li { margin-top: 5px; }
.instructions code { color: #5b2c1f; font-family: Consolas, "Courier New", monospace; }

[hidden] { display: none !important; }

@media (max-width: 1080px) {
  .page-shell { width: min(760px, calc(100% - 32px)); padding-top: 34px; }
  .intro { grid-template-columns: 1fr; gap: 18px; }
  .workspace { grid-template-columns: 1fr; }
  .monitor-column { position: static; grid-row: 1; }
}

@media (max-width: 640px) {
  .topbar { min-height: 64px; padding: 8px 16px; }
  .brand-mark { width: 54px; height: 40px; }
  .brand-mark img { width: 46px; }
  .identity strong { font-size: 16px; }
  .identity small,
  .format { display: none; }
  .connection { min-height: 38px; padding: 7px 9px; font-size: 12px; }
  .page-shell { width: min(100% - 24px, 760px); padding: 28px 0 40px; }
  .intro { padding-bottom: 24px; }
  .intro h1 { font-size: 40px; }
  .intro > p { font-size: 15px; }
  .panel,
  .monitor-panel { padding: 18px; }
  .panel-heading { padding-bottom: 16px; }
  .upload-row { align-items: flex-start; flex-wrap: wrap; }
  #photo-status { min-width: 140px; padding-top: 12px; }
  .actions { grid-template-columns: 1fr; }
  .preview-meta { flex-direction: column; gap: 4px; }
  .link-copy { align-items: stretch; flex-direction: column; }
  .link-copy button { width: 100%; }
}

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