:root {
  color-scheme: dark;
  --bg-0: #0a0c11;
  --bg-1: #121114;
  --bg-2: #1b1713;
  --card: rgba(26, 22, 18, 0.92);
  --card-strong: rgba(35, 29, 23, 0.97);
  --text: #e8dcc0;
  --muted: #b49b70;
  --accent: #c79a4b;
  --accent-2: #8a6428;
  --link: #d6bf82;
  --on-accent: #19120b;
  --surface: rgba(45, 36, 27, 0.74);
  --surface-border: rgba(199, 154, 75, 0.24);
  --tooltip-bg: rgba(19, 16, 14, 0.97);
  --tooltip-top: rgba(255, 244, 216, 0.08);
  --paper: #eadcb7;
  --ink: #2b2017;
  --ink-soft: #3c2f22;
  --steel: #20262f;
  --rune: #d7b67b;
  --rune-soft: rgba(215, 182, 123, 0.16);
  --rune-faint: rgba(238, 217, 179, 0.06);
  --shadow: 0 24px 48px rgba(2, 3, 6, 0.54);
  --radius: 16px;
  --sidebar-width: 274px;
  --sidebar-collapsed-width: 64px;
  --chat-column-width: 1040px;
  --composer-width: 1040px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", "Iowan Old Style", Georgia, serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 76%, rgba(215, 161, 73, 0.2), transparent 26%),
    radial-gradient(circle at 82% 8%, rgba(80, 98, 126, 0.12), transparent 26%),
    radial-gradient(circle at 50% 0%, rgba(255, 233, 182, 0.03), transparent 32%),
    linear-gradient(180deg, #07080c, #120f10 42%, #1b1612 100%);
  min-height: 100vh;
  overflow: hidden;
  text-rendering: optimizeLegibility;
}

body.app-auth {
  overflow-y: auto;
}

body.source-viewer-open {
  overflow: hidden;
}

.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.auth-shell[hidden],
.workspace[hidden] {
  display: none;
}

.auth-shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  background:
    radial-gradient(circle at 14% 72%, rgba(213, 166, 81, 0.22), transparent 24%),
    radial-gradient(circle at 82% 16%, rgba(77, 96, 124, 0.14), transparent 24%),
    linear-gradient(135deg, #090b10 0%, #17120f 50%, #0d0b0d 100%);
}

.auth-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), rgba(255, 223, 166, 0.04) calc(100% - 1px), rgba(255, 223, 166, 0.04) 100%),
    linear-gradient(180deg, transparent 0, transparent calc(100% - 1px), rgba(255, 223, 166, 0.03) calc(100% - 1px), rgba(255, 223, 166, 0.03) 100%);
  pointer-events: none;
}

.auth-poster {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 100vh;
  padding: clamp(40px, 6vw, 80px);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(9, 11, 16, 0.3), rgba(16, 12, 10, 0.86)),
    radial-gradient(circle at 48% 88%, rgba(229, 183, 86, 0.22), transparent 26%),
    radial-gradient(circle at 74% 18%, rgba(70, 88, 114, 0.18), transparent 24%);
}

.auth-poster::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(8, 9, 12, 0.26), rgba(8, 9, 12, 0.02)),
    radial-gradient(circle at 52% 82%, rgba(255, 225, 161, 0.12), transparent 11%),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 78px,
      rgba(255, 230, 184, 0.018) 78px,
      rgba(255, 230, 184, 0.018) 79px
    );
  pointer-events: none;
}

.auth-poster-copy {
  position: relative;
  z-index: 1;
  max-width: 760px;
  display: grid;
  gap: 18px;
  animation: authRise 520ms ease-out;
  padding-left: 18px;
}

.auth-poster-copy::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, transparent, rgba(215, 182, 123, 0.66) 16%, rgba(215, 182, 123, 0.12) 86%, transparent);
  box-shadow: 10px 0 0 -9px rgba(255, 231, 193, 0.08);
}

.auth-brand-lockup {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 22px;
  align-items: center;
}

.auth-mark-shell {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(224px, 20vw, 296px);
  aspect-ratio: 1;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 50%, rgba(222, 182, 104, 0.22), transparent 56%),
    radial-gradient(circle at 50% 50%, rgba(255, 238, 208, 0.08), transparent 72%),
    rgba(11, 10, 10, 0.44);
  box-shadow:
    inset 0 0 0 1px rgba(255, 226, 171, 0.08),
    0 18px 38px rgba(0, 0, 0, 0.32);
}

.auth-mark-shell::before,
.auth-mark-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.auth-mark-shell::before {
  inset: 8px;
  border: 1px solid rgba(215, 182, 123, 0.18);
}

.auth-mark-shell::after {
  inset: -14px;
  border: 1px solid rgba(215, 182, 123, 0.1);
  animation: orbitPulse 10s ease-in-out infinite;
}

.auth-mark {
  display: block;
  width: 82%;
  height: auto;
  filter:
    drop-shadow(0 0 20px rgba(215, 182, 123, 0.2))
    drop-shadow(0 12px 24px rgba(0, 0, 0, 0.26));
}

.auth-brand-meta {
  display: grid;
  gap: 6px;
  align-content: center;
  min-width: 0;
}

