:root {
  --ink: #211b16;
  --muted: #706459;
  --paper: #efe4cf;
  --paper-2: #d8c39b;
  --wood: #4c241a;
  --cinnabar: #9b3026;
  --gold: #b98f4a;
  --moss: #435d4d;
  --night: #171816;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "SimSun", serif;
  --kai: "Kaiti SC", "STKaiti", "KaiTi", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  background:
    radial-gradient(circle at 18% 10%, rgba(185, 143, 74, 0.22), transparent 24rem),
    linear-gradient(135deg, #1c1613, #5a3025 45%, #171816);
}

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

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  color: #f3e8d0;
  border: 1px solid rgba(236, 211, 160, 0.22);
  background: rgba(20, 15, 12, 0.68);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  letter-spacing: 0.08em;
}

.seal {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #f4dfc0;
  border: 2px solid var(--gold);
  background: rgba(155, 48, 38, 0.35);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.nav a {
  padding: 8px 11px;
  border: 1px solid rgba(243, 232, 208, 0.22);
  background: rgba(255,255,255,0.05);
  font-family: var(--kai);
}

.nav a[aria-current="page"], .nav a:hover {
  border-color: rgba(185, 143, 74, 0.75);
  background: rgba(185, 143, 74, 0.18);
}

.page {
  margin-top: 18px;
  border: 1px solid rgba(236, 211, 160, 0.26);
  background:
    linear-gradient(135deg, rgba(239, 228, 207, 0.96), rgba(216, 195, 155, 0.92)),
    var(--paper);
  box-shadow: 0 30px 90px rgba(0,0,0,0.3);
}

.hero {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  min-height: 560px;
}

.compact-hero {
  min-height: 420px;
}

.intro {
  padding: clamp(32px, 5vw, 70px);
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--cinnabar);
  font-family: var(--kai);
  letter-spacing: 0.18em;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

h1 {
  max-width: 9em;
  font-size: clamp(42px, 6vw, 76px);
  line-height: 1.05;
}

h2 { font-size: clamp(30px, 4vw, 50px); }

.lead {
  max-width: 38em;
  margin: 22px 0 0;
  color: #51463c;
  font-family: var(--kai);
  font-size: 20px;
  line-height: 1.85;
}

.stage {
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at center, rgba(255, 244, 214, 0.18), transparent 18rem),
    linear-gradient(160deg, #171a18, #3d443e 56%, #171817);
}

.journey-map {
  display: grid;
  gap: 12px;
  width: min(460px, 100%);
}

.node {
  padding: 16px 18px;
  color: #efe3ce;
  border: 1px solid rgba(231, 205, 150, 0.25);
  background: rgba(18, 16, 14, 0.68);
  box-shadow: inset 0 0 34px rgba(185,143,74,0.08);
}

.node b {
  display: block;
  margin-bottom: 6px;
  color: #f5ddaf;
  font-size: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 28px;
}

.card, .panel {
  padding: 20px;
  border: 1px solid rgba(84, 56, 30, 0.18);
  background: rgba(255, 251, 239, 0.52);
  box-shadow: inset 0 0 36px rgba(96, 60, 32, 0.08);
}

.card b {
  display: block;
  margin-bottom: 10px;
  color: var(--cinnabar);
  font-size: 24px;
}

.card p, .panel p, .list li {
  color: #56493f;
  font-family: var(--kai);
  line-height: 1.75;
}

/* .workbench legacy removed for pure ritual */
/* .workbench {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
  padding: 28px;
} */

.hall-gate {
  display: grid;
  grid-template-columns: minmax(300px, 0.92fr) minmax(0, 1.08fr);
  gap: 0;
  min-height: min(720px, calc(100vh - 108px));
  overflow: hidden;
  background:
    radial-gradient(circle at 26% 26%, rgba(244, 223, 184, 0.16), transparent 20rem),
    linear-gradient(135deg, rgba(28, 18, 14, 0.98), rgba(86, 45, 31, 0.92) 48%, rgba(20, 18, 15, 0.98));
}

.hall-door {
  position: relative;
  display: grid;
  align-content: center;
  min-height: 560px;
  padding: clamp(30px, 5vw, 62px);
  color: #f6dfb4;
  border-right: 1px solid rgba(231, 205, 150, 0.2);
  background:
    linear-gradient(90deg, rgba(255,255,255,0.08), transparent 18%, rgba(0,0,0,0.28) 82%),
    linear-gradient(145deg, #2a1711, #6a3424 46%, #1a1512);
  box-shadow:
    inset -28px 0 54px rgba(0, 0, 0, 0.32),
    inset 0 0 0 1px rgba(244, 223, 192, 0.08);
}

.hall-door::before,
.hall-door::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.hall-door::before {
  inset: 34px;
  border: 1px solid rgba(231, 205, 150, 0.24);
  box-shadow:
    inset 0 0 40px rgba(185, 143, 74, 0.09),
    0 24px 80px rgba(0, 0, 0, 0.24);
}

.hall-door::after {
  left: 50%;
  bottom: 76px;
  width: 58%;
  height: 10px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(232, 199, 130, 0.56), transparent);
  filter: blur(8px);
}

.door-beam {
  position: relative;
  z-index: 1;
  width: min(360px, 100%);
  margin: 0 auto 22px;
  padding: 16px 20px;
  text-align: center;
  color: #f7dfad;
  border: 1px solid rgba(231, 205, 150, 0.34);
  background:
    linear-gradient(180deg, rgba(124, 59, 38, 0.92), rgba(48, 24, 18, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 235, 185, 0.18),
    inset 0 -10px 24px rgba(0, 0, 0, 0.28),
    0 20px 42px rgba(0, 0, 0, 0.28);
  font-size: clamp(44px, 7vw, 74px);
  letter-spacing: 0.34em;
  text-indent: 0.34em;
}

.door-panels {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: min(360px, 100%);
  margin: 0 auto;
}

.door-panels span {
  display: grid;
  min-height: 240px;
  place-items: center;
  color: #f1d39c;
  border: 1px solid rgba(231, 205, 150, 0.28);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 233, 176, 0.13), transparent 6rem),
    linear-gradient(160deg, rgba(78, 33, 22, 0.98), rgba(32, 17, 13, 0.98));
  box-shadow:
    inset 10px 0 22px rgba(255, 238, 190, 0.05),
    inset -18px -18px 30px rgba(0, 0, 0, 0.34);
  font-size: clamp(54px, 9vw, 86px);
}

.altar-line {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  margin: 24px auto 0;
  color: #d8c8aa;
  text-align: center;
  font-family: var(--kai);
  line-height: 1.8;
}

.hall-gate-copy {
  display: grid;
  align-content: center;
  padding: clamp(32px, 6vw, 78px);
  background:
    linear-gradient(135deg, rgba(239, 228, 207, 0.96), rgba(216, 195, 155, 0.91)),
    var(--paper);
}

.hall-gate-copy h1 {
  max-width: 7em;
}

.chat {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 8px solid #2f3330;
  background: #eee6d9;
}

.bubble {
  padding: 14px 16px;
  border: 1px solid rgba(185,143,74,0.25);
  background: rgba(255,255,255,0.46);
}

.bubble.ai {
  background: rgba(255, 247, 228, 0.86);
  border-color: rgba(155, 48, 38, 0.28);
}

.artifact-card {
  border-left: 5px solid var(--cinnabar);
  background: rgba(255,255,255,0.42);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.compact-actions {
  margin: 2px 0 16px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 13px;
  color: #fff6e4;
  border: 0;
  background: var(--cinnabar);
  font-family: var(--kai);
  cursor: pointer;
}

.button.secondary {
  color: var(--wood);
  border: 1px solid rgba(84, 56, 30, 0.22);
  background: rgba(255,255,255,0.34);
}

.button:disabled {
  cursor: default;
  opacity: 0.52;
}

.list {
  margin: 16px 0 0;
  padding-left: 20px;
}

.timeline {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.timeline div {
  padding: 13px 15px;
  border-left: 4px solid var(--gold);
  background: rgba(255,255,255,0.35);
}

/* legacy metric styles removed for ritual purity */

.metric {
  padding: 16px;
  border: 1px solid rgba(84, 56, 30, 0.18);
  background: rgba(255, 251, 239, 0.52);
}

.metric strong {
  display: block;
  color: var(--cinnabar);
  font-size: 38px;
  line-height: 1;
}

.metric span {
  color: var(--muted);
  font-family: var(--kai);
}

/* .agent-form legacy removed for ritual */
/* .agent-form {
  display: grid;
  gap: 14px;
} */

/* .agent-form legacy removed for ritual */

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.check-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.file-drop {
  padding: 18px;
  border: 1px dashed rgba(84, 56, 30, 0.36);
  background: rgba(255, 252, 242, 0.42);
}

.status-line {
  min-height: 24px;
  color: var(--cinnabar);
  font-family: var(--kai);
}

/* legacy board styles removed for ritual purity GOAL_GATE_REV=9 */

.record-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.inline-card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.evidence-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(84, 56, 30, 0.16);
}

.evidence-card {
  border-left: 4px solid var(--gold);
}

.comment-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(84, 56, 30, 0.16);
}

