:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #5f6c7b;
  --border: #d8dee8;
  --accent: #146c58;
  --accent-dark: #0e5142;
  --danger: #b42318;
  --focus: #b68a19;
  --shadow: 0 12px 30px rgba(31, 41, 51, 0.08);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

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

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

input {
  min-height: 46px;
  padding: 0 14px;
}

textarea {
  min-height: 78px;
  resize: vertical;
  padding: 12px 14px;
}

input:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(182, 138, 25, 0.18);
}

h1,
p {
  margin-top: 0;
}

.auth-page,
.empty-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card,
.empty-state {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h1,
.empty-state h1 {
  margin-bottom: 22px;
  font-size: 30px;
  line-height: 1.15;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  color: var(--muted);
  font-weight: 700;
}

.chat-page {
  min-height: 100vh;
}

.chat-shell {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto auto auto;
  gap: 12px;
  width: min(920px, calc(100% - 24px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 12px 0 18px;
}

.chat-toolbar,
.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.secondary-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: #f3faf8;
  color: var(--accent-dark);
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.message-row {
  display: grid;
  gap: 5px;
  max-width: min(760px, 88%);
}

.message-user {
  justify-self: end;
}

.message-client {
  justify-self: start;
}

.message-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.message-user .message-label {
  text-align: right;
}

.message-bubble {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f7f9fc;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-user .message-bubble {
  border-color: #b9d9cf;
  background: #eaf7f3;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 10px;
  align-items: stretch;
}

.chat-form button {
  min-height: 78px;
}

.form-message {
  min-height: 24px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .chat-shell {
    width: min(100% - 16px, 920px);
    padding: 8px 0 12px;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat-form button {
    min-height: 44px;
  }

  .chat-toolbar button,
  .chat-actions button,
  .auth-form button {
    width: 100%;
  }

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