@import "./assets/vendor/fonts/outfit/outfit.css";
@import "./assets/vendor/fonts/newsreader/newsreader.css";
@import "./assets/vendor/phosphor/phosphor.css";

:root {
  color-scheme: light;
  --page: #f0ede4;
  --page-glow: #faf7ef;
  --panel: #fbfaf5;
  --panel-strong: #ffffff;
  --panel-soft: #eee9dc;
  --ink: #19171b;
  --ink-soft: #4e4952;
  --muted: #746d78;
  --line: rgba(35, 29, 39, 0.13);
  --line-strong: rgba(35, 29, 39, 0.24);
  --violet: #7140a8;
  --violet-strong: #5d2d94;
  --violet-soft: #eee3f8;
  --violet-glow: rgba(113, 64, 168, 0.22);
  --sidebar: #18141d;
  --sidebar-soft: #241c2b;
  --sidebar-ink: #f8f1df;
  --sidebar-muted: #aaa0ae;
  --sidebar-line: rgba(255, 255, 255, 0.1);
  --danger: #aa483d;
  --gold: #c18a37;
  --green: #4f7c64;
  --shadow: 0 22px 60px rgba(35, 28, 39, 0.12);
  --shadow-strong: 0 34px 90px rgba(35, 28, 39, 0.2);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font-ui: "Outfit Variable", "Segoe UI", sans-serif;
  --font-display: "Newsreader Variable", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --page: #111014;
    --page-glow: #18151c;
    --panel: #1b181f;
    --panel-strong: #221e26;
    --panel-soft: #29232e;
    --ink: #f4eddf;
    --ink-soft: #d6ccd9;
    --muted: #a89ead;
    --line: rgba(244, 237, 223, 0.12);
    --line-strong: rgba(244, 237, 223, 0.23);
    --violet: #ad79dc;
    --violet-strong: #c99bec;
    --violet-soft: #34253f;
    --violet-glow: rgba(173, 121, 220, 0.18);
    --sidebar: #0d0b10;
    --sidebar-soft: #18131d;
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.3);
    --shadow-strong: 0 34px 90px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #111014;
  --page-glow: #18151c;
  --panel: #1b181f;
  --panel-strong: #221e26;
  --panel-soft: #29232e;
  --ink: #f4eddf;
  --ink-soft: #d6ccd9;
  --muted: #a89ead;
  --line: rgba(244, 237, 223, 0.12);
  --line-strong: rgba(244, 237, 223, 0.23);
  --violet: #ad79dc;
  --violet-strong: #c99bec;
  --violet-soft: #34253f;
  --violet-glow: rgba(173, 121, 220, 0.18);
  --sidebar: #0d0b10;
  --sidebar-soft: #18131d;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.3);
  --shadow-strong: 0 34px 90px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  overflow: hidden;
  color: var(--ink);
  background: var(--page);
  font-family: var(--font-ui);
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.14;
  background:
    repeating-linear-gradient(0deg, rgba(22, 17, 25, 0.035) 0 1px, transparent 1px 4px),
    linear-gradient(115deg, transparent 0 48%, rgba(255, 255, 255, 0.24) 50%, transparent 52%);
  mix-blend-mode: soft-light;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

kbd {
  font-family: inherit;
}

.ph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

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

.chat-app {
  width: 100%;
  height: 100dvh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  overflow: hidden;
}

.chat-sidebar {
  min-width: 0;
  height: 100dvh;
  padding: 0.9rem;
  position: relative;
  z-index: 40;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  color: var(--sidebar-ink);
  background:
    radial-gradient(circle at 0 0, rgba(142, 83, 191, 0.17), transparent 28%),
    linear-gradient(155deg, rgba(255, 255, 255, 0.025), transparent 42%),
    var(--sidebar);
  border-right: 1px solid var(--sidebar-line);
}

.chat-sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background:
    repeating-linear-gradient(90deg, transparent 0 47px, rgba(255, 255, 255, 0.05) 47px 48px),
    repeating-radial-gradient(circle at 0 100%, transparent 0 44px, rgba(255, 255, 255, 0.06) 45px 46px, transparent 47px 76px);
}

.sidebar-header,
.new-chat-button,
.history-search,
.history-heading,
.history-list,
.sidebar-footer {
  position: relative;
  z-index: 1;
}

.sidebar-header {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.sidebar-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.62rem;
}

.sidebar-brand-mark {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff7e5;
  background: rgba(255, 255, 255, 0.06);
  font-family: var(--font-display);
  font-size: 0.92rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.sidebar-brand > span:last-child {
  min-width: 0;
  display: grid;
}

.sidebar-brand strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1;
}

