:root {
  color-scheme: light;
  --ink: #222f3a;
  --muted: #66727d;
  --page: #e9edf1;
  --panel: #ffffff;
  --panel-soft: #f6f8fa;
  --line: #c8d2dc;
  --line-dark: #9fb0bf;
  --navy: #123f67;
  --navy-dark: #0c2c49;
  --blue: #1d6fa5;
  --streamgage-green: #6cc091;
  --green: #25764b;
  --yellow: #d8a329;
  --red: #b34542;
  --shadow: 0 1px 2px rgba(20, 37, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--page);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1500px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 12px 0 18px;
}

.planner,
.results {
  border: 1px solid var(--line-dark);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.planner {
  align-self: start;
}

.results {
  min-height: calc(100vh - 30px);
  display: flex;
  flex-direction: column;
}

.brand-row,
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--line-dark);
  padding: 10px 12px;
  background: var(--streamgage-green);
  color: #fff;
}

.result-header {
  background: var(--panel-soft);
  color: var(--ink);
}

.brand-row {
  padding: 5px 8px;
  background: #fff;
}

.brand-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}

.brand-logo {
  width: 60%;
  max-height: 190px;
  height: auto;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-subtitle {
  margin-top: 1px;
  color: #115493;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-accent {
  color: #25a6ad;
}

.brand-tagline {
  color: #687382;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  font-size: 0.98rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: center;
}

.eyebrow {
  margin: 0 0 3px;
  color: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.82;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.08;
}

h1 {
  font-size: 1.55rem;
  font-weight: 700;
}

h2 {
  color: var(--navy-dark);
  font-size: 1.35rem;
  font-weight: 700;
}

.mode-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.result-header .mode-badge {
  border-color: var(--line-dark);
  color: var(--navy-dark);
  background: #eaf2f8;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
  align-items: start;
  padding: 8px;
  background: var(--panel-soft);
}

label {
  display: grid;
  gap: 3px;
  align-content: start;
  color: #344a5d;
  font-size: 0.72rem;
  font-weight: 700;
}

.control-help {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 500;
  line-height: 1.15;
}

select[multiple] {
  min-height: 82px;
  padding: 2px;
}

select[multiple] option {
  padding: 2px 5px;
}

.control-disabled {
  opacity: 0.48;
}

.control-disabled input,
.control-disabled .range-row {
  cursor: not-allowed;
  background: #e5e9ed;
}

.limit-hidden {
  display: none;
}

.wide,
.primary-action {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 31px;
  border: 1px solid var(--line-dark);
  border-radius: 0;
  padding: 5px 7px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 72px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(29, 111, 165, 0.16);
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 46px;
  gap: 6px;
  align-items: center;
  min-height: 31px;
  padding: 0 6px;
  border: 1px solid var(--line-dark);
  background: #fff;
}

input[type="range"] {
  padding: 0;
  border: 0;
  min-height: 0;
  box-shadow: none;
  accent-color: var(--blue);
  background: transparent;
}

output {
  color: var(--navy-dark);
  font-size: 0.76rem;
  font-weight: 700;
  text-align: right;
}

.primary-action,
.ghost-action {
  border: 1px solid var(--navy-dark);
  border-radius: 0;
  font-weight: 700;
  cursor: pointer;
}

.primary-action {
  min-height: 34px;
  margin-top: 0;
  color: #fff;
  background: linear-gradient(#1f679a, var(--navy));
}


.ghost-action {
  min-width: 70px;
  min-height: 32px;
  color: var(--navy-dark);
  background: #fff;
  border-color: var(--line-dark);
}

.primary-action:disabled {
  cursor: progress;
  opacity: 0.72;
}

.loading {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: max-content;
  margin: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line-dark);
  color: var(--navy-dark);
  background: #eef5fb;
  font-weight: 700;
}

.loading span {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(29, 111, 165, 0.22);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.hidden {
  display: none;
}

.temporarily-hidden {
  display: none;
}

.plan-output {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.empty-state {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.45;
}

.plan-card {
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}

.plan-card h3 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 7px 9px;
  color: var(--navy-dark);
  background: #eef2f6;
  font-size: 0.9rem;
  font-weight: 700;
}

.plan-card p,
.plan-card li {
  color: #263746;
  line-height: 1.42;
}

.plan-card p {
  margin: 0;
  padding: 9px;
}

.plan-card ul {
  margin: 0;
  padding: 9px 9px 9px 28px;
}

.collapsible-card summary {
  padding: 7px 9px;
  color: var(--navy-dark);
  background: #eef2f6;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  list-style-position: inside;
}

.collapsible-card[open] summary {
  border-bottom: 1px solid var(--line);
}

.collapsible-content .small-note {
  padding-top: 0;
}

.gauge-map-card {
  padding-bottom: 8px;
}

.map-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 7px 9px;
  color: var(--navy-dark);
  background: #eef2f6;
  cursor: pointer;
  list-style-position: inside;
}

.map-title {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 700;
}

.map-title-row > span:last-child {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.map-content {
  padding-bottom: 1px;
}

.gauge-map {
  z-index: 0;
  width: calc(100% - 16px);
  height: 360px;
  margin: 8px;
  border: 1px solid var(--line-dark);
  background: #e7edf1;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 0 9px;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.map-legend b {
  font-weight: 800;
}

.map-legend .ideal {
  color: #25764b;
}

.map-legend .search-location {
  color: #1476c6;
}

.map-legend .good {
  color: #6e9f45;
}

.map-legend .marginal {
  color: #b47a00;
}

.map-legend .forget-it {
  color: #b34542;
}

.map-legend .other {
  color: #507189;
}

.map-card-link {
  color: var(--navy-dark);
  font-weight: 800;
}

.stream-summary-wrap {
  overflow-x: auto;
  margin: 8px;
  border: 1px solid var(--line);
}

.summary-only-card > h3 {
  margin: 0;
  padding: 7px 9px;
  color: var(--navy-dark);
  background: #eef2f6;
  font-size: 0.9rem;
}

.stream-summary {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.78rem;
}

.stream-summary th,
.stream-summary td {
  width: 1%;
  padding: 5px 7px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.stream-summary th {
  color: var(--navy-dark);
  background: #eef2f6;
  font-size: 0.68rem;
  text-transform: uppercase;
}

.stream-summary tr:last-child td {
  border-bottom: 0;
}

.stream-summary th:first-child,
.stream-summary td:first-child {
  width: auto;
  min-width: 220px;
  max-width: 420px;
  white-space: normal;
}

.fishability-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.water-temp-badge {
  display: inline-block;
  min-width: 58px;
  border-radius: 999px;
  padding: 3px 8px;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.temp-optimal { background: #238636; }
.temp-sluggish { background: #2474b5; }
.temp-stress { background: #d96b16; }
.temp-lethal {
  background: #c62828;
  font-weight: 900;
}
.temp-na {
  color: #475569;
  background: #e2e8f0;
}

.stream-summary a {
  color: var(--navy-dark);
  font-weight: 700;
}

.query-preview {
  max-height: 420px;
  overflow: auto;
  margin: 0;
  border: 0;
  padding: 10px;
  color: #1b2b25;
  background: #fbfcfd;
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
  line-height: 1.42;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-thread {
  display: grid;
  gap: 8px;
  padding: 9px;
  background: #fbfcfd;
}

.chat-message {
  border: 1px solid var(--line);
  background: #fff;
}

.chat-message b {
  display: block;
  border-bottom: 1px solid var(--line);
  padding: 5px 7px;
  color: var(--navy-dark);
  background: #eef2f6;
  font-size: 0.78rem;
}

.chat-message.user b {
  color: #fff;
  background: var(--navy);
}

.chat-message p {
  white-space: pre-wrap;
}

.chat-reply {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 9px;
  background: var(--panel-soft);
}

.chat-reply .primary-action {
  grid-column: auto;
  justify-self: start;
  min-width: 120px;
  padding: 0 14px;
}

.small-note {
  margin-top: 0;
  color: var(--muted) !important;
  font-size: 0.86rem;
}

.stream-grid {
  display: grid;
  gap: 10px;
}

.stream-card {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  scroll-margin-top: 12px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
  padding: 0;
}

.stream-card:target {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(29, 111, 165, 0.2), var(--shadow);
}

.stream-rank {
  width: 100%;
  min-height: 100%;
  display: grid;
  place-items: start center;
  padding-top: 10px;
  color: #fff;
  background: var(--navy);
  font-weight: 700;
}

.stream-card > div:last-child {
  padding: 9px 10px 10px 0;
}

.stream-card h3 {
  margin: 0 0 8px;
  color: var(--navy-dark);
  font-size: 1.06rem;
}

.stream-card h3 a {
  color: inherit;
  text-decoration-color: #8aa8bb;
  text-underline-offset: 2px;
}

.stream-card h3 a:hover {
  color: var(--blue);
}

.stream-card dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  gap: 0;
  margin: 0 0 8px;
  border: 1px solid var(--line);
}

.stream-card dl div {
  border-right: 1px solid var(--line);
  background: #fbfcfd;
}

.stream-card dl div:last-child {
  border-right: 0;
}

.stream-card dt {
  border-bottom: 1px solid var(--line);
  padding: 4px 6px;
  color: var(--muted);
  background: #eef2f6;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
}

.stream-card dd {
  margin: 0;
  padding: 5px 6px;
  color: var(--ink);
  font-weight: 700;
}

.stream-card p {
  margin: 0;
  padding: 0;
  line-height: 1.42;
}

.stream-card-details {
  margin: 0 0 2px;
  border: 1px solid var(--line);
  background: #fff;
}

.stream-card-details > summary {
  padding: 6px 8px;
  color: var(--navy-dark);
  background: #eef2f6;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stream-card-details-content {
  display: grid;
  gap: 8px;
  padding: 8px;
}

.stream-card-details-content .weather-forecast {
  margin-bottom: 0;
}

.weather-forecast {
  margin: 0 0 9px;
  border: 1px solid #cbd9e2;
  background: #f4f8fa;
}

.weather-heading {
  padding: 4px 7px;
  color: var(--navy);
  background: #e2edf2;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.weather-heading a {
  float: right;
  color: inherit;
  font-size: 0.62rem;
  font-weight: 700;
}

.weather-days {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.weather-day {
  display: grid;
  gap: 2px;
  min-width: 0;
  border-right: 1px solid #cbd9e2;
  padding: 6px 7px;
}

.weather-day:last-child {
  border-right: 0;
}

.weather-day > b {
  color: var(--navy-dark);
  font-size: 0.76rem;
}

.weather-condition {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weather-temp {
  font-size: 0.88rem;
  font-weight: 800;
}

.weather-day small {
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.25;
}

.weather-forecast.unavailable {
  display: flex;
  gap: 8px;
  padding: 6px 7px;
  color: var(--muted);
  font-size: 0.76rem;
}

.range-graph {
  margin: 10px 0 12px;
  border: 1px solid var(--line);
  padding: 8px 9px 7px;
  background: #fbfcfd;
}

.range-graph.unavailable {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.range-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 175px;
  gap: 14px;
  align-items: stretch;
}

.range-plot {
  min-width: 0;
  padding-top: 23px;
}

.range-segment.ideal {
  --range-color: #25764b;
  background: #25764b;
}

.range-segment.good {
  --range-color: #6e9f45;
  background: #6e9f45;
}

.range-segment.marginal {
  --range-color: #d8a329;
  background: #d8a329;
}

.range-segment.forget {
  --range-color: #b34542;
  background: #b34542;
}

.range-track {
  position: relative;
  height: 28px;
  border: 1px solid var(--line-dark);
  background: #eef2f6;
}

.range-segment {
  position: absolute;
  top: 0;
  bottom: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.7);
}

.flow-marker {
  position: absolute;
  top: -5px;
  bottom: -5px;
  z-index: 2;
  width: 2px;
  background: #111;
}

.flow-marker::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -4px;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  border-top: 6px solid #111;
}

.flow-marker b {
  position: absolute;
  top: -25px;
  left: 50%;
  padding: 2px 4px;
  color: #fff;
  background: #111;
  font-size: 0.68rem;
  line-height: 1.2;
  white-space: nowrap;
  transform: translateX(-50%);
}

.range-axis {
  position: relative;
  height: 20px;
  margin-top: 4px;
}

.range-axis span {
  position: absolute;
  top: 0;
  color: var(--muted);
  font-size: 0.68rem;
  transform: translateX(-50%);
}

.range-axis span:first-child {
  transform: none;
}

.range-axis-label {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  text-align: right;
  text-transform: uppercase;
}

.range-values {
  display: grid;
  align-content: center;
  border-left: 1px solid var(--line);
  padding-left: 12px;
  color: var(--ink);
  font-size: 0.72rem;
}

.range-values div {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 5px;
  padding: 3px 0;
}

.range-values b {
  color: var(--navy-dark);
  font-weight: 800;
}

.range-values div:nth-child(1) b {
  color: #25764b;
}

.range-values div:nth-child(2) b {
  color: #6e9f45;
}

.range-values div:nth-child(3) b {
  color: #b47a00;
}

.range-values div:nth-child(4) b {
  color: #b34542;
}

.range-values span {
  color: var(--muted);
  text-align: right;
}

.source-line {
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 7px !important;
}

.access-line {
  margin-bottom: 8px !important;
  border: 1px solid #a9c9b7;
  padding: 6px 8px !important;
  color: #174d32;
  background: #edf7f1;
  font-size: 0.84rem;
  font-weight: 700;
}

.access-line a {
  margin-top: 0;
}

.stream-card a {
  display: inline-block;
  margin-top: 8px;
  color: var(--blue);
  font-weight: 700;
}

.analysis-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
}

.analysis-sources > b {
  color: var(--navy-dark);
  font-size: 0.76rem;
}

.analysis-sources a {
  margin-top: 0;
  border: 1px solid var(--line-dark);
  padding: 4px 7px;
  background: #eef5fb;
  font-size: 0.8rem;
}

.analysis-sources.unavailable span,
.source-unavailable {
  color: var(--muted);
  font-size: 0.76rem;
}

.stream-sources-card > summary {
  border-bottom: 1px solid var(--line);
  padding: 7px 9px;
  color: var(--navy-dark);
  background: #eef2f6;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
}

.stream-sources-list {
  display: grid;
}

.stream-source-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 2fr);
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 7px 9px;
}

.stream-source-row:last-child {
  border-bottom: 0;
}

.stream-source-row > b a {
  color: var(--navy-dark);
}

.stream-source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  align-items: center;
}

.stream-source-links a {
  border: 1px solid var(--line-dark);
  padding: 3px 6px;
  color: var(--blue);
  background: #eef5fb;
  font-size: 0.76rem;
  font-weight: 700;
}

.stream-detail-list {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.stream-detail-list h4 {
  margin: 0 0 6px;
  color: var(--navy-dark);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.stream-detail-list ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.stream-detail-list li {
  color: #263746;
  line-height: 1.38;
}

.stream-detail-list a {
  margin-top: 0;
}

.stream-detail-list span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.stream-detail-list p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.84rem;
}

.confidence {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px;
}

.confidence h3 {
  border: 0;
  padding: 0;
  background: transparent;
}

.meter {
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line-dark);
  background: #fff;
}

.meter span {
  display: block;
  width: var(--value, 50%);
  height: 100%;
  background: linear-gradient(90deg, var(--yellow), var(--green));
}

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 10px 0;
  }

  .results {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100vw - 18px, 1500px);
  }

  .brand-row,
  .result-header {
    display: grid;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .stream-source-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.4rem;
  }

  h2 {
    font-size: 1.18rem;
  }

  .brand-logo {
    width: 72%;
  }

  .brand-subtitle {
    font-size: 1.15rem;
  }

  .brand-tagline {
    font-size: 0.84rem;
  }

  .stream-card {
    grid-template-columns: 32px 1fr;
  }

  .gauge-map {
    height: 280px;
  }

  .stream-card dl {
    grid-template-columns: repeat(2, minmax(90px, 1fr));
  }

  .stream-card dl div:nth-child(2) {
    border-right: 0;
  }

  .stream-card dl div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .stream-card dl div:nth-child(4) {
    border-right: 0;
  }

  .weather-days {
    grid-template-columns: 1fr;
  }

  .weather-day {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid #cbd9e2;
  }

  .weather-day:last-child {
    border-bottom: 0;
  }

  .weather-day small {
    grid-column: 2 / 4;
  }

  .range-layout {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .range-values {
    border-top: 1px solid var(--line);
    border-left: 0;
    padding-top: 5px;
    padding-left: 0;
  }

  .range-values div {
    grid-template-columns: 70px 1fr;
  }

  .range-values span {
    text-align: left;
  }

  .flow-marker b {
    display: none;
  }
}
