:root {
  --paper: #f7f1e5;
  --paper-deep: #eee3cf;
  --ink: #211c17;
  --ink-soft: #635a4d;
  --line: rgba(48, 42, 35, 0.16);
  --qing: #9fb7ad;
  --dai: #314a4c;
  --cinnabar: #9d3528;
  --gold: #a37a36;
  --shadow: 0 24px 60px rgba(46, 37, 25, 0.12);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--serif);
  background:
    linear-gradient(90deg, rgba(49, 74, 76, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(49, 74, 76, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 16% 8%, rgba(163, 122, 54, 0.1), transparent 32%),
    radial-gradient(circle at 86% 10%, rgba(49, 74, 76, 0.1), transparent 28%),
    var(--paper);
  background-size: 42px 42px, 42px 42px, auto, auto, auto;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image:
    repeating-linear-gradient(0deg, rgba(33, 28, 23, 0.035), rgba(33, 28, 23, 0.035) 1px, transparent 1px, transparent 5px);
  mix-blend-mode: multiply;
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 241, 229, 0.88);
  backdrop-filter: blur(18px);
}

.brand,
.agent-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.seal {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: #fff8ed;
  background: var(--cinnabar);
  border: 1px solid rgba(75, 21, 16, 0.3);
  box-shadow: inset 0 0 0 4px rgba(255, 248, 237, 0.16);
  font-size: 24px;
  line-height: 1;
}

.seal.small {
  width: 38px;
  height: 38px;
  font-size: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cinnabar);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(20px, 2.5vw, 30px);
  font-weight: 700;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
}

.nav a {
  padding: 9px 12px;
  border: 1px solid transparent;
}

.nav a:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.24);
}

.nav a.active {
  color: #fffdf7;
  border-color: var(--dai);
  background: var(--dai);
}

main {
  padding: 0 clamp(16px, 4vw, 56px) 56px;
}

.memorial-portal {
  position: relative;
  min-height: calc(100vh - 86px);
  max-width: 1440px;
  margin: 0 auto;
  overflow: hidden;
  grid-template-columns: minmax(340px, 0.95fr) minmax(320px, 0.72fr);
  gap: clamp(20px, 4vw, 58px);
  align-items: stretch;
  padding: clamp(18px, 3vw, 34px) 0 clamp(26px, 4vw, 48px);
}

body[data-space="father"] .memorial-portal.space-father {
  display: grid;
}

body[data-space="father"]:not(.journey-entered) .hero.space-father,
body[data-space="father"]:not(.journey-entered) .agent-orchestrator,
body[data-space="father"]:not(.journey-entered) .workspace.space-father {
  display: none;
}

.portal-scene {
  position: relative;
  display: grid;
  min-height: min(760px, calc(100vh - 130px));
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(33, 28, 23, 0.18);
  background:
    linear-gradient(180deg, rgba(33, 28, 23, 0.08), transparent 26%),
    linear-gradient(90deg, rgba(49, 74, 76, 0.1), transparent 28%, transparent 72%, rgba(157, 53, 40, 0.08)),
    #e8ddc9;
  box-shadow: 0 32px 90px rgba(46, 37, 25, 0.18);
}

.portal-scene::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background:
    repeating-linear-gradient(90deg, rgba(33, 28, 23, 0.14), rgba(33, 28, 23, 0.14) 1px, transparent 1px, transparent 34px),
    linear-gradient(180deg, transparent, rgba(49, 74, 76, 0.16));
  opacity: 0.46;
}

.portal-sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.portal-sky span {
  position: absolute;
  top: 8%;
  bottom: 18%;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(157, 53, 40, 0.26), transparent);
}

.portal-sky span:first-child {
  left: 18%;
}

.portal-sky span:last-child {
  right: 16%;
}

.portal-gate {
  position: relative;
  width: min(520px, 86vw);
  min-height: min(690px, 76vh);
  perspective: 1400px;
}

.portal-gate::before {
  content: "";
  position: absolute;
  inset: 28px 26px;
  border: 1px solid rgba(255, 252, 245, 0.24);
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.86), rgba(198, 188, 171, 0.82)),
    var(--paper-deep);
  box-shadow: inset 0 0 46px rgba(49, 74, 76, 0.16);
}

