:root {
  --emerald-950: #092f2b;
  --emerald-900: #0d423b;
  --emerald-800: #14584f;
  --emerald-700: #1b6d60;
  --emerald-500: #3e9c83;
  --cream-50: #fbf7ef;
  --cream-100: #f5ecdc;
  --cream-200: #eadcc4;
  --gold-500: #cba55a;
  --gold-400: #dbbc76;
  --purple-900: #3b2b55;
  --purple-700: #654781;
  --purple-500: #8a6cab;
  --ink: #173631;
  --muted: #6f7f79;
  --white: #fffdf8;
  --shadow: 0 24px 60px rgba(9, 47, 43, .13);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 5%, rgba(138,108,171,.16), transparent 24%),
    radial-gradient(circle at 10% 0%, rgba(62,156,131,.12), transparent 28%),
    var(--cream-50);
}

.page-shell {
  min-height: 100vh;
  padding: 28px;
}

.hero {
  max-width: 1320px;
  margin: 0 auto 22px;
  min-height: 230px;
  border-radius: 34px;
  padding: 42px 46px;
  background: linear-gradient(135deg, var(--emerald-950), var(--emerald-800));
  color: var(--cream-50);
  display: flex;
  justify-content: space-between;
  gap: 28px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.hero-copy {
  position: relative;
  z-index: 2;
  max-width: 780px;
}

.eyebrow {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--gold-400);
  font-weight: 700;
  margin-bottom: 12px;
}

.hero h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 5vw, 64px);
  line-height: .98;
  font-weight: 600;
  max-width: 850px;
}

.hero p {
  max-width: 680px;
  margin: 22px 0 0;
  color: rgba(251,247,239,.78);
  font-size: 17px;
  line-height: 1.6;
}

.hero-mark {
  width: 260px;
  min-width: 220px;
  position: relative;
}

.orb {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(219,188,118,.55);
}

.orb-1 { width: 210px; height: 210px; right: -20px; top: -30px; }
.orb-2 { width: 150px; height: 150px; right: 40px; top: 30px; border-color: rgba(138,108,171,.75); }
.orb-3 { width: 80px; height: 80px; right: 75px; top: 64px; background: rgba(203,165,90,.18); }

.layout {
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: 22px;
}

.panel {
  background: rgba(255,253,248,.92);
  border: 1px solid rgba(20,88,79,.10);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 28px;
  backdrop-filter: blur(14px);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.panel-heading > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.step {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--emerald-900);
  color: var(--cream-50);
  font-weight: 800;
  font-size: 13px;
}

.panel h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  color: var(--emerald-950);
}

.pill, .mini-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(62,156,131,.12);
  color: var(--emerald-800);
}

.pill.gold {
  background: rgba(203,165,90,.16);
  color: #8c6927;
}

.section-block {
  padding: 22px 0;
  border-top: 1px solid rgba(20,88,79,.08);
}

.section-block:first-of-type { border-top: 0; padding-top: 0; }

.section-block h3,
.peaks-card h3 {
  margin: 0 0 16px;
  font-size: 15px;
  color: var(--purple-900);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

label span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
}

input, select {
  width: 100%;
  border: 1px solid rgba(20,88,79,.14);
  border-radius: 12px;
  padding: 12px 13px;
  font: inherit;
  color: var(--ink);
  background: var(--cream-50);
  outline: none;
  transition: .2s ease;
}

input:focus, select:focus {
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 4px rgba(62,156,131,.10);
  background: var(--white);
}

.advanced,
.diagnostics {
  border: 1px solid rgba(101,71,129,.16);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(138,108,171,.05);
  margin: 10px 0 18px;
}

.advanced summary,
.diagnostics summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  font-weight: 750;
  color: var(--purple-900);
}

.advanced-body,
.diagnostics-body {
  padding: 0 16px 16px;
}

.primary-btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--emerald-800), var(--emerald-700));
  color: white;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
  box-shadow: 0 14px 28px rgba(20,88,79,.18);
}

.primary-btn:hover { transform: translateY(-1px); }
.primary-btn:disabled { opacity: .55; cursor: wait; }