.comment-card.pending {
  border-left: 4px solid var(--gold);
}

.comment-card.accepted {
  border-left: 4px solid var(--moss);
}

.comment-card.rejected {
  border-left: 4px solid rgba(84, 56, 30, 0.34);
  opacity: 0.74;
}

.paragraph-editor {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(84, 56, 30, 0.18);
  background: rgba(247, 239, 224, 0.5);
}

.paragraph-editor summary {
  cursor: pointer;
  color: var(--wood);
  font-family: var(--kai);
}

.paragraph-stack {
  display: grid;
  gap: 10px;
}

.paragraph-editor textarea {
  min-height: 96px;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.timeline-board,
.citation-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 20px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-left: 4px solid var(--moss);
  background: rgba(255, 252, 242, 0.48);
  box-shadow: inset 0 0 20px rgba(96, 60, 32, 0.06);
}

.timeline-item.needs-check {
  border-left-color: var(--gold);
}

.timeline-item time {
  color: var(--cinnabar);
  font-family: var(--kai);
}

.timeline-item b,
.citation-item b {
  display: block;
  margin-bottom: 4px;
  color: var(--wood);
}

.timeline-item span,
.citation-item span {
  color: var(--muted);
  font-family: var(--kai);
}

.citation-item {
  padding: 12px;
  border: 1px solid rgba(84, 56, 30, 0.16);
  background: rgba(255, 252, 242, 0.42);
}

.citation-item p {
  margin: 8px 0 0;
  color: #56493f;
  font-family: var(--kai);
  line-height: 1.65;
}

.journey-channel {
  position: relative;
  min-height: 132px;
}

.journey-channel em {
  display: inline-flex;
  width: max-content;
  padding: 4px 8px;
  border: 1px solid rgba(84, 56, 30, 0.22);
  color: var(--cinnabar);
  font: 13px/1 var(--kai);
  background: rgba(255, 252, 242, 0.72);
}

.journey-channel.ready {
  border-left: 4px solid var(--moss);
}

.journey-channel.config {
  border-left: 4px solid var(--gold);
}

.journey-channel.locked {
  border-left: 4px solid rgba(84, 56, 30, 0.34);
}

.journey-v03 {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  padding: 28px;
}

.journey-summary {
  grid-row: span 2;
  position: sticky;
  top: 18px;
  align-self: start;
}

.journey-summary h2 {
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.18;
}

.focus-list {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
  padding-left: 18px;
  color: #56493f;
  font-family: var(--kai);
  line-height: 1.7;
}

.stage-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stage-step {
  display: grid;
  min-height: 118px;
  gap: 8px;
  padding: 14px;
  text-align: left;
  border: 1px solid rgba(84, 56, 30, 0.2);
  background:
    linear-gradient(145deg, rgba(255, 252, 242, 0.54), rgba(216, 195, 155, 0.24)),
    rgba(255, 252, 242, 0.42);
  box-shadow: inset 0 0 28px rgba(96, 60, 32, 0.08);
  cursor: pointer;
}

.stage-step b {
  color: var(--cinnabar);
  font-size: 14px;
  letter-spacing: 0.12em;
}

.stage-step span {
  color: var(--wood);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
}

.stage-step em {
  align-self: end;
  color: var(--muted);
  font: 13px/1 var(--kai);
}

.stage-step.active {
  color: #f6e5c5;
  border-color: rgba(231, 205, 150, 0.52);
  background:
    linear-gradient(145deg, rgba(23, 24, 22, 0.96), rgba(79, 42, 29, 0.88)),
    var(--night);
  box-shadow:
    inset 0 0 46px rgba(185, 143, 74, 0.14),
    0 18px 40px rgba(42, 22, 16, 0.28);
}

.stage-step.active b,
.stage-step.active span {
  color: #f5dcad;
}

.stage-step.active em {
  color: #d8c8aa;
}

.stage-detail {
  min-height: 520px;
}

.journey-stage-card {
  min-height: 520px;
  padding: clamp(22px, 4vw, 42px);
  color: #f3e5cd;
  border: 1px solid rgba(231, 205, 150, 0.28);
  background:
    radial-gradient(circle at 82% 8%, rgba(185, 143, 74, 0.16), transparent 16rem),
    linear-gradient(145deg, rgba(23, 24, 22, 0.96), rgba(71, 43, 31, 0.9) 54%, rgba(22, 22, 20, 0.98));
  box-shadow:
    inset 0 0 70px rgba(185, 143, 74, 0.11),
    0 24px 62px rgba(0, 0, 0, 0.22);
}

.journey-stage-card h3 {
  max-width: 12em;
  color: #f4d9a9;
  font-size: clamp(34px, 5vw, 60px);
  line-height: 1.08;
}

.stage-scene {
  max-width: 58em;
  margin: 18px 0 22px;
  color: #dbc8a9;
  font-family: var(--kai);
  font-size: 18px;
  line-height: 1.85;
}

.journey-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.journey-columns div,
.next-line {
  padding: 14px 16px;
  border: 1px solid rgba(231, 205, 150, 0.18);
  background: rgba(255, 252, 242, 0.06);
}

.journey-columns b,
.next-line b {
  display: block;
  margin-bottom: 6px;
  color: #f0cf92;
}

.journey-columns p,
.next-line span {
  margin: 0;
  color: #d8c8aa;
  font-family: var(--kai);
  line-height: 1.72;
}

.ui-token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.ui-token-row span {
  padding: 7px 10px;
  color: #f8e7c9;
  border: 1px solid rgba(231, 205, 150, 0.18);
  background: rgba(155, 48, 38, 0.16);
  font-family: var(--kai);
}

.evidence-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.evidence-tile {
  display: grid;
  gap: 6px;
  min-height: 128px;
  padding: 13px;
  color: inherit;
  border: 1px solid rgba(231, 205, 150, 0.2);
  background: rgba(255, 252, 242, 0.08);
}

.evidence-tile.ok {
  border-left: 4px solid var(--moss);
}

.evidence-tile.todo {
  border-left: 4px solid var(--gold);
}

.evidence-tile b {
  color: #f3d49e;
}

.evidence-tile span {
  color: #dbc8a9;
  font-family: var(--kai);
  line-height: 1.5;
}

.evidence-tile em {
  align-self: end;
  color: #c7a769;
  font: 13px/1.4 var(--kai);
}

.journey-lab {
  align-items: start;
}

.agent-role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.agent-role {
  padding: 12px;
  border: 1px solid rgba(84, 56, 30, 0.16);
  background: rgba(255, 252, 242, 0.42);
}

.agent-role b {
  display: block;
  color: var(--wood);
}

.agent-role span {
  display: inline-flex;
  margin: 6px 0 8px;
  padding: 3px 7px;
  color: var(--cinnabar);
  border: 1px solid rgba(155, 48, 38, 0.18);
  font: 13px/1 var(--kai);
}

.agent-role p {
  margin: 0;
  color: #56493f;
  font-family: var(--kai);
  line-height: 1.62;
}

.action-card {
  display: block;
}

.menu-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.menu-column {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(84, 56, 30, 0.18);
  background: rgba(255, 252, 242, 0.46);
}

.menu-column b {
  color: var(--wood);
}

.menu-column a {
  color: #56493f;
  font-family: var(--kai);
}

