:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #17202a;
  --muted: #667085;
  --line: #d6dde7;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --warn: #b54708;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  background: var(--surface-2);
  color: var(--text);
}

button.secondary:hover {
  background: #dde6ef;
}

button.danger {
  color: var(--danger);
}

.shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}

.mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #17202a;
  color: #fff;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
}

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

p {
  color: var(--muted);
  font-size: 13px;
}

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

.panel-head,
.panel-actions,
.topbar,
.permission-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  min-height: 32px;
  padding: 0 12px;
  background: var(--surface-2);
  color: var(--text);
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

input {
  height: 38px;
  padding: 0 12px;
}

textarea {
  min-height: 74px;
  max-height: 180px;
  resize: vertical;
  padding: 12px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.agent-list,
.session-list,
.auth-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pair-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 8px;
}

.pair-form input {
  text-align: center;
  font-weight: 700;
  letter-spacing: 0;
}

.agent-item,
.session-item,
.auth-item {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
  text-align: left;
  color: var(--text);
}

.agent-item:hover,
.agent-item.active,
.session-item:hover,
.session-item.active {
  border-color: var(--accent);
  background: #edf8f6;
}

.auth-item {
  cursor: default;
}

.agent-item strong,
.session-item strong,
.auth-item strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.agent-item span,
.session-item span,
.auth-item span {
  color: var(--muted);
  font-size: 12px;
}

.auth-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.auth-actions button {
  min-height: 30px;
  padding: 0 10px;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 100vh;
  padding: 18px;
  gap: 14px;
}

.topbar {
  min-height: 52px;
}

.messages {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.message {
  max-width: min(820px, 92%);
  border-radius: 8px;
  padding: 11px 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  align-self: flex-end;
  background: #dff4ef;
}

.message.assistant {
  align-self: flex-start;
  background: #f0f4f8;
}

.message.event {
  align-self: stretch;
  max-width: 100%;
  border: 1px solid #f1c48b;
  background: #fff8ed;
  color: var(--warn);
  font-size: 13px;
}

.message.error {
  align-self: stretch;
  max-width: 100%;
  border: 1px solid #f2b8b5;
  background: #fff1f0;
  color: var(--danger);
}

.permission-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid #f1c48b;
  border-radius: 8px;
  background: #fff8ed;
  padding: 12px;
}

.permission-box pre {
  max-height: 130px;
  overflow: auto;
  margin: 8px 0 0;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  align-items: end;
  gap: 12px;
}

.hidden {
  display: none;
}

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

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

  .workspace {
    min-height: calc(100vh - 360px);
  }

  .permission-box,
  .composer,
  .pair-form {
    grid-template-columns: 1fr;
  }

  .permission-actions {
    justify-content: stretch;
  }

  .permission-actions button,
  .composer button,
  .pair-form button {
    width: 100%;
  }
}
