:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-soft: #f8f9fb;
  --sidebar: #f0f1f3;
  --stroke: #dfe2e7;
  --stroke-strong: #cfd4dc;
  --text: #1f2630;
  --muted: #6f7683;
  --blue: #1758d5;
  --blue-strong: #0f49bc;
  --good: #1f8f5f;
  --bad: #b34848;
  --sand: #e6d7c2;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Nunito Sans", "Trebuchet MS", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f3f4f6 0%, #eceff3 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  min-height: 0;
}

.sidebar {
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
}

.brand-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 9px;
  background: #1d1f24;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #f4f4f5;
  line-height: 1;
  font-weight: 800;
}

.logo-sub {
  margin-top: 4px;
  font-size: 0.56rem;
  letter-spacing: 0.03em;
  background: #e2c27e;
  color: #2e2b22;
  padding: 2px 5px;
  border-radius: 4px;
}

.brand-title {
  font-weight: 800;
  font-size: 0.98rem;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.78rem;
}

.connect-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 11px;
  padding: 10px;
}

.tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

h2 {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
  color: var(--muted);
}

label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #5f6774;
}

input,
textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--stroke-strong);
  border-radius: 10px;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

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

button.ghost {
  background: #fff;
  color: #445166;
  border-color: var(--stroke-strong);
}

button.ghost:hover {
  background: #f2f4f8;
}

button.small {
  padding: 7px 10px;
  font-size: 0.8rem;
}

.actions {
  display: flex;
  gap: 8px;
}

.tool-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool-item {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 10px;
  cursor: pointer;
}

.tool-item:hover {
  background: #f2f4f7;
  border-color: #c0c6d0;
}

.tool-item .name {
  font-family: "IBM Plex Sans", "Trebuchet MS", sans-serif;
  font-size: 0.83rem;
  font-weight: 700;
  color: #293142;
}

.tool-item .desc {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.content {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

.primary {
  border: 1px solid #1a56cd;
  background: linear-gradient(180deg, #1f5ddd 0%, #0f47bc 100%);
}

.pill {
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.79rem;
  font-weight: 700;
}

.pill.online {
  color: var(--good);
  background: #eaf8f1;
  border: 1px solid #b9e6cd;
}

.pill.offline {
  color: var(--bad);
  background: #fdeeee;
  border: 1px solid #e9cbcb;
}

.chat {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 10px;
  padding: 10px;
  background:
    linear-gradient(#f8f9fb 1px, transparent 1px),
    linear-gradient(90deg, #f8f9fb 1px, transparent 1px),
    #fff;
  background-size: 40px 40px, 40px 40px, auto;
}

.chat-log {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-right: 2px;
}

.msg {
  border: 1px solid var(--stroke);
  border-radius: 11px;
  background: #fbfcfd;
  padding: 9px 10px;
  animation: fadeUp 150ms ease-out;
}

.msg.user {
  border-color: #ccd4e2;
  background: #f3f6fb;
}

.msg.assistant {
  border-color: #d5dae2;
  background: #fff;
}

.msg.system {
  border-color: #ddcfbb;
  background: #f8f2e9;
}

.msg-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.77rem;
  color: #626b79;
}

.msg-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "IBM Plex Mono", "Consolas", "Monaco", monospace;
  font-size: 0.82rem;
  line-height: 1.42;
  color: #1f2633;
}

.guided-options {
  border: 1px solid #ded3c3;
  background: #fbf6ee;
  border-radius: 10px;
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guided-options[hidden] {
  display: none !important;
}

.guided-title {
  color: #5e4f39;
  font-size: 0.83rem;
}

.guided-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.guided-chip {
  border-radius: 999px;
  border: 1px solid #dcc6a5;
  background: #fff;
  color: #4a3f2f;
  padding: 6px 10px;
  font-size: 0.8rem;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 8px;
}

html[data-ui-mode="chat"] .app-shell {
  grid-template-columns: 1fr;
  gap: 0;
  padding: 0;
}

html[data-ui-mode="chat"] .sidebar {
  display: none;
}

html[data-ui-mode="chat"] .content {
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}

html[data-ui-mode="chat"] .chat {
  border: 0;
  border-radius: 0;
  background: #ffffff;
  padding: 12px;
}

@keyframes fadeUp {
  from {
    transform: translateY(6px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .sidebar {
    max-height: 360px;
  }
}

@media (max-width: 760px) {
  .brand-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
