:root {
  color-scheme: light;
  --ink: #1f2927;
  --ink-soft: #5e6863;
  --paper: #f5f2ea;
  --paper-deep: #ece7dc;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --line: #dcd6ca;
  --line-soft: #e9e4da;
  --forest: #183f36;
  --forest-2: #245b4e;
  --sage: #dbe6dc;
  --gold: #b58a42;
  --gold-soft: #eee1c8;
  --wine: #713f42;
  --danger: #9e3d3d;
  --shadow: 0 18px 55px rgba(35, 43, 39, 0.14);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

body,
button,
input,
textarea,
select {
  font: inherit;
}

button,
input,
textarea,
select {
  color: inherit;
}

button {
  border: 0;
}

button:not(:disabled),
label,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(181, 138, 66, 0.34);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 76px minmax(270px, 330px) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  background:
    radial-gradient(circle at 85% -20%, rgba(218, 225, 213, 0.62), transparent 42%),
    var(--paper);
}

.rail {
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  padding: 22px 10px 18px;
  background: var(--forest);
  color: white;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(238, 225, 200, 0.72);
  border-radius: 50%;
  background: transparent;
  color: #f5e8cd;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  letter-spacing: 0.08em;
}

.brand-mark span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(238, 225, 200, 0.32);
  border-radius: 50%;
}

.rail-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  margin-top: 38px;
}

.rail-button,
.profile-button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 55px;
  border-radius: 13px;
  background: transparent;
  color: rgba(255, 255, 255, 0.58);
  transition: 160ms ease;
}

.rail-button:hover,
.rail-button.is-active {
  background: rgba(255, 255, 255, 0.09);
  color: white;
}

.rail-button.is-active::before {
  position: absolute;
  left: -10px;
  width: 3px;
  height: 27px;
  border-radius: 0 4px 4px 0;
  background: #dbc291;
  content: "";
}

.rail-glyph {
  font-family: Georgia, serif;
  font-size: 27px;
  line-height: 1;
}

.rail-glyph-memory {
  font-size: 22px;
}

.rail-label {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.03em;
}

.profile-button {
  width: 56px;
  min-height: 56px;
}

.profile-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: #315e52;
  color: #f4ead8;
  font-size: 11px;
  font-weight: 700;
}

.conversation-sidebar {
  z-index: 3;
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(248, 246, 240, 0.92);
  backdrop-filter: blur(18px);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 27px 25px 12px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.sidebar-header h1,
.workspace-header h2,
.drawer-header h2,
.modal-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.sidebar-header h1 {
  font-size: 25px;
}

.connection-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 25px 20px;
  color: var(--ink-soft);
  font-size: 11px;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c29652;
  box-shadow: 0 0 0 4px rgba(194, 150, 82, 0.12);
}

.connection-dot.is-online {
  background: #4d8f70;
  box-shadow: 0 0 0 4px rgba(77, 143, 112, 0.12);
}

.connection-dot.is-demo {
  background: #b17c4a;
}

.new-council-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  margin: 0 20px 24px;
  border: 1px solid rgba(24, 63, 54, 0.22);
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--forest);
  font-size: 13px;
  font-weight: 750;
  box-shadow: 0 5px 16px rgba(31, 41, 39, 0.05);
  transition: 150ms ease;
}

.new-council-button:hover {
  border-color: var(--forest-2);
  background: #fdfbf6;
  transform: translateY(-1px);
}

.plus-mark {
  font-size: 20px;
  font-weight: 300;
  line-height: 1;
}

.sidebar-scroll,
.workspace-scroll,
.drawer-body,
.modal-body {
  min-height: 0;
  overflow: auto;
  scrollbar-color: #c6c0b5 transparent;
  scrollbar-width: thin;
}

.sidebar-scroll {
  flex: 1;
  padding: 0 12px;
}

.conversation-section + .conversation-section {
  margin-top: 28px;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 9px;
}

.section-heading-row h2,
.section-heading-row span {
  margin: 0;
  color: #858a84;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.room-list {
  display: grid;
  gap: 4px;
}

.room-item {
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  padding: 8px 10px;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  transition: 140ms ease;
}

.room-item:hover {
  background: rgba(255, 255, 255, 0.62);
}

.room-item.is-active {
  background: var(--surface-strong);
  box-shadow: 0 4px 18px rgba(31, 41, 39, 0.07);
}

