:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --ink: #17211b;
  --muted: #667064;
  --panel: #ffffff;
  --line: #d9ddd2;
  --accent: #166c5b;
  --accent-2: #b24a38;
  --accent-3: #385f9f;
  --empty: #ebedf0;
  --low: #9be9a8;
  --medium: #40c463;
  --high: #30a14e;
  --marker: #216e39;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.92);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  font-weight: 800;
  text-decoration: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav a {
  text-decoration: none;
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--ink);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: end;
  min-height: 420px;
  padding: 48px 0 42px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 740px;
  margin: 0;
  font-size: clamp(2.8rem, 7vw, 6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.18rem;
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.lede {
  max-width: 700px;
  margin: 24px 0 0;
  color: #4e5a50;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.55;
}

.search-panel,
.panel,
.score-band,
.status {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.search-panel {
  padding: 24px;
  box-shadow: 0 18px 48px rgba(23, 33, 27, 0.08);
}

label {
  display: block;
  margin-bottom: 10px;
  font-weight: 750;
}

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

input,
select,
button {
  min-height: 46px;
  border-radius: 6px;
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid #c9cfc4;
  padding: 0 12px;
  background: #fbfcf8;
  color: var(--ink);
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(22, 108, 91, 0.16);
}

button {
  border: 0;
  padding: 0 18px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent);
}

.fine-print {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.status {
  margin: 12px 0 24px;
  padding: 16px 18px;
  color: var(--muted);
}

.status.error {
  border-color: rgba(178, 74, 56, 0.35);
  color: #8d2e22;
}

.results {
  display: grid;
  gap: 18px;
}

.score-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 280px);
  gap: 24px;
  align-items: center;
  padding: 24px;
}

.score-band h2 {
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  line-height: 1;
}

.score-band p:last-child {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.score-meter {
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--empty);
}

.score-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 300ms ease;
}

.score-meter[data-level="moderate"] span {
  background: var(--accent-3);
}

.score-meter[data-level="high"] span {
  background: var(--accent-2);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-grid article {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.metric-grid span {
  display: block;
  font-size: clamp(1.7rem, 4vw, 2.7rem);
  font-weight: 850;
}

.metric-grid p {
  margin: 6px 0 0;
  color: var(--muted);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.panel {
  padding: 20px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: baseline;
  margin-bottom: 18px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  text-align: right;
}

.calendar {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 12px);
  grid-auto-columns: 12px;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.day,
.legend i {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(23, 33, 27, 0.06);
}

.empty {
  background: var(--empty);
}

.low {
  background: var(--low);
}

.medium {
  background: var(--medium);
}

.high {
  background: var(--high);
}

.marker {
  background: var(--marker);
}

.calendar-blank {
  visibility: hidden;
}

.legend {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.86rem;
}

.signals {
  display: grid;
  gap: 10px;
}

.signal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.signal.active {
  border-color: rgba(178, 74, 56, 0.38);
  background: #fff8f5;
}

.signal p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.signal strong {
  white-space: nowrap;
}

.breakdown {
  display: grid;
  gap: 12px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 70px;
  gap: 12px;
  align-items: center;
}

.bar {
  height: 12px;
  border-radius: 999px;
  background: var(--empty);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.breakdown-row strong {
  text-align: right;
}

.roadmap {
  margin-top: 44px;
}

.tool-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.tool-list article {
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.tool-list p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.tool-list a {
  text-decoration: none;
}

.encode-hero h1 {
  max-width: 820px;
}

.encoder-metrics article:nth-child(3) span,
.encoder-metrics article:nth-child(4) span {
  color: var(--accent);
}

.encoder-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
}

.candidate-list {
  display: grid;
  gap: 10px;
}

.candidate {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.candidate p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.candidate strong {
  font-size: 0.95rem;
}

.candidate button {
  justify-self: start;
  min-height: 38px;
}

.candidate button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.encode-workspace {
  display: grid;
  gap: 18px;
}

.encode-form {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) 160px 165px auto auto;
  gap: 12px;
  align-items: end;
}

.encode-form input#message {
  font-weight: 800;
  letter-spacing: 0;
}

.fit-summary {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.fit-summary span {
  color: var(--muted);
  line-height: 1.45;
}

.fit-summary.good {
  border-color: rgba(22, 108, 91, 0.35);
  background: #f5fbf7;
}

.fit-summary.warning {
  border-color: rgba(178, 74, 56, 0.35);
  background: #fff8f5;
}

.preview-calendar .planned-zero,
.preview-calendar .planned-payload-low,
.preview-calendar .planned-payload-medium,
.preview-calendar .planned-payload-high,
.preview-calendar .planned-marker {
  box-shadow: inset 0 0 0 1px rgba(23, 33, 27, 0.08);
}

.preview-calendar .planned-zero {
  background: var(--empty);
}

.preview-calendar .planned-payload-low {
  background: var(--low);
}

.preview-calendar .planned-payload-medium {
  background: var(--medium);
}

.preview-calendar .planned-payload-high {
  background: var(--high);
}

.preview-calendar .planned-marker {
  background: var(--marker);
}

.preview-calendar .conflict {
  box-shadow: inset 0 0 0 2px var(--accent-2);
}

.preview-legend {
  flex-wrap: wrap;
}

.preview-legend i {
  position: relative;
  background: var(--empty);
}

.preview-legend .planned-zero {
  background: var(--empty);
  box-shadow: inset 0 0 0 1px rgba(23, 33, 27, 0.08);
}

.preview-legend .planned-payload {
  background: var(--medium);
  box-shadow: inset 0 0 0 1px rgba(23, 33, 27, 0.08);
}

.preview-legend .planned-marker {
  background: var(--marker);
  box-shadow: inset 0 0 0 1px rgba(23, 33, 27, 0.08);
}

.preview-legend .conflict {
  background: var(--high);
  box-shadow: inset 0 0 0 2px var(--accent-2);
}

.command-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.command-builder {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.hint-toggle {
  color: var(--ink);
}

.command-box h3 {
  margin: 0;
}

.command-box p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.command-box pre {
  grid-column: 1 / -1;
  margin: 0;
  overflow-x: auto;
  padding: 14px;
  border-radius: 6px;
  background: #17211b;
  color: #eef5ed;
  line-height: 1.5;
}

.command-box code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
  white-space: pre;
}

@media (max-width: 860px) {
  .topbar,
  .section-heading,
  .score-band {
    align-items: stretch;
  }

  .topbar,
  .hero,
  .score-band,
  .main-grid,
  .encoder-grid,
  .encode-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .hero {
    min-height: 0;
    padding-top: 26px;
  }

  .search-row,
  .metric-grid,
  .tool-list {
    grid-template-columns: 1fr;
  }

  .section-heading {
    display: grid;
  }

  .section-heading p {
    text-align: left;
  }

  .breakdown-row {
    grid-template-columns: 110px minmax(0, 1fr) 48px;
  }

  .command-box {
    grid-template-columns: 1fr;
  }

  .command-builder {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 520px) {
  main {
    width: min(100% - 24px, 1180px);
    padding-top: 24px;
  }

  .nav {
    flex-wrap: wrap;
  }

  .panel,
  .score-band,
  .search-panel {
    padding: 16px;
  }
}
