:root {
  color-scheme: dark;
  --background: #0d1220;
  --surface: #171e30;
  --input: #11192a;
  --text: #eef1fa;
  --muted: #abb7ce;
  --border: #344159;
  --control-border: #64728e;
  --accent: #a1b0ff;
  --accent-hover: #c0caff;
  --on-accent: #131b32;
  --own: #283555;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, textarea { font: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.shell { width: min(760px, calc(100% - 48px)); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--border); }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; text-decoration: none; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: .875rem; }
.back { color: var(--muted); text-decoration: none; font-size: .875rem; font-weight: 650; }
.back:hover { color: var(--accent); }

.chat { padding-block: clamp(28px, 6vw, 56px); }
.chat-header { margin-bottom: 20px; }
.chat-header h1 { margin: 0; font-size: clamp(2.25rem, 7vw, 3.45rem); line-height: 1.05; font-weight: 760; letter-spacing: -.055em; }
.chat-header p { margin: 8px 0 0; color: var(--muted); line-height: 1.45; }
.chat-panel { border: 1px solid var(--border); border-radius: 20px; background: var(--surface); }
.transcript { min-height: 250px; max-height: 48vh; overflow: auto; overscroll-behavior: contain; padding: 16px; }
.empty { margin: 10px 0; color: var(--muted); }
#messages { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.message { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 12px; width: fit-content; max-width: min(100%, 600px); padding: 8px 10px 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--input); }
.message.own { margin-inline-start: auto; background: var(--own); }
.message p { margin: 1px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.copy-message { padding: 4px 6px; background: transparent; border: 0; border-radius: 6px; color: var(--accent); font-size: .875rem; font-weight: 700; cursor: pointer; }
.copy-message:hover { color: var(--accent-hover); }
.compose { display: flex; align-items: end; gap: 10px; padding: 16px; border-top: 1px solid var(--border); }
.compose-text { flex: 1; min-width: 0; }
label { display: block; margin-bottom: 8px; color: var(--text); font-size: .875rem; font-weight: 650; }
textarea { display: block; min-width: 0; width: 100%; padding: 10px 12px; border: 1px solid var(--control-border); border-radius: 9px; background: var(--input); color: var(--text); resize: vertical; line-height: 1.45; min-height: 70px; max-height: 210px; }
.button { flex: 0 0 auto; min-height: 44px; padding: 8px 16px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; cursor: pointer; transition: background-color 150ms ease-out; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { cursor: default; opacity: .62; }
.primary { background: var(--accent); color: var(--on-accent); }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.feedback { margin: 12px 0 0; color: var(--muted); font-size: .875rem; line-height: 1.45; }

@media (max-width: 540px) {
  .shell { width: calc(100% - 32px); }
  .brand-row { min-height: 60px; }
  .chat-header { margin-bottom: 16px; }
  .transcript, .compose { padding: 12px; }
  .transcript { min-height: 192px; max-height: 44vh; }
  .button { padding-inline: 12px; }
  .message { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
  .button:active:not(:disabled) { transform: none; }
}
