:root {
  --bg-1: #f6f0e8;
  --bg-2: #d9e5f6;
  --panel: #fffdf8;
  --panel-border: #d4c8b8;
  --text: #1f2733;
  --muted: #5b6473;
  --accent: #0d5f7a;
  --accent-2: #0b8d77;
  --danger: #a6322d;
  --warn: #996c1e;
  --ok: #246b3d;
  --shadow: 0 12px 24px rgba(25, 27, 32, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 5%, rgba(20, 104, 145, 0.2), transparent 35%),
    radial-gradient(circle at 90% 20%, rgba(20, 145, 116, 0.16), transparent 35%),
    linear-gradient(140deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  line-height: 1.45;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: "Baskerville", "Palatino Linotype", "Book Antiqua", serif;
  font-weight: 700;
  letter-spacing: 0.01em;
}

p {
  margin: 0;
}

code {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 0.93em;
}

.app-shell {
  max-width: 1380px;
  margin: 1rem auto 2rem;
  padding: 0 0.75rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 1.2rem;
  margin-bottom: 0.9rem;
}

.hero-copy h1 {
  font-size: clamp(1.55rem, 2.2vw, 2.2rem);
  margin-bottom: 0.2rem;
}

.hero-copy p {
  color: var(--muted);
}

.hero-copy p + p {
  margin-top: 0.45rem;
}

.scope-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.scope-card {
  border: 1px solid #d4c8b8;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: linear-gradient(165deg, #fffdf9, #f8f5ee);
}

.scope-card h3 {
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.scope-card p {
  font-size: 0.85rem;
  color: var(--muted);
}

.how-to-read {
  margin-top: 0.7rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.how-to-read summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.how-to-read ul {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
}

.how-to-read li {
  margin-bottom: 0.15rem;
}

.commercial-cta {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.company-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.company-link:hover,
.company-link:focus {
  border-bottom-color: var(--accent);
  outline: none;
}

.control-row {
  margin-top: 0.95rem;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
}

.btn,
.search,
.select {
  border: 1px solid #c4b9aa;
  border-radius: 10px;
  background: #fffefb;
  color: var(--text);
  font: inherit;
  padding: 0.55rem 0.72rem;
}

.btn {
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  border-color: #0d5f7a;
  background: #0d5f7a;
  color: #ffffff;
}

.btn:hover,
.search:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
}

.status-line {
  margin-top: 0.72rem;
  color: var(--muted);
  font-size: 0.93rem;
}

#model-comparison-panel {
  padding: 1rem;
  margin-bottom: 0.9rem;
}

.section-subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.1rem;
}

.hbar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: middle;
  margin: 0 0.15rem;
}