.auth-brand {
  margin: 0;
  font-family: "Baskerville", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(3.2rem, 7vw, 5.8rem);
  line-height: 0.94;
  letter-spacing: -0.03em;
  text-wrap: balance;
  color: #f0e2bf;
  text-shadow: 0 0 26px rgba(231, 190, 112, 0.08);
}

.auth-tagline {
  margin: 0;
  color: #d9c39b;
  font-size: 0.78rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.auth-orbit {
  position: absolute;
  border-radius: 999px;
  border: 1px solid rgba(199, 154, 75, 0.16);
  pointer-events: none;
}

.auth-orbit-a {
  width: min(54vw, 760px);
  height: min(54vw, 760px);
  left: -8vw;
  top: 10vh;
  box-shadow: inset 0 0 100px rgba(199, 154, 75, 0.08);
  animation: orbitDrift 18s linear infinite;
}

.auth-orbit-b {
  width: min(22vw, 300px);
  height: min(22vw, 300px);
  left: 32vw;
  top: 16vh;
  animation: orbitPulse 9s ease-in-out infinite;
}

.auth-panel {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
  padding: clamp(28px, 4vw, 48px);
  background:
    linear-gradient(180deg, rgba(12, 11, 13, 0.92), rgba(16, 12, 10, 0.96)),
    rgba(14, 12, 11, 0.94);
  border-left: 1px solid rgba(214, 188, 131, 0.08);
}

.auth-panel-inner {
  width: min(100%, 420px);
  margin: auto;
  display: grid;
  gap: 14px;
  animation: authRise 620ms ease-out;
  position: relative;
  padding-top: 18px;
}

.auth-panel-inner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 160px;
  height: 1px;
  background: linear-gradient(90deg, rgba(232, 205, 150, 0.7), rgba(232, 205, 150, 0.1), transparent);
}

.auth-panel-inner::after {
  content: "";
  position: absolute;
  right: 0;
  top: 8px;
  width: 110px;
  height: 110px;
  opacity: 0.18;
  border-radius: 999px;
  border: 1px solid rgba(215, 182, 123, 0.28);
  background:
    radial-gradient(circle, transparent 50%, rgba(215, 182, 123, 0.34) 50%, rgba(215, 182, 123, 0.34) 51%, transparent 51%),
    linear-gradient(180deg, transparent 0, transparent 30%, rgba(215, 182, 123, 0.24) 30%, rgba(215, 182, 123, 0.24) 31%, transparent 31%),
    linear-gradient(90deg, transparent 0, transparent 48%, rgba(215, 182, 123, 0.18) 48%, rgba(215, 182, 123, 0.18) 49%, transparent 49%);
  pointer-events: none;
}

.auth-panel-inner h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.7rem);
  line-height: 1;
  font-family: "Baskerville", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  color: #f0e2bf;
}

.auth-copy {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.65;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-label {
  font-size: 0.84rem;
  color: #f4e5c9;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  border: 1px solid rgba(199, 154, 75, 0.2);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(17, 15, 13, 0.96), rgba(12, 10, 8, 0.94)),
    rgba(12, 10, 8, 0.92);
  color: var(--text);
  padding: 14px 15px;
  font: inherit;
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 216, 0.04),
    inset 0 0 0 1px rgba(255, 219, 143, 0.02);
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
  outline: 2px solid rgba(214, 144, 64, 0.22);
  border-color: rgba(214, 144, 64, 0.44);
}

.remember-option {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  color: #d8c3a1;
  font-size: 0.92rem;
}

.remember-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.login-feedback {
  min-height: 1.25em;
  color: var(--muted);
  font-size: 0.88rem;
}

.workspace {
  animation: workspaceReveal 260ms ease-out;
}

.mobile-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 38px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  transition: grid-template-columns 180ms ease;
  position: relative;
}

.workspace.history-collapsed {
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100vh;
  min-height: 100vh;
  padding: 16px 12px 16px;
  background:
    linear-gradient(180deg, rgba(14, 14, 17, 0.98), rgba(17, 13, 11, 0.97)),
    repeating-linear-gradient(
      180deg,
      rgba(255, 214, 130, 0.012) 0,
      rgba(255, 214, 130, 0.012) 1px,
      transparent 1px,
      transparent 28px
    ),
    rgba(14, 11, 10, 0.97);
  border-right: 1px solid rgba(214, 188, 131, 0.06);
  box-shadow:
    inset -1px 0 0 rgba(255, 255, 255, 0.02),
    inset 0 0 0 1px rgba(255, 225, 174, 0.02);
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  transition: padding 180ms ease;
  position: relative;
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 10px 10px 10px 10px;
  border: 1px solid rgba(255, 222, 162, 0.04);
  pointer-events: none;
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  text-align: center;
  padding: 10px 10px 12px;
  margin-bottom: 8px;
  position: relative;
}

.sidebar-brand::after {
  content: "";
  width: 78%;
  height: 1px;
  margin-top: 4px;
  background: linear-gradient(90deg, transparent, rgba(215, 182, 123, 0.34), transparent);
}

.sidebar-brand-title {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 0;
  position: relative;
}