.avatar {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  color: white;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  letter-spacing: 0.05em;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.12);
}

.avatar-napoleon {
  background: linear-gradient(145deg, #334b4b, #142d2c);
}

.avatar-machiavelli {
  background: linear-gradient(145deg, #875d52, #503437);
}

.avatar-council {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--forest) 50%, var(--wine) 50%);
  font-size: 10px;
}

.avatar-small {
  width: 32px;
  height: 32px;
  font-size: 9px;
}

.room-copy {
  min-width: 0;
}

.room-copy strong,
.room-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-copy strong {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 750;
}

.room-copy span {
  color: var(--ink-soft);
  font-size: 11px;
}

.room-meta {
  align-self: start;
  padding-top: 5px;
  color: #999b95;
  font-size: 9px;
}

.sidebar-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 14px 20px 20px;
  padding: 13px;
  border: 1px solid #e0d7c6;
  border-radius: 12px;
  background: #f0e9dc;
}

.sidebar-note p {
  margin: 0;
  color: #68675f;
  font-size: 10px;
  line-height: 1.45;
}

.sidebar-note strong {
  color: var(--ink);
  font-size: 10.5px;
}

.note-seal {
  display: grid;
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: #956f33;
  font-family: Georgia, serif;
  font-size: 12px;
  font-style: italic;
}

.main-panel {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.chat-view,
.workspace-view {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex-direction: column;
}

.chat-header {
  z-index: 2;
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px clamp(18px, 3vw, 38px);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(250, 248, 243, 0.77);
  backdrop-filter: blur(16px);
}

.chat-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.chat-identity-copy {
  min-width: 0;
}

.chat-identity-copy h2 {
  overflow: hidden;
  margin: 0 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity-subline {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 10px;
}

.reconstruction-badge {
  padding: 2px 6px;
  border: 1px solid #d5cbb9;
  border-radius: 20px;
  color: #826a42;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 38px;
  padding: 0 15px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 750;
  transition: 150ms ease;
}

.primary-button {
  background: var(--forest);
  color: white;
  box-shadow: 0 5px 15px rgba(24, 63, 54, 0.14);
}

.primary-button:hover {
  background: var(--forest-2);
  transform: translateY(-1px);
}

.secondary-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.secondary-button:hover {
  border-color: #bbb4a7;
  background: white;
}

.danger-button {
  border: 1px solid rgba(158, 61, 61, 0.35);
  background: #fffafa;
  color: var(--danger);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 20px;
}

.icon-button:hover {
  background: rgba(31, 41, 39, 0.06);
  color: var(--ink);
}

.back-button,
.mobile-only {
  display: none;
}

.demo-banner {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px clamp(18px, 3vw, 38px);
  border-bottom: 1px solid #dfcfb2;
  background: #f1e7d4;
  color: #705b39;
  font-size: 11px;
}

.demo-banner button {
  margin-left: auto;
  background: transparent;
  color: inherit;
  font-size: 18px;
}

.message-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.message-feed {
  width: min(100%, 900px);
  min-height: 100%;
  margin: 0 auto;
  padding: 34px clamp(20px, 4vw, 55px) 16px;
}

.conversation-intro {
  display: grid;
  justify-items: center;
  max-width: 590px;
  margin: 22px auto 40px;
  text-align: center;
}

.intro-avatar {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  border-radius: 50%;
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.62), 0 8px 22px rgba(31, 41, 39, 0.12);
}

.conversation-intro h3 {
  margin: 0 0 7px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 500;
}

.conversation-intro p {
  max-width: 510px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

.intro-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
}

.intro-pills span,
.topic-pill {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: #636a65;
  font-size: 9px;
  letter-spacing: 0.025em;
}

.date-divider {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 28px 0;
  color: #9a9d96;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.date-divider::before,
.date-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line-soft);
  content: "";
}

.message-row {
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr);
  gap: 10px;
  max-width: 780px;
  margin: 0 auto 25px;
}

.message-row.is-user {
  display: flex;
  justify-content: flex-end;
}

.message-row.is-system {
  display: block;
  max-width: 650px;
  margin: 27px auto;
}

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

.message-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin: 0 0 7px 2px;
}

.message-meta strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 600;
}

.message-meta time {
  color: #999c96;
  font-size: 9px;
}

.message-bubble {
  position: relative;
  display: inline-block;
  max-width: min(630px, 100%);
  padding: 13px 15px;
  border: 1px solid var(--line-soft);
  border-radius: 4px 15px 15px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 4px 14px rgba(31, 41, 39, 0.035);
}

