:root {
  --bg: #f4efe5;
  --panel: rgba(255, 251, 244, 0.92);
  --panel-strong: #fff9ef;
  --text: #2b241c;
  --muted: #6e6559;
  --line: rgba(81, 62, 35, 0.12);
  --accent: #9d5c2f;
  --accent-strong: #7f441d;
  --assistant: #efe4d2;
  --user: #f6c37b;
  --shadow: 0 24px 60px rgba(59, 39, 19, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 214, 153, 0.55), transparent 35%),
    linear-gradient(135deg, #f7f2e9 0%, #efe7d9 54%, #eadfcf 100%);
}

body {
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
}

.side-panel,
.chat-panel {
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.side-panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.brand h1,
.chat-header h2,
.settings-card h2 {
  margin: 0;
}

.brand p,
.chat-header p,
.hint,
.message-meta {
  margin: 0;
  color: var(--muted);
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #c98038, #8d4c23);
  color: white;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.settings-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
}

.settings-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  color: var(--text);
  padding: 12px 14px;
}

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

button {
  cursor: pointer;
  border-radius: 999px;
  border: 0;
  padding: 12px 18px;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

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

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

.primary-button {
  background: linear-gradient(160deg, var(--accent), var(--accent-strong));
  color: white;
}

.secondary-button,
.ghost-button {
  background: rgba(157, 92, 47, 0.1);
  color: var(--accent-strong);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: calc(100vh - 48px);
}

.chat-header,
.chat-form {
  padding: 22px 24px;
}

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

.chat-messages {
  padding: 22px 24px;
  height: 100%;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.message {
  max-width: min(78ch, 84%);
  padding: 14px 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(60, 39, 16, 0.08);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.message-assistant {
  align-self: flex-start;
  background: var(--assistant);
}

.message-user {
  align-self: flex-end;
  background: var(--user);
}

.message-body {
  margin-top: 6px;
  white-space: pre-wrap;
  line-height: 1.55;
}

.message-streaming {
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0)),
    var(--assistant);
  box-shadow: 0 16px 34px rgba(60, 39, 16, 0.12);
  transform: translateY(-1px);
}

.message-streaming .message-meta {
  color: var(--accent-strong);
}

.message-streaming .message-body::after {
  content: "";
  display: inline-block;
  width: 0.62rem;
  height: 1.1em;
  margin-left: 0.18rem;
  vertical-align: -0.16em;
  border-radius: 999px;
  background: var(--accent-strong);
  animation: writing-caret 0.9s steps(1, end) infinite;
}

@keyframes writing-caret {
  0%,
  45% {
    opacity: 1;
    transform: scaleY(1);
  }

  50%,
  100% {
    opacity: 0.18;
    transform: scaleY(0.92);
  }
}

.chat-form {
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

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

  .chat-panel {
    min-height: 70vh;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
    gap: 14px;
  }

  .side-panel,
  .chat-panel {
    border-radius: 22px;
  }

  .chat-header,
  .chat-form,
  .chat-messages,
  .side-panel {
    padding-left: 16px;
    padding-right: 16px;
  }

  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
