:root {
  color-scheme: dark;
  --bg: #02060c;
  --surface: #07111c;
  --panel: #0b1824;
  --text: #f5f7fb;
  --muted: #99a3b3;
  --line: #173a43;
  --accent: #07e0d3;
  --accent-2: #e7e96c;
  --danger: #ff766d;
  --max: 1180px;
  font-family: "Sarabun", "IBM Plex Sans", "Segoe UI", "Noto Sans Thai", sans-serif;
}

body[data-theme="daylight"] {
  color-scheme: light;
  --bg: #f7f4ea;
  --surface: #ffffff;
  --panel: #e8f4eb;
  --text: #102118;
  --muted: #526459;
  --line: #cad7cf;
  --accent: #167a4b;
  --accent-2: #b66a00;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(7, 224, 211, 0.08), transparent 16rem),
    radial-gradient(circle at 92% 12%, rgba(231, 233, 108, 0.09), transparent 23rem),
    var(--bg);
  color: var(--text);
}

a { color: inherit; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem max(1rem, calc((100vw - var(--max)) / 2));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  min-width: 11rem;
}
.brand-mark {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, #ffffff 0 42%, #dffefa 43% 60%, var(--accent) 61%);
  color: #08796f;
  font-weight: 900;
  border-radius: 999px;
  box-shadow: 0 0 22px rgba(7, 224, 211, 0.26);
}
.brand strong,
.brand small { display: block; }
.brand small { color: var(--muted); font-size: 0.75rem; }
.nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.92rem;
}
.nav a { text-decoration: none; }
.toolbar { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.tool,
.button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
  font: inherit;
}
.tool.active,
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 800;
}
.tool.wide { min-width: 4.5rem; }
.button.small { padding: 0.55rem 0.7rem; font-size: 0.9rem; }
.section-shell {
  width: min(var(--max), calc(100% - 2rem));
  margin: 0 auto;
  padding: 4rem 0;
}
.hero {
  min-height: calc(100vh - 5rem);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(20rem, 0.9fr);
  align-items: center;
  gap: 2rem;
}
.hero-visual {
  width: 100%;
  position: relative;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  padding: 0 max(1rem, calc((100vw - var(--max)) / 2));
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(2, 6, 12, 0.93) 0%, rgba(2, 6, 12, 0.62) 45%, rgba(2, 6, 12, 0.38) 100%),
    linear-gradient(180deg, rgba(2, 6, 12, 0.24) 0%, rgba(2, 6, 12, 0.74) 84%, var(--bg) 100%),
    url("./assets/solar-carport-hero-desktop.jpg") center / cover no-repeat;
}
.hero-visual::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 8rem;
  background: linear-gradient(180deg, transparent, var(--bg));
  pointer-events: none;
}
.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 45rem;
}
.solution-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(7, 224, 211, 0.55);
  background: rgba(7, 224, 211, 0.14);
  color: var(--accent);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  font-weight: 800;
  margin-bottom: 1.4rem;
  box-shadow: inset 0 0 18px rgba(7, 224, 211, 0.14);
}
.hero-metrics {
  position: absolute;
  left: max(1rem, calc((100vw - var(--max)) / 2));
  right: max(1rem, calc((100vw - var(--max)) / 2));
  bottom: 1.8rem;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(7, 224, 211, 0.38);
}
.hero-metrics div {
  text-align: center;
}
.hero-metrics strong {
  display: block;
  color: var(--accent);
  font-size: clamp(1.2rem, 3vw, 2rem);
}
.hero-metrics span {
  color: var(--muted);
  font-size: 0.85rem;
}
.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 800;
}
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 {
  font-family: "Sarabun", "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: clamp(2.3rem, 6vw, 5.8rem);
  line-height: 1.02;
  margin: 0;
  max-width: 13ch;
  text-shadow: 0 0 34px rgba(0, 0, 0, 0.55);
}
h2 {
  font-family: "Sarabun", "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: clamp(1.8rem, 4vw, 3.5rem);
  line-height: 1.04;
  margin: 0 0 1rem;
}
h3 { margin: 0 0 0.7rem; font-size: 1.05rem; }
.lead {
  max-width: 45rem;
  color: #c8ced8;
  font-size: 1.16rem;
  line-height: 1.7;
}
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.5rem; }
.energy-panel,
.calc-card,
.config-card,
.feature-grid article,
.answer-grid article {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
}
.energy-panel { padding: 1rem; }
.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}
.panel-grid div {
  min-height: 8rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
}
.panel-grid span { color: var(--muted); font-size: 0.8rem; }
.panel-grid strong { font-size: 1.15rem; }
.power-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.45rem;
  margin-top: 0.85rem;
}
.power-strip span {
  height: 5.5rem;
  background: linear-gradient(180deg, var(--accent), transparent);
  opacity: 0.25;
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
  gap: 2rem;
}
.feature-grid,
.answer-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns, 4), minmax(0, 1fr));
  gap: 0.75rem;
}
.feature-grid article,
.answer-grid article,
.config-card { padding: 1rem; }
.feature-grid p,
.answer-grid p,
.admin p { color: var(--muted); line-height: 1.65; }
.estimator {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(20rem, 1fr);
  gap: 2rem;
}
.calc-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  padding: 1rem;
}
label { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; }
input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  padding: 0.75rem;
  font: inherit;
}
.calc-card button,
.roi-output { grid-column: 1 / -1; }
.roi-output {
  display: block;
  padding: 1rem;
  min-height: 4.5rem;
  background: var(--panel);
  color: var(--text);
  line-height: 1.7;
}
.admin-grid { --grid-columns: 3; }
.config-card label { margin-bottom: 0.8rem; }
.check { display: flex; align-items: center; grid-template-columns: auto 1fr; }
.check input { width: auto; }
.status-line {
  padding: 0.8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
}
.status-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.55rem;
}
.status-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.55rem;
}
.status-list span { color: var(--muted); }
.mermaid-code {
  white-space: pre-wrap;
  background: #050806;
  color: #d9ffe9;
  border: 1px solid var(--line);
  padding: 1rem;
  overflow-x: auto;
}
.visual-source {
  display: grid;
  grid-template-columns: minmax(0, 0.48fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}
.source-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 0.8rem;
}
.source-grid figure {
  margin: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}