.is-user .message-bubble {
  border-color: var(--forest);
  border-radius: 15px 15px 4px 15px;
  background: var(--forest);
  color: white;
}

.message-bubble p {
  margin: 0;
  font-size: 13px;
  line-height: 1.58;
}

.message-bubble.is-streaming p::after {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  background: var(--gold);
  content: "";
  vertical-align: -2px;
  animation: blink 750ms steps(1) infinite;
}

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

.reply-reference {
  display: block;
  margin-bottom: 9px;
  padding-left: 9px;
  border-left: 2px solid var(--gold);
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.4;
}

.is-user .reply-reference {
  color: rgba(255, 255, 255, 0.68);
}

.message-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  margin-top: 7px;
}

.grounding-pill {
  padding: 4px 7px;
  border-radius: 20px;
  background: var(--gold-soft);
  color: #715b36;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.grounding-pill.inference { background: #e6e5db; color: #5e625b; }
.grounding-pill.simulation { background: #efe1e0; color: #734a4d; }
.grounding-pill.mixed { background: #e0e7e1; color: #355a4e; }

.message-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transform: translateY(-2px);
  transition: 130ms ease;
}

.message-row:hover .message-actions,
.message-row:focus-within .message-actions {
  opacity: 1;
  transform: none;
}

.message-action {
  padding: 4px 7px;
  border-radius: 7px;
  background: transparent;
  color: #757c76;
  font-size: 9px;
  font-weight: 700;
}

.message-action:hover {
  background: rgba(31, 41, 39, 0.07);
  color: var(--ink);
}

.system-card {
  padding: 18px 20px;
  border: 1px solid #d8ceb9;
  border-radius: 15px;
  background: rgba(239, 232, 216, 0.74);
}

.system-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.system-card-top strong {
  font-family: Georgia, serif;
  font-size: 14px;
}

.system-card-top span {
  color: #866c41;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.system-card p {
  margin: 0;
  color: #5f625c;
  font-size: 12px;
  line-height: 1.55;
}

.typing-row {
  display: flex;
  width: min(100%, 790px);
  align-items: center;
  gap: 10px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 55px) 15px;
  color: var(--ink-soft);
  font-size: 10px;
}

.typing-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold);
  animation: typing 1.15s infinite ease-in-out;
}

.typing-dots i:nth-child(2) { animation-delay: 120ms; }
.typing-dots i:nth-child(3) { animation-delay: 240ms; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.38; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.composer-wrap {
  z-index: 2;
  padding: 8px clamp(18px, 5vw, 70px) 15px;
  border-top: 1px solid rgba(220, 214, 202, 0.58);
  background: linear-gradient(to top, #f7f4ed 76%, rgba(247, 244, 237, 0.86));
}

.composer,
.reply-preview {
  width: min(100%, 790px);
  margin: 0 auto;
}

.composer {
  overflow: hidden;
  border: 1px solid #cbc5b8;
  border-radius: 16px;
  background: var(--surface-strong);
  box-shadow: 0 9px 30px rgba(31, 41, 39, 0.08);
  transition: 140ms ease;
}

.composer:focus-within {
  border-color: #8b9e93;
  box-shadow: 0 9px 34px rgba(31, 65, 54, 0.11), 0 0 0 3px rgba(36, 91, 78, 0.06);
}

.composer textarea {
  display: block;
  width: 100%;
  max-height: 165px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 15px 17px 7px;
  background: transparent;
  font-size: 13px;
  line-height: 1.55;
}

.composer textarea::placeholder {
  color: #a0a49e;
}

.composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px 8px 12px;
}

.composer-hints {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.composer-tool {
  padding: 4px 6px;
  border-radius: 6px;
  background: transparent;
  color: #66716b;
  font-size: 10px;
  font-weight: 700;
}

.composer-tool:hover {
  background: var(--paper);
}

.desktop-hint {
  color: #a1a39e;
  font-size: 9px;
}

.send-button {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 9px;
  padding: 0 8px 0 13px;
  border-radius: 10px;
  background: var(--forest);
  color: white;
  font-size: 10px;
  font-weight: 750;
}

.send-button b {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.13);
  font-size: 14px;
}

.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: #f1eee6;
}

.reply-preview div {
  min-width: 0;
}