.gate-leaf {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 3;
  border: 1px solid rgba(255, 248, 237, 0.12);
  background:
    repeating-linear-gradient(90deg, rgba(255, 248, 237, 0.045), rgba(255, 248, 237, 0.045) 1px, transparent 1px, transparent 22px),
    linear-gradient(180deg, #59402f, #2b211a 64%, #1f1814);
  transition: transform 920ms cubic-bezier(0.19, 1, 0.22, 1), box-shadow 920ms ease;
}

.gate-leaf::before {
  content: "王府";
  position: absolute;
  top: 42%;
  color: rgba(255, 248, 237, 0.76);
  font-size: clamp(28px, 4vw, 44px);
  writing-mode: vertical-rl;
}

.gate-leaf.left {
  left: 0;
  transform-origin: left center;
}

.gate-leaf.left::before {
  right: 20%;
}

.gate-leaf.right {
  right: 0;
  transform-origin: right center;
}

.gate-leaf.right::before {
  left: 20%;
  content: "墓门";
}

.portal-gate.is-open .gate-leaf.left {
  transform: rotateY(78deg);
  box-shadow: 24px 0 44px rgba(33, 28, 23, 0.26);
}

.portal-gate.is-open .gate-leaf.right {
  transform: rotateY(-78deg);
  box-shadow: -24px 0 44px rgba(33, 28, 23, 0.26);
}

.gate-threshold {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -14px;
  height: 38px;
  z-index: 4;
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.54), rgba(92, 82, 70, 0.28)),
    #a99e8d;
  transform: skewX(-10deg);
}

.stone-tablet-hero {
  position: absolute;
  inset: 78px 72px 92px;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
  border: 1px solid rgba(33, 28, 23, 0.24);
  background:
    linear-gradient(90deg, rgba(33, 28, 23, 0.08), transparent 24%, transparent 76%, rgba(33, 28, 23, 0.08)),
    linear-gradient(180deg, rgba(255, 252, 245, 0.88), rgba(190, 183, 171, 0.88)),
    #bdb5a8;
  box-shadow: inset 0 0 0 10px rgba(255, 252, 245, 0.14), 0 18px 50px rgba(33, 28, 23, 0.18);
  opacity: 0.42;
  transform: scale(0.96);
  filter: blur(0.8px);
  transition: opacity 520ms ease 280ms, transform 520ms ease 280ms, filter 520ms ease 280ms;
}

.portal-gate.is-open .stone-tablet-hero {
  opacity: 1;
  transform: scale(1);
  filter: none;
}

.stone-tablet-hero p,
.stone-tablet-hero small {
  margin: 0;
  color: var(--ink-soft);
}

.stone-tablet-hero p {
  color: var(--cinnabar);
}

.stone-tablet-hero h2 {
  margin: 0;
  font-size: clamp(44px, 7vw, 82px);
  line-height: 1.05;
  writing-mode: vertical-rl;
}

.incense-bowl {
  position: relative;
  width: 128px;
  height: 70px;
  margin-top: 12px;
  border: 1px solid rgba(33, 28, 23, 0.2);
  border-radius: 0 0 52px 52px;
  background: linear-gradient(180deg, #7b3128, #391e19);
}

.incense-bowl i {
  position: absolute;
  bottom: 48px;
  width: 2px;
  height: 58px;
  background: #5a2e22;
}

.incense-bowl i:nth-child(1) {
  left: 48px;
  transform: rotate(-6deg);
}

.incense-bowl i:nth-child(2) {
  left: 63px;
}

.incense-bowl i:nth-child(3) {
  left: 78px;
  transform: rotate(6deg);
}

.incense-bowl::before {
  content: "";
  position: absolute;
  left: 45px;
  top: -92px;
  width: 40px;
  height: 90px;
  border-left: 1px solid rgba(99, 90, 77, 0.26);
  border-radius: 50%;
  opacity: 0;
  animation: incense-smoke 4s ease-in-out infinite;
}

.journey-entered .incense-bowl::before {
  opacity: 1;
}

@keyframes incense-smoke {
  0% { transform: translateY(10px) translateX(0) scale(0.7); opacity: 0; }
  28% { opacity: 0.55; }
  100% { transform: translateY(-22px) translateX(16px) scale(1.18); opacity: 0; }
}

.portal-open {
  position: absolute;
  left: 50%;
  bottom: 28px;
  z-index: 5;
  min-width: 128px;
  border: 1px solid rgba(255, 248, 237, 0.34);
  padding: 13px 20px;
  color: #fff8ed;
  background: rgba(33, 28, 23, 0.9);
  cursor: pointer;
}

.portal-side {
  display: grid;
  align-content: center;
  padding: clamp(24px, 4vw, 48px);
  border-left: 1px solid var(--line);
}

.portal-side h2 {
  max-width: 560px;
  margin-bottom: 18px;
  font-size: clamp(42px, 6vw, 82px);
  line-height: 1.04;
}

.portal-side > p:not(.quote) {
  max-width: 560px;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1.9;
}

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

.portal-paths a {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 5px 12px;
  align-items: center;
  min-height: 94px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.58);
  box-shadow: 0 16px 46px rgba(46, 37, 25, 0.08);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.portal-paths a:hover {
  transform: translateY(-2px);
  border-color: rgba(49, 74, 76, 0.38);
  background: rgba(255, 252, 245, 0.86);
}

.portal-paths span {
  grid-row: span 2;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fffdf7;
  background: var(--dai);
  font-size: 22px;
}

.portal-paths a:first-child span {
  background: var(--cinnabar);
}

.portal-paths strong {
  font-size: 18px;
}

.portal-paths em {
  color: var(--ink-soft);
  font-size: 13px;
  font-style: normal;
}

.portal-agent {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.portal-agent input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.48);
  outline: none;
}

