:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #f6f4ef;
  color: #1d2430;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(246, 244, 239, 0.96)),
    #f6f4ef;
}

.app-shell {
  width: 100%;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 22px 28px 18px;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

.status {
  color: #53606f;
  font-size: 14px;
  line-height: 1.4;
  margin: 6px 0 0;
}

.status.connected {
  color: #176d52;
}

.status.disconnected {
  color: #9b2c2c;
}

.metric {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  min-width: 96px;
}

.metric-label {
  color: #687483;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric-value {
  color: #1d2430;
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.1;
}

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  padding: 0 28px 28px;
  width: 100%;
}

.diagram-panel {
  height: min(600px, calc(100vh - 118px));
  min-height: 360px;
  position: relative;
  width: 100%;
}

.stage-controls {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #dce2e8;
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  left: 14px;
  max-width: calc(100% - 28px);
  min-height: 42px;
  padding: 8px 10px;
  position: absolute;
  top: 14px;
  z-index: 2;
}

.stage-option {
  align-items: center;
  color: #25313e;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 7px;
  line-height: 1.2;
}

.stage-option input {
  accent-color: #155f7a;
}

.stage-swatch {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

#chart {
  background: #ffffff;
  display: block;
  height: 100%;
  max-height: 600px;
  width: 100%;
}

.chat-panel {
  background: #ffffff;
  border-left: 1px solid #dce2e8;
  display: flex;
  flex-direction: column;
  height: min(600px, calc(100vh - 118px));
  min-height: 360px;
}

.chat-header {
  align-items: center;
  border-bottom: 1px solid #dce2e8;
  display: flex;
  justify-content: space-between;
  padding: 16px 18px;
}

.chat-header h2 {
  font-size: 18px;
  line-height: 1.2;
  margin: 0;
}

.chat-state {
  color: #687483;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 18px;
}

.message {
  max-width: 92%;
}

.message.user {
  align-self: flex-end;
  text-align: right;
}

.sender {
  color: #687483;
  display: block;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}

.message p {
  background: #eef3f6;
  border-radius: 8px;
  color: #25313e;
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
  padding: 10px 12px;
}

.message.user p {
  background: #dceee7;
}

.chat-input {
  border-top: 1px solid #dce2e8;
  display: flex;
  gap: 10px;
  padding: 14px;
}

.chat-input input {
  border: 1px solid #c7d0d9;
  border-radius: 6px;
  flex: 1;
  font: inherit;
  min-width: 0;
  padding: 10px 11px;
}

.chat-input button {
  background: #155f7a;
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: default;
  font: inherit;
  font-weight: 700;
  padding: 10px 14px;
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 18px 18px 14px;
  }

  .metric {
    align-items: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 0 18px 18px;
  }

  .chat-panel {
    height: 360px;
  }
}
