:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-2: #f0f3f1;
  --ink: #20242b;
  --muted: #68717a;
  --border: #d7dbd4;
  --danger: #b43f3a;
  --danger-2: #f6e7e4;
  --amber: #b27322;
  --amber-2: #f7ecd8;
  --teal: #25756f;
  --teal-2: #dff0ed;
  --blue: #365f9c;
  --blue-2: #e4ebf6;
  --green: #587d43;
  --shadow: 0 18px 45px rgba(36, 42, 50, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease;
}

button:hover:not(:disabled) {
  border-color: #aeb7ad;
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.primary {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(37, 117, 111, 0.13);
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 18px;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 3vw, 3.6rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
}

.status-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.version-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  padding: 0 12px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  white-space: nowrap;
}

.status-pill.ok {
  border-color: #a9c4b3;
  background: #e8f2eb;
  color: var(--green);
}

.status-pill.warn {
  border-color: #e2c18d;
  background: var(--amber-2);
  color: #8a5719;
}

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

.control-panel,
.fights-pane,
.analysis-pane {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 14px;
}

.report-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(150px, 190px) minmax(140px, 170px) auto;
  gap: 12px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.button-row {
  display: grid;
  grid-template-columns: 110px 110px;
  gap: 8px;
}

.message-line {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.message-line.error {
  color: var(--danger);
}

.message-line.ok {
  color: var(--teal);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(330px, 410px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.fights-pane,
.analysis-pane {
  min-height: 620px;
  padding: 14px;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

.segment {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.segment.active {
  background: var(--ink);
  color: #fff;
}

.report-meta {
  min-height: 48px;
  margin: 14px 0;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.fight-list {
  display: grid;
  gap: 8px;
  max-height: 720px;
  overflow: auto;
  padding-right: 2px;
}

.fight-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: 100%;
  min-height: 72px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
  text-align: left;
}

.fight-item.active {
  border-color: var(--danger);
  background: var(--danger-2);
}

.fight-title {
  font-weight: 800;
  line-height: 1.2;
}

.fight-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.fight-badge {
  align-self: start;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.fight-badge.wipe {
  background: var(--danger-2);
  color: var(--danger);
}

.fight-badge.kill {
  background: var(--teal-2);
  color: var(--teal);
}

.empty-state {
  display: grid;
  place-content: center;
  min-height: 560px;
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 1.25rem;
}

.analysis-stack {
  display: grid;
  gap: 14px;
}

.analysis-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.analysis-title {
  margin-bottom: 6px;
  font-size: 1.35rem;
}

.confidence {
  min-width: 90px;
  border-radius: 999px;
  background: var(--blue-2);
  color: var(--blue);
  padding: 7px 10px;
  font-size: 0.84rem;
  font-weight: 800;
  text-align: center;
}

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

.metric-card,
.evidence-card,
.recommendation,
.death-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.metric-card {
  min-height: 104px;
  padding: 12px;
}

.metric-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.metric-value {
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1.05;
}

.metric-note {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.82rem;
}

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

.timeline {
  position: relative;
  height: 86px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(to right, rgba(180, 63, 58, 0.12) 0 1px, transparent 1px) 0 0 / 10% 100%,
    var(--surface);
  overflow: hidden;
}

.timeline-axis {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 42px;
  height: 2px;
  background: #cfd5d1;
}

.death-marker {
  position: absolute;
  top: 20px;
  width: 12px;
  height: 42px;
  border-radius: 999px;
  background: var(--danger);
  transform: translateX(-50%);
}

.death-marker::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  top: 48px;
  width: max-content;
  max-width: 140px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 12px;
}

.mechanic-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.mechanic-card {
  padding: 12px;
  border-left: 4px solid var(--amber);
}

.mechanic-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.mechanic-title {
  font-weight: 900;
  line-height: 1.3;
}

.mechanic-source {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.mechanic-guide {
  display: inline-flex;
  margin-top: 4px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  text-decoration: none;
}

.mechanic-guide:hover {
  text-decoration: underline;
}

.mechanic-classification {
  display: grid;
  gap: 2px;
  margin-top: 6px;
  max-width: 560px;
  border-left: 3px solid var(--border);
  padding-left: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.35;
}

.mechanic-classification span {
  font-weight: 700;
}

.mechanic-classification.bad {
  border-color: var(--danger);
  color: var(--danger);
}

.mechanic-classification.good {
  border-color: var(--teal);
  color: var(--teal);
}

.severity-chip {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 900;
}

.severity-chip.high {
  background: var(--danger-2);
  color: var(--danger);
}

.mechanic-evidence,
.mechanic-interpretation {
  margin: 0 0 8px;
  color: #3f4851;
  line-height: 1.55;
}

.mechanic-actions {
  margin: 0;
  padding-left: 18px;
  color: #3f4851;
  line-height: 1.5;
}

.mechanic-actions li + li {
  margin-top: 4px;
}

.evidence-card {
  padding: 12px;
}

.score-list,
.recommendation-list,
.death-list {
  display: grid;
  gap: 8px;
}

.score-row {
  display: grid;
  grid-template-columns: minmax(120px, 170px) minmax(0, 1fr) 54px;
  gap: 10px;
  align-items: center;
  min-height: 44px;
}

.score-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-class {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.score-bar {
  height: 9px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--danger);
}

.score-value {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: right;
}

.score-reasons {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 0.78rem;
}

.death-card {
  padding: 12px;
}

.death-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.rank-chip {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--danger-2);
  color: var(--danger);
  font-weight: 900;
}

.death-name {
  font-weight: 900;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pill {
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.pill.warn {
  background: var(--amber-2);
  color: var(--amber);
}

.pill.bad {
  background: var(--danger-2);
  color: var(--danger);
}

.pill.good {
  background: var(--teal-2);
  color: var(--teal);
}

.pill.neutral {
  background: var(--surface-2);
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

td.number,
th.number {
  text-align: right;
  white-space: nowrap;
}

.recommendation {
  padding: 12px;
  border-left: 4px solid var(--teal);
}

.recommendation h3 {
  margin-bottom: 6px;
}

.recommendation p {
  margin-bottom: 0;
  color: #3f4851;
  line-height: 1.55;
}

.raw-counts {
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 1180px) {
  .report-form,
  .content-grid,
  .split-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .button-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fights-pane,
  .analysis-pane {
    min-height: auto;
  }

  .fight-list {
    max-height: 420px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .pane-head,
  .analysis-head {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .status-pill,
  .version-pill,
  .confidence {
    width: 100%;
    justify-content: center;
  }

  .topbar-status {
    width: 100%;
    justify-content: center;
  }

  .segmented {
    width: 100%;
  }

  .score-row {
    grid-template-columns: 1fr 54px;
  }

  .score-bar {
    grid-column: 1 / 3;
    grid-row: 2;
  }

  .score-reasons {
    grid-column: 1 / 3;
  }

  .death-head {
    grid-template-columns: auto minmax(0, 1fr);
  }
}
