:root {
  --ink: #18201e;
  --muted: #6e7773;
  --line: #dce2df;
  --paper: #f5f7f6;
  --white: #ffffff;
  --green: #167d5b;
  --green-dark: #0e6045;
  --blue: #245fc7;
  --red: #bd3d3d;
  --shadow: 0 12px 30px rgba(21, 36, 31, 0.08);
}

* { box-sizing: border-box; }

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

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.topbar {
  height: 72px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--ink); color: white; font-weight: 800; border-radius: 5px;
}
.brand div { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 14px; }
.brand div span { margin-top: 4px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.privacy { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px #dff1e9; }

main { max-width: 1180px; margin: 0 auto; padding: 48px 24px 64px; }
section { background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow); }
.connection { padding: 30px; }
.test-area { margin-top: 20px; padding: 30px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.section-heading > div { display: flex; align-items: center; gap: 12px; }
.step { color: var(--green); font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
h1, h2 { margin: 0; font-size: 20px; line-height: 1.2; }
.status { padding: 6px 9px; border-radius: 4px; font-size: 11px; font-weight: 650; }
.status.idle { color: var(--muted); background: #eef1f0; }
.status.success { color: var(--green-dark); background: #dff1e9; }
.status.error { color: var(--red); background: #f8e6e6; }
.status.loading { color: var(--blue); background: #e5ecf9; }
.latency { color: var(--muted); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }

.connection-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 8px; }
.field > span, .mode-row > span { color: #3e4945; font-size: 12px; font-weight: 700; }
.field small { color: var(--muted); font-size: 11px; }
input, select, textarea {
  width: 100%; color: var(--ink); background: #fbfcfc; border: 1px solid #cfd7d3;
  border-radius: 4px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input, select { height: 44px; padding: 0 13px; }
textarea { padding: 13px; resize: vertical; min-height: 150px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22, 125, 91, .1); }
.key-input { position: relative; }
.key-input input { padding-right: 46px; }
.icon-button { position: absolute; right: 3px; top: 3px; width: 38px; height: 38px; border: 0; background: transparent; color: var(--muted); }
.primary-button {
  margin-top: 24px; height: 44px; padding: 0 16px; display: inline-flex; align-items: center; gap: 28px;
  color: white; background: var(--ink); border: 0; border-radius: 4px; font-size: 12px; font-weight: 700;
}
.primary-button:hover { background: #29332f; }
.primary-button:disabled, .run-button:disabled { cursor: not-allowed; opacity: .5; }
.button-arrow { font-size: 18px; font-weight: 400; }

.test-grid { display: grid; grid-template-columns: minmax(300px, .85fr) minmax(380px, 1.15fr); gap: 28px; }
.composer { min-width: 0; }
.select-wrap { position: relative; }
.mode-row { margin: 20px 0; display: flex; align-items: center; justify-content: space-between; }
.segmented { padding: 3px; display: flex; background: #edf1ef; border-radius: 5px; }
.mode { min-width: 62px; height: 30px; padding: 0 12px; border: 0; border-radius: 3px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 700; }
.mode.active { color: var(--ink); background: white; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.prompt-field small { align-self: flex-end; }
.request-previews { margin-top: 18px; display: grid; gap: 12px; }
.request-export-bar { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.request-export-bar > span { color: #3e4945; font-size: 12px; font-weight: 700; }
.export-button {
  height: 32px; padding: 0 11px; display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid #bfcac5; border-radius: 4px; color: var(--green-dark); background: white;
  font-size: 11px; font-weight: 700;
}
.export-button:hover { border-color: var(--green); background: #f0f7f4; }
.request-preview { min-width: 0; border: 1px solid #d4dcd8; background: #f4f7f5; }
.request-preview-header {
  height: 38px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #d4dcd8; color: #3e4945; font-size: 11px; font-weight: 700;
}
.preview-copy { padding: 4px 0; border: 0; color: var(--green-dark); background: transparent; font-size: 11px; font-weight: 700; }
#request-info,
#request-json {
  margin: 0; padding: 13px; overflow: auto;
  color: #31413b; white-space: pre-wrap; word-break: break-word;
  font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
#request-info { min-height: 92px; word-break: break-all; }
#request-json { min-height: 160px; max-height: 240px; }
.run-button {
  width: 100%; height: 46px; margin-top: 20px; display: flex; align-items: center; justify-content: center; gap: 10px;
  color: white; background: var(--green); border: 0; border-radius: 4px; font-size: 12px; font-weight: 750;
}
.run-button:hover:not(:disabled) { background: var(--green-dark); }
.run-icon { font-size: 10px; }

.result-panel { min-height: 390px; display: flex; flex-direction: column; border: 1px solid #27332f; background: #111916; color: #d7e2dd; }
.result-header { height: 48px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #2a3732; font-size: 11px; font-weight: 700; }
.copy-button { border: 0; color: #9eafa7; background: transparent; font-size: 11px; }
.copy-button:disabled { opacity: .35; cursor: not-allowed; }
.empty-result { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: #788981; }
.empty-result strong { color: #aab8b2; font-size: 13px; }
.empty-result span:last-child { font-size: 11px; }
.terminal-icon { margin-bottom: 6px; color: #6ba68f; font: 24px ui-monospace, SFMono-Regular, Menlo, monospace; }
#result { flex: 1; margin: 0; padding: 18px; overflow: auto; white-space: pre-wrap; word-break: break-word; font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.result-meta { min-height: 38px; padding: 11px 16px; border-top: 1px solid #2a3732; color: #8da098; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }

footer { max-width: 1180px; margin: 0 auto; padding: 0 24px 30px; display: flex; justify-content: space-between; color: #8a938f; font-size: 10px; text-transform: uppercase; }
.spin { display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .topbar { height: 64px; padding: 0 16px; }
  .privacy { font-size: 0; }
  main { padding: 24px 14px 40px; }
  .connection, .test-area { padding: 20px; }
  .connection-grid, .test-grid { grid-template-columns: 1fr; }
  .test-grid { gap: 22px; }
  .result-panel { min-height: 320px; }
  .primary-button { width: 100%; justify-content: space-between; }
  footer { padding: 0 16px 24px; gap: 12px; }
  footer span:last-child { text-align: right; }
}
