:root {
  color-scheme: light;
  --bg: #082f38;
  --surface: #f2fbfb;
  --panel: #ffffff;
  --panel-2: #f7fcfd;
  --line: #cfe4e8;
  --text: #12333d;
  --muted: #64748b;
  --teal: #0891b2;
  --teal-dark: #0e7490;
  --green: #16a34a;
  --amber: #c47f16;
  --fail: #dc2626;
  --shadow: 0 24px 70px rgba(8, 47, 56, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-y: auto;
  background:
    linear-gradient(135deg, #0e7490 0 22%, transparent 22% 100%),
    linear-gradient(315deg, #14b8a6 0 18%, transparent 18% 100%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

button {
  border: 1px solid #b8dce3;
  border-radius: 8px;
  background: #ecfeff;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: #dff8fb;
}

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

.shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(1440px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 34px;
}

.topbar {
  display: grid;
  grid-template-columns: 220px 1fr 42px;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  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;
}

.brand-mark {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #0f766e, #0891b2);
  color: #ffffff;
  font-weight: 900;
}

.endpoint {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.endpoint strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 18px;
}

.prompt-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.prompt-card {
  margin-bottom: 12px;
  padding: 18px;
}

.prompt-head {
  display: grid;
  grid-template-columns: 1fr 190px;
  gap: 16px;
  align-items: start;
}

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

.eyebrow {
  margin-bottom: 7px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 820px;
  font-size: clamp(25px, 2.4vw, 36px);
  line-height: 1.16;
  letter-spacing: 0;
}

.status-panel {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 4px 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid #d8eef1;
  border-radius: 8px;
  background: var(--panel-2);
}

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

.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(--fail);
}

.composer textarea {
  width: 100%;
  min-height: 54px;
  max-height: 150px;
  resize: vertical;
  border: 1px solid #bddfe5;
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
  color: var(--text);
  background: #fbfeff;
  line-height: 1.55;
}

.composer textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.16);
}

.primary-action {
  min-height: 40px;
  padding: 9px 12px;
}

.primary-action {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.primary-action:hover {
  background: var(--teal-dark);
}

.workspace {
  display: grid;
  min-height: 0;
}

.panel {
  min-height: 0;
  overflow: hidden;
  box-shadow: none;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  height: calc(100vh - 220px);
  min-height: 560px;
  max-height: 900px;
}

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

.panel-head h2 {
  font-size: 17px;
}

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

.messages {
  display: grid;
  align-content: start;
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  background: #f8fdfe;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f2fbfb);
}

.composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.user-message {
  display: flex;
  justify-content: flex-end;
}

.bubble {
  max-width: min(760px, 88%);
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--teal);
  color: #ffffff;
  line-height: 1.55;
}

.assistant-message {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.empty-state {
  border-style: dashed;
  background: #f5fbfc;
}

.empty-state p {
  margin-top: 8px;
  color: var(--muted);
}

.answer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.answer-head h3 {
  font-size: 17px;
  line-height: 1.42;
}

.answer-head span {
  height: fit-content;
  border-radius: 999px;
  padding: 4px 9px;
  background: #ecfeff;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
}

.text-block {
  line-height: 1.65;
  white-space: pre-wrap;
}

.result-block {
  margin-top: 12px;
}

.result-block h3 {
  margin-bottom: 9px;
  font-size: 15px;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid #e4f0f2;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: #effafb;
  color: var(--teal-dark);
  font-weight: 900;
}

.chart-card canvas {
  width: 100%;
  height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.swatch {
  display: grid;
  gap: 6px;
  min-height: 132px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.swatch span {
  display: block;
  height: 44px;
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.swatch code,
.swatch small {
  color: var(--muted);
}

.loading {
  display: inline-flex;
  width: fit-content;
  gap: 6px;
}

.loading span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--teal);
  animation: pulse 0.9s infinite ease-in-out alternate;
}

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

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

@keyframes pulse {
  from {
    opacity: 0.35;
    transform: translateY(0);
  }
  to {
    opacity: 1;
    transform: translateY(-4px);
  }
}

@media (max-width: 920px) {
  .topbar,
  .prompt-head,
  .workspace,
  .composer-row {
    grid-template-columns: 1fr;
  }

  .primary-action {
    width: 100%;
  }

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