:root {
  color-scheme: light;
  --bg: #eef1f3;
  --panel: #ffffff;
  --ink: #12161a;
  --muted: #5d6872;
  --line: #cfd6dc;
  --focus: #006b8f;
  --good: #18744b;
  --active: #9b5b00;
  --bad: #b3261e;
  --shadow: 0 10px 30px rgb(16 24 32 / 10%);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  color: var(--ink);
  cursor: pointer;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 180px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(0 107 143 / 16%);
}

.app {
  min-height: 100vh;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto 14px;
}

.topbarActions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbarActions a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #f8fafb;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.clientReportPanel {
  max-width: 1280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 auto 14px;
  padding: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.reportToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.reportToolbar button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
}

.clientReportPanel pre {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 0;
  padding: 10px;
  background: #f8fafb;
  color: #151a1f;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
}

.copyBuffer {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  border: 0;
  padding: 0;
  opacity: 0.01;
}

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

h1 {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 760;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

#connectionState,
.sectionHeader span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.clientStatus {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.clientStatus span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

[data-tone="good"] {
  color: var(--good) !important;
}

[data-tone="active"] {
  color: var(--active) !important;
}

[data-tone="bad"] {
  color: var(--bad) !important;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(280px, 0.85fr) minmax(320px, 1fr);
  gap: 14px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.composer,
.runs,
.detail {
  padding: 14px;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  text-transform: uppercase;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tokenRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 82px 96px;
  gap: 8px;
}

.miniState {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

#sendButton {
  border-color: #0a5d42;
  background: #0f6f4f;
  color: #ffffff;
  font-weight: 720;
}

.dangerButton {
  width: 100%;
  margin: 0 0 12px;
  border-color: #aa1f17;
  background: #b3261e;
  color: #ffffff;
  font-weight: 720;
}

.approvalPanel {
  display: grid;
  gap: 10px;
  border: 1px solid #b87500;
  border-radius: 6px;
  margin: 0 0 12px;
  padding: 12px;
  background: #fff7e8;
}

.approvalPanel[hidden] {
  display: none;
}

.approvalPanel h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.approvalPanel p {
  color: #3e3321;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.approvalActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.approvalActions .dangerButton {
  margin: 0;
}

.outcomePanel {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 0 0 12px;
  padding: 12px;
  background: #f8fafb;
}

.outcomePanel[data-tone="good"] {
  border-color: #74b493;
  background: #effaf4;
}

.outcomePanel[data-tone="active"] {
  border-color: #d1a35e;
  background: #fff7e8;
}

.outcomePanel[data-tone="bad"] {
  border-color: #db8b86;
  background: #fff1f0;
}

.outcomePanel h3 {
  margin: 0;
  font-size: 14px;
}

.outcomePanel pre {
  max-height: 180px;
  overflow: auto;
  margin: 0;
  color: #151a1f;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sectionHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  border-bottom: 1px solid var(--line);
  margin: -2px 0 12px;
  padding-bottom: 10px;
}

.detailHeaderActions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.detailHeaderActions a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #f8fafb;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.runList {
  display: grid;
  gap: 8px;
}

.runRow {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "main badge"
    "meta badge"
    "preview preview";
  align-items: center;
  gap: 3px 10px;
  width: 100%;
  min-height: 72px;
  padding: 9px 10px;
  text-align: left;
}

.runRow[data-selected="true"] {
  border-color: var(--focus);
  background: #edf7fa;
}

.runMain {
  grid-area: main;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runMeta {
  grid-area: meta;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runPreview {
  grid-area: preview;
  overflow: hidden;
  color: #2f3b43;
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  grid-area: badge;
  font-size: 12px;
  font-weight: 760;
}

.lastMessage {
  min-height: 180px;
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 0 0 12px;
  padding: 12px;
  background: #101820;
  color: #f5f8fa;
  line-height: 1.45;
  white-space: pre-wrap;
}

.meta {
  display: grid;
  gap: 8px;
}

.meta div {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
}

.meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.meta dd {
  overflow-wrap: anywhere;
}

.logPanel {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.logTabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.logTabs button {
  min-width: 0;
  min-height: 38px;
  padding: 0 6px;
  font-size: 13px;
  font-weight: 700;
}

.logToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.logToolbar p {
  margin: 0;
}

.logToolbar button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
}

.logOutput {
  min-height: 160px;
  max-height: 44vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 0;
  padding: 10px;
  background: #f8fafb;
  color: #151a1f;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.empty {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr 1fr;
  }

  .composer {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbarActions {
    width: 100%;
  }

  .topbarActions button {
    flex: 1;
  }

  .layout,
  .grid {
    grid-template-columns: 1fr;
  }

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

  .tokenRow input {
    grid-column: 1 / -1;
  }

  h1 {
    font-size: 24px;
  }

  .panel {
    border-radius: 6px;
  }
}