.sidebar-brand-title::before {
  content: "";
  position: absolute;
  inset: -16px;
  border-radius: 999px;
  background:
    radial-gradient(circle, rgba(215, 182, 123, 0.12), transparent 58%);
  opacity: 0.9;
  pointer-events: none;
}

.numidium-mark {
  display: block;
  width: 94px;
  height: auto;
  overflow: visible;
  filter:
    drop-shadow(0 0 24px rgba(215, 182, 123, 0.18))
    drop-shadow(0 14px 26px rgba(0, 0, 0, 0.26));
}

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

.sidebar-brand-subtitle {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  max-width: none;
  white-space: nowrap;
  padding-left: 0;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 0 4px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
}

.sidebar-controls::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(215, 182, 123, 0.28), transparent);
}

.new-chat-button {
  width: 100%;
  justify-content: flex-start;
  padding-block: 11px;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: "Baskerville", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

.chat-list-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  padding-top: 2px;
  overflow: hidden;
}

.chat-list {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 1px;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  padding-inline: 4px;
  padding-top: 8px;
}

.workspace.history-collapsed .sidebar {
  padding: 14px 8px;
}

.workspace.history-collapsed .sidebar-brand-subtitle,
.workspace.history-collapsed .sidebar-brand-title,
.workspace.history-collapsed .new-chat-button,
.workspace.history-collapsed .sidebar-controls,
.sidebar.history-collapsed .chat-list-wrap {
  display: none;
}

.chat-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 2px 0;
  background: transparent;
  color: var(--text);
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
  position: relative;
}

.chat-item:hover {
  border-color: rgba(199, 154, 75, 0.1);
  background: rgba(61, 45, 27, 0.18);
  transform: translateX(1px);
}

.chat-item.active {
  border-color: rgba(199, 154, 75, 0.24);
  background:
    linear-gradient(90deg, rgba(199, 154, 75, 0.18), rgba(199, 154, 75, 0.05) 40%, transparent 100%),
    rgba(57, 43, 28, 0.24);
  color: #f4e5c9;
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 216, 0.05),
    0 8px 18px rgba(0, 0, 0, 0.12);
}

.chat-item.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, rgba(215, 182, 123, 0.9), rgba(215, 182, 123, 0.18));
}

.chat-item-open {
  display: block;
  width: 100%;
  min-width: 0;
  text-align: left;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  box-shadow: none;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.3;
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  padding: 8px 9px;
}

.chat-item-open:hover {
  transform: none;
  box-shadow: none;
  background: rgba(58, 46, 36, 0.44);
}

.chat-item-delete {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: none;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  background: transparent;
  color: #d7c2a3;
  box-shadow: none;
  opacity: 0.78;
  pointer-events: auto;
  transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
}

.chat-item-delete:hover {
  transform: none;
  box-shadow: none;
  background: rgba(214, 144, 64, 0.12);
  color: #f2e4ce;
  opacity: 1;
}

.conversation-panel {
  position: relative;
  min-width: 0;
  height: 100vh;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    radial-gradient(circle at 16% 104%, rgba(233, 186, 88, 0.14), transparent 24%),
    radial-gradient(circle at 82% 10%, rgba(64, 82, 110, 0.12), transparent 22%),
    linear-gradient(180deg, rgba(14, 14, 18, 0.97), rgba(20, 16, 14, 0.92)),
    rgba(19, 15, 13, 0.92);
  overflow: hidden;
}

.conversation-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 242, 214, 0.018), transparent 26%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 20%);
  pointer-events: none;
}

.header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px clamp(24px, 4vw, 42px) 16px;
  background:
    linear-gradient(180deg, rgba(15, 14, 17, 0.94), rgba(18, 14, 12, 0.84) 72%, transparent);
  border-bottom: 1px solid rgba(214, 188, 131, 0.06);
  backdrop-filter: blur(14px);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.header-main > div {
  display: grid;
  gap: 2px;
}

.title {
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #efe2c0;
  font-family: "Baskerville", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  text-transform: uppercase;
  opacity: 0.94;
}

.subtitle {
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 12px;
  border: 1px solid rgba(199, 154, 75, 0.16);
  background:
    linear-gradient(180deg, rgba(35, 29, 24, 0.82), rgba(22, 19, 17, 0.72)),
    rgba(28, 22, 19, 0.54);
}

.account-pill-label {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.account-pill-name {
  color: #f4e5c9;
  font-size: 0.83rem;
  font-weight: 600;
}

.logout-button {
  width: auto;
  padding-inline: 14px;
}

.chat {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 26px;
  height: 100%;
  width: min(var(--chat-column-width), calc(100% - clamp(48px, 7vw, 120px)));
  margin: 0 auto;
  padding: 40px clamp(8px, 1.4vw, 18px) 216px;
  background: transparent;
  box-shadow: none;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
}

.chat > * {
  position: relative;
  z-index: 1;
}

.chat::before {
  content: "";
  position: absolute;
  left: clamp(4px, 1vw, 12px);
  top: 0;
  bottom: 170px;
  width: 1px;
  background: linear-gradient(180deg, rgba(199, 154, 75, 0.28), rgba(199, 154, 75, 0.05) 40%, transparent 100%);
  pointer-events: none;
}

.chat::after {
  content: "";
  position: absolute;
  left: clamp(18px, 1.8vw, 28px);
  right: clamp(30px, 4vw, 58px);
  top: 20px;
  bottom: 176px;
  border: 1px solid rgba(215, 182, 123, 0.08);
  border-radius: 18px 18px 22px 18px;
  background:
    linear-gradient(180deg, rgba(255, 238, 203, 0.02), transparent 18%),
    linear-gradient(180deg, rgba(21, 18, 17, 0.52), rgba(14, 13, 15, 0.18) 26%, transparent 72%);
  box-shadow:
    inset 0 1px 0 rgba(255, 241, 215, 0.04),
    inset 0 0 0 1px rgba(255, 234, 188, 0.015);
  pointer-events: none;
}

.message {
  line-height: 1.72;
  white-space: normal;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  animation: rise 180ms ease-out;
  font-size: 1rem;
  color: #e5d9bc;
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.16);
}

