:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  color: #e9f2ed;
  background: #07110f;
  font-synthesis: none;
  --jade: #63c6a4;
  --gold: #d5ad62;
  --ink: #07110f;
  --panel: rgba(13, 29, 25, .8);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 14%, rgba(48, 133, 105, .18), transparent 31rem),
    linear-gradient(155deg, #091714 0%, #050b0a 72%);
}
button, textarea { font: inherit; }
button { color: inherit; }

.ink-wash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .7;
  background:
    radial-gradient(ellipse at 8% 78%, rgba(65, 118, 101, .16), transparent 29rem),
    radial-gradient(ellipse at 93% 72%, rgba(180, 132, 55, .09), transparent 27rem),
    repeating-linear-gradient(90deg, transparent 0, transparent calc(25% - 1px), rgba(136, 190, 171, .025) 25%);
}
.ink-wash::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.06) .6px, transparent .6px);
  background-size: 5px 5px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
  opacity: .18;
}

.app-shell { position: relative; z-index: 1; height: 100dvh; display: grid; grid-template-rows: 64px minmax(0, 1fr) auto; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid rgba(131, 195, 170, .11);
  background: rgba(5, 15, 12, .72);
  backdrop-filter: blur(20px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: #f0f6f2; text-decoration: none; font-size: 18px; font-weight: 640; letter-spacing: -.02em; }
.seal-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(218, 178, 99, .8);
  border-radius: 8px 3px 8px 3px;
  color: #f0ca7c;
  background: linear-gradient(145deg, rgba(213, 173, 98, .15), rgba(60, 137, 111, .17));
  box-shadow: inset 0 0 0 3px #091512, 0 6px 20px rgba(0,0,0,.25);
  font-family: Georgia, serif;
  font-size: 18px;
}
.header-actions, .status { display: flex; align-items: center; }
.header-actions { gap: 14px; }
.status { gap: 7px; color: #849b92; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #69756f; }
.status.online .status-dot { background: #5bd09f; box-shadow: 0 0 0 4px rgba(91, 208, 159, .11); }
.status.offline .status-dot { background: #d96d70; }
.new-chat {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(125, 181, 159, .16);
  border-radius: 11px;
  background: rgba(15, 35, 29, .74);
  cursor: pointer;
  transition: .2s ease;
}
.new-chat:hover { transform: translateY(-1px); border-color: rgba(213, 173, 98, .4); background: rgba(22, 47, 39, .9); }
.new-chat svg, .send-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.chat { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #285344 transparent; }
.welcome { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 22px 20px 14px; text-align: center; }
.welcome.hidden { display: none; }
.portrait-wrap {
  width: 218px;
  height: 218px;
  position: relative;
  padding: 4px;
  margin-bottom: 20px;
  border-radius: 42% 58% 48% 52% / 53% 45% 55% 47%;
  background: linear-gradient(140deg, #65c4a4, #173e33 55%, #d3a758);
  box-shadow: 0 24px 70px rgba(19, 93, 71, .28), 0 0 0 10px rgba(98, 196, 161, .035);
}
.portrait-wrap img { width: 100%; height: 100%; display: block; border-radius: inherit; object-fit: cover; }
.portrait-orbit {
  position: absolute;
  inset: -14px;
  border: 1px solid rgba(213, 173, 98, .32);
  border-left-color: transparent;
  border-bottom-color: rgba(97, 195, 160, .24);
  border-radius: 47% 53% 44% 56%;
  animation: orbit 18s linear infinite;
}
@keyframes orbit { to { transform: rotate(360deg); } }
.eyebrow { margin: 0 0 8px; color: #8bcdb5; font-size: 10px; font-weight: 700; letter-spacing: .2em; }
.welcome h1 { margin: 0; color: #f1f6f3; font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 4vw, 50px); font-weight: 500; letter-spacing: -.035em; }
.intro { margin: 9px 0 0; color: #8fa39b; font-size: 14px; }

.messages { width: min(800px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 28px; }
.message { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 14px; margin-bottom: 26px; }
.message.user { grid-template-columns: minmax(0, 1fr); }
.message.user .avatar { display: none; }
.message.user .message-body { justify-self: end; max-width: 78%; padding: 12px 16px; border: 1px solid rgba(118, 179, 154, .13); border-radius: 20px 20px 5px 20px; background: rgba(29, 59, 49, .78); color: #e6f0eb; }
.avatar { width: 38px; height: 38px; overflow: hidden; border: 1px solid rgba(213, 173, 98, .5); border-radius: 12px 6px 12px 6px; background: #102b23; box-shadow: 0 5px 18px rgba(0,0,0,.25); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.message-body { min-width: 0; padding-top: 7px; color: #cfddd7; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.pending .message-body::after { content: ""; display: inline-block; width: 7px; height: 16px; margin-left: 3px; background: var(--jade); animation: blink .9s steps(1) infinite; vertical-align: -2px; }
.message.error .message-body { color: #e59898; }
@keyframes blink { 50% { opacity: 0; } }

.composer-wrap { padding: 10px 18px 14px; background: linear-gradient(180deg, rgba(7,17,15,0), rgba(7,17,15,.96) 25%); }
.composer {
  width: min(780px, 100%);
  min-height: 62px;
  margin: 0 auto;
  padding: 9px 9px 9px 20px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border: 1px solid rgba(114, 183, 155, .2);
  border-radius: 22px 12px 22px 12px;
  background: rgba(12, 29, 24, .9);
  box-shadow: 0 18px 56px rgba(0,0,0,.32), inset 0 1px rgba(255,255,255,.025);
  backdrop-filter: blur(20px);
}
.composer:focus-within { border-color: rgba(213, 173, 98, .48); box-shadow: 0 18px 58px rgba(0,0,0,.38), 0 0 0 3px rgba(98, 198, 164, .06); }
.composer textarea { flex: 1; max-height: 170px; min-height: 42px; padding: 10px 0 7px; resize: none; overflow-y: auto; border: 0; outline: 0; background: transparent; color: #edf5f1; line-height: 1.45; }
.composer textarea::placeholder { color: #70857d; }
.send-button { flex: 0 0 44px; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 15px 8px 15px 8px; background: linear-gradient(135deg, #3f9c7c, #b68d49); color: #06110d; cursor: pointer; box-shadow: 0 8px 22px rgba(44, 125, 96, .24); transition: .2s ease; }
.send-button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.send-button:disabled { opacity: .3; cursor: default; box-shadow: none; }
.disclaimer { margin: 8px auto 0; text-align: center; color: #687b74; font-size: 11px; }

@media (max-width: 720px) {
  .topbar { padding: 0 15px; }
  .status-text { display: none; }
  .welcome { justify-content: flex-start; padding-top: 34px; }
  .portrait-wrap { width: 172px; height: 172px; margin-bottom: 16px; }
  .welcome h1 { font-size: 35px; }
  .messages { width: calc(100% - 24px); padding-top: 22px; }
  .message { grid-template-columns: 34px minmax(0, 1fr); gap: 10px; }
  .avatar { width: 34px; height: 34px; }
  .message.user .message-body { max-width: 88%; }
  .composer-wrap { padding-inline: 10px; }
  .composer { min-height: 56px; padding-left: 15px; }
  .send-button { width: 40px; height: 40px; flex-basis: 40px; }
}
@media (max-height: 720px) and (min-width: 721px) {
  .portrait-wrap { width: 154px; height: 154px; margin-bottom: 12px; }
  .welcome h1 { font-size: 36px; }
  .intro { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