.reply-preview span {
  color: #826a42;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.reply-preview p {
  overflow: hidden;
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-preview button {
  background: transparent;
  color: var(--ink-soft);
  font-size: 18px;
}

.reply-preview:not([hidden]) + .composer {
  border-radius: 0 0 16px 16px;
}

.reconstruction-note {
  margin: 7px auto 0;
  color: #92958f;
  font-size: 8.5px;
  text-align: center;
}

.workspace-view {
  background: var(--paper);
}

.workspace-header {
  display: flex;
  min-height: 126px;
  align-items: center;
  padding: 25px clamp(28px, 5vw, 70px);
  border-bottom: 1px solid var(--line);
  background: rgba(250, 248, 243, 0.75);
}

.workspace-header h2 {
  font-size: 28px;
}

.workspace-header p:last-child {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.workspace-scroll {
  flex: 1;
  padding: 28px clamp(28px, 5vw, 70px) 55px;
}

.memory-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto 22px;
}

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper-deep);
}

.segmented button,
.segmented label span {
  display: grid;
  min-height: 32px;
  place-items: center;
  padding: 0 11px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
}

.segmented button.is-active,
.segmented label:has(input:checked) span {
  background: white;
  color: var(--forest);
  box-shadow: 0 2px 8px rgba(31, 41, 39, 0.08);
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented.full-width {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.search-field {
  display: flex;
  min-width: 240px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.search-field input {
  width: 100%;
  min-height: 39px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 11px;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  max-width: 1100px;
  margin: 0 auto;
}

.memory-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
}

.memory-card {
  padding: 18px;
}

.memory-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.memory-visibility {
  padding: 4px 7px;
  border-radius: 20px;
  background: var(--sage);
  color: var(--forest);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.memory-card time {
  color: #999c96;
  font-size: 9px;
}

.memory-card h3 {
  margin: 0 0 7px;
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 500;
}

.memory-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.55;
}

.memory-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
  padding-top: 11px;
  border-top: 1px solid var(--line-soft);
}

.memory-card-footer span {
  color: var(--ink-soft);
  font-size: 9px;
}

.memory-card-footer button {
  background: transparent;
  color: var(--danger);
  font-size: 9px;
  font-weight: 700;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 58px 30px;
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 7px;
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 500;
}

.empty-state p {
  max-width: 460px;
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.6;
}

.settings-layout {
  display: grid;
  align-content: start;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.settings-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
}

.settings-card:nth-child(2) {
  grid-row: span 2;
}

.settings-card-heading {
  display: flex;
  gap: 13px;
  padding: 20px;
  border-bottom: 1px solid var(--line-soft);
}

.settings-index {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 12px;
}

.settings-card h3 {
  margin: 0 0 4px;
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 500;
}

.settings-card p,
.setting-row small,
.select-row small {
  display: block;
  margin: 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.45;
}

.setting-row,
.select-row {
  position: relative;
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.setting-row:last-child,
.select-row:last-child {
  border-bottom: 0;
}

.setting-row strong,
.select-row strong {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
}

.switch-input {
  position: absolute;
  right: 20px;
  width: 39px;
  height: 22px;
  opacity: 0;
}

.switch {
  position: relative;
  width: 39px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #c8c8c2;
  transition: 160ms ease;
}

.switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  content: "";
  transition: 160ms ease;
}

.switch-input:checked + .switch {
  background: var(--forest-2);
}

.switch-input:checked + .switch::after {
  transform: translateX(17px);
}

.select-row select {
  min-width: 178px;
  min-height: 37px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 28px 0 10px;
  background: white;
  font-size: 10px;
}

.danger-card {
  border-color: rgba(158, 61, 61, 0.2);
}

.danger-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 18px 20px;
}

.detail-drawer {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  display: flex;
  width: min(440px, 94vw);
  height: 100dvh;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(105%);
  transition: transform 230ms cubic-bezier(0.22, 1, 0.36, 1);
}

.detail-drawer.is-open {
  transform: none;
}

.drawer-scrim {
  position: fixed;
  z-index: 19;
  inset: 0;
  visibility: hidden;
  background: rgba(20, 30, 27, 0.27);
  opacity: 0;
  transition: 180ms ease;
}

.detail-drawer.is-open + .drawer-scrim {
  visibility: visible;
  opacity: 1;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 94px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h2 {
  font-size: 22px;
}

.drawer-body {
  flex: 1;
  padding: 24px;
}

.drawer-loading {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--ink-soft);
  font-size: 11px;
}