.chat > .message.message-active-citation {
  z-index: 20;
}

.message.user {
  width: fit-content;
  max-width: min(42ch, 54%);
  align-self: flex-end;
  margin-right: clamp(22px, 3.4vw, 42px);
  margin-top: 8px;
  padding: 14px 18px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(54, 42, 27, 0.94), rgba(30, 23, 16, 0.94)),
    rgba(14, 12, 11, 0.94);
  border: 1px solid rgba(199, 154, 75, 0.22);
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 216, 0.08),
    0 14px 34px rgba(0, 0, 0, 0.28);
}

.message.assistant {
  align-self: flex-start;
  width: min(100%, 90ch);
  padding: 0 0 0 28px;
  background: transparent;
  border: none;
  position: relative;
}

.message.assistant > * {
  position: relative;
  z-index: 1;
}

.message.assistant > *.message-active-citation-block,
.message.user > *.message-active-citation-block,
.message.system > *.message-active-citation-block {
  z-index: 25;
}

.message.assistant::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 0.3rem;
  bottom: 0.3rem;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(199, 154, 75, 0.9), rgba(199, 154, 75, 0.1));
}

.message.system {
  align-self: center;
  width: fit-content;
  max-width: min(100%, 620px);
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(51, 42, 30, 0.24);
  border: 1px solid rgba(214, 188, 131, 0.08);
  color: var(--muted);
  text-align: center;
}

.message p {
  margin: 0 0 0.9em;
  max-width: 72ch;
}

.message p:last-child {
  margin-bottom: 0;
}

.message h1,
.message h2,
.message h3,
.message h4,
.message h5,
.message h6 {
  margin: 0.8em 0 0.4em;
  font-weight: 700;
  line-height: 1.22;
  font-family: "Baskerville", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

.message h1 { font-size: 1.25rem; }
.message h2 { font-size: 1.15rem; }
.message h3 { font-size: 1.05rem; }
.message h4,
.message h5,
.message h6 { font-size: 1rem; }

.message ul,
.message ol {
  margin: 0.4em 0 0.6em 1.2em;
  padding: 0;
}

.message li {
  margin: 0.28em 0;
}

.message blockquote {
  margin: 0.6em 0;
  padding-left: 0.75em;
  border-left: 3px solid rgba(214, 144, 64, 0.45);
  color: var(--muted);
}

.message code {
  font-family: "JetBrainsMono Nerd Font", "JetBrains Mono", monospace;
  font-size: 0.9em;
  background: rgba(255, 243, 217, 0.05);
  padding: 0.12em 0.36em;
  border-radius: 6px;
}

.message pre {
  background:
    linear-gradient(180deg, rgba(24, 19, 16, 0.92), rgba(15, 13, 14, 0.88)),
    rgba(18, 14, 12, 0.8);
  border: 1px solid rgba(199, 154, 75, 0.16);
  padding: 14px 15px;
  border-radius: 12px;
  overflow-x: auto;
}

.message pre code {
  background: transparent;
  padding: 0;
  font-size: 0.9em;
}

.message a {
  color: var(--link);
  text-decoration: none;
}

.message a:hover {
  text-decoration: underline;
}

.message .tex-placeholder {
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
}

.message .tex-placeholder.tex-block {
  display: block;
  margin: 0.75em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.2em 0;
}

.message .katex-display {
  margin: 0.75em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.1em;
}

.citation-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.35em;
  vertical-align: middle;
  cursor: pointer;
  outline: none;
  line-height: 1;
}

.citation-chip.citation-chip-active {
  z-index: 90;
}

.citation-chip-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  max-width: min(280px, 42vw);
  padding: 0.18rem 0.52rem;
  border-radius: 10px;
  background: rgba(238, 225, 196, 0.94);
  color: #2f2418;
  font-size: 0.72rem;
  line-height: 1.25;
  font-weight: 600;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.citation-chip:hover .citation-chip-label,
.citation-chip:focus-visible .citation-chip-label,
.citation-chip.citation-chip-active .citation-chip-label {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
  background: rgba(244, 232, 205, 0.98);
}

.citation-chip-extra {
  color: #5a4734;
  font-weight: 700;
  font-size: 0.7rem;
}