.kinship-map {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.kinship-nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kinship-node {
  display: grid;
  min-width: 118px;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgba(84, 56, 30, 0.2);
  background: rgba(255, 252, 242, 0.48);
}

.kinship-node.verified {
  border-color: rgba(67, 93, 77, 0.5);
  background: rgba(67, 93, 77, 0.12);
}

.kinship-node b {
  color: var(--wood);
}

.kinship-node em {
  color: var(--muted);
  font: 13px/1.3 var(--kai);
}

.compact-form {
  margin: 16px 0;
}

.generation-axis,
.migration-route {
  display: grid;
  gap: 12px;
  margin: 12px 0 20px;
}

.migration-map {
  padding: 12px;
  border: 1px solid rgba(84, 56, 30, 0.18);
  background:
    linear-gradient(135deg, rgba(255, 252, 242, 0.82), rgba(246, 239, 226, 0.54)),
    repeating-linear-gradient(90deg, rgba(84, 56, 30, 0.035) 0 1px, transparent 1px 18px);
}

.migration-map svg {
  width: 100%;
  aspect-ratio: 100 / 88;
  display: block;
}

.map-land {
  fill: rgba(185, 145, 79, 0.13);
  stroke: rgba(84, 56, 30, 0.18);
  stroke-width: 0.8;
}

.migration-line {
  fill: none;
  stroke: url(#migrationInk);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 4 3;
}

.migration-point circle {
  fill: #fffaf0;
  stroke: var(--cinnabar);
  stroke-width: 1.6;
}

.migration-point.medium circle {
  stroke: var(--gold);
  fill: rgba(185, 145, 79, 0.16);
}

.migration-point.high circle {
  fill: rgba(155, 63, 47, 0.18);
  stroke-width: 2.2;
}

.migration-point text {
  fill: var(--wood);
  font: 4px var(--kai);
  paint-order: stroke;
  stroke: rgba(255, 250, 240, 0.88);
  stroke-width: 1.8;
}

.migration-map p {
  margin: 8px 0 0;
  color: var(--muted);
  font-family: var(--kai);
  font-size: 13px;
}

.migration-stops {
  display: grid;
  gap: 10px;
}

.generation-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(84, 56, 30, 0.18);
  background: rgba(255, 252, 242, 0.48);
}

.generation-row b {
  color: var(--cinnabar);
  font-family: var(--kai);
}

.generation-row div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.generation-row span {
  padding: 4px 8px;
  border: 1px solid rgba(84, 56, 30, 0.18);
  color: #56493f;
  background: rgba(255, 255, 255, 0.24);
}

.migration-stop {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  background: linear-gradient(90deg, rgba(255, 252, 242, 0.58), rgba(255, 252, 242, 0.24));
  border-left: 4px solid var(--gold);
}

.migration-stop i {
  display: grid;
  place-items: center;
  width: 28px;
  aspect-ratio: 1;
  color: #fff7e6;
  background: var(--wood);
  font-style: normal;
}

.migration-stop b {
  display: block;
  color: var(--wood);
}

.migration-stop span {
  display: block;
  color: var(--muted);
  font-family: var(--kai);
}

.migration-stop em {
  display: block;
  margin-top: 3px;
  color: rgba(84, 56, 30, 0.78);
  font: 13px/1.5 var(--kai);
}

.disambiguation-board {
  display: grid;
  gap: 10px;
  margin: 12px 0 20px;
}

.disambiguation-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(84, 56, 30, 0.2);
  border-left: 4px solid var(--gold);
  background: rgba(255, 252, 242, 0.58);
}

.disambiguation-card.high {
  border-left-color: var(--cinnabar);
}

.disambiguation-card > b {
  color: var(--wood);
  font-family: var(--kai);
}

.disambiguation-card > span {
  color: var(--muted);
  font-family: var(--kai);
}

.disambiguation-card mark {
  padding: 6px 8px;
  color: #6d5126;
  background: rgba(185, 145, 79, 0.16);
  border: 1px solid rgba(185, 145, 79, 0.28);
}

.disambiguation-card div {
  display: grid;
  gap: 8px;
}

.disambiguation-card section {
  padding: 10px;
  border: 1px solid rgba(84, 56, 30, 0.16);
  background: rgba(255, 255, 255, 0.24);
}

.disambiguation-card strong,
.disambiguation-card em,
.disambiguation-card small {
  display: block;
}

.disambiguation-card em,
.disambiguation-card small {
  color: var(--muted);
  font-style: normal;
  font-family: var(--kai);
}

.disambiguation-card p {
  margin: 6px 0;
}

.disambiguation-review-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(100px, 0.6fr) minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.disambiguation-review-form select,
.disambiguation-review-form input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  border: 1px solid rgba(84, 56, 30, 0.24);
  background: rgba(255, 252, 242, 0.78);
  font: inherit;
}

.disambiguation-review-form .status-line {
  grid-column: 1 / -1;
}

@media (max-width: 760px) {
  .disambiguation-review-form {
    grid-template-columns: 1fr;
  }
}

.memory-niche,
.answer-card,
.mini-card {
  padding: 18px;
  border: 1px solid rgba(84, 56, 30, 0.2);
  background: rgba(255, 252, 242, 0.55);
  box-shadow: inset 0 0 28px rgba(96, 60, 32, 0.08);
}

.memory-niche.is-approved {
  border-left: 5px solid var(--moss);
}

.memory-niche.review-high {
  border-left: 5px solid var(--cinnabar);
}

.memory-niche.review-medium {
  border-left: 5px solid var(--gold);
}

.memory-niche.review-low {
  border-left: 5px solid var(--moss);
}

.maintenance-card {
  position: relative;
  overflow: hidden;
}

.maintenance-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--gold);
}

.maintenance-card.todo {
  background: linear-gradient(135deg, rgba(255, 252, 242, 0.86), rgba(185, 75, 48, 0.08));
}

.maintenance-card.todo::before {
  background: var(--cinnabar);
}

.maintenance-card.ok {
  background: linear-gradient(135deg, rgba(255, 252, 242, 0.86), rgba(65, 97, 75, 0.09));
}

.maintenance-card.ok::before {
  background: var(--moss);
}

.memory-niche h3,
.answer-card h3,
.mini-card b {
  display: block;
  margin: 0 0 8px;
  color: var(--wood);
  font-size: 22px;
}

.memory-niche p,
.answer-card p,
.mini-card span {
  margin: 0 0 12px;
  color: #56493f;
  font-family: var(--kai);
  line-height: 1.75;
}

.facts {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 6px 10px;
  margin: 14px 0;
  padding: 12px;
  background: rgba(255,255,255,0.32);
}

.facts.compact {
  grid-template-columns: 52px 1fr;
}

.facts dt {
  color: var(--muted);
  font-family: var(--kai);
}

.facts dd {
  margin: 0;
}

.question-list {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}

.question-list span {
  padding: 8px 10px;
  color: #5c4c3e;
  border-left: 3px solid var(--gold);
  background: rgba(255,255,255,0.28);
  font-family: var(--kai);
}

.processing-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.processing-job {
  display: grid;
  grid-template-columns: 112px 88px 1fr;
  gap: 8px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid rgba(84, 56, 30, 0.16);
  background: rgba(255,255,255,0.28);
  font-family: var(--kai);
}

.production-flow {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid rgba(84, 56, 30, 0.18);
  background: linear-gradient(135deg, rgba(255,255,255,0.34), rgba(235, 218, 178, 0.22));
}

.production-flow p {
  margin: 6px 0 10px;
}

.production-flow ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-family: var(--kai);
}

.destination-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.destination-pill {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(155, 48, 38, 0.18);
  color: inherit;
  text-decoration: none;
  background: rgba(255,255,255,0.36);
}

.destination-pill b {
  color: var(--cinnabar);
}

.destination-pill span {
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.processing-job b {
  color: var(--wood);
}

.processing-job span {
  color: var(--cinnabar);
}

.processing-job.done span {
  color: var(--moss);
}

.processing-job.failed span {
  color: #8c1f16;
}

.processing-job em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.5;
}

.file-link {
  display: inline-flex;
  margin: 0 0 10px;
  color: var(--cinnabar);
  font-family: var(--kai);
}

.answer-card ul {
  margin: 8px 0 18px;
  padding-left: 20px;
  color: #56493f;
  font-family: var(--kai);
  line-height: 1.8;
}

.followup-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(84, 56, 30, 0.2);
  background: rgba(255, 248, 231, 0.68);
}

.followup-box pre {
  white-space: pre-wrap;
  margin: 8px 0 12px;
  color: #4e3f34;
  font: 15px/1.75 var(--kai);
}

.reply-box {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(84, 56, 30, 0.18);
  background: rgba(255,255,255,0.24);
}

.reply-box label {
  color: var(--muted);
  font-family: var(--kai);
}

.reply-box textarea {
  min-height: 96px;
  padding: 10px 12px;
  border: 1px solid rgba(84, 56, 30, 0.24);
  background: rgba(255, 252, 242, 0.78);
  font: 15px/1.7 var(--kai);
  resize: vertical;
}