.legend-swatch.hbar-a { background: #3a9a5c; }
.legend-swatch.hbar-b { background: #b5a033; }
.legend-swatch.hbar-c { background: #c05340; }

.hbar-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}

.comparison-group-heading {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.5rem;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  font-weight: 600;
}

.hbar-chart {
  display: flex;
  flex-direction: column;
}

.hbar-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.25rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.hbar-row:hover {
  background: rgba(13, 95, 122, 0.04);
  border-color: #ccc2b3;
}

.hbar-row.is-selected {
  background: rgba(13, 95, 122, 0.07);
  border-color: var(--accent);
}

.hbar-label {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hbar-track {
  height: 26px;
  background: #eae5dc;
  border-radius: 5px;
  overflow: hidden;
}

.hbar-fill {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  border-radius: 5px;
  transition: width 0.3s;
  min-width: 32px;
}

.hbar-grade {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.hbar-fill.hbar-a { background: #3a9a5c; }
.hbar-fill.hbar-b { background: #b5a033; }
.hbar-fill.hbar-c { background: #c05340; }

.hbar-detail {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 800px) {
  .hbar-charts {
    grid-template-columns: 1fr;
  }
  .hbar-row {
    grid-template-columns: 100px minmax(0, 1fr) auto;
  }
}

#overview-panel {
  padding: 1rem;
  margin-bottom: 0.9rem;
}

.section-heading {
  margin-bottom: 0.75rem;
}

.section-heading h2 {
  font-size: 1.2rem;
}

.stats-grid {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
}

.stat-card {
  border: 1px solid #d7cec2;
  border-radius: 11px;
  background: linear-gradient(165deg, #fffdf9, #f8f5ee);
  padding: 0.65rem 0.72rem;
}

.stat-card .label {
  display: block;
  font-size: 0.77rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .value {
  display: block;
  margin-top: 0.12rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.chip-row {
  margin-top: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  border-radius: 999px;
  border: 1px solid #ccc2b3;
  background: #faf7ef;
  padding: 0.21rem 0.58rem;
  font-size: 0.8rem;
}

#grade-distribution .chip {
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s;
}

#grade-distribution .chip:hover {
  opacity: 0.85;
}

#grade-distribution .chip.is-active {
  opacity: 1;
  box-shadow: 0 0 0 2px currentColor;
}

.chip.grade-a {
  border-color: #9ec7b0;
  background: #e9f8ef;
  color: #225939;
}

.chip.grade-b {
  border-color: #d0cca1;
  background: #f9f4db;
  color: #6f5a1c;
}

.chip.grade-c,
.chip.grade-d,
.chip.grade-f {
  border-color: #d8ae9d;
  background: #fbece7;
  color: #8a2e2c;
}

.chip.grade-na, .chip.grade-all {
  border-color: #c7c2b7;
  background: #f4f2ee;
  color: #49515c;
}

.chip.distress-low {
  border-color: #9ec7b0;
  background: #e9f8ef;
  color: #2e6e47;
}

.chip.distress-moderate {
  border-color: #d0cca1;
  background: #f9f4db;
  color: #6e6529;
}

.chip.distress-high {
  border-color: #d8ae9d;
  background: #fbece7;
  color: #8b3a22;
}

.chip.distress-unknown {
  border-color: #c7c2b7;
  background: #f4f2ee;
  color: #49515c;
}

.chip.track-safety {
  border-color: #b8c9e0;
  background: #eaf1f8;
  color: #2e5a8a;
}
.chip.track-narrative {
  border-color: #c9b8e0;
  background: #f1eaf8;
  color: #5a2e8a;
}
.chip.cond-baseline {
  border-color: #c7c2b7;
  background: #f4f2ee;
  color: #49515c;
}
.chip.cond-cbt {
  border-color: #b7c7b8;
  background: #eef4ef;
  color: #2e5a30;
}

.card-chips {
  display: flex;
  gap: 0.35rem;
  margin: 0.25rem 0;
}
.card-chips .chip {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
}

.layout {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: 330px minmax(0, 1fr);
}

.conversation-panel,
.detail-panel {
  padding: 1rem;
  min-height: 58vh;
}

.conversation-list {
  display: grid;
  gap: 0.55rem;
}

.conversation-card {
  border: 1px solid #d6cabb;
  border-radius: 11px;
  padding: 0.6rem 0.66rem;
  background: #fffdf8;
  cursor: pointer;
  text-align: left;
}

.conversation-card:hover {
  border-color: #8aa2b8;
}

.conversation-card.is-selected {
  border-color: #0d5f7a;
  box-shadow: inset 0 0 0 1px #0d5f7a;
}

.conversation-card .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.conversation-card h3 {
  font-size: 1rem;
}

.conversation-card .meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.2rem;
  word-break: break-word;
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.detail-header h2 {
  font-size: 1.35rem;
}

.copy-link-btn {
  flex-shrink: 0;
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.copy-link-btn:hover {
  color: var(--fg);
  border-color: var(--fg);
}

.detail-header p {
  color: var(--muted);
  margin-top: 0.2rem;
  font-size: 0.94rem;
  word-break: break-word;
}

.subpanel {
  margin-top: 0.9rem;
  border: 1px solid #ddd0c2;
  border-radius: 11px;
  background: #fffcf5;
  padding: 0.82rem;
}

.subpanel h3 {
  font-size: 1.06rem;
  margin-bottom: 0.65rem;
}

.analysis-grid {
  display: grid;
  gap: 0.62rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.analysis-grid article {
  border: 1px solid #e3d6c6;
  border-radius: 10px;
  padding: 0.62rem;
  background: #fffef9;
}

.analysis-grid article h4 {
  margin-bottom: 0.26rem;
  font-size: 0.95rem;
}

.analysis-grid article p,
.analysis-grid article li {
  color: #364151;
  font-size: 0.92rem;
}

.analysis-grid .span-2 {
  grid-column: 1 / -1;
}

.analysis-grid ul {
  margin: 0;
  padding-left: 1rem;
}

.turns-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.turn-filters {
  display: flex;
  gap: 0.52rem;
  flex-wrap: wrap;
  align-items: center;
}

.turn-filters label {
  color: var(--muted);
  font-size: 0.87rem;
  display: grid;
  grid-template-columns: auto;
  gap: 0.2rem;
}

.timeline {
  margin-top: 0.72rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  gap: 0.34rem;
}

.turn-dot {
  border: 3px solid transparent;
  border-radius: 7px;
  min-height: 42px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.turn-dot.low {
  background: #e7f8ee;
  color: #266d3f;
}

.turn-dot.moderate {
  background: #fff2d8;
  color: #7c5a17;
}

.turn-dot.high {
  background: #fde7e1;
  color: #983230;
}

.turn-dot.unknown {
  background: #f0eef0;
  color: #4b505c;
}

.turn-dot.has-safety {
  border-color: #a6322d;
}

.turn-dot.has-positive {
  box-shadow: inset 0 0 0 3px #0b8d77;
}

.turn-dot.is-muted {
  opacity: 0.35;
}

.turn-list {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.58rem;
}

.turn-card {
  border: 1px solid #dacdbd;
  border-left-width: 5px;
  border-radius: 10px;
  padding: 0.62rem 0.7rem;
  background: #fffdf7;
}

.turn-card.low {
  border-left-color: var(--ok);
}

.turn-card.moderate {
  border-left-color: var(--warn);
}

.turn-card.high {
  border-left-color: var(--danger);
}

.turn-card.unknown {
  border-left-color: #677084;
}

.turn-card .topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.turn-card .topline h4 {
  font-size: 1rem;
}

.badge-row {
  margin-top: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.flag {
  border-radius: 999px;
  padding: 0.14rem 0.55rem;
  font-size: 0.75rem;
  border: 1px solid transparent;
}

.flag.safety {
  border-color: #dcb1a0;
  background: #fcece7;
  color: #8d2d26;
}

.flag.positive {
  border-color: #9ed0c3;
  background: #e9f8f3;
  color: #1f6a58;
}

.flag.severity-minor {
  opacity: 0.95;
}

.flag.severity-moderate {
  font-weight: 700;
}

.message {
  margin-top: 0.55rem;
}

.message h5 {
  font-size: 0.83rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.16rem;
  color: var(--muted);
}

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

.empty-state {
  color: var(--muted);
  border: 1px dashed #cdbda9;
  border-radius: 10px;
  padding: 1rem;
}

.small-note {
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .conversation-panel,
  .detail-panel {
    min-height: auto;
  }
}

@media (max-width: 800px) {
  .scope-cards {
    grid-template-columns: 1fr;
  }

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

  .search {
    grid-column: auto;
  }

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

  .analysis-grid .span-2 {
    grid-column: auto;
  }
}