.citation-card {
  position: fixed;
  left: var(--citation-card-left, 12px);
  top: var(--citation-card-top, 12px);
  min-width: 360px;
  max-width: min(560px, 78vw);
  border-radius: 10px;
  overflow: hidden;
  background: var(--tooltip-bg);
  border: 1px solid var(--surface-border);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.35;
  white-space: normal;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.46);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 80;
}

.citation-card-top {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2rem;
  padding: 0.3rem 0.45rem;
  background: var(--tooltip-top);
}

.citation-nav {
  min-width: 1.55rem;
  min-height: 1.55rem;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  color: #f0e3c7;
  box-shadow: none;
  font-size: 0.95rem;
  line-height: 1;
  display: none;
}

.citation-nav:hover {
  transform: none;
  box-shadow: none;
  background: rgba(214, 144, 64, 0.2);
}

.citation-card-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.82rem;
}

.citation-card-body {
  display: block;
  padding: 0.68rem 0.85rem 0.82rem;
}

.citation-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
}

.citation-card-heading-copy {
  display: block;
  min-width: 0;
  flex: 1 1 auto;
}

.citation-card-title {
  display: block;
  font-weight: 600;
  color: #f4e5c9;
  margin-bottom: 0.35rem;
}

.citation-card-detail {
  display: block;
  color: var(--text);
  line-height: 1.35;
  font-size: 0.94rem;
}

.citation-card-open-source {
  flex: 0 0 auto;
  min-height: 1.95rem;
  padding: 0.34rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(211, 164, 82, 0.28);
  background: rgba(66, 50, 33, 0.78);
  color: #f3e4c3;
  box-shadow: none;
  font-size: 0.74rem;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.citation-card-open-source:hover {
  transform: none;
  box-shadow: none;
  background: rgba(92, 67, 38, 0.92);
  border-color: rgba(220, 177, 97, 0.42);
}

.citation-card-open-source:focus-visible {
  outline: 2px solid rgba(225, 183, 99, 0.68);
  outline-offset: 2px;
}

.citation-card-excerpt {
  display: block;
  margin-top: 0.42rem;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.86rem;
}

.citation-card-preview-status {
  display: block;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.citation-card-preview-link {
  display: block;
  margin-top: 0.72rem;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.citation-card-preview-link:hover {
  text-decoration: none;
}

.citation-card-preview-image {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(11, 9, 8, 0.86);
  border: 1px solid rgba(199, 154, 75, 0.14);
}

.citation-card-preview-label {
  display: block;
  margin-top: 0.48rem;
  color: #f4e5c9;
  font-size: 0.82rem;
}

.citation-card-preview-meta {
  display: block;
  margin-top: 0.22rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.citation-chip:hover .citation-card,
.citation-chip.citation-chip-active .citation-card,
.citation-chip:focus-visible .citation-card,
.citation-chip:focus-within .citation-card {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.citation-chip[data-citation-ready="0"] .citation-card {
  display: none;
}

@media (max-width: 640px) {
  .citation-card-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .citation-card-open-source {
    align-self: flex-start;
  }
}

.citation-chip[data-citation-multi="1"] .citation-nav {
  display: inline-flex;
}

.sources-block {
  margin-top: 1.05em;
  border: 1px solid rgba(199, 154, 75, 0.16);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(29, 24, 20, 0.58), rgba(17, 15, 14, 0.42)),
    rgba(25, 20, 17, 0.42);
  overflow: hidden;
}

.sources-block > summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
}

.sources-block > summary::-webkit-details-marker {
  display: none;
}

.sources-block > summary::before {
  content: ">";
  display: inline-block;
  margin-right: 8px;
  transform: rotate(0deg);
  transition: transform 120ms ease;
}

.sources-block[open] > summary::before {
  transform: rotate(90deg);
}

.sources-content {
  padding: 0 14px 14px;
  border-top: 1px solid rgba(214, 144, 64, 0.12);
}

.message-attachments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 280px));
  gap: 14px;
  margin-top: 1rem;
}

.message-attachment-card {
  margin: 0;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(25, 20, 17, 0.74);
  border: 1px solid var(--surface-border);
  box-shadow: 0 16px 30px rgba(8, 6, 5, 0.28);
}

.message-attachment-link {
  display: block;
  background: rgba(11, 9, 8, 0.86);
}

.message-attachment-file-link {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.message-attachment-link:hover {
  text-decoration: none;
}

.message-attachment-image {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: rgba(11, 9, 8, 0.86);
}

.message-attachment-caption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 12px;
}

.message-attachment-card-file .message-attachment-caption {
  padding: 0;
}

.message-attachment-file-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 0.34rem 0.6rem;
  border-radius: 999px;
  background: rgba(214, 144, 64, 0.14);
  border: 1px solid rgba(214, 144, 64, 0.2);
  color: #f4e5c9;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.message-attachment-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: #f4e5c9;
  line-height: 1.35;
}

.message-attachment-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.composer {
  width: min(var(--composer-width), calc(100% - clamp(48px, 7vw, 120px)));
  margin: 0 auto 28px;
  background:
    linear-gradient(180deg, rgba(45, 35, 23, 0.96), rgba(24, 20, 18, 0.97)),
    rgba(37, 30, 25, 0.96);
  border: 1px solid rgba(199, 154, 75, 0.2);
  border-radius: 14px;
  box-shadow: 0 24px 46px rgba(8, 6, 5, 0.44);
  position: sticky;
  bottom: 26px;
  z-index: 25;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
  overflow: hidden;
}

