:root {
  color-scheme: light;
  --bg: #2a1025;
  --surface: #fff8f8;
  --panel: #ffffff;
  --panel-2: #fffafa;
  --line: #f0dde0;
  --text: #291421;
  --muted: #8a7581;
  --soft: #fff0f2;
  --green: #20a66a;
  --blue: #5f65d8;
  --red: #e60023;
  --amber: #d98c18;
  --pink: #ff4f86;
  --shadow: 0 24px 70px rgba(55, 18, 42, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, #f43b37 0 24%, transparent 24% 100%),
    linear-gradient(315deg, #e60023 0 20%, transparent 20% 100%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  margin-bottom: 22px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding-left: 4px;
  font-weight: 850;
  white-space: nowrap;
}

.brand-logo {
  display: block;
  width: 92px;
  height: 28px;
  object-fit: contain;
}

.nav-pills {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border-radius: 8px;
  background: #fff0f2;
}

.nav-pill {
  border: 0;
  padding: 7px 11px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.nav-pill.active {
  background: var(--red);
  color: #ffffff;
}

.nav-pill:hover {
  background: #ffe2e7;
}

.nav-pill.active:hover {
  background: var(--red);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #fff0f2;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.12;
  color: #ffffff;
}

.summary {
  max-width: 720px;
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.55;
}

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

.status-panel {
  min-width: 230px;
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 4px 10px;
  align-items: center;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 18px currentColor;
}

.dot.ok {
  background: var(--green);
}

.dot.fail {
  background: var(--red);
}

.status-panel small {
  grid-column: 2;
  color: var(--muted);
  line-height: 1.35;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 0.72fr) minmax(680px, 1.5fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  height: min(720px, calc(100vh - 260px));
  min-height: 540px;
}

.panel {
  min-height: 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: none;
}

.prompt-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fff8f8);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

h2 {
  font-size: 17px;
}

button {
  border: 1px solid #f0cbd2;
  border-radius: 8px;
  background: #fff5f6;
  color: var(--text);
  font-weight: 800;
  padding: 9px 12px;
  cursor: pointer;
}

button:hover {
  background: #ffebef;
}

button:disabled {
  opacity: 0.64;
  cursor: wait;
}

.dark-action {
  border-color: var(--red);
  background: var(--red);
  color: #ffffff;
}

.dark-action:hover {
  background: #c9001e;
}

.danger-button {
  border-color: #f0c9ce;
  background: #fff4f5;
  color: #9f2636;
}

.danger-button:hover {
  background: #ffe9ec;
}

.tool-list {
  display: grid;
  gap: 10px;
  padding: 14px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.quick-list {
  align-content: start;
  grid-template-columns: 1fr;
  background: #fffafa;
}

.quick {
  display: block;
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px 16px;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  text-align: left;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 10px 24px rgba(55, 18, 42, 0.06);
}

.quick:hover {
  background: #fff0f2;
  color: var(--red);
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 18px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff8f9;
  scroll-padding-bottom: 24px;
}

.message {
  display: grid;
  gap: 5px;
  flex: 0 0 auto;
}

.message.user {
  justify-items: end;
}

.msg-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.bubble {
  max-width: 82%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-2);
  color: var(--text);
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
  box-shadow: 0 10px 24px rgba(55, 18, 42, 0.06);
}

.message.user .bubble {
  border-color: #f0cbd2;
  background: #fff0f2;
  color: #6d1221;
}

.message.assistant .bubble {
  border-color: #ead5d9;
  background: #ffffff;
}

.answer-text + .answer-table-wrap,
.answer-table-wrap + .answer-text,
.answer-table-wrap + .answer-table-wrap,
.answer-text + .training-list,
.training-list + .answer-text,
.training-list + .answer-table-wrap,
.answer-table-wrap + .training-list,
.answer-text + .structured-list,
.structured-list + .answer-text,
.structured-list + .answer-table-wrap,
.answer-table-wrap + .structured-list,
.training-list + .structured-list,
.structured-list + .training-list,
.answer-text + .metric-summary,
.metric-summary + .answer-text,
.metric-summary + .answer-table-wrap,
.answer-table-wrap + .metric-summary,
.metric-summary + .training-list,
.training-list + .metric-summary,
.metric-summary + .structured-list,
.structured-list + .metric-summary,
.metric-summary + .metric-summary {
  margin-top: 10px;
}

.answer-table-wrap {
  position: relative;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.answer-table-toolbar {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: flex;
}

.graph-toggle {
  min-height: 26px;
  border-color: #ead5d9;
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.94);
  color: #6d1221;
  font-size: 11px;
  font-weight: 850;
  box-shadow: 0 6px 16px rgba(55, 18, 42, 0.08);
  backdrop-filter: blur(8px);
}

.graph-toggle:hover,
.graph-toggle.active {
  border-color: var(--red);
  background: #fff0f2;
  color: var(--red);
}

.answer-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  white-space: normal;
  font-size: 13px;
  line-height: 1.45;
}

.answer-table.wide-table {
  width: max-content;
  min-width: max(100%, 1120px);
  white-space: nowrap;
}

.answer-table th,
.answer-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.answer-table.wide-table th,
.answer-table.wide-table td {
  white-space: nowrap;
}

.answer-table th {
  background: #fff0f2;
  color: #6d1221;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.answer-table tr:last-child td {
  border-bottom: 0;
}

.answer-table td {
  color: var(--text);
}

.line-chart {
  min-width: 560px;
  margin: 10px;
  padding: 10px;
  border: 1px solid #ead5d9;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #ffffff, #fffafa);
}

.line-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid-line {
  stroke: #f0dde0;
  stroke-width: 1;
}

.chart-tick {
  stroke: #cdb9bf;
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.chart-y-label {
  text-anchor: end;
}

.chart-x-label {
  text-anchor: middle;
}

.chart-line {
  fill: none;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot {
  stroke: #ffffff;
  stroke-width: 2.5;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 8px 4px 8px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chart-legend span::before {
  content: "";
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: var(--legend-color);
}

.training-list {
  display: grid;
  gap: 10px;
  white-space: normal;
}

.training-card {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffafa;
}

.training-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.training-card-head strong {
  font-size: 14px;
  line-height: 1.35;
}

.training-priority {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  background: #f3f0ff;
  color: var(--blue);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.training-priority.priority-high {
  background: #fff0f2;
  color: var(--red);
}

.training-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.training-meta span {
  border: 1px solid #ead5d9;
  border-radius: 999px;
  padding: 4px 8px;
  background: #ffffff;
  color: #6d1221;
  font-size: 12px;
  font-weight: 750;
}

.training-reason {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.structured-list {
  display: grid;
  gap: 10px;
  white-space: normal;
}

.structured-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffafa;
}

.structured-title {
  color: #6d1221;
  font-size: 14px;
  line-height: 1.35;
}

.structured-summary {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.structured-details {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 10px;
  margin: 0;
  padding-top: 2px;
}

.structured-details dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.structured-details dd {
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.metric-summary {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffafa;
  white-space: normal;
}

.metric-summary-title {
  color: #6d1221;
  font-size: 14px;
  line-height: 1.35;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
}

.metric-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 4px;
  align-items: baseline;
  min-width: 0;
  padding: 10px;
  border: 1px solid #ead5d9;
  border-radius: 8px;
  background: #ffffff;
}

.metric-item-strong {
  border-color: #f0cbd2;
  background: #fff0f2;
}

.metric-item-action {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.metric-item-action:hover,
.metric-item-action:focus {
  border-color: var(--red);
  box-shadow: 0 8px 18px rgba(230, 0, 35, 0.1);
  outline: none;
  transform: translateY(-1px);
}

.metric-label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.metric-value {
  color: var(--text);
  font-size: 22px;
  font-weight: 850;
  line-height: 1;
}

.metric-unit {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.metric-detail {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding-top: 2px;
}

.metric-detail-title {
  color: #6d1221;
  font-size: 13px;
  line-height: 1.35;
}

.metric-detail .answer-table-wrap {
  margin: 0;
}

.metric-detail-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.loading-bubble {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 74px;
  min-height: 42px;
}

.loading-bubble span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--red);
  opacity: 0.35;
  animation: loadingPulse 0.9s ease-in-out infinite;
}

.loading-bubble span:nth-child(2) {
  animation-delay: 0.14s;
}

.loading-bubble span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes loadingPulse {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.chat-input {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #ffffff;
  position: relative;
  z-index: 2;
}

.chat-input input {
  flex: 1;
  min-width: 0;
  border: 1px solid #f0cbd2;
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  font: inherit;
}

.chat-input input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(230, 0, 35, 0.1);
}

@media (max-width: 960px) {
  .hero,
  .workspace {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .nav-pills {
    justify-self: start;
    max-width: 100%;
    overflow-x: auto;
  }

  .status-panel {
    width: 100%;
  }

  .shell {
    width: min(100% - 22px, 1180px);
    padding: 24px 0;
  }

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