.sidebar-brand small {
  margin-top: 0.1rem;
  color: var(--sidebar-muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.sidebar-close,
.history-heading button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--sidebar-muted);
  background: transparent;
  transition: color 180ms ease, background 180ms ease;
}

.sidebar-close:hover,
.history-heading button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-close {
  display: none;
}

.new-chat-button {
  min-height: 48px;
  border: 1px solid rgba(189, 137, 226, 0.35);
  border-radius: 14px;
  padding: 0 0.8rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.58rem;
  color: #fff;
  background: linear-gradient(135deg, rgba(126, 68, 173, 0.88), rgba(79, 42, 110, 0.88));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  font-weight: 780;
  text-align: left;
  transition: transform 220ms var(--ease), border-color 220ms ease, box-shadow 220ms var(--ease);
}

.new-chat-button:hover {
  border-color: rgba(219, 176, 244, 0.65);
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.new-chat-button kbd {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 0.18rem 0.34rem;
  color: rgba(255, 255, 255, 0.62);
  background: rgba(0, 0, 0, 0.16);
  font-size: 0.62rem;
  font-weight: 650;
}

.history-search {
  min-height: 40px;
  border: 1px solid var(--sidebar-line);
  border-radius: 12px;
  padding: 0 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.48rem;
  color: var(--sidebar-muted);
  background: rgba(255, 255, 255, 0.035);
  transition: border-color 180ms ease, background 180ms ease;
}

.history-search:focus-within {
  border-color: rgba(189, 137, 226, 0.44);
  background: rgba(255, 255, 255, 0.055);
}

.history-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--sidebar-ink);
  background: transparent;
  font-size: 0.82rem;
}

.history-search input::placeholder {
  color: #8e8493;
}

.history-heading {
  min-height: 34px;
  padding: 0 0.15rem 0 0.38rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--sidebar-muted);
  font-size: 0.68rem;
  font-weight: 790;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

.history-empty {
  margin: 1.4rem 0;
  padding: 0 0.45rem;
  color: #8d8391;
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: center;
}

.history-item {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.58rem 0.42rem 0.58rem 0.66rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  color: #c9c0cb;
  background: transparent;
  transition: color 180ms ease, background 180ms ease, border-color 180ms ease;
}

.history-item:hover,
.history-item.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.065);
}

.history-item.is-active {
  border-color: rgba(189, 137, 226, 0.18);
  background: linear-gradient(90deg, rgba(128, 72, 170, 0.2), rgba(255, 255, 255, 0.04));
}

.history-item > .ph {
  color: #9f73bd;
  font-size: 0.9rem;
}

.history-item-main {
  min-width: 0;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.history-item-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 700;
}

.history-item-date {
  display: block;
  margin-top: 0.12rem;
  color: #8d8391;
  font-size: 0.64rem;
}

.history-item-actions {
  display: flex;
  opacity: 0;
  transition: opacity 160ms ease;
}

.history-item:hover .history-item-actions,
.history-item:focus-within .history-item-actions,
.history-item.is-active .history-item-actions {
  opacity: 1;
}

.history-item-actions button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #9d939f;
  background: transparent;
}

.history-item-actions button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-line);
  padding-top: 0.72rem;
  display: grid;
  gap: 0.58rem;
}