.portal-agent button {
  height: 48px;
  border: 1px solid var(--dai);
  padding: 0 16px;
  color: #fffdf7;
  background: var(--dai);
  cursor: pointer;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: clamp(22px, 4vw, 44px);
  min-height: 520px;
  align-items: center;
  max-width: 1240px;
  margin: 0 auto;
  padding: 56px 0 36px;
}

.hero-copy {
  position: relative;
  max-width: 790px;
}

.memorial-hero .hero-copy::before {
  content: "数字墓碑";
  position: absolute;
  right: 4%;
  top: -28px;
  writing-mode: vertical-rl;
  color: rgba(157, 53, 40, 0.18);
  font-size: 46px;
  font-weight: 700;
}

.quote {
  display: inline-block;
  margin-bottom: 22px;
  padding: 8px 12px;
  border-left: 3px solid var(--cinnabar);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.25);
}

.hero h2 {
  max-width: 720px;
  margin-bottom: 22px;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero p {
  max-width: 660px;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1.9;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.button {
  border: 1px solid rgba(33, 28, 23, 0.18);
  padding: 12px 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.38);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(46, 37, 25, 0.12);
}

.button.primary {
  border-color: var(--dai);
  color: #fffdf7;
  background: var(--dai);
}

.button.ghost {
  color: var(--dai);
  background: transparent;
}

.button.full {
  width: 100%;
}

.button.small {
  padding: 9px 12px;
  font-size: 14px;
}

.tombstone-card {
  position: relative;
  padding: 32px 26px;
  text-align: center;
  border: 1px solid rgba(33, 28, 23, 0.22);
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.88), rgba(238, 227, 207, 0.72)),
    var(--paper-deep);
  box-shadow: var(--shadow);
}

.tombstone-card::before,
.tombstone-card::after {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  height: 1px;
  background: rgba(49, 74, 76, 0.22);
}

.tombstone-card::before {
  top: 18px;
}

.tombstone-card::after {
  bottom: 18px;
}

.portrait-placeholder {
  display: grid;
  width: 132px;
  height: 156px;
  place-items: center;
  margin: 0 auto 20px;
  color: rgba(33, 28, 23, 0.46);
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(49, 74, 76, 0.1), rgba(163, 122, 54, 0.12)),
    rgba(255, 255, 255, 0.34);
  font-size: 44px;
}

.portrait-placeholder.has-portrait {
  overflow: hidden;
  padding: 0;
  background: rgba(255, 255, 255, 0.34);
}

.portrait-placeholder img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tablet-kicker,
.life-dates,
.tablet-line,
.tablet-meta {
  color: var(--ink-soft);
}

.tablet-kicker {
  margin-bottom: 8px;
  color: var(--cinnabar);
}

.tombstone-card h3 {
  margin-bottom: 8px;
  font-size: 34px;
}

.tablet-line {
  margin: 22px auto;
  line-height: 1.8;
}

.tablet-meta {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.ritual-panel,
.intake,
.agent,
.memory-card,
.timeline,
.chapters,
.gateway-card,
.genealogy-panel,
.hall-list div {
  border: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.64);
  box-shadow: var(--shadow);
}

.ritual-panel {
  padding: 28px;
}

.panel-title {
  margin-bottom: 20px;
  color: var(--ink-soft);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.metrics div {
  padding: 18px 10px;
  text-align: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.26);
}

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

.metrics span,
.small-note {
  color: var(--ink-soft);
  font-size: 13px;
}

.small-note {
  margin: 18px 0 0;
  line-height: 1.7;
}

.workspace {
  max-width: 1240px;
  margin: 32px auto 0;
  padding-top: 28px;
}

.page-section {
  display: none;
}

