* { box-sizing: border-box; }

:root {
  --bg: #101418;
  --panel: #181e24;
  --panel-2: #1f272f;
  --border: #2c3640;
  --text: #d7dde3;
  --muted: #8b98a5;
  --accent: #f0c04a;
  --pending: #f0c04a;
  --ok: #6fbf8a;
  --err: #d97070;
  font-size: 15px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
}

code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

a { color: var(--accent); }
button {
  background: var(--accent);
  color: #14100c;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 400;
}
button.danger-ghost { background: none; border: none; color: var(--muted); padding: 2px 6px; }
button.danger-ghost:hover { color: var(--err); }

input, select, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}
textarea { resize: vertical; }

/* ---- landing ---- */
.landing { max-width: 720px; margin: 8vh auto; padding: 0 24px; }
.landing h1 { font-size: 2.4rem; margin-bottom: 0; }
.landing .accent { color: var(--accent); }
.landing .tagline { color: var(--muted); margin-top: 6px; margin-bottom: 28px; }
.landing pre {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
}
.urlrow { margin: 10px 0; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.urlrow .label { color: var(--muted); min-width: 180px; }
.urlrow code { background: var(--panel); padding: 3px 8px; border-radius: 5px; border: 1px solid var(--border); word-break: break-all; }
.hint { color: var(--muted); font-size: 0.9rem; }

/* ---- console layout ---- */
.console {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
}
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar header h1 { font-size: 1.1rem; margin: 0; }
.sidebar header .session-id { color: var(--muted); font-size: 0.75rem; word-break: break-all; }
#request-list { list-style: none; margin: 0; padding: 0; }
#request-list li {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
#request-list li:hover { background: var(--panel-2); }
#request-list li.selected { background: var(--panel-2); border-left: 3px solid var(--accent); padding-left: 13px; }
#request-list .row1 { display: flex; justify-content: space-between; align-items: baseline; }
#request-list .model { color: var(--muted); font-size: 0.8rem; }
#request-list .time { color: var(--muted); font-size: 0.75rem; }
.badge {
  font-size: 0.7rem;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge.pending { background: var(--pending); color: #201a08; }
.badge.answered { background: var(--panel-2); color: var(--ok); border: 1px solid var(--ok); }
.badge.disconnected { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }

.main { overflow-y: auto; padding: 20px 28px 60px; }
.empty { color: var(--muted); margin-top: 20vh; text-align: center; }

.meta-line { color: var(--muted); font-size: 0.85rem; margin-bottom: 14px; }
.meta-line b { color: var(--text); }

details.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}
details.panel > summary { padding: 10px 14px; cursor: pointer; color: var(--muted); user-select: none; }
details.panel > .panel-body { padding: 0 14px 12px; }
details.panel pre { white-space: pre-wrap; word-break: break-word; margin: 6px 0; }
.tool-def { margin-bottom: 10px; }
.tool-def .tool-name { color: var(--accent); font-weight: 600; }
.tool-def .tool-desc { color: var(--muted); font-size: 0.9rem; }
.tool-def pre { font-size: 0.8rem; color: var(--muted); }

/* ---- transcript ---- */
.transcript { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.turn { max-width: 85%; }
.turn.user { align-self: flex-start; }
.turn.assistant { align-self: flex-end; }
.turn .role { font-size: 0.7rem; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.turn.assistant .role { text-align: right; }
.bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.turn.assistant .bubble { background: var(--panel-2); }
.card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px 12px;
  margin-top: 6px;
  font-size: 0.9rem;
}
.card.result { border-left-color: var(--ok); }
.card.error { border-left-color: var(--err); }
.card .card-title { font-weight: 600; }
.card pre { white-space: pre-wrap; word-break: break-word; margin: 4px 0 0; font-size: 0.85rem; color: var(--muted); }

/* ---- rendered markdown ---- */
.md { white-space: normal; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 0.7em 0 0.35em; line-height: 1.25; }
.md h1 { font-size: 1.25rem; }
.md h2 { font-size: 1.15rem; }
.md h3, .md h4 { font-size: 1rem; }
.md p, .md ul, .md ol, .md blockquote, .md table { margin: 0.45em 0; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: 0.15em 0; }
.md code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.85em;
}
.md pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: pre;
}
.md pre code { background: none; border: none; padding: 0; }
.md blockquote {
  border-left: 3px solid var(--border);
  padding-left: 12px;
  color: var(--muted);
}
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 10px; }
.md th { background: var(--panel-2); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 0.8em 0; }
.md img { max-width: 100%; }

/* ---- composer ---- */
.composer {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-top: 8px;
}
.composer h3 { margin: 0 0 10px; font-size: 1rem; }
.composer textarea { min-height: 90px; }
.composer .actions { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.composer .note { color: var(--muted); font-size: 0.85rem; }
.toolcall-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 12px;
}
.toolcall-card .tc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.toolcall-card .tc-head .tool-name { color: var(--accent); font-weight: 600; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 0.85rem; margin-bottom: 3px; }
.field label .req { color: var(--err); }
.field label .type { color: var(--muted); font-weight: 400; }
.field .desc { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }
.field.checkbox { display: flex; gap: 8px; align-items: center; }
.field.checkbox input { width: auto; }
.readonly-response { margin-top: 8px; }
.flash-error { color: var(--err); font-size: 0.9rem; }