.sidebar-diogene {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-diogene img {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 11px;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.sidebar-diogene > span {
  min-width: 0;
  display: grid;
}

.sidebar-diogene strong {
  font-family: var(--font-display);
  font-size: 0.98rem;
}

.sidebar-diogene small {
  color: var(--sidebar-muted);
  font-size: 0.68rem;
}

.sidebar-footer > a {
  min-height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 0.48rem;
  padding: 0 0.58rem;
  color: var(--sidebar-muted);
  font-size: 0.76rem;
  font-weight: 690;
  transition: color 180ms ease, background 180ms ease;
}

.sidebar-footer > a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-overlay {
  display: none;
}

.chat-main {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-rows: 68px minmax(0, 1fr) auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 82% 3%, var(--violet-glow), transparent 24%),
    radial-gradient(circle at 8% 92%, rgba(193, 138, 55, 0.08), transparent 24%),
    linear-gradient(90deg, rgba(44, 34, 48, 0.035) 1px, transparent 1px),
    var(--page);
  background-size: auto, auto, 72px 100%, auto;
}

.chat-main::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background: repeating-radial-gradient(circle at 100% 0, transparent 0 70px, rgba(113, 64, 168, 0.08) 71px 72px, transparent 73px 112px);
  mask-image: linear-gradient(180deg, #000, transparent 60%);
}

.chat-header {
  min-width: 0;
  padding: 0 clamp(0.8rem, 2vw, 1.5rem);
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: blur(18px) saturate(1.18);
}

.chat-header-leading,
.chat-header-actions,
.chat-identity {
  min-width: 0;
  display: flex;
  align-items: center;
}

.chat-header-leading {
  gap: 0.72rem;
}

.chat-header-actions {
  gap: 0.45rem;
}

.chat-identity {
  gap: 0.62rem;
}

.chat-avatar {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  position: relative;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.chat-avatar-small {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  box-shadow: 0 8px 20px rgba(35, 28, 39, 0.14);
}

.chat-identity > span:last-child {
  min-width: 0;
  display: grid;
  gap: 0.12rem;
}

.chat-identity strong {
  font-family: var(--font-display);
  font-size: 1.12rem;
  line-height: 1;
}

.chat-identity small {
  display: flex;
  align-items: center;
  gap: 0.38rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 680;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #4e8a62;
  box-shadow: 0 0 0 4px rgba(78, 138, 98, 0.13);
}

.chat-app[data-mode="local"] .status-dot {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(193, 138, 55, 0.14);
}

.chat-app[data-mode="error"] .status-dot {
  background: #b7574c;
  box-shadow: 0 0 0 4px rgba(183, 87, 76, 0.14);
}

.header-icon {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  transition: transform 200ms var(--ease), border-color 200ms ease, color 200ms ease, background 200ms ease;
}

.header-icon:hover {
  border-color: var(--line-strong);
  color: var(--violet-strong);
  background: var(--panel);
  transform: translateY(-2px);
}

.sidebar-open {
  display: none;
}

.chat-scroll {
  min-width: 0;
  min-height: 0;
  position: relative;
  z-index: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 32%, transparent) transparent;
}

.chat-column,
.composer-column {
  width: min(900px, calc(100% - 36px));
  margin: 0 auto;
}

.chat-column {
  min-height: 100%;
  padding: clamp(1.8rem, 5vh, 4rem) 0 2.5rem;
}

.chat-welcome {
  min-height: calc(100% - 3rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  animation: welcome-in 720ms var(--ease) both;
}

.chat-welcome[hidden] {
  display: none;
}

.lantern-stage {
  width: 150px;
  height: 150px;
  margin-bottom: 1.45rem;
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
}

.lantern-stage::before {
  content: "";
  width: 230px;
  height: 230px;
  position: absolute;
  z-index: -2;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(113, 64, 168, 0.2), transparent 68%);
  filter: blur(4px);
}

.lantern-stage::after {
  content: "";
  width: 94px;
  height: 26px;
  position: absolute;
  left: 28px;
  bottom: -8px;
  z-index: -1;
  border-radius: 50%;
  background: rgba(45, 29, 52, 0.2);
  filter: blur(10px);
}

.lantern-stage img {
  width: 128px;
  height: 128px;
  border: 1px solid rgba(120, 72, 44, 0.2);
  border-radius: 28px;
  object-fit: cover;
  box-shadow: 0 24px 56px rgba(67, 44, 76, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  animation: lantern-float 5.2s ease-in-out infinite;
}

.lantern-orbit,
.lantern-spark {
  position: absolute;
  pointer-events: none;
}

.lantern-orbit {
  border: 1px solid color-mix(in srgb, var(--violet) 30%, transparent);
  border-radius: 50%;
}

.lantern-orbit::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: -4px;
  background: var(--violet);
  box-shadow: 0 0 16px var(--violet);
}

.lantern-orbit-one {
  width: 150px;
  height: 150px;
  animation: orbit 15s linear infinite;
}

.lantern-orbit-two {
  width: 178px;
  height: 112px;
  rotate: 38deg;
  animation: orbit 21s linear infinite reverse;
}

.lantern-spark {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 16px rgba(193, 138, 55, 0.7);
  animation: spark 3.4s ease-in-out infinite;
}

.lantern-spark-one {
  top: 12px;
  right: 8px;
}

.lantern-spark-two {
  left: 3px;
  bottom: 24px;
  animation-delay: -1.7s;
}

.welcome-kicker {
  margin: 0 0 0.72rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--violet-strong);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chat-welcome h1 {
  max-width: 760px;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3rem, 6vw, 5.7rem);
  font-weight: 600;
  line-height: 0.92;
  letter-spacing: -0.035em;
}

