:root {
  color-scheme: light;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-soft: #eef4f2;
  --surface-raised: #fbfcfb;
  --field: #ffffff;
  --card-soft: #fbfcfc;
  --chip-bg: #edf3f1;
  --ink: #15201d;
  --muted: #5c6b67;
  --line: #d5dfdb;
  --line-strong: #bdcbc6;
  --teal: #087a75;
  --green: #31743a;
  --amber: #a85f00;
  --red: #b8323a;
  --blue: #2f68a3;
  --violet: #7056a6;
  --shadow: 0 16px 44px rgba(28, 42, 38, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1413;
  --surface: #171e1c;
  --surface-soft: #1d2825;
  --surface-raised: #131a18;
  --field: #0f1614;
  --card-soft: #121a18;
  --chip-bg: #22302c;
  --ink: #edf5f2;
  --muted: #9aaca7;
  --line: #2e3d39;
  --line-strong: #465853;
  --teal: #48c4ba;
  --green: #7dcc84;
  --amber: #e2ad5f;
  --red: #ef8087;
  --blue: #82b7ec;
  --violet: #ad99df;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(300px, 0.75fr) minmax(380px, 1fr);
  gap: 28px;
  align-items: end;
  padding: 22px max(118px, clamp(18px, 3vw, 42px)) 22px clamp(18px, 3vw, 42px);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--line);
}

.brand-block h1,
.asset-intro h2,
.panel-heading h2,
.feed-heading h2,
.action-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-block h1 {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

.brand-block p:last-child {
  max-width: 620px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.top-tools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: end;
}

.theme-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 50;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-weight: 850;
}

.lookup-form {
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.lookup-form label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.lookup-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.lookup-row input,
.prefix-search {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 13px;
  background: var(--field);
  color: var(--ink);
  outline: none;
}

.lookup-row input:focus,
.prefix-search:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 122, 117, 0.15);
}

.lookup-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 104px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 850;
}

.lookup-row button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.asset-strip {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(420px, 1.1fr);
  gap: 20px;
  align-items: stretch;
  padding: 20px clamp(18px, 3vw, 42px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.prefix-profile-band {
  padding: 18px clamp(18px, 3vw, 42px);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--line);
}

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

.profile-heading h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.profile-heading p {
  max-width: 780px;
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.profile-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 13px;
}

.profile-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.profile-card strong {
  display: block;
  margin-top: 7px;
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.18;
}

.profile-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.profile-card.good {
  border-left: 4px solid var(--green);
}

.profile-card.info {
  border-left: 4px solid var(--blue);
}

.profile-card.watch {
  border-left: 4px solid var(--amber);
}

.profile-card.bad {
  border-left: 4px solid var(--red);
}

.replay-band {
  padding: 18px clamp(18px, 3vw, 42px);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

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

.replay-heading h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.replay-heading p {
  max-width: 850px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.replay-form {
  display: grid;
  grid-template-columns: minmax(240px, 1.25fr) minmax(250px, 0.95fr) minmax(190px, 0.75fr) minmax(190px, 0.75fr) minmax(240px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.replay-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.scope-toggle {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: var(--field);
}

.scope-toggle legend {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.scope-toggle label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.scope-toggle input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.scope-toggle span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 6px;
  padding: 0 10px;
  text-align: center;
}

.scope-toggle input:checked + span {
  background: var(--ink);
  color: var(--bg);
}

.replay-form input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--field);
  color: var(--ink);
  outline: none;
}

.replay-form input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 122, 117, 0.15);
}

.replay-form .scope-toggle input {
  inline-size: 1px;
  block-size: 1px;
  min-width: 0;
  padding: 0;
  border: 0;
}

.replay-actions {
  display: grid;
  grid-template-columns: auto;
  gap: 8px;
}

.replay-actions button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 850;
  white-space: nowrap;
}

.replay-actions button[type="submit"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.replay-actions button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.replay-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(520px, 1.1fr);
  gap: 12px;
  align-items: start;
}

.replay-summary,
.replay-cards article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.replay-summary {
  grid-column: 1 / -1;
  padding: 15px;
}

.replay-summary strong,
.replay-summary span {
  display: block;
}

.replay-summary strong {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.2;
}

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

.answer-kicker {
  margin-bottom: 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.answer-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-soft);
  padding: 10px 11px;
}

.answer-row span,
.answer-row strong,
.answer-row small {
  display: block;
}

.answer-row span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.answer-row strong {
  margin-top: 7px;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.2;
}

.answer-row small {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.learning-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.learning-note {
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 11px;
}

.learning-note span {
  display: block;
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.learning-note p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.replay-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  align-content: start;
  align-self: start;
  gap: 8px;
}

.replay-cards article {
  min-height: 0;
  padding: 11px 12px;
}

.replay-cards span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.replay-cards strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.15;
}

.replay-cards small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.replay-feed {
  display: grid;
  align-content: start;
  gap: 10px;
}

.sparkline {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 3px;
  height: 30px;
  margin-top: 8px;
}

.sparkline i {
  display: block;
  min-height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--teal);
}

.asset-intro h2 {
  font-size: clamp(22px, 2.4vw, 34px);
  line-height: 1.08;
}

.asset-intro p,
.feed-heading p,
.action-panel p,
.event-card p {
  color: var(--muted);
  line-height: 1.52;
}

