:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --fg: #1b2330;
  --muted: #5b6676;
  --line: #d5dae2;
  --accent: #0f6e78;
  --accent-bg: #e3f1f2;
  --good: #1a8048;
  --bad: #b3261e;
  --in: #5a3fc0;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d;
    --surface: #1a2029;
    --fg: #e6eaf0;
    --muted: #9aa5b5;
    --line: #323b49;
    --accent: #6fcbd3;
    --accent-bg: #143238;
    --good: #5fd08e;
    --bad: #ff8a80;
    --in: #b3a2ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--sans); }
h1, h2, p, ol { margin: 0; }
h1 { font-size: 16px; font-weight: 600; }
h2 { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
code, pre, textarea, input { font-family: var(--mono); font-size: 13px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.hint { color: var(--muted); font-size: 13px; }
.error { color: var(--bad); font-size: 13px; }

button {
  font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 4px; padding: 4px 12px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 600; }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input, textarea {
  color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 4px; padding: 5px 8px;
}

.app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 20px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.tabs { display: flex; gap: 4px; }
.tab { border-color: transparent; background: none; font-family: var(--mono); font-size: 13px; }
.tab.active { background: var(--accent-bg); border-color: var(--accent); }

.panel {
  flex: 1; min-height: 0; display: grid; gap: 1px; background: var(--line);
  grid-template-columns: 200px minmax(280px, 420px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "connection connection connection" "methods call log";
}
.panel > * { background: var(--bg); min-width: 0; }

.connection { grid-area: connection; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 16px; }
.connection label { font-weight: 600; }
.connection input { flex: 0 1 340px; min-width: 0; }
.connection .hint { flex-basis: 100%; }
.status { font-size: 13px; color: var(--muted); }
.status::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.status.connected { color: var(--good); }
.status.connected::before { background: var(--good); }
.status.disconnected::before { background: var(--bad); }

.methods { grid-area: methods; overflow-y: auto; padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; }
.methods > div { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.methods h2 { padding: 0 8px 4px; }
.methods > .hint { padding: 0 8px; }
.method { text-align: left; border-color: transparent; background: none; font-family: var(--mono); font-size: 13px; padding: 3px 8px; }
.method.active { background: var(--accent-bg); border-color: var(--accent); }
.var { padding: 0 8px; }
.var pre { font-size: 12px; max-height: 240px; overflow: auto; }

.call { grid-area: call; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.call h2 { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--fg); }
.call h2 code { font-size: 15px; }
.path { font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--muted); }
.param { display: flex; flex-direction: column; gap: 3px; }
.param textarea { width: 100%; resize: vertical; }
.type { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.actions { display: flex; gap: 8px; }

.log { grid-area: log; display: flex; flex-direction: column; min-height: 0; }
.log-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.log-head button { margin-left: auto; }
.log ol { list-style: none; padding: 0; overflow-y: auto; flex: 1; }
.entry { border-bottom: 1px solid var(--line); }
.entry.empty, .log .empty { padding: 16px; }
.entry summary { display: flex; align-items: baseline; gap: 8px; padding: 5px 16px; cursor: pointer; list-style: none; }
.entry summary::-webkit-details-marker { display: none; }
.entry summary:hover { background: var(--surface); }
.entry pre { padding: 8px 16px 12px 40px; font-size: 12px; max-height: 420px; overflow: auto; background: var(--surface); }
.time { color: var(--muted); font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.arrow { font-weight: 700; color: var(--accent); }
.entry.in .arrow { color: var(--in); }
.name { font-weight: 600; white-space: nowrap; }
.correlation { color: var(--muted); white-space: nowrap; }
.summary { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.state { font-size: 12px; color: var(--muted); white-space: nowrap; }
.state.good { color: var(--good); }
.state.bad { color: var(--bad); }

@media (max-width: 900px) {
  html, body, #root { height: auto; }
  .panel { grid-template-columns: 1fr; grid-template-rows: none; grid-template-areas: "connection" "methods" "call" "log"; }
  .log ol { max-height: 70vh; }
}