/* .prompt-row legacy removed for ritual */
/* .prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.ancestral-grid {
  display: grid;
  gap: 14px;
}

.ancestral-slot {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 16px;
  align-items: center;
  padding: 18px;
  color: #f4e5c8;
  border: 1px solid rgba(231, 205, 150, 0.28);
  background:
    linear-gradient(145deg, rgba(23, 24, 22, 0.95), rgba(79, 42, 29, 0.86)),
    var(--night);
  box-shadow: inset 0 0 46px rgba(185, 143, 74, 0.13);
}

.ancestral-slot img,
.ancestral-tablet {
  width: 108px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 1px solid rgba(244, 223, 192, 0.36);
  background: #211814;
}

.ancestral-tablet {
  display: grid;
  place-items: center;
  color: #f2d7a7;
  font-size: 48px;
  box-shadow: inset 0 0 34px rgba(185, 143, 74, 0.14);
}

.ancestral-slot h3 {
  margin: 0 0 8px;
  color: #f6dfb4;
  font-size: 30px;
}

.ancestral-slot p {
  margin: 0 0 12px;
  color: #d8c8aa;
  font-family: var(--kai);
  line-height: 1.7;
}

.festival-card {
  border-left: 4px solid var(--moss);
}

.festival-card.urgent {
  border-left-color: var(--cinnabar);
}

.announcement-card {
  display: grid;
  gap: 6px;
  text-decoration: none;
}

.announcement-card em {
  width: max-content;
  padding: 3px 8px;
  color: var(--cinnabar);
  border: 1px solid rgba(84, 56, 30, 0.18);
  background: rgba(255, 252, 242, 0.58);
  font: 13px/1 var(--kai);
}

.voice-asset-card {
  border-left: 4px solid var(--moss);
}

.voice-reading-card pre {
  white-space: pre-wrap;
  margin: 14px 0;
  padding: 16px;
  color: #3d3028;
  border: 1px solid rgba(84, 56, 30, 0.18);
  background: rgba(255, 252, 242, 0.62);
  font: 17px/1.9 var(--kai);
}

.readiness-score {
  width: min(320px, 100%);
  text-align: center;
}

.readiness-score strong {
  display: block;
  color: var(--cinnabar);
  font-size: 72px;
  line-height: 1;
}

.production-score strong {
  color: var(--moss);
}

.readiness-score span {
  color: var(--muted);
  font-family: var(--kai);
}

.package-card,
.readiness-item {
  display: grid;
  gap: 5px;
  text-decoration: none;
}

.package-card {
  border-left: 4px solid var(--moss);
}

.readiness-group {
  display: grid;
  gap: 10px;
}

.readiness-item {
  padding: 12px;
  border: 1px solid rgba(84, 56, 30, 0.16);
  background: rgba(255, 252, 242, 0.42);
}

.readiness-item.ok {
  border-left: 4px solid var(--moss);
}

.readiness-item.todo {
  border-left: 4px solid var(--gold);
}

.readiness-item b {
  color: var(--wood);
}

.readiness-item span {
  color: #56493f;
  font-family: var(--kai);
  line-height: 1.6;
}

.family-hero .stage {
  background:
    radial-gradient(circle at 42% 38%, rgba(244, 223, 192, 0.18), transparent 15rem),
    linear-gradient(145deg, #1b1714, #4b2d22 48%, #171817);
}

.identity-card {
  width: min(380px, 100%);
  border-color: rgba(231, 205, 150, 0.34);
  background:
    linear-gradient(135deg, rgba(255, 252, 242, 0.92), rgba(216, 195, 155, 0.76));
}

.identity-card h3 {
  color: var(--wood);
  font-size: 34px;
}

.identity-card p {
  color: #58483b;
  font-family: var(--kai);
  line-height: 1.75;
}

.family-prompt {
  position: relative;
  overflow: hidden;
}

.family-prompt::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 4px;
  background: linear-gradient(90deg, var(--cinnabar), var(--gold), var(--moss));
}

@media (max-width: 850px) {
  .shell { width: 100%; padding-top: 0; }
  .topbar { border-width: 0 0 1px; }
  .hero, .workbench, .journey-v03, .hall-gate { grid-template-columns: 1fr; }
  .form-row, .record-grid, .inline-card-grid, .menu-preview { grid-template-columns: 1fr; }
  .stage-rail, .evidence-grid, .journey-columns, .agent-role-grid { grid-template-columns: 1fr; }
  .journey-summary { position: static; }
  .processing-job { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; padding: 16px; }
  .page { margin-top: 0; border-width: 0; }
  .nav { justify-content: flex-start; }
  .hall-door {
    min-height: 72vh;
    border-right: 0;
    border-bottom: 1px solid rgba(231, 205, 150, 0.2);
  }
  .door-panels span {
    min-height: 210px;
  }
  .ancestral-slot { grid-template-columns: 82px 1fr; }
  .ancestral-slot img, .ancestral-tablet { width: 82px; }
}

/* GOAL_GATE_REV=8 weather-overlay
动态天气与环境 - 扩展到堂前/传记，与墓碑一致的广州天河 + 诞寿日氛围（subtle for hall） - FINAL harness-visible [source edit for harness] */
.weather-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.12;
  overflow: hidden;
}
.weather-overlay.rain::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(135deg, transparent, transparent 2px, rgba(170,200,240,0.25) 2px, rgba(170,200,240,0.25) 5px);
  animation: rain-fall 0.7s linear infinite;
}
.weather-overlay.wind-leaves::before {
  content: '🍂';
  position: absolute;
  font-size: 14px;
  opacity: 0.35;
  animation: leaf-fall 5s linear infinite;
  left: 8%;
}
.weather-overlay.special-day {
  box-shadow: inset 0 0 80px rgba(255, 195, 90, 0.18);
  opacity: 0.18;
}
@keyframes rain-fall { 0% { background-position: 0 0; } 100% { background-position: 0 50px; } }
@keyframes leaf-fall { 0% { top: -5%; } 100% { top: 105%; transform: rotate(90deg); } }

/* P0 mobile hall stack: keep both the door and the scroll in one readable column. */
@media (max-width: 850px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  .hall-gate {
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
  }

  .hall-door,
  .hall-gate-copy {
    width: 100%;
    min-width: 0;
  }

  .hall-gate-copy {
    padding: 34px 24px 42px;
  }

  .hall-gate-copy h1 {
    max-width: 100%;
    font-size: clamp(38px, 12vw, 58px);
  }
}

/* Memory Agent: a quiet evidence desk, not a generic chat window. */
.memory-agent-page {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.28fr);
  min-height: calc(100vh - 132px);
  overflow: hidden;
}

.memory-agent-intro {
  position: relative;
  padding: clamp(34px, 5vw, 68px);
  color: #f2e4c7;
  background:
    radial-gradient(circle at 48% 24%, rgba(231, 202, 145, 0.13), transparent 18rem),
    linear-gradient(150deg, #171714, #35342d 56%, #171715);
}

.memory-agent-intro::after {
  position: absolute;
  inset: 28px;
  content: "";
  pointer-events: none;
  border: 1px solid rgba(221, 193, 136, 0.18);
}

.memory-agent-intro > * {
  position: relative;
  z-index: 1;
}

.memory-agent-intro h1 {
  max-width: 5em;
  font-size: clamp(46px, 5vw, 72px);
  line-height: 1.12;
}

.memory-lead {
  margin: 24px 0 0;
  color: #d9cbb2;
  font: 18px/1.9 var(--kai);
}

.memory-boundary {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 14px;
  align-items: start;
  margin-top: 38px;
  padding-top: 22px;
  border-top: 1px solid rgba(221, 193, 136, 0.18);
}

.memory-boundary > span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #f2d9a7;
  border: 1px solid rgba(221, 193, 136, 0.5);
  font-family: var(--kai);
}

.memory-boundary p {
  margin: 0;
  color: #cbbda5;
  font: 15px/1.75 var(--kai);
}

.memory-agent-workspace {
  min-width: 0;
  padding: clamp(28px, 5vw, 62px);
  background:
    linear-gradient(90deg, rgba(112, 76, 42, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(112, 76, 42, 0.05) 1px, transparent 1px),
    linear-gradient(135deg, rgba(245, 237, 219, 0.98), rgba(220, 202, 165, 0.96));
  background-size: 32px 32px, 32px 32px, auto;
}

.memory-ask-form {
  display: grid;
  gap: 14px;
}

.memory-ask-form > label {
  color: var(--cinnabar);
  font-family: var(--kai);
  letter-spacing: 0.12em;
}

.memory-ask-form textarea {
  width: 100%;
  min-height: 132px;
  padding: 18px 20px;
  color: var(--ink);
  border: 1px solid rgba(84, 56, 30, 0.3);
  outline: none;
  background: rgba(255, 253, 247, 0.72);
  box-shadow: inset 0 12px 30px rgba(93, 61, 34, 0.05);
  font: 18px/1.8 var(--serif);
  resize: vertical;
}

.memory-ask-form textarea:focus {
  border-color: rgba(155, 48, 38, 0.66);
  box-shadow: 0 0 0 3px rgba(155, 48, 38, 0.1);
}

.memory-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.memory-prompts button {
  min-height: 40px;
  padding: 8px 12px;
  color: #665445;
  border: 1px solid rgba(84, 56, 30, 0.2);
  background: rgba(255, 252, 242, 0.48);
  font: 14px var(--kai);
  cursor: pointer;
}

.memory-prompts button:hover {
  color: var(--cinnabar);
  border-color: rgba(155, 48, 38, 0.42);
}

.memory-submit-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
}

