:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --panel-2: #eef2f6;
  --text: #17202a;
  --muted: #657383;
  --line: #d9e0e7;
  --brand: #1f7a6b;
  --brand-strong: #115c52;
  --danger: #b42318;
  --shadow: 0 16px 48px rgba(23, 32, 42, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}

button,
textarea,
input {
  font: inherit;
}

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

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

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

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: var(--brand);
  border-radius: 8px;
}

.brand small,
.status-panel small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  text-align: left;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
}

.nav-item.active {
  border-color: #c9ded9;
  background: #e8f4f1;
}

.nav-item:disabled {
  color: #a0acb8;
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #d0d5dd;
}

.status-dot.ok {
  background: var(--brand);
}

.status-dot.error {
  background: var(--danger);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--brand-strong);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  padding: 28px;
}

.message {
  max-width: min(760px, 100%);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  color: #fff;
  border-color: var(--brand-strong);
  background: var(--brand-strong);
}

.message.system {
  box-shadow: none;
  background: var(--panel-2);
}

.message small {
  display: block;
  margin-bottom: 7px;
  color: inherit;
  font-weight: 700;
  opacity: 0.76;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 12px;
  padding: 18px 28px 24px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

textarea {
  width: 100%;
  min-height: 52px;
  max-height: 160px;
  resize: vertical;
  padding: 13px 14px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

textarea:focus,
input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 122, 107, 0.14);
}

.composer button,
.settings footer button {
  border: 1px solid var(--brand-strong);
  border-radius: 8px;
  color: #fff;
  background: var(--brand-strong);
  cursor: pointer;
}

.composer button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.settings {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.settings::backdrop {
  background: rgba(23, 32, 42, 0.34);
}

.settings-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.settings-form header,
.settings-form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

.settings-form input[type="url"] {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.checkbox-line {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.settings footer button {
  min-height: 38px;
  padding: 0 16px;
}

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

  .sidebar {
    display: none;
  }

  .topbar {
    min-height: 72px;
    padding: 14px 16px;
  }

  .messages {
    padding: 16px;
  }

  .composer {
    grid-template-columns: 1fr;
    padding: 14px 16px 18px;
  }

  .composer button {
    min-height: 44px;
  }
}