.drawer-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding: 13px 14px;
  border: 1px solid #ddd2bc;
  border-radius: 12px;
  background: #f3ecdf;
}

.drawer-status span {
  color: #6d624e;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.drawer-status strong {
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 500;
}

.drawer-section {
  margin-bottom: 25px;
}

.drawer-section h3 {
  margin: 0 0 9px;
  color: var(--gold);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.drawer-section p,
.drawer-section li {
  color: #515a55;
  font-size: 11.5px;
  line-height: 1.65;
}

.drawer-section p {
  margin: 0;
}

.drawer-section ul {
  margin: 0;
  padding-left: 18px;
}

.source-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.source-card + .source-card {
  margin-top: 9px;
}

.source-card strong,
.source-card span {
  display: block;
}

.source-card strong {
  margin-bottom: 4px;
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 500;
}

.source-card span {
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.45;
}

.modal {
  width: min(680px, calc(100vw - 30px));
  max-height: min(88dvh, 780px);
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(18, 31, 27, 0.48);
  backdrop-filter: blur(3px);
}

.modal-card {
  display: flex;
  max-height: inherit;
  flex-direction: column;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  font-size: 24px;
}

.modal-body {
  padding: 22px 24px;
}

.modal-footer {
  border-top: 1px solid var(--line);
  background: #f7f4ed;
}

.modal-footer p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 9.5px;
}

.field-label,
.modal fieldset {
  display: block;
  margin: 0 0 20px;
}

.field-label,
.modal legend {
  color: #5e655f;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.025em;
}

.field-label input,
.field-label textarea {
  display: block;
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  outline: 0;
  background: white;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
}

.field-label textarea {
  resize: vertical;
}

.modal fieldset {
  min-width: 0;
  border: 0;
  padding: 0;
}

.modal legend {
  margin-bottom: 9px;
}

.character-choice {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  min-height: 62px;
  margin-bottom: 7px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 8px 12px;
  background: white;
}

.character-choice:has(input:checked) {
  border-color: #9cad9f;
  background: #f8fbf8;
}

.character-choice input,
.option-cards input {
  position: absolute;
  opacity: 0;
}

.character-choice strong,
.character-choice small {
  display: block;
}

.character-choice strong {
  margin-bottom: 3px;
  font-size: 11px;
}

.character-choice small {
  color: var(--ink-soft);
  font-size: 9px;
}

.character-choice b {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: transparent;
  font-size: 10px;
}

.character-choice:has(input:checked) b {
  border-color: var(--forest-2);
  background: var(--forest-2);
  color: white;
}

.option-cards {
  display: grid;
  gap: 7px;
}

.option-cards.three-up {
  grid-template-columns: repeat(3, 1fr);
}

.option-cards label span {
  display: block;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px;
  background: white;
}

.option-cards label:has(input:checked) span {
  border-color: var(--forest-2);
  box-shadow: inset 0 0 0 1px var(--forest-2);
}

.option-cards strong,
.option-cards small {
  display: block;
}

.option-cards strong {
  margin-bottom: 5px;
  font-size: 10px;
}

.option-cards small {
  color: var(--ink-soft);
  font-size: 8.5px;
  font-weight: 400;
  line-height: 1.35;
}

.two-column-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.form-span {
  grid-column: 1 / -1;
}

.toast {
  position: fixed;
  z-index: 60;
  right: 24px;
  bottom: 24px;
  visibility: hidden;
  max-width: min(350px, calc(100vw - 30px));
  padding: 12px 15px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 11px;
  background: var(--forest);
  color: white;
  box-shadow: var(--shadow);
  font-size: 11px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(8px);
  transition: 170ms ease;
}

.auth-modal::backdrop {
  background: rgba(24, 22, 18, 0.58);
  backdrop-filter: blur(10px);
}

.auth-card {
  width: min(520px, calc(100vw - 28px));
}