.memory-submit-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font: 13px var(--kai);
}

.memory-submit-row .memory-submit-button {
  display: inline-grid;
  grid-template-columns: 34px auto;
  min-width: 156px;
  min-height: 50px;
  padding: 7px 18px 7px 8px;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(91, 25, 19, 0.2);
}

.memory-submit-button > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255, 238, 210, 0.64);
  font-family: var(--serif);
}

.memory-submit-button > strong {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.memory-submit-row .button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.memory-status {
  min-height: 24px;
  margin: 16px 0 0;
  color: #6f5c49;
  font: 15px/1.6 var(--kai);
}

.memory-answer-board {
  scroll-margin-top: 18px;
  margin-top: 28px;
  padding-top: 26px;
  border-top: 1px solid rgba(84, 56, 30, 0.22);
}

.memory-answer-board[hidden] {
  display: none;
}

.memory-answer-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.memory-answer-heading .eyebrow {
  margin-bottom: 8px;
}

.memory-answer-heading h2 {
  max-width: 12em;
  font-size: clamp(26px, 3vw, 40px);
  line-height: 1.35;
}

.memory-evidence-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  color: #6c532a;
  border: 1px solid rgba(185, 143, 74, 0.44);
  background: rgba(185, 143, 74, 0.1);
  font: 13px var(--kai);
}

.memory-evidence-badge.is-grounded {
  color: #365443;
  border-color: rgba(67, 93, 77, 0.42);
  background: rgba(67, 93, 77, 0.1);
}

.memory-evidence-badge.is-insufficient {
  color: #87352c;
  border-color: rgba(155, 48, 38, 0.38);
  background: rgba(155, 48, 38, 0.08);
}

.memory-answer-copy {
  margin-top: 22px;
  padding: 20px;
  white-space: pre-wrap;
  color: #3f342b;
  border-left: 4px solid var(--gold);
  background: rgba(255, 253, 247, 0.52);
  font: 17px/1.9 var(--serif);
}

.memory-result-section {
  margin-top: 26px;
}

.memory-result-section h3 {
  margin-bottom: 12px;
  color: var(--wood);
  font-size: 22px;
}

.memory-source-grid,
.memory-agent-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.memory-source-card,
.memory-agent-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(84, 56, 30, 0.18);
  background: rgba(255, 253, 247, 0.48);
}

.memory-source-card strong,
.memory-agent-card strong {
  color: var(--wood);
}

.memory-source-card p,
.memory-agent-card p {
  margin: 0;
  color: #65564a;
  font: 14px/1.7 var(--kai);
}

.memory-source-card span,
.memory-agent-card span {
  color: var(--cinnabar);
  font: 13px var(--kai);
}

.memory-agent-cards {
  margin-top: 14px;
}

.memory-agent-card.is-collection {
  border-left: 4px solid var(--cinnabar);
}

.memory-followups {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
  color: #56493f;
  font: 15px/1.7 var(--kai);
}

.memory-disclaimer {
  margin: 20px 0 0;
  color: #786b60;
  font: 13px/1.7 var(--kai);
}

@media (max-width: 850px) {
  .memory-agent-page {
    grid-template-columns: minmax(0, 1fr);
  }

  .memory-agent-intro {
    padding: 38px 26px 42px;
  }

  .memory-agent-intro::after {
    inset: 14px;
  }

  .memory-agent-intro h1 {
    font-size: 46px;
  }

  .memory-agent-workspace {
    padding: 30px 18px 44px;
  }

  .memory-source-grid,
  .memory-agent-cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .memory-answer-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .memory-submit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .memory-submit-row .memory-submit-button {
    width: 100%;
  }

  .memory-submit-meta {
    display: flex;
    justify-content: space-between;
  }
}

/* Voice Agent: one quiet conversation surface, not a navigation dashboard. */
.voice-agent-body {
  min-height: 100vh;
  color: #2a211b;
  background:
    radial-gradient(circle at 22% 4%, rgba(170, 113, 67, 0.22), transparent 28rem),
    linear-gradient(145deg, #1d1714, #512c22 54%, #151615);
}

.voice-agent-shell {
  width: min(940px, calc(100% - 28px));
  min-height: calc(100vh - 36px);
  margin: 18px auto;
  overflow: visible;
  border: 1px solid rgba(236, 211, 160, 0.24);
  background: #eee1c7;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
}

.voice-agent-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 66px;
  padding: 10px 14px;
  color: #f4e6ca;
  border-bottom: 1px solid rgba(232, 203, 148, 0.22);
  background: rgba(29, 23, 20, 0.96);
  backdrop-filter: blur(14px);
}

.voice-icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  color: #f3dfbb;
  border: 1px solid rgba(236, 211, 160, 0.26);
  background: transparent;
  font: 30px/1 var(--serif);
  cursor: pointer;
  list-style: none;
}

.voice-icon-button::-webkit-details-marker {
  display: none;
}

.voice-agent-title {
  display: grid;
  gap: 3px;
  text-align: center;
}

.voice-agent-title strong {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.voice-agent-title span {
  color: #bfae93;
  font: 12px var(--kai);
}

.voice-agent-menu {
  position: relative;
}

.voice-agent-menu nav {
  position: absolute;
  top: 50px;
  right: 0;
  display: grid;
  width: 160px;
  padding: 6px;
  border: 1px solid rgba(236, 211, 160, 0.28);
  background: #251c18;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
}

.voice-agent-menu nav a {
  padding: 11px 13px;
  color: #ead9bd;
  border-bottom: 1px solid rgba(236, 211, 160, 0.12);
  font: 14px var(--kai);
}

.voice-agent-menu nav a:last-child {
  border-bottom: 0;
}

.voice-agent-main {
  min-height: calc(100vh - 104px);
  padding: clamp(18px, 4vw, 36px);
  background:
    linear-gradient(90deg, rgba(112, 76, 42, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(112, 76, 42, 0.05) 1px, transparent 1px),
    linear-gradient(140deg, #f3ead8, #dcc49b);
  background-size: 32px 32px, 32px 32px, auto;
}

.voice-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(360px, 100%);
  margin: 0 auto 22px;
  padding: 3px;
  border: 1px solid rgba(77, 47, 29, 0.2);
  background: rgba(255, 252, 243, 0.46);
}

.voice-mode-switch button {
  min-height: 42px;
  color: #725e4e;
  border: 0;
  background: transparent;
  font: 15px var(--kai);
  cursor: pointer;
}

.voice-mode-switch button[aria-selected="true"] {
  color: #fff5df;
  background: #873329;
  box-shadow: 0 5px 14px rgba(89, 35, 27, 0.18);
}

.voice-mode-panel[hidden] {
  display: none;
}

.voice-conversation {
  display: grid;
  gap: 14px;
  width: min(720px, 100%);
  margin: 0 auto;
}

.voice-message {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  width: min(610px, 94%);
  padding: 16px;
  border: 1px solid rgba(76, 50, 31, 0.16);
  background: rgba(255, 253, 247, 0.7);
  box-shadow: 0 12px 34px rgba(74, 49, 27, 0.08);
}

.voice-message p {
  margin: 0;
  color: #3e332b;
  font: 16px/1.8 var(--kai);
}

.voice-message small {
  display: block;
  margin-top: 7px;
  color: #75675b;
  font: 13px/1.65 var(--kai);
}

.voice-message h2 {
  margin: 6px 0 8px;
  font-size: 24px;
  line-height: 1.35;
}

.voice-message-seal {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #8d342a;
  border: 1px solid rgba(141, 52, 42, 0.46);
  font-family: var(--serif);
}

.voice-message.is-result {
  width: 100%;
  border-left: 4px solid #8d342a;
}

.voice-agent-kicker,
.voice-agent-route {
  color: #8a392f !important;
}

.voice-fact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.voice-fact-row span {
  padding: 5px 8px;
  color: #55483d;
  border: 1px solid rgba(76, 50, 31, 0.16);
  background: #f7efdf;
  font: 12px var(--kai);
}

.voice-followup-title {
  display: block;
  margin: 13px 0 8px;
  color: #4a392e;
  font: 14px var(--kai);
}

.voice-followup-list {
  display: grid;
  gap: 6px;
}

.voice-followup-list button {
  padding: 9px 10px;
  color: #5f4a3b;
  border: 1px solid rgba(76, 50, 31, 0.16);
  background: rgba(246, 236, 216, 0.68);
  text-align: left;
  font: 13px/1.55 var(--kai);
  cursor: pointer;
}

.voice-composer {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: grid;
  gap: 10px;
  width: min(720px, 100%);
  margin: 18px auto 0;
  padding: 12px;
  border: 1px solid rgba(76, 50, 31, 0.22);
  background: rgba(255, 252, 242, 0.96);
  box-shadow: 0 -10px 32px rgba(73, 45, 25, 0.1);
}

.voice-submission-receipt {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 14px;
  width: min(720px, 100%);
  margin: 16px auto 0;
  padding: 16px;
  color: #2d3128;
  border: 1px solid rgba(67, 93, 77, 0.34);
  border-left: 5px solid #435d4d;
  background: rgba(246, 242, 225, 0.97);
  box-shadow: 0 16px 38px rgba(48, 57, 43, 0.13);
}

.voice-submission-receipt[hidden] {
  display: none;
}

.voice-receipt-seal {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #f5ecd7;
  background: #435d4d;
  font: 20px var(--serif);
}

.voice-receipt-body {
  min-width: 0;
}

.voice-receipt-body > p {
  margin: 0 0 4px;
  color: #526556;
  font: 12px var(--kai);
}

.voice-receipt-body h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.45;
}

.voice-receipt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 9px 0;
  color: #635d50;
  font: 12px/1.5 var(--kai);
}