.welcome-copy {
  max-width: 650px;
  margin: 1rem auto 0;
  color: var(--muted);
  font-size: clamp(0.96rem, 1.2vw, 1.08rem);
  line-height: 1.58;
}

.starter-grid {
  width: 100%;
  margin-top: clamp(1.5rem, 3vh, 2.25rem);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.starter-grid button {
  min-width: 0;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 0.78rem;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--panel-strong) 90%, transparent), color-mix(in srgb, var(--panel) 76%, transparent));
  box-shadow: 0 12px 28px rgba(35, 28, 39, 0.055);
  text-align: left;
  transition: transform 230ms var(--ease), border-color 230ms ease, box-shadow 230ms var(--ease), background 230ms ease;
}

.starter-grid button:hover {
  border-color: color-mix(in srgb, var(--violet) 42%, var(--line));
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  background: var(--panel-strong);
}

.starter-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
}

.starter-violet {
  color: #7442aa;
  background: #eee4f7;
}

.starter-red {
  color: #a34b3f;
  background: #f5e5df;
}

.starter-blue {
  color: #3f668d;
  background: #e2ebf3;
}

.starter-gold {
  color: #946820;
  background: #f5ead3;
}

:root[data-theme="dark"] .starter-violet {
  background: color-mix(in srgb, #7442aa 22%, var(--panel));
}

:root[data-theme="dark"] .starter-red {
  background: color-mix(in srgb, #a34b3f 20%, var(--panel));
}

:root[data-theme="dark"] .starter-blue {
  background: color-mix(in srgb, #3f668d 24%, var(--panel));
}

:root[data-theme="dark"] .starter-gold {
  background: color-mix(in srgb, #946820 24%, var(--panel));
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .starter-violet {
    background: color-mix(in srgb, #7442aa 22%, var(--panel));
  }

  :root:not([data-theme]) .starter-red {
    background: color-mix(in srgb, #a34b3f 20%, var(--panel));
  }

  :root:not([data-theme]) .starter-blue {
    background: color-mix(in srgb, #3f668d 24%, var(--panel));
  }

  :root:not([data-theme]) .starter-gold {
    background: color-mix(in srgb, #946820 24%, var(--panel));
  }
}

.starter-grid button > span:last-child {
  min-width: 0;
  display: grid;
  gap: 0.15rem;
}

.starter-grid strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.05;
}

.starter-grid small {
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 650;
}

.archive-ready {
  margin: 1.05rem 0 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 680;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.chat-message {
  width: 100%;
  animation: message-in 450ms var(--ease) both;
}

.message-layout {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: start;
  gap: 0.8rem;
}

.message-avatar {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
  background: var(--violet);
  box-shadow: 0 9px 20px rgba(35, 28, 39, 0.12);
  font-size: 0.68rem;
  font-weight: 850;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-body {
  min-width: 0;
}

.message-author {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 820;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.message-content {
  min-width: 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.65;
}

.message-content > p {
  margin: 0;
}

.message-content > p + p {
  margin-top: 0.72rem;
}

.message-user .message-layout {
  grid-template-columns: minmax(0, 1fr) 42px;
  margin-left: clamp(2rem, 12vw, 8rem);
}

.message-user .message-avatar {
  grid-column: 2;
  grid-row: 1;
  border-color: transparent;
  color: #fff;
  background: var(--violet);
}

.message-user .message-body {
  grid-column: 1;
  grid-row: 1;
}

.message-user .message-author {
  text-align: right;
}

.message-user .message-content {
  border: 1px solid color-mix(in srgb, var(--violet) 20%, var(--line));
  border-radius: 18px 5px 18px 18px;
  padding: 0.82rem 1rem;
  color: var(--ink);
  background: color-mix(in srgb, var(--violet-soft) 62%, var(--panel));
}

.message-assistant .message-body {
  border-bottom: 1px solid var(--line);
  padding: 0 0 1.15rem;
}

.message-mode {
  margin-left: 0.32rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.17rem 0.38rem;
  color: var(--muted);
  font-size: 0.56rem;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.open-question {
  margin-top: 1rem;
  border-left: 3px solid var(--violet);
  border-radius: 0 12px 12px 0;
  padding: 0.78rem 0.9rem;
  color: var(--ink);
  background: color-mix(in srgb, var(--violet-soft) 56%, transparent);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.45;
}

.open-question strong {
  display: block;
  margin-bottom: 0.22rem;
  color: var(--violet-strong);
  font-family: var(--font-ui);
  font-size: 0.64rem;
  font-style: normal;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.message-actions {
  min-height: 34px;
  margin-top: 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.message-actions button {
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  color: var(--muted);
  background: transparent;
  font-size: 0.67rem;
  font-weight: 700;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.message-actions button:hover {
  border-color: var(--line);
  color: var(--violet-strong);
  background: var(--panel);
}

.thinking-dots {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 0.28rem;
}

.thinking-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--violet);
  animation: thinking 1.05s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 120ms;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 240ms;
}

.related-shelf {
  margin-top: 1.15rem;
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}

.related-heading {
  margin-bottom: 0.65rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.related-heading strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.related-heading span {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 780;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 0.62rem;
}

.related-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(35, 28, 39, 0.055);
  animation: related-in 480ms var(--ease) both;
  animation-delay: var(--delay, 0ms);
  transition: transform 220ms var(--ease), border-color 220ms ease, box-shadow 220ms var(--ease);
}

.related-card:only-child {
  max-width: 280px;
}

.related-card:hover {
  border-color: color-mix(in srgb, var(--card-accent) 55%, var(--line));
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.related-visual {
  aspect-ratio: 16 / 9;
  position: relative;
  overflow: hidden;
  background: var(--sidebar);
}

.related-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.35), transparent 52%);
}

.related-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 380ms var(--ease);
}

.related-card:hover .related-visual img {
  transform: scale(1.035);
}

.related-play {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  z-index: 1;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--card-accent);
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.3);
}

.related-copy {
  min-width: 0;
  padding: 0.7rem;
  display: grid;
  align-content: start;
  gap: 0.28rem;
}

.related-copy small {
  color: var(--card-accent);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.related-copy strong {
  font-family: var(--font-display);
  font-size: 0.92rem;
  line-height: 1.08;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.related-reason {
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.35;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.composer-dock {
  min-width: 0;
  position: relative;
  z-index: 12;
  padding: 0.65rem 0 max(0.72rem, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--page) 96%, transparent) 20%);
}

.chat-composer {
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 0.78rem 0.82rem 0.62rem;
  position: relative;
  background: color-mix(in srgb, var(--panel-strong) 94%, transparent);
  box-shadow: 0 18px 48px rgba(35, 28, 39, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(18px);
  transition: border-color 200ms ease, box-shadow 200ms var(--ease), transform 200ms var(--ease);
}

.chat-composer:focus-within {
  border-color: color-mix(in srgb, var(--violet) 62%, var(--line));
  box-shadow: 0 22px 58px rgba(55, 35, 65, 0.18), 0 0 0 4px var(--violet-glow);
  transform: translateY(-1px);
}

.chat-composer textarea {
  width: 100%;
  min-height: 34px;
  max-height: 160px;
  border: 0;
  outline: 0;
  padding: 0 0.15rem;
  display: block;
  resize: none;
  color: var(--ink);
  background: transparent;
  font-size: 0.96rem;
  line-height: 1.5;
}

.chat-composer textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 76%, transparent);
}

.composer-actions {
  margin-top: 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.48rem;
}

.model-badge {
  min-height: 29px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 0.56rem;
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  color: var(--violet-strong);
  background: var(--violet-soft);
  font-size: 0.65rem;
  font-weight: 780;
}

.character-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.64rem;
  font-variant-numeric: tabular-nums;
}

.send-button,
.stop-button {
  min-height: 36px;
  border: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--violet-strong);
  box-shadow: 0 9px 20px rgba(93, 45, 148, 0.24);
  transition: transform 200ms var(--ease), opacity 200ms ease, background 200ms ease, box-shadow 200ms var(--ease);
}

.send-button {
  width: 38px;
}

.stop-button {
  padding: 0 0.7rem;
  gap: 0.34rem;
  background: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 760;
}

.send-button:hover,
.stop-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 13px 26px rgba(93, 45, 148, 0.3);
}

.send-button:disabled {
  cursor: default;
  opacity: 0.46;
  transform: none;
}

.stop-button[hidden] {
  display: none;
}

.composer-meta {
  min-height: 22px;
  padding: 0.38rem 0.4rem 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.61rem;
  line-height: 1.35;
}

.composer-meta span:last-child {
  text-align: right;
}

.composer-meta .is-warning {
  color: var(--danger);
}

.chat-toast {
  min-width: 160px;
  max-width: min(340px, calc(100% - 32px));
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.72rem 0.9rem;
  position: fixed;
  left: 50%;
  bottom: 1.1rem;
  z-index: 120;
  color: #fff;
  background: rgba(24, 20, 29, 0.92);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.26);
  font-size: 0.76rem;
  font-weight: 680;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  translate: -50% 10px;
  transition: opacity 180ms ease, translate 240ms var(--ease);
  backdrop-filter: blur(14px);
}

.chat-toast.is-visible {
  opacity: 1;
  translate: -50% 0;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--violet) 86%, #fff);
  outline-offset: 3px;
}

@keyframes welcome-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes lantern-float {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-7px) rotate(1deg);
  }
}

