:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #201d1b;
  background: #f5f2ed;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: #f5f2ed; }
button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, textarea:focus-visible { outline: 3px solid #9c806b; outline-offset: 2px; }
[hidden] { display: none !important; }

.shell { min-height: 100vh; display: grid; grid-template: 58px 1fr / 232px minmax(0, 1fr); }
.global-header {
  min-width: 0;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  background: #292522;
  color: #fff;
}
.world-identity { min-width: 0; display: flex; align-items: center; gap: 16px; }
.global-header strong { flex: none; font-size: 20px; letter-spacing: .16em; }
.global-header span, .global-header time { color: #d8d0c9; font-size: 12px; }
#world-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.primary-nav { display: flex; align-items: center; gap: 4px; }
.primary-nav button {
  border: 0;
  border-radius: 7px;
  padding: 8px 18px;
  background: transparent;
  color: #e9e4df;
  font-size: 12px;
}
.primary-nav button.active { background: #5a544f; color: #fff; font-weight: 700; }
.primary-nav button:disabled { opacity: .45; }
.clock { display: flex; align-items: center; justify-content: flex-end; gap: 10px; white-space: nowrap; }
#clock-mode {
  padding: 3px 8px;
  border: 1px solid #716861;
  border-radius: 999px;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
}

.sidebar {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 18px 14px;
  border-right: 1px solid #dcd5ce;
  background: #fff;
}
.persona-nav { display: grid; gap: 5px; }
.persona-nav button {
  min-width: 0;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 10px 12px;
  color: #504943;
}
.persona-nav button.active { background: #eee8e1; color: #201d1b; font-weight: 700; }
.world-controls { border-top: 1px solid #e5ded7; padding-top: 16px; }
.world-controls h2, .section-eyebrow {
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #766e68;
}
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.control-grid button {
  border: 1px solid #d7cec6;
  border-radius: 7px;
  padding: 8px 5px;
  background: #fff;
  font-size: 11px;
}
.sync-live { width: 100%; margin-top: 7px; border: 0; background: transparent; color: #615850; font-size: 11px; text-decoration: underline; }

.conversation { min-width: 0; display: grid; grid-template-rows: auto 1fr auto auto; max-height: calc(100vh - 58px); }
.conversation-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 28px 14px; border-bottom: 1px solid #ddd6cf; }
.conversation-heading p { margin: 0 0 4px; color: #80766e; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.conversation-heading h1 { margin: 0; font-size: 21px; }
.conversation-actions { display: flex; align-items: center; gap: 7px; }
.conversation-actions button { border: 1px solid #cfc6be; border-radius: 8px; padding: 7px 11px; background: #fff; color: #403934; font-size: 11px; font-weight: 700; }
.conversation-actions button:hover { border-color: #9c8d82; background: #f8f5f1; }
#exit-chat { border-color: transparent; background: transparent; color: #71665e; }
.messages { overflow-y: auto; padding: 22px 28px; display: flex; flex-direction: column; gap: 12px; }
.empty { margin: auto; color: #8a817a; text-align: center; }
.message { max-width: min(680px, 82%); }
.message.user { align-self: flex-end; }
.message .name { margin: 0 0 4px; font-size: 11px; color: #766e68; }
.bubble { margin: 0; padding: 10px 13px; border-radius: 12px; background: #fff; border: 1px solid #ded7d0; line-height: 1.45; }
.message-line { white-space: pre-wrap; }
.message-break { height: .65em; }
.message-list { margin: 5px 0; padding-left: 22px; }
.message-list:first-child { margin-top: 0; }
.message-list:last-child { margin-bottom: 0; }
.bubble strong { font-weight: 750; }
.user .bubble { background: #27221f; border-color: #27221f; color: #fff; }
form { display: flex; gap: 10px; padding: 14px 28px 8px; border-top: 1px solid #ddd6cf; background: #fff; }
textarea { flex: 1; resize: none; border: 1px solid #cfc6be; border-radius: 9px; padding: 10px 12px; }
form button { border: 0; border-radius: 9px; padding: 0 20px; background: #27221f; color: #fff; font-weight: 700; }
button:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
#chat-status, #time-status { min-height: 18px; margin: 0; font-size: 11px; color: #7e332b; }
#chat-status { padding: 0 28px 8px; background: #fff; }

.dossier { min-width: 0; height: calc(100vh - 58px); overflow: auto; padding: 12px; background: #f5f2ed; }
.dossier-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 2px 10px 12px; }
.dossier-heading h1 { margin: 0 0 2px; font-size: 21px; }
.dossier-heading p { margin: 0; color: #756d66; font-size: 12px; }
.view-modes { display: flex; align-items: center; gap: 5px; padding: 4px; border-radius: 8px; background: #eee9e3; }
.view-modes > span { padding: 0 6px; }
.view-modes button { border: 0; border-radius: 6px; padding: 7px 15px; background: transparent; font-size: 11px; }
.view-modes button.active { background: #292522; color: #fff; font-weight: 700; }
.dossier-grid { display: grid; grid-template-columns: 240px minmax(390px, 1fr) 330px; gap: 10px; align-items: start; }
.surface-card, .rail-card { border: 1px solid #ded7d0; border-radius: 9px; background: #fff; box-shadow: 0 1px 2px rgb(45 35 28 / 4%); }

.identity-card { position: sticky; top: 0; padding: 14px; }
.identity-card > .section-eyebrow { margin-top: 0; }
.identity-name { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.identity-role, .identity-home { margin: 5px 0 0; color: #645c56; font-size: 12px; line-height: 1.4; }
.identity-focus { margin: 16px 0 0; padding: 18px 14px; border-radius: 7px; background: #e7e1da; }
.identity-focus-label { margin: 0 0 7px; color: #766e68; font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .1em; }
.identity-focus-copy { margin: 0; font-family: Georgia, serif; font-size: 22px; line-height: 1.14; color: #332d29; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.chip { padding: 5px 9px; border-radius: 999px; background: #eeeae5; color: #48413c; font-size: 10px; }
.identity-quote { margin: 16px 0 0; padding: 14px 0 0; border-top: 1px solid #e5ded7; color: #4a423d; font-family: Georgia, serif; font-size: 14px; line-height: 1.45; }
.identity-quote cite { display: block; margin-top: 7px; color: #857a72; font-family: inherit; font-size: 10px; font-style: normal; }
.grounding-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 14px; }

.profile-panel { min-width: 0; overflow: hidden; }
.profile-tabs { position: sticky; top: 0; z-index: 2; display: flex; gap: 2px; overflow-x: auto; padding: 0 14px; border-bottom: 1px solid #e3dcd5; background: #fff; }
.profile-tabs button { flex: none; border: 0; border-bottom: 2px solid transparent; padding: 13px 8px 10px; background: transparent; color: #675f59; font-size: 10px; }
.profile-tabs button:hover, .profile-tabs button.active { border-color: #2c2724; color: #201d1b; }
.profile-section { scroll-margin-top: 48px; padding: 17px 18px; border-bottom: 1px solid #e5ded7; }
.profile-section:last-child { border-bottom: 0; }
.profile-section .section-eyebrow { margin: 0 0 5px; }
.profile-section h2, .rail-card h2 { margin: 0 0 12px; font-size: 15px; }
.profile-section h3, .living-item h3, .domain-card h3 { margin: 14px 0 6px; font-size: 12px; }
.profile-section p { line-height: 1.5; }
.lead-copy { margin: 0 0 16px; font-size: 13px; color: #3f3935; }
.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.characteristics { border-left: 1px solid #e2dbd4; padding-left: 18px; }
.characteristics h3 { margin-top: 0; }
.overview-chips { margin: 0; }
.overview-portrait { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.overview-compact-card { min-width: 0; padding: 12px; border-radius: 7px; background: #f6f3ef; }
.overview-compact-card .section-eyebrow { margin: 0 0 7px; }
.overview-compact-card .text-list { margin-top: 0; }
.cue-copy { margin: 0; color: #3f3935; font-size: 11px; font-weight: 650; }
.cue-question { margin: 8px 0 0; color: #5a5049; font-family: Georgia, serif; font-size: 12px; line-height: 1.4; }
.overview-messages { margin-top: 16px; padding-top: 15px; border-top: 1px solid #e5ded7; }
.overview-messages .section-eyebrow { margin: 0 0 5px; }
.overview-messages h2 { margin: 0 0 10px; font-size: 13px; }
.fact-list { display: grid; grid-template-columns: minmax(90px, .8fr) minmax(0, 1.4fr); gap: 7px 12px; margin: 0; font-size: 11px; }
.fact-list dt { color: #827870; }
.fact-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: #38322e; }
.text-list { margin: 6px 0 0; padding-left: 17px; color: #49423d; font-size: 11px; line-height: 1.55; }
.text-list.compact { margin: 0; }
.domain-card { margin-top: 10px; padding: 12px; border-radius: 7px; background: #f6f3ef; }
.domain-card > h3 { margin-top: 0; }
.domain-list { display: grid; grid-template-columns: minmax(110px, .7fr) minmax(0, 1.5fr); gap: 8px 12px; margin: 0; font-size: 11px; }
.domain-list dt { color: #786f68; font-weight: 650; }
.domain-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.domain-value { margin: 0 !important; font-size: 11px; }
.public-messages { display: grid; gap: 8px; }
.public-message { padding: 9px 10px; border-radius: 7px; background: #f6f3ef; }
.public-message strong { font-size: 10px; }
.public-message p { margin: 3px 0 0; font-size: 11px; }
.text-action { margin-top: 10px; padding: 0; border: 0; background: transparent; color: #4b433e; font-size: 11px; text-decoration: underline; }

.living-rail { display: grid; gap: 9px; }
.living-rail > .section-eyebrow { margin: 1px 8px -2px; }
.rail-card { padding: 14px; }
.rail-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rail-heading h2 { margin: 0; }
.rail-action { flex: none; border: 0; padding: 0; background: transparent; color: #655c56; font-size: 9px; text-decoration: underline; }
.status-pill { padding: 3px 8px; border-radius: 999px; background: #dcefd8; color: #2f6b27; font-size: 9px; font-weight: 750; }
.meter-list { display: grid; gap: 8px; margin-top: 13px; }
.meter-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 3px; font-size: 10px; }
.meter-label strong { font-size: 10px; }
meter { width: 100%; height: 7px; border: 0; background: #e7e2dd; }
meter::-webkit-meter-bar { border: 0; border-radius: 999px; background: #e7e2dd; }
meter::-webkit-meter-optimum-value { border-radius: 999px; background: #8eb391; }
.living-item { padding: 10px 0; border-top: 1px solid #e8e2dc; }
.living-item:first-of-type { padding-top: 0; border-top: 0; }
.living-item h3 { margin: 0 0 4px; }
.living-item > p { margin: 0 0 8px; font-size: 11px; line-height: 1.4; }
.living-item .fact-list, .relationship-item .fact-list { grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 9px; }
.belief-copy { font-weight: 620; }
.provenance { display: inline-block; margin-top: 7px; padding: 3px 6px; border: 1px solid #d8d0c8; border-radius: 999px; color: #6d635c; font-size: 8px; }
.provenance.missing { border-style: dashed; }
.summary-item { padding: 9px 0; border-top: 1px solid #e8e2dc; }
.summary-item:first-of-type { border-top: 0; }
.summary-item h3, .summary-item .belief-copy { margin: 0; font-size: 11px; line-height: 1.35; }
.summary-meta { margin: 4px 0 0; color: #81766e; font-size: 9px; }
.summary-item .provenance { margin-top: 5px; }
.relationship-summary { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 8px 0; border-top: 1px solid #e8e2dc; font-size: 10px; }
.relationship-summary:first-of-type { border-top: 0; }
.relationship-summary strong { grid-row: 1 / span 2; font-size: 11px; }
.relationship-summary span, .relationship-summary small { color: #776d65; text-align: right; }
.more-state { margin-top: 11px; border-top: 1px solid #e8e2dc; padding-top: 9px; }
.more-state summary { color: #6f655e; cursor: pointer; font-size: 9px; }
.detail-item { padding: 14px 0; border-top: 1px solid #e8e2dc; }
.detail-item:first-of-type { padding-top: 0; border-top: 0; }
.detail-item > h3 { margin-top: 0; }
.detail-item > p { margin: 0 0 9px; color: #49413c; font-size: 11px; line-height: 1.45; }
.detail-item .fact-list { max-width: 520px; }
.relationship-label { font-weight: 650; }
.memory-copy { font-weight: 620; }
.relationship-item { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 9px 0; border-top: 1px solid #e8e2dc; font-size: 10px; }
.relationship-item:first-of-type { border-top: 0; }
.relationship-item strong { font-size: 11px; }
.relationship-item > span { color: #625a54; }
.relationship-item small { grid-column: 1 / -1; color: #8a7f77; }
.relationship-item .fact-list { grid-column: 1 / -1; }
.item-kicker { color: #7b716a; font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.empty-copy, .muted { color: #8b8179; font-size: 11px; }
.dossier-loading, .dossier-error { margin: 20vh auto; text-align: center; color: #776e67; }
.dossier-error { color: #7e332b; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@media (max-width: 1120px) {
  .dossier-grid { grid-template-columns: 220px minmax(360px, 1fr); }
  .living-rail { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .living-rail > .section-eyebrow { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .dossier-grid { grid-template-columns: minmax(0, 1fr); }
  .identity-card { position: static; }
  .living-rail { grid-column: 1; grid-template-columns: minmax(0, 1fr); }
  .living-rail > .section-eyebrow { grid-column: 1; }
}

@media (max-width: 680px) {
  .global-header { grid-template-columns: 1fr auto; height: auto; min-height: 58px; padding: 9px 16px; }
  .primary-nav { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .clock { grid-column: 2; grid-row: 1; }
  #world-name { display: none; }
  .shell { grid-template-rows: auto auto 1fr; grid-template-columns: 1fr; }
  .sidebar { grid-row: 2; border-right: 0; border-bottom: 1px solid #ddd6cf; padding: 10px 14px; }
  .persona-nav { width: 100%; min-width: 0; grid-template-columns: repeat(5, 76px); overflow-x: auto; }
  .world-controls { display: none; }
  .conversation, .dossier { grid-row: 3; max-height: none; height: auto; min-height: 70vh; }
}

@media (max-width: 520px) {
  .global-header { gap: 8px; }
  .world-identity { gap: 8px; }
  .global-header strong { font-size: 17px; }
  .global-header time { font-size: 10px; }
  .clock { gap: 6px; }
  .primary-nav button { padding: 6px 16px; }
  .dossier { padding: 9px; }
  .dossier-heading { align-items: flex-start; flex-direction: column; }
  .view-modes { width: 100%; }
  .view-modes button { flex: 1; }
  .overview-grid { grid-template-columns: 1fr; }
  .overview-portrait { grid-template-columns: 1fr; }
  .characteristics { border-left: 0; border-top: 1px solid #e2dbd4; padding: 12px 0 0; }
  .profile-section { padding: 15px 14px; }
  .fact-list, .domain-list { grid-template-columns: 1fr; gap: 2px; }
  .fact-list dd, .domain-list dd { margin-bottom: 7px; }
  .messages, .conversation-heading, form { padding-left: 16px; padding-right: 16px; }
  .conversation-heading { align-items: flex-start; }
  .conversation-actions { flex-wrap: wrap; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* World extends the existing paper/card language. */
.world-view { min-width: 0; padding: 24px 28px; }
.world-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.world-tabs button { border: 1px solid #d7cec6; border-radius: 8px; padding: 9px 14px; background: #fff; color: #504943; }
.world-tabs button.active { background: #292522; color: #fff; }
.world-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 16px; }
.world-card { min-width: 0; padding: 16px; border: 1px solid #dcd5ce; border-radius: 12px; background: #fff; overflow-wrap: anywhere; }
.world-card h2 { margin-top: 0; font-size: 17px; }
.world-card h3 { font-size: 13px; margin-top: 18px; }
.context-copy { margin: 6px 0; line-height: 1.6; font-size: 13px; }
.context-fields { display: grid; gap: 8px; }
.context-fields h4 { margin: 8px 0 2px; }
.world-evidence { margin-top: 18px; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.world-evidence summary { cursor: pointer; color: #615850; }
.world-provenance { font-size: 11px; line-height: 1.6; }
.grounding-research_grounded { background: #e7eee7; }
.grounding-synthetic_construction { background: #f3ead8; }
.grounding-emergent { background: #ede9f1; }
.world-flow { display: block; columns: 2 360px; column-gap: 16px; }
.world-flow > .world-card { break-inside: avoid; margin-bottom: 16px; }
.world-name { margin: 0 0 5px; font-size: 16px; font-weight: 700; line-height: 1.35; }
.world-context-item { padding: 14px 0; border-top: 1px solid #e9e3dc; break-inside: avoid; }
.world-context-item:first-of-type { padding-top: 0; border-top: 0; }
.world-context-item .context-title { margin: 0 0 5px; font-size: 14px; line-height: 1.35; }
.context-headline { margin: 5px 0; font-size: 25px; font-weight: 750; letter-spacing: -.03em; }
.context-lead { margin: 4px 0 0; color: #403934; font-size: 12px; line-height: 1.5; }
.context-scope { margin: 7px 0 0; color: #746b64; font-size: 11px; line-height: 1.4; }
.context-note { margin: 7px 0 0; color: #5d534b; font-size: 11px; line-height: 1.45; }
.context-metrics { display: grid; gap: 7px; margin: 9px 0 0; }
.context-metric { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 9px; border-radius: 6px; background: #f7f4f0; }
.context-metric dt { color: #615850; font-size: 11px; }
.context-metric dd { margin: 0; color: #27221f; font-size: 13px; font-weight: 700; text-align: right; }
.context-metric dd small { display: block; margin-top: 3px; color: #756c65; font-size: 10px; font-weight: 400; }
.context-evidence { margin-top: 9px; padding-top: 7px; border-top: 1px solid #f0ebe6; }
.context-evidence summary { font-size: 11px; }
.evidence-fields { display: grid; gap: 8px; padding: 10px 0; }
.evidence-field > strong, .evidence-sources > strong { display: block; color: #6d635c; font-size: 10px; }
.evidence-field > .context-copy, .evidence-field > .context-fields, .evidence-field > .text-list { margin: 2px 0 0; font-size: 11px; }
.evidence-source { padding: 7px 0; border-top: 1px solid #eee8e2; }
.evidence-source p { margin: 3px 0; font-size: 11px; }
.world-domain-card > h2 { margin-bottom: 8px; }
.shared-domain-title { padding-top: 10px; border-top: 1px solid #e9e3dc; }
.lens-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 681px) { .global-header { grid-template-columns: minmax(100px, 1fr) auto minmax(150px, 1fr); gap: 12px; } .primary-nav button { padding: 8px 10px; } }
@media (max-width: 1120px) { .lens-grid { grid-template-columns: 1fr; } }
@media (max-width: 680px) { .world-view { grid-row: 3; padding: 14px; } .world-grid { grid-template-columns: 1fr; } .world-flow { columns: 1; } .primary-nav { width: 100%; justify-content: center; } .primary-nav button { padding: 8px 9px; } }