body[data-space="father"] .space-father,
body[data-space="biography"] .space-biography,
body[data-space="hall"] .space-hall,
body[data-space="genealogy"] .space-genealogy,
body[data-space="inbox"] .space-inbox {
  display: block;
}

body[data-space="father"] .hero.space-father,
body[data-space="father"] .two-col.space-father,
body[data-space="biography"] .two-col.space-biography,
body[data-space="hall"] .two-col.space-hall,
body[data-space="genealogy"] .two-col.space-genealogy {
  display: grid;
}

.space-intro {
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(44px, 8vw, 92px) 0 18px;
}

.space-intro h2 {
  max-width: 760px;
  margin-bottom: 18px;
  font-size: clamp(36px, 6vw, 76px);
  line-height: 1.08;
}

.space-intro p:not(.quote) {
  max-width: 740px;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1.9;
}

.agent-orchestrator {
  max-width: 1240px;
  margin: 26px auto 0;
  padding: 24px;
  border: 1px solid rgba(49, 74, 76, 0.24);
  background:
    linear-gradient(135deg, rgba(49, 74, 76, 0.08), rgba(163, 122, 54, 0.08)),
    rgba(255, 252, 245, 0.7);
  box-shadow: var(--shadow);
}

.agent-orchestrator .agent-head {
  align-items: flex-start;
}

.agent-orchestrator h2 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 38px);
}

.agent-orchestrator-copy {
  max-width: 880px;
  margin: 14px 0 18px;
  color: var(--ink-soft);
  line-height: 1.8;
}

.agent-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.agent-prompts button {
  border: 1px solid var(--line);
  padding: 9px 12px;
  color: var(--dai);
  background: rgba(255, 255, 255, 0.4);
  cursor: pointer;
}

.agent-prompts button:hover {
  border-color: rgba(49, 74, 76, 0.42);
  background: rgba(255, 255, 255, 0.72);
}

.agent-console {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: 18px;
  align-items: start;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h2 {
  margin-bottom: 8px;
  font-size: clamp(24px, 3vw, 40px);
}

.section-heading p:not(.eyebrow) {
  color: var(--ink-soft);
  line-height: 1.8;
}

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

.gateway-card {
  min-height: 210px;
  padding: 20px;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.gateway-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 28px 64px rgba(46, 37, 25, 0.16);
}

.gateway-card span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  margin-bottom: 18px;
  color: #fffdf7;
  background: var(--dai);
  font-size: 22px;
}

.gateway-card:nth-child(1) span,
.gateway-card:nth-child(3) span {
  background: var(--cinnabar);
}

.gateway-card h3 {
  margin-bottom: 10px;
  font-size: 22px;
}

.gateway-card p {
  color: var(--ink-soft);
  line-height: 1.75;
}

.input-grid,
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  align-items: start;
}

.ritual-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ritual-button {
  min-height: 112px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 252, 245, 0.64);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease;
}

.ritual-button:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.58);
}

.hall-list {
  display: grid;
  gap: 12px;
}

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

.published-item {
  min-height: 190px;
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.64);
  box-shadow: var(--shadow);
}

.published-item h3 {
  margin-bottom: 10px;
  font-size: 21px;
}

.published-item p:not(.eyebrow),
.published-item small {
  color: var(--ink-soft);
  line-height: 1.75;
}

.hall-list div {
  display: grid;
  gap: 6px;
  padding: 18px;
}

.hall-list span,
.genealogy-panel p {
  color: var(--ink-soft);
  line-height: 1.75;
}

.genealogy-panel {
  padding: 24px;
}

.genealogy-panel h3 {
  margin-bottom: 14px;
  font-size: 26px;
}

.family-chain {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.family-chain span {
  position: relative;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.28);
}

.family-chain span:nth-child(4) {
  color: #fffdf7;
  background: var(--cinnabar);
  border-color: var(--cinnabar);
}

.intake,
.agent {
  padding: 22px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 14px;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.52);
  outline: none;
}

textarea {
  min-height: 180px;
  resize: vertical;
  padding: 16px;
  line-height: 1.8;
}

select {
  height: 46px;
  padding: 0 12px;
}

textarea:focus,
select:focus {
  border-color: rgba(49, 74, 76, 0.5);
  box-shadow: 0 0 0 3px rgba(49, 74, 76, 0.08);
}

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

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.inline-check input {
  width: 16px;
  height: 16px;
}

.file-drop {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 150px;
  margin-bottom: 16px;
  padding: 24px;
  text-align: center;
  border: 1px dashed rgba(49, 74, 76, 0.36);
  background: rgba(159, 183, 173, 0.1);
  cursor: pointer;
}

