:root {
  --bg: #f7f6f3;
  --panel: #ffffff;
  --text: #3b3b3b;
  --muted: #7c7c7c;
  --line: #e9e5dd;
  --accent: #f6a612;
  --accent-dark: #de9000;
  --assistant: #f3f1eb;
  --user: linear-gradient(135deg, #ffb72b, #f39a00);
  --danger: #d94242;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #fff8e8, var(--bg) 42%);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.panel {
  width: min(100%, 920px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 18px 55px rgba(58, 45, 9, 0.08);
}

.panel-login {
  max-width: 460px;
  padding: 32px;
}

.panel-chat {
  display: flex;
  flex-direction: column;
  min-height: 78vh;
  padding: 18px;
}

.hidden { display: none; }

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

.brand-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd34d, #f6a612);
  box-shadow: 0 0 0 6px rgba(246, 166, 18, 0.16);
}

h1, h2 { margin: 0; }
.muted { color: var(--muted); }
.status { min-height: 22px; margin: 14px 2px 0; }
.status.error { color: var(--danger); }
.status.ok { color: #2f8b3d; }

.form-card {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

label { display: grid; gap: 8px; font-weight: 600; }
input, textarea {
  width: 100%;
  border: 1px solid #d7d0c4;
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  resize: vertical;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(246, 166, 18, 0.15);
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
}
.btn-secondary {
  background: #f5f5f5;
  color: var(--text);
  border: 1px solid #dfdfdf;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid var(--line);
}

.messages {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 8px;
}

.message {
  max-width: 78%;
  padding: 12px 15px;
  border-radius: 18px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.message.assistant {
  background: var(--assistant);
  align-self: flex-start;
}
.message.user {
  background: var(--user);
  color: #fff;
  align-self: flex-end;
}
.message.system {
  background: #fff7e1;
  color: #8b6400;
  align-self: center;
  max-width: 100%;
}
.message.error {
  background: #fff0f0;
  color: var(--danger);
  align-self: center;
  max-width: 100%;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding: 18px 8px 8px;
}

.chat-form textarea {
  min-height: 74px;
}

@media (max-width: 720px) {
  .panel-chat {
    min-height: 100vh;
    border-radius: 0;
  }
  .app-shell {
    padding: 0;
  }
  .message { max-width: 92%; }
  .chat-form {
    grid-template-columns: 1fr;
  }
}