.result-panel {
  position: sticky;
  top: 20px;
  align-self: start;
  min-height: 620px;
}

.empty-state,
.loading,
.error-state {
  min-height: 470px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  width: 76px;
  height: 76px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  font-size: 34px;
  color: var(--gold-500);
  background: linear-gradient(135deg, rgba(203,165,90,.16), rgba(138,108,171,.14));
  margin-bottom: 18px;
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--emerald-950);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
}

.empty-state p { max-width: 360px; line-height: 1.55; }

.hidden { display: none !important; }

.spinner {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 4px solid rgba(20,88,79,.12);
  border-top-color: var(--emerald-700);
  animation: spin .8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.summary-card {
  background: linear-gradient(145deg, var(--emerald-950), var(--emerald-800));
  color: var(--cream-50);
  border-radius: 22px;
  padding: 24px;
  margin-bottom: 16px;
}

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

.summary-top h3 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 31px;
}

.muted { color: rgba(251,247,239,.65); font-size: 12px; }

.score-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(219,188,118,.7);
  background: rgba(203,165,90,.10);
}

.score-ring span { font-size: 24px; font-weight: 800; color: var(--gold-400); }
.score-ring small { font-size: 10px; color: rgba(251,247,239,.6); margin-top: 2px; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 22px;
}

.metric {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.08);
  padding: 12px;
  border-radius: 13px;
}

.metric span { display:block; font-size: 10px; color: rgba(251,247,239,.58); margin-bottom: 5px; }
.metric strong { font-size: 13px; color: var(--cream-50); }

.window-card,
.peaks-card {
  border: 1px solid rgba(20,88,79,.10);
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--white);
}

.window-row {
  padding: 15px 16px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid rgba(20,88,79,.08);
}

.window-row:last-child { border-bottom: 0; }
.window-row span { color: var(--muted); font-size: 12px; }
.window-row strong { font-size: 13px; text-align: right; color: var(--emerald-950); }
.window-row.accent { background: rgba(203,165,90,.10); }

.peaks-card { padding: 18px; }
.card-title-row { display:flex; align-items:center; justify-content:space-between; }
.peaks-list { display: grid; gap: 10px; }

.peak-item {
  padding: 13px 14px;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(138,108,171,.08), rgba(203,165,90,.08));
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.peak-item strong { color: var(--purple-900); }
.peak-item small { color: var(--muted); }

.diagnostics-body {
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.diag-item {
  padding: 10px 0;
  border-top: 1px solid rgba(101,71,129,.10);
}

.error-state strong { color: #8f3f47; font-size: 18px; }
.error-state p { max-width: 420px; line-height: 1.5; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .result-panel { position: static; }
  .hero-mark { display: none; }
}

@media (max-width: 680px) {
  .page-shell { padding: 12px; }
  .hero { padding: 30px 24px; border-radius: 24px; }
  .panel { padding: 18px; border-radius: 22px; }
  .grid.two, .grid.three, .metrics-grid { grid-template-columns: 1fr; }
  .summary-top { align-items: flex-start; }
  .score-ring { width: 84px; height: 84px; }
}

.install-hint {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(203,165,90,.10);
  color: var(--emerald-900);
  font-size: 12px;
  line-height: 1.5;
}
.saved-list { display:grid; gap:10px; margin-top:12px; }
.saved-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(62,156,131,.08);
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
}
.saved-item button {
  border:0; border-radius:10px; padding:8px 10px; cursor:pointer;
  background:var(--purple-700); color:white;
}
.offline-badge {
  position: fixed; right: 14px; bottom: 14px; z-index: 10;
  border-radius:999px; padding:8px 12px; font-size:12px; font-weight:700;
  background:var(--emerald-950); color:var(--cream-50);
  box-shadow:var(--shadow);
}

.secondary-install-btn {
  width: 100%;
  margin-top: 12px;
  border: 1px solid rgba(101,71,129,.24);
  border-radius: 16px;
  padding: 14px 18px;
  background: rgba(101,71,129,.08);
  color: var(--purple-900);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.secondary-install-btn:hover {
  background: rgba(101,71,129,.13);
}