.source-grid figure:first-child {
  grid-column: 1 / -1;
}
.source-grid img,
.calculator-preview img {
  display: block;
  width: 100%;
  height: auto;
}
.source-grid figcaption {
  padding: 0.7rem 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.calculator-preview {
  margin-top: 1rem;
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--surface);
}
.chat-widget {
  position: fixed;
  right: 1.2rem;
  bottom: 1.1rem;
  z-index: 20;
  display: grid;
  justify-items: end;
  gap: 0.5rem;
  pointer-events: none;
}
.chat-bubble {
  position: relative;
  max-width: min(22rem, calc(100vw - 2rem));
  padding: 1rem 1.1rem;
  background: #1d2a3d;
  border: 1px solid #40516a;
  color: var(--text);
  border-radius: 1rem;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
}
.chat-bubble::after {
  content: "";
  position: absolute;
  right: 3.5rem;
  bottom: -0.8rem;
  border: 0.8rem solid transparent;
  border-top-color: #1d2a3d;
}
.chat-bubble strong,
.chat-bubble span {
  display: block;
}
.chat-bubble span {
  margin-top: 0.35rem;
  color: #c1c9d6;
}
.chat-fab,
.chat-close {
  pointer-events: auto;
  border: 0;
  cursor: pointer;
}
.chat-fab {
  width: 5.3rem;
  height: 5.3rem;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), #16cb61);
  color: white;
  font-size: 2.5rem;
  box-shadow: 0 0 0 0.5rem rgba(7, 224, 211, 0.14), 0 18px 50px rgba(7, 224, 211, 0.28);
}
.chat-close {
  position: absolute;
  top: 0.2rem;
  right: 0.25rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #61718a;
  color: white;
  font-size: 1.3rem;
}
.footer {
  width: min(var(--max), calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.timeline {
  display: grid;
  gap: 0.7rem;
}
.timeline article {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--line);
  background: var(--surface);
}
.timeline strong {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  background: var(--accent);
  color: var(--bg);
}

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .hero,
  .split,
  .estimator,
  .visual-source { grid-template-columns: 1fr; }
  .hero-visual {
    min-height: 100svh;
    padding-top: 7rem;
    align-content: start;
    background:
      linear-gradient(180deg, rgba(2, 6, 12, 0.28) 0%, rgba(2, 6, 12, 0.78) 64%, var(--bg) 100%),
      url("./assets/solar-carport-hero-mobile.jpg") center top / cover no-repeat;
  }
  .hero-metrics {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 1.5rem;
  }
  .source-grid { grid-template-columns: 1fr; }
  .feature-grid,
  .answer-grid,
  .admin-grid { grid-template-columns: 1fr; }
  .calc-card { grid-template-columns: 1fr; }
  h1 { max-width: 100%; }
  .chat-bubble { max-width: calc(100vw - 7rem); }
  .chat-fab { width: 4.6rem; height: 4.6rem; }
}