.voice-receipt-body > strong {
  display: block;
  color: #315041;
  font: 13px/1.5 var(--serif);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.voice-receipt-body > small {
  display: block;
  margin-top: 5px;
  color: #786f61;
  font: 12px/1.55 var(--kai);
}

.voice-submission-receipt > button {
  align-self: center;
}

.voice-composer textarea {
  width: 100%;
  min-height: 74px;
  max-height: 180px;
  padding: 12px 13px;
  color: #332820;
  border: 0;
  outline: none;
  background: transparent;
  font: 16px/1.65 var(--kai);
  resize: vertical;
}

.voice-composer textarea:focus {
  box-shadow: inset 0 -2px #9b3026;
}

.voice-composer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.voice-input-tools {
  display: flex;
  align-items: center;
  gap: 7px;
}

.voice-tool-button,
.voice-send-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid rgba(76, 50, 31, 0.22);
  font: 14px var(--kai);
  cursor: pointer;
}

.voice-tool-button {
  color: #59483a;
  background: #f4ead6;
}

.voice-tool-button.is-recording {
  color: #fff7e8;
  border-color: #9b3026;
  background: #9b3026;
}

.voice-tool-button.is-recording > span:first-child {
  animation: voice-record-pulse 1.1s ease-in-out infinite;
}

@keyframes voice-record-pulse {
  50% { opacity: 0.35; }
}

.voice-send-button {
  min-width: 98px;
  color: #fff6e4;
  border-color: #8d342a;
  background: #8d342a;
}

.voice-send-button b {
  font-size: 18px;
  font-weight: 400;
}

.voice-send-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.voice-record-time {
  color: #9b3026;
  font: 13px/1 var(--serif);
  font-variant-numeric: tabular-nums;
}

.voice-attachment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  color: #5f5045;
  border-left: 3px solid #b98f4a;
  background: #f2e5ce;
  font: 13px var(--kai);
}

.voice-attachment[hidden] {
  display: none;
}

.voice-attachment button {
  width: 28px;
  height: 28px;
  padding: 0;
  color: #7a3c34;
  border: 0;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
}

.voice-recording-preview {
  width: 100%;
  height: 42px;
}

.voice-agent-status {
  min-height: 20px;
  margin: 0;
  color: #76685d;
  font: 12px/1.55 var(--kai);
}

.voice-source-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.voice-source-list > .eyebrow,
.voice-source-list > .voice-empty-note {
  grid-column: 1 / -1;
}

.voice-source-button {
  display: grid;
  gap: 7px;
  min-height: 110px;
  padding: 14px;
  color: #382c24;
  border: 1px solid rgba(76, 50, 31, 0.18);
  background: rgba(255, 253, 247, 0.68);
  text-align: left;
  cursor: pointer;
}

.voice-source-button strong {
  font: 17px/1.4 var(--serif);
}

.voice-source-button span {
  color: #74665b;
  font: 13px/1.65 var(--kai);
}

.voice-reading-result {
  padding: 20px;
  border-top: 4px solid #b98f4a;
  background: rgba(255, 253, 247, 0.76);
  box-shadow: 0 18px 45px rgba(73, 45, 25, 0.09);
}

.voice-reading-result[hidden] {
  display: none;
}

.voice-reading-result h2 {
  font-size: 28px;
}

.voice-reading-result > div:not(.voice-reading-actions) {
  margin-top: 16px;
  white-space: pre-wrap;
  color: #3f342b;
  font: 16px/1.9 var(--kai);
}

.voice-reading-result > p:last-child,
.voice-empty-note {
  color: #796b60;
  font: 12px/1.65 var(--kai);
}

.voice-reading-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

@media (max-width: 700px) {
  .voice-agent-shell {
    width: 100%;
    min-height: 100dvh;
    margin: 0;
    border: 0;
    box-shadow: none;
  }

  .voice-agent-topbar {
    min-height: 62px;
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .voice-agent-main {
    min-height: calc(100dvh - 62px);
    padding: 16px 14px calc(18px + env(safe-area-inset-bottom));
  }

  .voice-mode-switch {
    margin-bottom: 16px;
  }

  .voice-message {
    width: 96%;
    padding: 14px;
  }

  .voice-composer {
    margin-top: 14px;
    padding: 10px;
  }

  .voice-submission-receipt {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px;
    padding: 13px;
  }

  .voice-submission-receipt > button {
    grid-column: 2;
    justify-self: start;
  }

  .voice-composer textarea {
    min-height: 92px;
  }

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

  .voice-input-tools {
    gap: 5px;
  }

  .voice-tool-button {
    padding: 8px 9px;
  }
}

/* Agentic chat: conversation is the product; structured UI appears only on demand. */
.voice-chat-body {
  min-height: 100vh;
  overflow: hidden;
  color: #2c241e;
  background: #211a17;
}

.voice-chat-body,
.voice-chat-body * {
  letter-spacing: 0;
}

.voice-chat-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(920px, calc(100% - 32px));
  height: calc(100dvh - 32px);
  margin: 16px auto;
  overflow: hidden;
  border: 1px solid rgba(226, 203, 163, 0.26);
  background: #e8dcc4;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.voice-chat-topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  min-height: 62px;
  padding: 8px 14px;
  color: #f2e5c9;
  border-bottom: 1px solid rgba(225, 198, 151, 0.2);
  background: #201a17;
}

.voice-chat-icon {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  color: #f0dfbe;
  border: 1px solid rgba(226, 203, 163, 0.3);
  background: transparent;
  font: 26px/1 var(--serif);
  cursor: pointer;
  list-style: none;
}

.voice-chat-icon::-webkit-details-marker {
  display: none;
}

.voice-chat-heading {
  display: grid;
  gap: 2px;
  text-align: center;
}

.voice-chat-heading strong {
  font: 500 17px/1.3 var(--serif);
}

.voice-chat-heading span {
  color: #aeb7a7;
  font: 12px/1.3 var(--kai);
}

.voice-chat-menu {
  position: relative;
}