.badge-row,
.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge,
.stream-state,
.event-type,
.event-time,
.meta-chip,
.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--chip-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.badge.good,
.event-card.good .event-type,
.signal-card.good strong {
  color: var(--green);
}

.badge.watch,
.event-card.watch .event-type,
.signal-card.watch strong {
  color: var(--amber);
}

.badge.bad,
.event-card.bad .event-type,
.signal-card.bad strong {
  color: var(--red);
}

.badge.info,
.event-card.info .event-type,
.signal-card.info strong {
  color: var(--blue);
}

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

.signal-card,
.impact-grid article,
.prefix-panel,
.main-panel,
.action-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.signal-card {
  display: grid;
  align-content: center;
  min-height: 118px;
  padding: 15px;
}

.signal-label,
.impact-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.signal-card strong {
  display: block;
  min-width: 0;
  margin: 8px 0 6px;
  overflow-wrap: anywhere;
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.1;
}

.signal-card small {
  color: var(--muted);
  line-height: 1.35;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(420px, 1fr) minmax(250px, 320px);
  gap: 18px;
  padding: 18px clamp(18px, 3vw, 42px) 36px;
}

.prefix-panel,
.main-panel,
.action-panel {
  min-width: 0;
  padding: 16px;
}

.main-panel {
  box-shadow: var(--shadow);
}

.panel-heading,
.feed-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.panel-heading {
  margin-bottom: 12px;
}

.panel-heading h2,
.feed-heading h2,
.action-panel h2 {
  font-size: 22px;
}

.prefix-search {
  margin-bottom: 12px;
}

.prefix-tools {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.prefix-tools button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.prefix-tools span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-align: right;
}

.prefix-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 360px);
  min-height: 280px;
  overflow: auto;
  padding-right: 3px;
}

.prefix-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: stretch;
}

.prefix-check {
  display: grid;
  place-items: center;
  width: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.prefix-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.prefix-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 11px 12px;
  color: var(--ink);
  text-align: left;
}

.prefix-button:hover {
  border-color: var(--line-strong);
  background: var(--card-soft);
}

.prefix-button.active {
  border-color: var(--teal);
  background: var(--surface-soft);
  box-shadow: inset 4px 0 0 var(--teal);
}

.prefix-row.selected .prefix-check,
.prefix-row.selected .prefix-button {
  border-color: var(--teal);
}

.prefix-button strong,
.prefix-button small {
  display: block;
}

.prefix-button strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.prefix-button small {
  margin-top: 4px;
  color: var(--muted);
}

.stream-state {
  white-space: nowrap;
}

.stream-state.live {
  background: color-mix(in srgb, var(--green) 16%, transparent);
  color: var(--green);
}

.stream-state.info {
  background: color-mix(in srgb, var(--blue) 16%, transparent);
  color: var(--blue);
}

.stream-state.watch {
  background: color-mix(in srgb, var(--amber) 18%, transparent);
  color: var(--amber);
}

.stream-state.error {
  background: color-mix(in srgb, var(--red) 18%, transparent);
  color: var(--red);
}

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

.impact-grid article {
  min-height: 82px;
  padding: 13px;
  background: var(--card-soft);
}

.impact-grid strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.bad-text {
  color: var(--red);
}

.event-feed,
.action-list {
  display: grid;
  gap: 12px;
}

.event-card {
  border: 1px solid var(--line);
  border-left: 5px solid #a9b8b4;
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
}

.event-card.good {
  border-left-color: var(--green);
}

.event-card.watch {
  border-left-color: var(--amber);
}

.event-card.bad {
  border-left-color: var(--red);
}

.event-card.info {
  border-left-color: var(--blue);
}

.event-card h3 {
  margin: 10px 0 6px;
  font-size: 18px;
  line-height: 1.25;
}

.event-card p {
  margin: 0 0 12px;
}

.event-topline {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.event-next {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}

.event-details {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.event-details summary {
  color: var(--teal);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.event-detail-row {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-soft);
}

.event-detail-row strong {
  font-size: 14px;
}

.event-detail-row span,
.event-detail-row small {
  color: var(--muted);
  line-height: 1.35;
}

.action-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.action-item strong {
  display: block;
  margin-bottom: 4px;
}

.action-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.empty-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.empty-card {
  border-left-color: #94a39f;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(240px, 320px) minmax(420px, 1fr);
  }

  .action-panel {
    grid-column: 1 / -1;
  }

  .action-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .top-bar,
  .asset-strip,
  .replay-layout,
  .workspace {
    grid-template-columns: 1fr;
  }

  .top-bar {
    padding-right: 18px;
    padding-top: 64px;
  }

  .top-tools {
    grid-template-columns: 1fr;
  }

  .replay-heading {
    flex-direction: column;
  }

  .profile-heading {
    flex-direction: column;
  }

  .replay-form {
    grid-template-columns: 1fr;
  }

  .scope-toggle {
    grid-template-columns: 1fr;
  }

  .replay-actions {
    grid-template-columns: 1fr;
  }

  .signal-grid,
  .impact-grid,
  .replay-cards {
    grid-template-columns: 1fr;
  }

  .prefix-list {
    max-height: 360px;
  }

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

  .lookup-row button {
    min-height: 46px;
  }

  .action-list {
    grid-template-columns: 1fr;
  }
}
