:root {
  color-scheme: light;
  --bg: #eef3f7;
  --panel: #ffffff;
  --ink: #18202a;
  --muted: #647284;
  --line: #d7e0e8;
  --primary: #176b87;
  --primary-dark: #0f4d62;
  --accent: #d45b3f;
  --soft: #f7fafc;
  --good: #2f7d57;
  --warn: #a45c1b;
  --shadow: 0 18px 50px rgba(24, 32, 42, 0.12);
  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;
  background: var(--bg);
  color: var(--ink);
}

button {
  font: inherit;
}

.shell {
  display: block;
  width: min(960px, 100%);
  min-height: 100vh;
  padding: 18px;
  margin: 0 auto;
}

.chat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

h2 {
  margin-bottom: 10px;
  font-size: 15px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--primary-dark);
  cursor: pointer;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.text-link,
.text-button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary-dark);
  background: var(--soft);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.text-button[aria-pressed="true"] {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.chat__body {
  overflow: auto;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.72), rgba(255,255,255,0.94)),
    var(--bg);
}

.message {
  max-width: 86%;
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 8px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message__meta {
  margin-bottom: 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
}

.message--bot {
  background: var(--panel);
  border: 1px solid var(--line);
}

.message--user {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
}

.message__image {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
}

.inline-editor {
  width: min(100%, 760px);
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid rgba(23, 107, 135, 0.28);
  border-radius: 8px;
  background: #f5fbfd;
}

.inline-editor h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.inline-editor__meta {
  margin-bottom: 12px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.inline-editor__source {
  margin: -6px 0 10px;
  padding: 8px 10px;
  border: 1px solid rgba(23, 107, 135, 0.18);
  border-radius: 8px;
  color: var(--primary-dark);
  background: #fff;
  font-size: 12px;
}

.inline-editor__form {
  display: grid;
  gap: 12px;
}

.inline-editor label,
.inline-editor__field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.inline-editor input,
.inline-editor textarea,
.inline-editor select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

.inline-editor textarea {
  min-height: 130px;
  resize: vertical;
}

.inline-editor__row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.inline-editor__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-editor__actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.inline-editor__actions .primary {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.inline-editor__status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.chat__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.actions-divider {
  grid-column: 1 / -1;
  padding-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.text-answer {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.text-answer__field {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.text-answer__field:focus {
  outline: 2px solid rgba(23, 107, 135, 0.18);
  border-color: var(--primary);
}

.text-answer__controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  padding: 10px 12px;
}

.action:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.action[data-urgent="true"] {
  border-color: rgba(212, 91, 63, 0.4);
  color: #8d2f1c;
  background: #fff3ef;
}

.action--secondary {
  color: var(--muted);
  background: #fff;
}

.action--global {
  min-height: 38px;
  color: var(--muted);
  background: #fff;
  border-style: dashed;
}

.production {
  background:
    linear-gradient(180deg, rgba(238, 246, 244, 0.92), rgba(238, 243, 247, 0.98)),
    var(--bg);
}

.shell--public {
  width: min(760px, 100%);
}

.chat--public {
  min-height: calc(100vh - 36px);
}

.chat--public .chat__header {
  align-items: flex-start;
}

.chat--public .message__meta {
  display: none;
}

.chat--public .actions-divider {
  display: none;
}

.text-answer__label {
  color: var(--ink);
  font-weight: 700;
}

.form-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.error-report-form {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 900px) {
  .shell {
    padding: 10px;
  }

  .chat {
    min-height: 78vh;
  }

  .chat__actions {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 100%;
  }
}
