:root {
  --ink: #1B2A45;
  --ink-soft: #3C4A63;
  --parchment: #F6F3EC;
  --parchment-deep: #EDE8DB;
  --paper: #FFFFFF;
  --bronze: #A8763A;
  --bronze-deep: #8C6129;
  --line: #DFD9C8;
  --danger: #9B3B3B;

  --font-display: 'PT Serif', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-body);
  background-image:
    radial-gradient(circle at 20% 8%, rgba(168, 118, 58, 0.06), transparent 45%),
    radial-gradient(circle at 85% 92%, rgba(27, 42, 69, 0.05), transparent 40%);
}

.app {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 20px;
}

/* ---------- Header ---------- */

.app__header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 4px 18px;
  border-bottom: 1px solid var(--line);
}

.seal {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bronze);
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 3px var(--parchment), 0 0 0 4px var(--line);
}

.app__title h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}

.app__title p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* ---------- Chat area ---------- */

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 28px 4px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.chat__empty {
  margin: auto;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14.5px;
  line-height: 1.7;
}

.msg {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: rise 0.35s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg--user {
  align-self: flex-end;
  align-items: flex-end;
}

.msg--assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.msg__bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg--user .msg__bubble {
  background: var(--ink);
  color: var(--parchment);
  border-bottom-right-radius: 4px;
}

.msg--assistant .msg__bubble {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.msg--error .msg__bubble {
  background: #FBF0EE;
  border: 1px solid #E3B8B0;
  color: var(--danger);
}

.msg__label {
  font-size: 11px;
  color: var(--ink-soft);
  padding: 0 4px;
  letter-spacing: 0.02em;
}

/* cursor for typewriter effect */
.msg__bubble .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--bronze);
  margin-left: 1px;
  vertical-align: -0.15em;
  animation: blink 0.9s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* thinking indicator */
.thinking {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 13px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bronze);
  animation: bob 1.1s ease-in-out infinite;
}

.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bob {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Composer ---------- */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 10px;
}

.composer__input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  max-height: 160px;
  padding: 6px 4px;
}

.composer__input::placeholder {
  color: #9C9584;
}

.composer__send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--bronze);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.composer__send:hover { background: var(--bronze-deep); }
.composer__send:active { transform: scale(0.94); }
.composer__send:disabled {
  background: #C9BFA9;
  cursor: not-allowed;
}

.composer__send:focus-visible,
.composer__input:focus-visible {
  outline: 2px solid var(--bronze);
  outline-offset: 2px;
}

.disclaimer {
  text-align: center;
  font-size: 11.5px;
  color: #A39C89;
  margin: 0 0 16px;
}

/* ---------- Responsive ---------- */

@media (max-width: 560px) {
  .app { padding: 0 12px; }
  .msg { max-width: 92%; }
  .app__title h1 { font-size: 17px; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .msg, .thinking span, .cursor {
    animation: none !important;
  }
}
