:root {
  --panel: #f8faf7;
  --panel-strong: #ffffff;
  --ink: #17211d;
  --muted: #607067;
  --line: #d8e0db;
  --accent: #c4492d;
  --accent-dark: #8e2f1e;
  --green: #246b57;
  --shadow: 0 16px 44px rgba(34, 45, 40, 0.16);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #e8eee9;
  color: var(--ink);
  padding-top: 54px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.demo-tabs {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 54px;
  padding: 8px 18px;
  border-bottom: 1px solid #cfd9d3;
  background: rgba(248, 250, 247, 0.94);
  box-shadow: 0 10px 30px rgba(23, 33, 29, 0.12);
  backdrop-filter: blur(14px);
}

.demo-tab {
  min-width: 118px;
  min-height: 36px;
  border: 1px solid #b7c4bc;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
}

.demo-tab.is-active {
  border-color: #17211d;
  background: #17211d;
  color: #ffffff;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 348px) minmax(0, 1fr);
  width: 100vw;
  height: calc(100vh - 54px);
}

.prompt-view {
  position: fixed;
  inset: 54px 0 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(90deg, rgba(23, 33, 29, 0.88), rgba(23, 33, 29, 0.54)),
    radial-gradient(circle at 80% 18%, rgba(196, 73, 45, 0.24), transparent 32%),
    #17211d;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 240ms ease,
    transform 240ms ease,
    visibility 240ms ease;
}

body[data-active-tab="output"] .prompt-view {
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
}

.prompt-card {
  display: grid;
  gap: 18px;
  width: min(860px, 100%);
  padding: clamp(22px, 5vw, 44px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(248, 250, 247, 0.96);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.prompt-kicker {
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.prompt-card h2 {
  font-size: clamp(2rem, 6vw, 4.2rem);
  line-height: 0.96;
  max-width: 12ch;
}

.prompt-card pre {
  margin: 0;
  max-height: 32vh;
  overflow: auto;
  padding: 18px;
  border: 1px solid #d6dfd9;
  border-radius: 8px;
  background: #ffffff;
  color: #17211d;
  white-space: pre-wrap;
}

.prompt-card code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(0.92rem, 2vw, 1.08rem);
  line-height: 1.48;
}

.prompt-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.prompt-actions p {
  max-width: 34rem;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.4;
}

.prompt-actions button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--accent-dark);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 900;
}

.control-panel {
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  padding: 18px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand-block {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding-bottom: 4px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 2px solid #17211d;
  border-radius: 8px;
  background: #ffffff;
  color: #17211d;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.24rem, 1.8vw, 1.52rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.brand-block p {
  max-width: 29rem;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.38;
}

.control-section,
.legend-section,
.live-section,
.instructions {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

label,
.section-heading span,
#active-variable-kicker {
  display: block;
  color: #53625b;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

select,
input {
  width: 100%;
  height: 42px;
  margin-top: 8px;
  padding: 0 12px;
  border: 1px solid #bcc9c1;
  border-radius: 8px;
  outline: none;
  background: var(--panel-strong);
  color: var(--ink);
  font-size: 0.95rem;
}

select:focus,
input:focus,
button:focus-visible {
  outline: 3px solid rgba(36, 107, 87, 0.24);
  outline-offset: 2px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.icon-button,
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #b7c4bc;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.icon-button {
  width: 42px;
  height: 42px;
  margin-top: 8px;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-button {
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  font-size: 0.92rem;
  font-weight: 750;
}

.action-button:hover,
.icon-button:hover,
.basemap-menu button:hover {
  border-color: #8fa198;
  background: #edf3ef;
}

.basemap-control {
  position: relative;
}

.basemap-control .action-button {
  width: 100%;
}

.basemap-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  display: grid;
  width: 190px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 32px rgba(23, 33, 29, 0.18);
}

.basemap-menu[hidden] {
  display: none;
}

.basemap-menu button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 0.88rem;
  text-align: left;
}

.mini-button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #b7c4bc;
  border-radius: 7px;
  background: #ffffff;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 850;
}

.mini-button:hover {
  border-color: #8fa198;
  background: #edf3ef;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-heading h2,
.instructions h2 {
  font-size: 1rem;
  line-height: 1.1;
}

.live-section {
  display: grid;
  gap: 9px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid #dce5df;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 760;
  text-transform: none;
}

.toggle-row span {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.toggle-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.toggle-row strong {
  flex: 0 0 auto;
  min-width: 44px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #17211d;
  color: #ffffff;
  font-size: 0.72rem;
  line-height: 1;
  text-align: center;
}

.fire-legend {
  display: grid;
  gap: 7px;
  padding: 8px 9px 9px;
  border: 1px solid #dce5df;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
}

.fire-legend p {
  color: #53625b;
  font-size: 0.75rem;
  font-weight: 820;
  line-height: 1;
  text-transform: uppercase;
}

.fire-gradient {
  height: 14px;
  overflow: hidden;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff1f1f 0%, #ff841c 25%, #ffe236 50%, #80d24e 75%, #169146 100%);
  box-shadow: 0 0 0 1px rgba(23, 33, 29, 0.16);
}

.fire-legend__scale {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1;
}

.fire-legend__scale span:nth-child(2) {
  text-align: center;
}

.fire-legend__scale span:nth-child(3) {
  text-align: right;
}

.fire-legend__unknown {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1;
}

.fire-legend__unknown span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.fire-dot {
  display: block;
  width: 11px;
  height: 11px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(23, 33, 29, 0.2);
}

.fire-dot--unknown {
  background: #7a8580;
}

.legend-ramp {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  height: 18px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 6px;
}

.legend-ramp span {
  min-width: 0;
}

.legend-breaks {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.legend-breaks span:nth-child(2) {
  text-align: center;
}

.legend-breaks span:nth-child(3) {
  text-align: right;
}

.instructions ol {
  display: grid;
  gap: 6px;
  margin: 9px 0 0;
  padding-left: 21px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.34;
}

.instructions p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

a {
  color: var(--accent-dark);
  font-weight: 800;
}

.map-stage {
  position: relative;
  min-width: 0;
  height: 100%;
}

#viewDiv {
  width: 100%;
  height: 100%;
}

.map-topbar {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(216, 224, 219, 0.82);
  border-radius: 8px;
  background: rgba(248, 250, 247, 0.92);
  box-shadow: 0 12px 26px rgba(28, 42, 35, 0.15);
  backdrop-filter: blur(12px);
}

.map-topbar h2 {
  margin-top: 4px;
  font-size: clamp(1.1rem, 2.2vw, 1.45rem);
  line-height: 1.08;
}

#map-status {
  max-width: 28rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.25;
  text-align: right;
}

.popup-content {
  display: grid;
  gap: 12px;
  min-width: 240px;
}

.popup-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.popup-stat {
  padding: 8px;
  border: 1px solid #dbe3de;
  border-radius: 8px;
  background: #f7faf8;
}

.popup-stat span {
  display: block;
  color: #607067;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.popup-stat strong {
  display: block;
  margin-top: 4px;
  color: #17211d;
  font-size: 0.92rem;
}

.popup-overview {
  color: #425048;
  font-size: 0.9rem;
  line-height: 1.42;
}

.live-popup {
  display: grid;
  gap: 11px;
  min-width: 245px;
}

.live-popup__summary {
  color: #425048;
  font-size: 0.9rem;
  line-height: 1.42;
}

.live-popup__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.live-popup__grid div {
  padding: 8px;
  border: 1px solid #dbe3de;
  border-radius: 8px;
  background: #f7faf8;
}

.live-popup__grid span {
  display: block;
  color: #607067;
  font-size: 0.7rem;
  font-weight: 850;
  line-height: 1.12;
  text-transform: uppercase;
}

.live-popup__grid strong {
  display: block;
  margin-top: 4px;
  color: #17211d;
  font-size: 0.9rem;
  line-height: 1.25;
}

.live-popup a {
  width: fit-content;
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 72vh;
    height: auto;
    min-height: 100vh;
  }

  .control-panel {
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map-stage {
    min-height: 72vh;
  }

  .map-topbar {
    top: 10px;
    left: 10px;
    right: 10px;
    align-items: flex-start;
    padding: 12px;
  }

  #map-status {
    max-width: 13rem;
    font-size: 0.75rem;
  }
}

@media (max-width: 500px) {
  body {
    padding-top: 50px;
  }

  .demo-tabs {
    height: 50px;
    padding: 7px 10px;
  }

  .demo-tab {
    min-width: 0;
    flex: 1;
  }

  .prompt-view {
    inset: 50px 0 0;
    padding: 16px;
  }

  .prompt-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .prompt-actions button {
    width: 100%;
  }

  .control-panel {
    padding: 18px;
  }

  .brand-block,
  .button-grid {
    grid-template-columns: 1fr;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .map-topbar {
    flex-direction: column;
    gap: 8px;
  }

  #map-status {
    max-width: none;
    text-align: left;
  }
}