.composer-main {
  display: grid;
  gap: 12px;
  padding: 16px 18px 16px 20px;
}

.composer-input-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: end;
}

.composer.is-dragover {
  border-color: rgba(214, 144, 64, 0.48);
  box-shadow: 0 30px 58px rgba(8, 6, 5, 0.56);
}

.composer.is-dragover .composer-drop-hint {
  opacity: 1;
  transform: translateY(0);
}

.composer-upload-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  position: relative;
  z-index: 1;
}

.composer-upload-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(18, 15, 13, 0.8);
  border: 1px solid rgba(199, 154, 75, 0.16);
}

.composer-upload-item[data-state="error"] {
  border-color: rgba(212, 115, 91, 0.34);
}

.composer-upload-preview {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(11, 9, 8, 0.92);
  border: 1px solid rgba(199, 154, 75, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e4c591;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.composer-upload-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.composer-upload-body {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.composer-upload-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #f4e5c9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-upload-meta,
.composer-upload-status {
  font-size: 0.78rem;
  color: var(--muted);
}

.composer-upload-status[data-state="error"] {
  color: #efb3a5;
}

.composer-upload-remove {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  border-radius: 10px;
  font-size: 1.05rem;
}

.composer-attach {
  width: 46px;
  height: 46px;
  min-width: 46px;
  padding: 0;
  border-radius: 12px;
  font-size: 1.4rem;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.composer-drop-hint {
  position: absolute;
  inset: auto 18px 12px 20px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(214, 144, 64, 0.14);
  border: 1px solid rgba(214, 144, 64, 0.24);
  color: #f4e5c9;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 120ms ease, transform 120ms ease;
  pointer-events: none;
  z-index: 1;
}

.composer::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(244, 223, 183, 0.22), transparent);
  pointer-events: none;
}

.composer::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 226, 171, 0.04);
  pointer-events: none;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
}

.composer:focus-within {
  border-color: rgba(199, 154, 75, 0.34);
  box-shadow: 0 28px 52px rgba(8, 6, 5, 0.5);
  transform: translateY(-1px);
}

#input {
  resize: none;
  width: 100%;
  min-width: 0;
  min-height: calc(1.5em + 2px);
  max-height: 240px;
  overflow-y: hidden;
  display: block;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 1.02rem;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  line-height: 1.6;
  position: relative;
  z-index: 1;
}

#send {
  align-self: end;
  width: 50px;
  height: 50px;
  min-width: 50px;
  padding: 0;
  border-radius: 12px;
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255, 246, 222, 0.18),
    0 10px 22px rgba(113, 79, 24, 0.36);
  position: relative;
  z-index: 1;
}

button {
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, #d0a55a, #8b6429),
    linear-gradient(135deg, #d69040, #c07a32);
  color: var(--on-accent);
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 246, 222, 0.16),
    0 12px 30px rgba(110, 79, 26, 0.32);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  font-family: "Baskerville", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

button.secondary {
  background:
    linear-gradient(180deg, rgba(54, 43, 30, 0.84), rgba(31, 26, 23, 0.82)),
    rgba(108, 74, 48, 0.34);
  color: var(--text);
  box-shadow: none;
  border: 1px solid rgba(199, 154, 75, 0.12);
}

button.secondary:hover {
  box-shadow: none;
  background: rgba(108, 74, 48, 0.5);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(192, 122, 50, 0.44);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.api-key-modal {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(214, 144, 64, 0.1), transparent 42%),
    rgba(10, 8, 7, 0.76);
  backdrop-filter: blur(10px);
}

.api-key-modal[hidden] {
  display: none;
}

.api-key-dialog {
  width: min(100%, 460px);
  padding: 26px 24px 24px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(34, 27, 23, 0.98), rgba(24, 19, 16, 0.98)),
    rgba(24, 19, 16, 0.98);
  border: 1px solid rgba(214, 144, 64, 0.24);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.48);
}

.api-key-eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  background: rgba(214, 144, 64, 0.14);
  color: #f4e5c9;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.api-key-dialog h2 {
  margin: 14px 0 10px;
  font-size: 1.4rem;
  line-height: 1.15;
}

.api-key-copy {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.api-key-form {
  display: grid;
  gap: 12px;
}

.api-key-label {
  font-size: 0.88rem;
  color: #f4e5c9;
  font-weight: 600;
}

.api-key-form input {
  width: 100%;
  border: 1px solid rgba(214, 144, 64, 0.2);
  border-radius: 14px;
  background: rgba(12, 10, 8, 0.84);
  color: var(--text);
  padding: 13px 14px;
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.api-key-form input:focus {
  outline: 2px solid rgba(214, 144, 64, 0.22);
  border-color: rgba(214, 144, 64, 0.4);
}

.api-key-feedback {
  min-height: 1.2em;
  font-size: 0.86rem;
  color: var(--muted);
}

.source-viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    radial-gradient(circle at 16% 16%, rgba(214, 144, 64, 0.12), transparent 28%),
    radial-gradient(circle at 84% 8%, rgba(74, 92, 118, 0.18), transparent 24%),
    rgba(7, 6, 7, 0.84);
  backdrop-filter: blur(14px);
}

.source-viewer-modal[hidden] {
  display: none;
}

.source-viewer-dialog {
  width: min(1280px, 100%);
  max-height: min(92vh, 980px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  padding: 22px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(28, 23, 20, 0.98), rgba(16, 14, 14, 0.98)),
    rgba(18, 15, 14, 0.98);
  border: 1px solid rgba(214, 144, 64, 0.2);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.56);
  overflow: hidden;
}