@keyframes orbit {
  to {
    transform: rotate(360deg);
  }
}

@keyframes spark {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.7);
  }
  50% {
    opacity: 1;
    transform: scale(1.3);
  }
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes related-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes thinking {
  0%,
  60%,
  100% {
    opacity: 0.32;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-5px);
  }
}

@media (max-height: 780px) and (min-width: 901px) {
  .chat-column {
    padding-top: 1.5rem;
  }

  .lantern-stage {
    width: 118px;
    height: 118px;
    margin-bottom: 0.85rem;
  }

  .lantern-stage img {
    width: 102px;
    height: 102px;
    border-radius: 23px;
  }

  .chat-welcome h1 {
    font-size: clamp(3rem, 5vw, 4.5rem);
  }

  .starter-grid {
    margin-top: 1.15rem;
  }
}

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

  .chat-sidebar {
    width: min(310px, calc(100% - 42px));
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-104%);
    box-shadow: 28px 0 70px rgba(0, 0, 0, 0.32);
    transition: transform 320ms var(--ease);
  }

  .chat-app.is-sidebar-open .chat-sidebar {
    transform: translateX(0);
  }

  .sidebar-close,
  .sidebar-open {
    display: grid;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    border: 0;
    display: block;
    background: rgba(10, 8, 12, 0.52);
    opacity: 0;
    pointer-events: none;
    transition: opacity 240ms ease;
    backdrop-filter: blur(3px);
  }

  .chat-app.is-sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 620px) {
  .chat-main {
    grid-template-rows: 62px minmax(0, 1fr) auto;
  }

  .chat-header {
    padding: 0 0.7rem;
  }

  .chat-avatar-small {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .chat-identity strong {
    font-size: 1rem;
  }

  .chat-column,
  .composer-column {
    width: min(100% - 20px, 900px);
  }

  .chat-column {
    padding-top: 1.25rem;
  }

  .lantern-stage {
    width: 120px;
    height: 120px;
    margin-bottom: 1rem;
  }

  .lantern-stage img {
    width: 102px;
    height: 102px;
    border-radius: 22px;
  }

  .chat-welcome h1 {
    font-size: clamp(2.65rem, 12vw, 4rem);
  }

  .welcome-copy {
    font-size: 0.92rem;
  }

  .starter-grid {
    grid-template-columns: 1fr;
    gap: 0.52rem;
  }

  .starter-grid button {
    min-height: 68px;
  }

  .message-layout {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 0.55rem;
  }

  .message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .message-user .message-layout {
    grid-template-columns: minmax(0, 1fr) 34px;
    margin-left: 1rem;
  }

  .message-content {
    font-size: 0.93rem;
  }

  .related-grid {
    grid-template-columns: 1fr;
  }

  .related-card,
  .related-card:only-child {
    max-width: none;
    grid-template-columns: 126px minmax(0, 1fr);
    grid-template-rows: 1fr;
  }

  .related-visual {
    min-height: 92px;
    aspect-ratio: auto;
  }

  .composer-dock {
    padding: 0.42rem 0 max(0.55rem, env(safe-area-inset-bottom));
  }

  .chat-composer {
    border-radius: 17px;
    padding: 0.65rem 0.68rem 0.55rem;
  }

  .composer-meta {
    justify-content: center;
  }

  .composer-meta > span:first-child {
    display: none;
  }

  .composer-meta span:last-child {
    text-align: center;
  }
}

@media (max-width: 390px) {
  .chat-identity small {
    max-width: 155px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-icon {
    width: 37px;
    height: 37px;
  }

  .chat-header-actions {
    gap: 0.32rem;
  }

  .related-card,
  .related-card:only-child {
    grid-template-columns: 108px minmax(0, 1fr);
  }

  .model-badge {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
.composer-meta a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 160ms ease;
}

.composer-meta a:hover {
  color: var(--violet-strong);
}