.auth-seal {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong, #b9ad96);
  border-radius: 50%;
  color: var(--ink, #26231e);
  font-family: Georgia, serif;
  letter-spacing: 0.06em;
}

.auth-intro {
  margin: 0 0 8px;
  color: var(--muted, #716b60);
  line-height: 1.55;
}

.auth-fields {
  display: grid;
  gap: 16px;
}

.auth-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #c9978d;
  border-radius: 10px;
  background: #fff3f0;
  color: #7b2f24;
}

.auth-footer {
  justify-content: space-between;
}

.toast.is-visible {
  visibility: visible;
  opacity: 1;
  transform: none;
}

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 68px 286px minmax(0, 1fr); }
  .rail { padding-inline: 7px; }
  .rail-button.is-active::before { left: -7px; }
  .sidebar-note { display: none; }
  .sources-header-button { display: none; }
  .desktop-hint { display: none; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-card:nth-child(2) { grid-row: auto; }
}

@media (max-width: 760px) {
  body { background: var(--paper); }
  .app-shell { display: block; }
  .rail {
    position: fixed;
    z-index: 15;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    height: 62px;
    grid-template-columns: repeat(3, 1fr);
    padding: 5px 14px max(5px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-right: 0;
  }
  .brand-mark,
  .profile-button { display: none; }
  .rail-nav { display: contents; }
  .rail-button { min-height: 48px; }
  .rail-button.is-active::before {
    top: -5px;
    left: 50%;
    width: 28px;
    height: 2px;
    transform: translateX(-50%);
  }
  .rail-glyph { font-size: 22px; }
  .rail-label { font-size: 9px; }
  .conversation-sidebar {
    position: fixed;
    z-index: 5;
    inset: 0 0 62px;
    width: 100%;
    border-right: 0;
    transform: translateX(-102%);
    transition: transform 210ms ease;
  }
  .app-shell.is-sidebar-open .conversation-sidebar { transform: none; }
  .mobile-only { display: grid; }
  .main-panel { height: calc(100dvh - 62px); }
  .app-shell.is-sidebar-open .main-panel { visibility: hidden; }
  .chat-header { min-height: 69px; padding: 10px 13px; gap: 8px; }
  .chat-header .back-button { display: grid; }
  .chat-header .avatar { width: 39px; height: 39px; }
  .chat-identity { gap: 8px; }
  .chat-identity-copy h2 { font-size: 16px; }
  .identity-subline { font-size: 8.5px; }
  .reconstruction-badge { display: none; }
  .chat-header-actions .primary-button { padding: 0 10px; font-size: 10px; }
  .more-button { display: none; }
  .demo-banner { align-items: flex-start; padding: 8px 13px; font-size: 9px; }
  .demo-banner strong { display: none; }
  .message-feed { padding: 20px 12px 12px; }
  .conversation-intro { margin: 10px auto 30px; padding-inline: 14px; }
  .conversation-intro h3 { font-size: 21px; }
  .message-row { grid-template-columns: 31px minmax(0, 1fr); gap: 7px; margin-bottom: 20px; }
  .message-row .avatar-small { width: 30px; height: 30px; }
  .message-bubble { padding: 11px 12px; }
  .message-bubble p { font-size: 12.5px; }
  .message-actions { opacity: 1; transform: none; }
  .message-action { padding-inline: 5px; }
  .typing-row { padding: 0 12px 10px; }
  .composer-wrap { padding: 7px 9px 10px; }
  .composer textarea { padding: 12px 13px 6px; }
  .composer-tool { display: none; }
  .send-button span { display: none; }
  .send-button { padding: 0 6px; }
  .reconstruction-note { display: none; }
  .workspace-header { min-height: 100px; padding: 16px; }
  .workspace-header .back-button { display: none; }
  .workspace-header h2 { font-size: 24px; }
  .workspace-scroll { padding: 16px 13px 35px; }
  .memory-toolbar { align-items: stretch; flex-direction: column; }
  .segmented { overflow-x: auto; }
  .search-field { min-width: 0; }
  .memory-grid { grid-template-columns: 1fr; }
  .settings-layout { gap: 11px; }
  .setting-row,
  .select-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .select-row select { width: 100%; }
  .modal { width: calc(100vw - 18px); max-height: calc(100dvh - 18px); border-radius: 16px; }
  .modal-header,
  .modal-footer { padding: 16px; }
  .modal-header h2 { font-size: 21px; }
  .modal-body { padding: 16px; }
  .option-cards.three-up { grid-template-columns: 1fr; }
  .option-cards label span { min-height: 0; }
  .two-column-form { grid-template-columns: 1fr; }
  .form-span { grid-column: auto; }
  .modal-footer p { display: none; }
  .toast { right: 12px; bottom: 75px; }
}

@media (min-width: 761px) {
  .conversation-sidebar { transform: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