.source-viewer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.source-viewer-header-copy {
  min-width: 0;
}

.source-viewer-eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.58rem;
  border-radius: 999px;
  background: rgba(214, 144, 64, 0.14);
  color: #f4e5c9;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-viewer-header h2 {
  margin: 12px 0 6px;
  font-size: clamp(1.55rem, 2.8vw, 2.4rem);
  line-height: 1.02;
  color: #f1e3c1;
}

.source-viewer-subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  max-width: 78ch;
}

.source-viewer-close {
  width: auto;
  flex: 0 0 auto;
  padding-inline: 16px;
}

.source-viewer-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 18px;
}

.source-viewer-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
}

.source-viewer-nav {
  align-self: center;
  width: 50px;
  height: 50px;
  min-width: 50px;
  padding: 0;
  border-radius: 999px;
  font-size: 1.25rem;
}

.source-viewer-frame {
  position: relative;
  min-width: 0;
  min-height: 480px;
  display: grid;
  place-items: center;
  padding: clamp(14px, 2vw, 24px);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(18, 16, 16, 0.98), rgba(10, 10, 11, 0.94)),
    rgba(14, 12, 12, 0.94);
  border: 1px solid rgba(214, 144, 64, 0.12);
  overflow: hidden;
}

.source-viewer-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 240, 208, 0.02), transparent 18%),
    radial-gradient(circle at 50% 0%, rgba(214, 144, 64, 0.08), transparent 32%);
  pointer-events: none;
}

.source-viewer-loading,
.source-viewer-stage-copy,
.source-viewer-empty {
  padding: 24px;
  line-height: 1.5;
}

.source-viewer-loading,
.source-viewer-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.source-viewer-loading {
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.source-viewer-loading[hidden],
.source-viewer-image[hidden],
.source-viewer-embed[hidden],
.source-viewer-stage-copy[hidden],
.source-viewer-empty[hidden],
.source-viewer-image-link[hidden] {
  display: none !important;
}

.source-viewer-image {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 100%;
  max-height: min(72vh, 760px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 16px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.34),
    0 0 0 1px rgba(255, 234, 188, 0.08);
  background: rgba(5, 5, 6, 0.88);
}

.source-viewer-embed {
  position: relative;
  z-index: 1;
  width: 100%;
  height: min(76vh, 820px);
  border: 0;
  border-radius: 18px;
  background: rgba(5, 5, 6, 0.88);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.34),
    0 0 0 1px rgba(255, 234, 188, 0.08);
}

.source-viewer-stage-copy {
  position: relative;
  z-index: 1;
  align-self: stretch;
  justify-self: center;
  width: min(100%, 72ch);
  overflow: auto;
  color: var(--text);
  line-height: 1.74;
  white-space: pre-wrap;
  font-size: 1rem;
  text-wrap: pretty;
}

.source-viewer-rail {
  min-width: 0;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(33, 27, 23, 0.78), rgba(18, 16, 16, 0.74)),
    rgba(24, 19, 17, 0.72);
  border: 1px solid rgba(214, 144, 64, 0.12);
  overflow: auto;
}

.source-viewer-page-meta {
  color: #f4e5c9;
  font-size: 0.92rem;
  font-weight: 600;
}

.source-viewer-image-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.46rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(214, 144, 64, 0.18);
  background: rgba(214, 144, 64, 0.08);
  color: #f1e1bf;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease;
}

.source-viewer-image-link:hover {
  text-decoration: none;
  background: rgba(214, 144, 64, 0.14);
  border-color: rgba(214, 144, 64, 0.28);
}

.source-viewer-status {
  min-height: 1.25em;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.source-viewer-excerpt {
  display: grid;
  gap: 10px;
}

.source-viewer-excerpt-label {
  color: #f4e5c9;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-viewer-excerpt-copy {
  color: var(--text);
  line-height: 1.62;
  white-space: pre-wrap;
  font-size: 0.95rem;
}

.source-viewer-modal[data-reader-mode="text"] .source-viewer-frame {
  place-items: stretch;
}

.source-viewer-modal[data-reader-mode="text"] .source-viewer-excerpt {
  display: none;
}

.source-viewer-modal[data-reader-mode="document"] .source-viewer-frame {
  place-items: stretch;
}

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

@keyframes orbitDrift {
  from {
    transform: rotate(0deg) scale(1);
  }
  to {
    transform: rotate(360deg) scale(1.03);
  }
}

@keyframes orbitPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.52;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.9;
  }
}

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

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

