:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #171a1d;
  --panel-strong: #1f2428;
  --line: #394047;
  --text: #e7ecef;
  --muted: #9aa7af;
  --accent: #55d6a9;
  --warn: #ffcc66;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.app {
  height: 100dvh;
  padding: clamp(12px, 3vw, 28px);
  overflow: hidden;
}

.terminal {
  height: calc(100dvh - clamp(24px, 6vw, 56px));
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}

.topbar,
.composer {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--panel-strong);
  border-bottom: 1px solid var(--line);
}

.topbar {
  justify-content: space-between;
}

#tokenLabel,
.status,
.pane-title {
  color: var(--muted);
}

.status[data-state="online"] {
  color: var(--accent);
}

.status[data-state="waiting"] {
  color: var(--warn);
}

.panes {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.pane + .pane {
  border-left: 1px solid var(--line);
}

.pane-title {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.stream {
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
}

.line {
  margin: 0 0 8px;
}

.line-meta {
  color: var(--muted);
}

.composer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

#prompt {
  flex: 0 0 auto;
  color: var(--accent);
}

input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font: inherit;
}

button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: #243038;
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

  .terminal {
    height: 100dvh;
    min-height: 0;
    border: 0;
  }

  .panes {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .pane + .pane {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