.voice-chat-menu nav {
  position: absolute;
  top: 49px;
  right: 0;
  display: grid;
  width: 172px;
  padding: 6px;
  border: 1px solid rgba(226, 203, 163, 0.28);
  background: #27201c;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}

.voice-chat-menu nav a,
.voice-chat-menu nav button {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: #eadcc0;
  border: 0;
  border-bottom: 1px solid rgba(226, 203, 163, 0.12);
  background: transparent;
  text-align: left;
  font: 14px/1.4 var(--kai);
  cursor: pointer;
}

.voice-chat-menu nav > :last-child {
  border-bottom: 0;
}

.voice-chat-thread {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 22px max(18px, calc((100% - 720px) / 2)) 28px;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  background-color: #e8dcc4;
  background-image:
    linear-gradient(rgba(100, 71, 43, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 71, 43, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
}

.voice-chat-day {
  margin: 0 0 18px;
  color: #7c6e5f;
  text-align: center;
  font: 12px/1.4 var(--kai);
}

.voice-chat-message {
  display: flex;
  width: 100%;
  margin: 0 0 14px;
  align-items: flex-start;
  gap: 9px;
}

.voice-chat-message.is-user {
  justify-content: flex-end;
}

.voice-chat-avatar {
  display: grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #f2e6cc;
  border: 1px solid #664c37;
  background: #35483d;
  font: 15px/1 var(--serif);
}

.voice-chat-bubble {
  max-width: min(78%, 560px);
  padding: 11px 13px;
  border: 1px solid rgba(83, 59, 39, 0.14);
  border-radius: 6px;
  background: rgba(255, 252, 244, 0.92);
  box-shadow: 0 6px 18px rgba(74, 49, 29, 0.07);
}

.voice-chat-message.is-user .voice-chat-bubble {
  color: #fff8e9;
  border-color: #873329;
  background: #873329;
}

.voice-chat-message.is-unsent .voice-chat-bubble {
  border-color: #b13b31;
  opacity: 0.68;
}

.voice-chat-bubble p {
  margin: 0;
  font: 16px/1.65 var(--kai);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.voice-chat-bubble small {
  display: block;
  margin-top: 6px;
  color: #74685d;
  font: 12px/1.55 var(--kai);
}

.voice-chat-message.is-user .voice-chat-bubble small {
  color: #eadac4;
}

.voice-chat-summary {
  font-size: 13px !important;
}

.voice-chat-question-label {
  margin-top: 10px !important;
  color: #4a5f50 !important;
}

.voice-chat-question-list {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.voice-chat-question-list button,
.voice-chat-retry {
  min-height: 38px;
  padding: 8px 10px;
  color: #5c493a;
  border: 1px solid rgba(83, 59, 39, 0.18);
  background: #f2e7d1;
  text-align: left;
  font: 13px/1.45 var(--kai);
  cursor: pointer;
}

.voice-chat-result-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 9px;
  border-top: 1px solid rgba(83, 59, 39, 0.13);
}

.voice-chat-result-foot span {
  color: #697268;
  font: 11px/1.4 var(--serif);
  font-variant-numeric: tabular-nums;
}

.voice-chat-result-foot button {
  min-height: 36px;
  padding: 6px 9px;
  color: #8b352b;
  border: 1px solid rgba(139, 53, 43, 0.28);
  background: transparent;
  font: 13px/1.4 var(--kai);
  cursor: pointer;
}

.voice-chat-message.is-error .voice-chat-bubble {
  border-left: 3px solid #9b3026;
}

.voice-chat-message.is-typing .voice-chat-bubble {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
}

.voice-typing-label {
  color: #6c6157;
  font: 13px/1.4 var(--kai);
}

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

.voice-typing-dots i {
  width: 5px;
  height: 5px;
  background: #6d7d70;
  animation: voice-chat-dot 1s ease-in-out infinite;
}

.voice-typing-dots i:nth-child(2) { animation-delay: 0.14s; }
.voice-typing-dots i:nth-child(3) { animation-delay: 0.28s; }

@keyframes voice-chat-dot {
  50% { opacity: 0.28; transform: translateY(-2px); }
}

.voice-chat-composer {
  position: relative;
  z-index: 15;
  width: 100%;
  padding: 10px max(18px, calc((100% - 720px) / 2)) calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(83, 59, 39, 0.17);
  background: rgba(246, 239, 224, 0.98);
  box-shadow: 0 -8px 28px rgba(73, 46, 26, 0.08);
}

.voice-chat-input-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px 42px;
  gap: 7px;
  align-items: end;
}

.voice-chat-icon.is-composer,
.voice-chat-send {
  width: 42px;
  height: 42px;
  color: #58473a;
  border: 1px solid rgba(83, 59, 39, 0.2);
  background: #eee2ca;
  font-size: 19px;
}

.voice-chat-icon.is-composer.is-recording {
  color: #fff5df;
  border-color: #94372d;
  background: #94372d;
}

.voice-chat-send {
  display: grid;
  padding: 0;
  place-items: center;
  color: #fff7e8;
  border-color: #873329;
  background: #873329;
  font: 20px/1 var(--serif);
  cursor: pointer;
}

.voice-chat-send:disabled,
.voice-chat-icon:disabled {
  cursor: wait;
  opacity: 0.52;
}

.voice-chat-input-row textarea {
  width: 100%;
  min-height: 42px;
  max-height: 116px;
  padding: 9px 11px;
  color: #302720;
  border: 1px solid rgba(83, 59, 39, 0.2);
  border-radius: 6px;
  outline: none;
  background: #fffdf7;
  font: 16px/1.45 var(--kai);
  resize: none;
}

.voice-chat-input-row textarea:focus {
  border-color: rgba(135, 51, 41, 0.62);
  box-shadow: 0 0 0 2px rgba(135, 51, 41, 0.08);
}

.voice-chat-attachment {
  display: flex;
  max-width: 100%;
  min-height: 34px;
  margin: 0 0 7px 49px;
  padding: 6px 8px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #584a3f;
  border-left: 3px solid #b58b4b;
  background: #eadcc2;
  font: 12px/1.4 var(--kai);
}

.voice-chat-attachment[hidden],
.voice-chat-preview[hidden],
.voice-chat-status[hidden] {
  display: none;
}

.voice-chat-attachment button {
  width: 28px;
  height: 28px;
  padding: 0;
  color: #7e3e35;
  border: 0;
  background: transparent;
  font-size: 19px;
  cursor: pointer;
}

.voice-chat-preview {
  width: calc(100% - 49px);
  height: 36px;
  margin: 0 0 7px 49px;
}

.voice-chat-status {
  margin: 0 0 7px 49px;
  color: #98382e;
  font: 12px/1.4 var(--kai);
}

.voice-chat-status[data-tone="ok"] {
  color: #435d4d;
}

.voice-chat-composer-foot {
  display: flex;
  min-height: 17px;
  margin: 5px 49px 0;
  align-items: center;
  justify-content: space-between;
  color: #887b6e;
  font: 10px/1.3 var(--kai);
}

.voice-chat-dialog {
  width: min(640px, calc(100% - 28px));
  max-height: min(760px, calc(100dvh - 40px));
  padding: 0;
  overflow: auto;
  color: #2c241e;
  border: 1px solid rgba(226, 203, 163, 0.48);
  border-radius: 6px;
  background: #f4ead7;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

.voice-chat-dialog::backdrop {
  background: rgba(20, 16, 14, 0.72);
  backdrop-filter: blur(2px);
}

.voice-dialog-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  min-height: 66px;
  padding: 12px 14px;
  align-items: center;
  justify-content: space-between;
  color: #f2e5c9;
  border-bottom: 1px solid rgba(226, 203, 163, 0.2);
  background: #201a17;
}

.voice-dialog-head p {
  margin: 0 0 2px;
  color: #b7c1b2;
  font: 11px/1.3 var(--kai);
}

.voice-dialog-head h2,
.voice-dialog-head h3 {
  margin: 0;
  color: #f2e5c9;
  font: 500 20px/1.35 var(--serif);
}

.voice-dialog-summary {
  margin: 0;
  padding: 20px 20px 8px;
  color: #41362d;
  font: 16px/1.75 var(--kai);
}

.voice-dialog-facts {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  margin: 10px 20px;
  border-top: 1px solid rgba(83, 59, 39, 0.14);
}

.voice-dialog-facts dt,
.voice-dialog-facts dd {
  margin: 0;
  padding: 9px 0;
  border-bottom: 1px solid rgba(83, 59, 39, 0.12);
  font: 13px/1.5 var(--kai);
}

.voice-dialog-facts dt { color: #7b6e62; }
.voice-dialog-facts dd { color: #392f27; }

.voice-dialog-file,
.voice-dialog-receipt,
.voice-dialog-status {
  margin: 12px 20px;
  color: #66594d;
  font: 12px/1.55 var(--kai);
}

.voice-dialog-route {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 20px;
}

.voice-dialog-route span {
  padding: 5px 7px;
  color: #3f5849;
  border: 1px solid rgba(63, 88, 73, 0.22);
  background: #e7e8d8;
  font: 11px/1.4 var(--kai);
}

.voice-listen-dialog .voice-source-list {
  grid-template-columns: minmax(0, 1fr);
  padding: 16px 20px;
}

.voice-listen-dialog .voice-source-button {
  min-height: 0;
  padding: 10px 4px;
  border: 0;
  border-bottom: 1px solid rgba(83, 59, 39, 0.15);
  border-radius: 0;
  background: transparent;
}

.voice-listen-dialog .voice-source-button strong {
  font-size: 15px;
}

.voice-listen-dialog .voice-source-button span {
  font-size: 12px;
  line-height: 1.5;
}

.voice-listen-dialog .voice-reading-result {
  margin: 0 20px 18px;
  padding: 16px;
  border-top-width: 3px;
  border-radius: 4px;
}

.voice-listen-dialog .voice-reading-result h3 {
  font: 500 20px/1.45 var(--serif);
}

.voice-chat-primary,
.voice-chat-secondary {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid rgba(83, 59, 39, 0.22);
  font: 14px/1.4 var(--kai);
  cursor: pointer;
}

.voice-chat-primary {
  color: #fff7e8;
  border-color: #873329;
  background: #873329;
}

.voice-chat-secondary {
  color: #58473a;
  background: #eee2ca;
}

@media (max-width: 700px) {
  .voice-chat-shell {
    width: 100%;
    height: 100dvh;
    margin: 0;
    border: 0;
    box-shadow: none;
  }

  .voice-chat-topbar {
    min-height: 58px;
    padding-top: max(7px, env(safe-area-inset-top));
  }

  .voice-chat-thread {
    padding: 16px 12px 20px;
  }

  .voice-chat-bubble {
    max-width: 84%;
  }

  .voice-chat-composer {
    padding: 8px 9px calc(8px + env(safe-area-inset-bottom));
  }

  .voice-chat-input-row {
    grid-template-columns: 42px minmax(0, 1fr) 42px 42px;
    gap: 5px;
  }

  .voice-chat-attachment,
  .voice-chat-preview,
  .voice-chat-status {
    margin-left: 47px;
  }

  .voice-chat-composer-foot {
    margin: 4px 47px 0;
  }

  .voice-chat-composer-foot > span:last-child {
    display: none;
  }

  .voice-chat-dialog {
    width: 100%;
    max-width: none;
    max-height: 82dvh;
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 6px 6px 0 0;
  }
}

@media (max-width: 350px) {
  .voice-chat-input-row {
    grid-template-columns: 40px minmax(0, 1fr) 40px 40px;
    gap: 4px;
  }

  .voice-chat-icon.is-composer,
  .voice-chat-send {
    width: 40px;
    height: 40px;
  }

  .voice-chat-bubble {
    max-width: 88%;
  }
}

/* Context Agent: visible on biography, hall and genealogy without replacing the page. */
.context-agent {
  position: fixed;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 80;
  letter-spacing: 0;
}

.context-agent-trigger {
  width: 52px;
  height: 52px;
  padding: 0;
  color: #f4e7cc;
  border: 1px solid rgba(230, 203, 157, 0.55);
  border-radius: 50%;
  background: #873329;
  box-shadow: 0 14px 34px rgba(28, 18, 12, 0.34);
  font: 20px/1 var(--serif);
  cursor: pointer;
}

.context-agent-panel {
  position: absolute;
  right: 0;
  bottom: 62px;
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto auto;
  width: min(390px, calc(100vw - 28px));
  height: min(620px, calc(100dvh - 100px));
  overflow: hidden;
  border: 1px solid rgba(226, 203, 163, 0.38);
  border-radius: 8px;
  background: #e8dcc4;
  box-shadow: 0 24px 70px rgba(16, 10, 7, 0.48);
}

.context-agent-panel[hidden] { display: none; }

.context-agent-head {
  display: flex;
  min-height: 58px;
  padding: 10px 12px;
  align-items: center;
  justify-content: space-between;
  color: #f3e7cf;
  background: #211a17;
}

.context-agent-head div { display: grid; gap: 2px; }
.context-agent-head strong { font: 500 16px/1.3 var(--serif); }
.context-agent-head span { color: #adb9aa; font: 11px/1.3 var(--kai); }

.context-agent-close {
  width: 38px;
  height: 38px;
  padding: 0;
  color: #f2e4c9;
  border: 1px solid rgba(226, 203, 163, 0.25);
  background: transparent;
  font-size: 22px;
  cursor: pointer;
}

.context-agent-thread {
  min-height: 0;
  padding: 14px 12px;
  overflow-y: auto;
  background-image:
    linear-gradient(rgba(100, 71, 43, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 71, 43, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
}

.context-agent-message {
  display: flex;
  margin: 0 0 11px;
  align-items: flex-start;
  gap: 7px;
}

.context-agent-message.is-user { justify-content: flex-end; }
.context-agent-message.is-pending { opacity: 0.72; }

.context-agent-avatar {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #efe3c9;
  background: #35483d;
  font: 13px/1 var(--serif);
}

.context-agent-bubble {
  max-width: 82%;
  margin: 0;
  padding: 9px 10px;
  color: #372e27;
  border: 1px solid rgba(83, 59, 39, 0.14);
  border-radius: 6px;
  background: rgba(255, 252, 244, 0.94);
  font: 14px/1.65 var(--kai);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.context-agent-message.is-user .context-agent-bubble {
  color: #fff8e9;
  border-color: #873329;
  background: #873329;
}

.context-agent-evidence { margin-top: 8px; padding-top: 7px; border-top: 1px solid rgba(83, 59, 39, 0.14); }
.context-agent-evidence summary { color: #7f352d; cursor: pointer; font-size: 12px; }
.context-agent-evidence p { margin: 7px 0 0; color: #6b5e53; font-size: 12px; }

.context-agent-prompts {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  border-top: 1px solid rgba(83, 59, 39, 0.12);
  background: #efe4cf;
}

.context-agent-prompts button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 9px;
  color: #5b493b;
  border: 1px solid rgba(83, 59, 39, 0.18);
  border-radius: 6px;
  background: #faf4e7;
  font: 12px/1.35 var(--kai);
  cursor: pointer;
}

.context-agent-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 7px;
  padding: 9px;
  border-top: 1px solid rgba(83, 59, 39, 0.16);
  background: #f3ead9;
}

.context-agent-form textarea {
  min-height: 42px;
  max-height: 96px;
  padding: 9px 10px;
  color: #302720;
  border: 1px solid rgba(83, 59, 39, 0.2);
  border-radius: 6px;
  outline: 0;
  background: #fffdf7;
  font: 15px/1.45 var(--kai);
  resize: none;
}

.context-agent-send {
  width: 42px;
  height: 42px;
  padding: 0;
  color: #fff7e8;
  border: 1px solid #873329;
  border-radius: 50%;
  background: #873329;
  font-size: 19px;
  cursor: pointer;
}

.ritual-agent-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 4px 0 18px 45px;
}

.ritual-agent-quick button,
.ritual-draft-open {
  min-height: 36px;
  padding: 7px 10px;
  color: #5b493b;
  border: 1px solid rgba(83, 59, 39, 0.2);
  border-radius: 6px;
  background: #f7efe0;
  font: 13px/1.4 var(--kai);
  cursor: pointer;
}

.ritual-draft-open {
  display: block;
  width: 100%;
  margin-top: 9px;
  text-align: left;
}

.ritual-draft-open {
  color: #f7ead4;
  border-color: #35483d;
  background: #35483d;
}

.ritual-followup-question {
  margin-top: 10px !important;
  padding-top: 9px;
  color: #67594d;
  border-top: 1px solid rgba(83, 59, 39, 0.14);
  font-size: 14px !important;
}

.ritual-agent-composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 7px;
  align-items: end;
}

.ritual-agent-composer-row textarea {
  width: 100%;
  min-height: 42px;
  max-height: 116px;
  padding: 9px 11px;
  color: #302720;
  border: 1px solid rgba(83, 59, 39, 0.2);
  border-radius: 6px;
  outline: none;
  background: #fffdf7;
  font: 16px/1.45 var(--kai);
  resize: none;
}

.ritual-draft-text {
  margin: 0;
  padding: 22px 20px 10px;
  color: #362d26;
  font: 17px/1.9 var(--kai);
  white-space: pre-wrap;
}

.ritual-draft-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 20px 20px;
}

.ritual-draft-actions button {
  min-height: 44px;
  padding: 8px;
  color: #f5e9d2;
  border: 1px solid #6e2c25;
  border-radius: 6px;
  background: #873329;
  font: 14px/1.4 var(--kai);
  cursor: pointer;
}

.memory-chat-source-list {
  display: grid;
  gap: 0;
  padding: 10px 20px;
}

.memory-chat-source {
  padding: 14px 0;
  border-bottom: 1px solid rgba(83, 59, 39, 0.14);
}

.memory-chat-source strong { color: #3d332b; font: 500 15px/1.4 var(--serif); }
.memory-chat-source p { margin: 6px 0; color: #66594d; font: 13px/1.7 var(--kai); }
.memory-chat-source a { color: #873329; font: 12px/1.4 var(--kai); }

@media (max-width: 700px) {
  .ritual-agent-quick { margin-left: 0; }
  .ritual-agent-quick button { flex: 1 1 calc(50% - 7px); }
  .ritual-draft-actions { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .context-agent { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .context-agent-panel { right: -2px; bottom: 60px; height: min(620px, calc(100dvh - 86px)); }
}