@media (max-width: 720px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.app-authenticated {
    overflow: hidden;
  }

  body.mobile-sidebar-open {
    overflow: hidden;
  }

  .app {
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    padding: 10px;
    height: auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    min-height: calc(100dvh - 20px);
    border-radius: 24px;
    overflow: hidden;
  }

  .auth-poster {
    min-height: auto;
    padding: 24px 18px 28px;
    align-items: flex-start;
  }

  .auth-brand-lockup {
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: flex-start;
  }

  .auth-mark-shell {
    width: 168px;
  }

  .auth-brand {
    font-size: clamp(2.5rem, 14vw, 4rem);
  }

  .auth-tagline {
    font-size: 0.7rem;
    letter-spacing: 0.18em;
  }

  .auth-panel {
    min-height: auto;
    padding: 22px 18px 24px;
  }

  .auth-panel-inner {
    width: 100%;
  }

  .auth-panel-inner::before,
  .auth-panel-inner::after,
  .conversation-panel::after {
    display: none;
  }

  .numidium-mark {
    width: 54px;
  }

  .header {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 10px 12px;
    gap: 10px;
    flex-direction: row;
    align-items: center;
  }

  .header-main {
    min-width: 0;
    flex: 1 1 auto;
  }

  .header-actions {
    gap: 8px;
    flex: 0 0 auto;
  }

  .mobile-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
  }

  .title {
    font-size: 1.22rem;
  }

  .subtitle {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .account-pill {
    display: none;
  }

  .logout-button {
    padding-inline: 12px;
  }

  .workspace {
    width: 100%;
    max-width: 100%;
    display: block;
    height: auto;
    min-height: 100dvh;
    transition: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 320px);
    max-width: 320px;
    margin: 0;
    border-radius: 0 14px 14px 0;
    z-index: 80;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    padding: 12px;
  }

  .sidebar-brand {
    padding-top: 4px;
  }

  body.mobile-sidebar-open .sidebar {
    transform: translateX(0);
  }

  .workspace.history-collapsed .sidebar {
    padding: 12px;
  }

  .workspace.history-collapsed .new-chat-button,
  .sidebar.history-collapsed .chat-list-wrap {
    display: block;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(6, 5, 4, 0.54);
  }

  body.mobile-sidebar-open .sidebar-backdrop {
    display: block;
  }

  .chat-list {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: 2px;
  }

  .chat-item {
    min-width: 0;
  }

  .chat-item-open,
  .chat-item-delete {
    width: auto;
  }

  .conversation-panel {
    height: auto;
    min-height: 100dvh;
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .chat {
    width: 100%;
    max-width: 100%;
    margin: 0;
    overflow-x: hidden;
    min-height: 0;
    max-height: none;
    padding: 22px 12px 144px;
    border-radius: 0;
    box-shadow: none;
  }

  .chat::before {
    display: none;
  }

  .message {
    width: 100%;
    max-width: 100%;
    padding: 11px 12px;
  }

  .message.user {
    max-width: 88%;
  }

  .message.assistant {
    width: 100%;
    padding: 0 0 0 14px;
  }

  .message.system {
    max-width: calc(100% - 16px);
  }

  .message pre {
    max-width: 100%;
    overflow-x: auto;
  }

  .message-attachments {
    grid-template-columns: 1fr;
  }

  .citation-card {
    min-width: min(280px, calc(100vw - 52px));
    max-width: calc(100vw - 52px);
  }

  .source-viewer-modal {
    padding: 10px;
  }

  .source-viewer-dialog {
    max-height: calc(100dvh - 20px);
    padding: 14px;
    border-radius: 22px;
    gap: 14px;
  }

  .source-viewer-header {
    gap: 12px;
    align-items: center;
  }

  .source-viewer-body {
    grid-template-columns: 1fr;
  }

  .source-viewer-stage {
    grid-template-columns: minmax(0, 1fr);
  }

  .source-viewer-nav {
    position: absolute;
    z-index: 2;
    bottom: 14px;
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  #source-viewer-prev {
    left: 14px;
  }

  #source-viewer-next {
    right: 14px;
  }

  .source-viewer-frame {
    min-height: 320px;
    padding: 14px;
  }

  .source-viewer-image {
    max-height: min(58vh, 520px);
  }

  .source-viewer-rail {
    padding: 14px;
    border-radius: 18px;
  }

  .composer {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 50;
    margin: 0;
    border-radius: 18px;
  }

  .composer-main {
    gap: 10px;
    padding: 10px 12px;
  }

  .composer-input-row {
    gap: 8px;
  }

  .composer-upload-list {
    grid-template-columns: 1fr;
  }

  .composer-upload-item {
    grid-template-columns: 56px 1fr auto;
  }

  .composer-upload-preview {
    width: 56px;
    height: 56px;
  }

  #input {
    min-height: 42px;
    max-height: 124px;
  }

  .composer-attach,
  #send {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    align-self: end;
    font-size: 1.3rem;
  }

  button {
    width: 100%;
  }

  .logout-button {
    width: auto;
  }

  .composer button,
  .chat-item-open,
  .chat-item-delete,
  .mobile-sidebar-toggle {
    width: auto;
  }

  .api-key-modal {
    padding: 14px;
  }

  .api-key-dialog {
    padding: 22px 18px 18px;
    border-radius: 18px;
  }

  .source-viewer-close,
  .source-viewer-image-link {
    width: auto;
  }
}