.file-drop input {
  display: none;
}

.file-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fffdf7;
  background: var(--gold);
}

.file-drop em {
  color: var(--ink-soft);
  font-size: 13px;
  font-style: normal;
}

.chat-log {
  display: grid;
  gap: 12px;
  max-height: 520px;
  overflow: auto;
  padding-top: 18px;
}

.agent-ask {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.agent-ask textarea {
  min-height: 104px;
}

.bubble {
  padding: 12px 14px;
  line-height: 1.75;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.44);
}

.bubble p {
  margin-bottom: 0;
}

.bubble.agent-msg {
  border-left: 3px solid var(--dai);
}

.bubble.user-msg {
  border-right: 3px solid var(--cinnabar);
  background: rgba(157, 53, 40, 0.05);
}

.agent-ui-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.agent-ui-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(49, 74, 76, 0.2);
  background: rgba(247, 241, 229, 0.58);
}

.agent-ui-card strong {
  color: var(--dai);
  font-size: 15px;
}

.agent-ui-card span {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
}

.agent-ui-card em {
  color: var(--cinnabar);
  font-size: 13px;
  font-style: normal;
}

.card-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

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

.card-status {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 1;
  padding: 5px 8px;
  color: #fffdf7;
  background: var(--cinnabar);
  font-size: 12px;
}

.card-status.approved {
  background: var(--dai);
}

.preview {
  min-height: 132px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(49, 74, 76, 0.14), rgba(163, 122, 54, 0.09)),
    rgba(255, 255, 255, 0.35);
}

.preview img,
.preview video,
.preview audio {
  display: block;
  width: 100%;
}

.preview img,
.preview video {
  height: 190px;
  object-fit: cover;
}

.preview audio {
  margin: 54px 12px;
  width: calc(100% - 24px);
}

.preview .doc {
  display: grid;
  min-height: 132px;
  place-items: center;
  color: var(--ink-soft);
  font-size: 32px;
}

.card-body {
  padding: 18px;
}

.card-title {
  margin-bottom: 10px;
  font-size: 21px;
}

.summary {
  min-height: 72px;
  color: var(--ink-soft);
  line-height: 1.75;
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 14px;
}

.facts dt {
  color: var(--ink);
}

.facts dd {
  margin: 0;
}

.questions {
  display: grid;
  gap: 8px;
}

.question {
  padding: 9px 10px;
  color: var(--dai);
  background: rgba(159, 183, 173, 0.14);
  font-size: 14px;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.timeline,
.chapters {
  padding: 18px;
}

.timeline-item {
  position: relative;
  padding: 0 0 20px 22px;
  border-left: 1px solid rgba(49, 74, 76, 0.28);
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 2px;
  width: 9px;
  height: 9px;
  background: var(--cinnabar);
}

.timeline-item strong {
  display: block;
  margin-bottom: 6px;
}

.timeline-item p,
.chapter p {
  color: var(--ink-soft);
  line-height: 1.7;
}

.chapter {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.chapter:last-child {
  border-bottom: 0;
}

.empty {
  padding: 28px;
  color: var(--ink-soft);
  text-align: center;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 980px) {
  .memorial-portal {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .portal-scene {
    min-height: 72vh;
  }

  .portal-side {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 24px 0 0;
  }

  .portal-side h2 {
    font-size: clamp(38px, 12vw, 64px);
  }

  .portal-agent {
    grid-template-columns: 1fr;
  }

  .topbar,
  .nav {
    align-items: flex-start;
  }

  .topbar,
  .hero,
  .agent-console,
  .input-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .hero {
    min-height: auto;
    padding-top: 34px;
  }

  .hero-copy::before {
    display: none;
  }

  .card-board,
  .published-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gateway-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-paths {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  main {
    padding-inline: 12px;
  }

  .topbar {
    padding: 14px 12px;
  }

  .nav {
    flex-wrap: wrap;
  }

  .hero h2 {
    font-size: 34px;
  }

  .portal-scene {
    min-height: 68vh;
  }

  .portal-gate {
    width: min(420px, 88vw);
    min-height: 58vh;
  }

  .stone-tablet-hero {
    inset: 48px 42px 76px;
  }

  .stone-tablet-hero h2 {
    font-size: clamp(40px, 14vw, 64px);
  }

  .hero p {
    font-size: 16px;
  }

  .form-row,
  .card-board,
  .published-list,
  .gateway-grid,
  .portal-paths,
  .ritual-actions {
    grid-template-columns: 1fr;
  }

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