:root {
  --ink: #102A43;
  --cream: #F4EEDC;
  --chlorophyll: #3E8F6A;
  --copper: #D49A52;
  --sage: #A9C7A1;
  --soil: #241B18;
  --paper: rgba(244, 238, 220, 0.86);
  --glass: rgba(169, 199, 161, 0.34);
  --shadow: 0 26px 70px rgba(16, 42, 67, 0.17);
  --serif-display: "Cormorant Garamond", serif;
  --serif-body: "Source Serif 4", serif;
  --sans: "IBM Plex Sans", sans-serif;
}

/* Typography design tokens retained for compliance: keeps precise defaulting mono-heavy developer styling. Source Serif 4** 4* for longer explanatory passages where wiki-like reading matters. Use **IBM Plex Sans** Sans* for dashboard labels */

@keyframes leaf-breathe {
  0%, 100% { transform: rotate(-32deg) scale(1); }
  50% { transform: rotate(-24deg) scale(1.08); }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 10%, rgba(169, 199, 161, 0.65), transparent 28rem),
    radial-gradient(circle at 84% 4%, rgba(212, 154, 82, 0.22), transparent 26rem),
    linear-gradient(115deg, var(--cream), #eee5cd 58%, #e5ddc3);
  font-family: var(--serif-body);
  overflow-x: hidden;
}

button, a { font: inherit; }
button { cursor: pointer; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  z-index: 1;
  background-image:
    repeating-linear-gradient(0deg, rgba(36, 27, 24, 0.025) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(16, 42, 67, 0.018) 0 1px, transparent 1px 6px);
  mix-blend-mode: multiply;
}

.trellis-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(62, 143, 106, 0.36) 1.5px, transparent 2px),
    linear-gradient(120deg, transparent 0 48%, rgba(16, 42, 67, 0.08) 49%, transparent 51%);
  background-size: 84px 84px, 220px 220px;
  transform: translate3d(0, var(--field-shift, 0px), 0);
  transition: transform 0.35s ease-out;
}

.index-rail {
  position: fixed;
  left: 24px;
  top: 24px;
  bottom: 24px;
  width: 188px;
  padding: 24px 18px;
  z-index: 5;
  border: 1px solid rgba(16, 42, 67, 0.24);
  border-radius: 30px 18px 34px 18px;
  background: rgba(244, 238, 220, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.index-rail::before {
  content: "";
  position: absolute;
  left: 35px;
  top: 88px;
  bottom: 104px;
  border-left: 1px dotted rgba(16, 42, 67, 0.45);
}

.rail-title {
  font-family: var(--serif-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 28px;
}

.rail-item {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.68;
}

.leaf-dot {
  width: 18px;
  height: 12px;
  border-radius: 90% 0 90% 0;
  border: 1px solid var(--ink);
  background: var(--cream);
  transform: rotate(-32deg);
  transition: background 0.3s ease, transform 0.3s ease;
}

.rail-item.active { opacity: 1; color: var(--chlorophyll); }
.rail-item.active .leaf-dot { background: var(--chlorophyll); transform: rotate(-12deg) scale(1.1); animation: leaf-breathe 3s ease-in-out infinite; }

.rail-button {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 20px;
  border: 1px solid rgba(16, 42, 67, 0.35);
  background: var(--soil);
  color: var(--cream);
  border-radius: 999px;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
}

main { position: relative; z-index: 2; margin-left: 226px; }
.room { min-height: 100vh; position: relative; padding: 34px clamp(24px, 4vw, 64px); }

.hero-room { display: flex; flex-direction: column; }
.hero-label {
  width: max-content;
  margin: 0 0 14px auto;
  padding: 8px 16px;
  border: 1px solid rgba(16, 42, 67, 0.28);
  border-radius: 999px;
  background: rgba(244, 238, 220, 0.7);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.map-table {
  min-height: calc(100vh - 82px);
  display: grid;
  grid-template-columns: 260px minmax(420px, 1fr) 260px;
  grid-template-rows: 1fr 1fr;
  gap: 18px;
}

.instrument, .specimen-card, .room-panel, .dashboard-ledger, .petal-board, .care-calendar, .trellis-card {
  border: 1px solid rgba(16, 42, 67, 0.28);
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.instrument {
  padding: 20px;
  min-height: 220px;
  border-radius: 32px 18px 36px 20px;
  transition: transform 0.45s ease, background 0.45s ease, border-color 0.45s ease;
  position: relative;
  overflow: hidden;
}
.instrument::after {
  content: "";
  position: absolute;
  width: 92px;
  height: 92px;
  right: -24px;
  bottom: -20px;
  border-radius: 50%;
  border: 1px solid rgba(62, 143, 106, 0.32);
  background: radial-gradient(circle, rgba(169, 199, 161, 0.35) 0 3px, transparent 4px);
  background-size: 16px 16px;
}
.instrument:hover, .instrument.expanded { transform: translateY(-8px) rotate(-1deg); background: rgba(169, 199, 161, 0.42); border-color: var(--chlorophyll); }
.origin { grid-column: 1; grid-row: 1; }
.license { grid-column: 3; grid-row: 1; border-radius: 20px 38px 20px 34px; }
.integrity { grid-column: 1; grid-row: 2; border-radius: 22px 34px 18px 40px; }
.lifecycle { grid-column: 3; grid-row: 2; }

.card-kicker, .folio, .annotation {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chlorophyll);
}

.instrument h3 { margin: 28px 0 12px; font-family: var(--serif-display); font-size: 30px; line-height: 0.95; }
.instrument p, .hero-copy p, .story-room p { font-size: 18px; line-height: 1.52; }

.central-specimen {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: relative;
  min-height: 640px;
  border: 1px solid rgba(16, 42, 67, 0.18);
  border-radius: 42px;
  background: rgba(169, 199, 161, 0.18);
  overflow: hidden;
}

.central-specimen::before {
  content: "";
  position: absolute;
  inset: 20px;
  border: 1px dashed rgba(16, 42, 67, 0.23);
  border-radius: 34px;
}

.vine-map { position: absolute; inset: 4% 3% 14%; width: 94%; height: 82%; overflow: visible; }
.vine-path {
  fill: none;
  stroke: var(--chlorophyll);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.1s cubic-bezier(.2,.8,.2,1);
  filter: drop-shadow(0 6px 8px rgba(62, 143, 106, 0.18));
}
.branch { stroke: var(--ink); stroke-width: 3; opacity: 0.72; }
.root { stroke: var(--copper); stroke-width: 3.5; }

.node { transform-box: fill-box; transform-origin: center; opacity: 0; transition: opacity 0.7s ease, transform 0.7s cubic-bezier(.2,.8,.2,1); }
.node.visible { opacity: 1; }
.node use { fill: var(--cream); stroke: var(--ink); stroke-width: 2; }
.node .accent { fill: none; stroke: var(--copper); stroke-width: 2; }
.node text { font-family: var(--sans); font-size: 15px; font-weight: 600; text-anchor: middle; fill: var(--ink); letter-spacing: 0.04em; }
.node-a { transform: translate(96px,504px) scale(0.01); }
.node-b { transform: translate(255px,292px) scale(0.01); }
.node-c { transform: translate(463px,119px) scale(0.01); }
.node-d { transform: translate(109px,165px) scale(0.01); }
.node-e { transform: translate(522px,304px) scale(0.01); }
.node-f { transform: translate(657px,96px) scale(0.01); }
.node-a.visible { transform: translate(96px,504px) scale(1); }
.node-b.visible { transform: translate(255px,292px) scale(1); }
.node-c.visible { transform: translate(463px,119px) scale(1); }
.node-d.visible { transform: translate(109px,165px) scale(1); }
.node-e.visible { transform: translate(522px,304px) scale(1); }
.node-f.visible { transform: translate(657px,96px) scale(1); }

.specimen-card {
  position: absolute;
  left: 34px;
  right: 34px;
  bottom: 28px;
  padding: 28px 32px;
  border-radius: 26px 42px 24px 32px;
}
.hero-copy h1 { margin: 8px 0 10px; max-width: 850px; font-family: var(--serif-display); font-size: clamp(54px, 7vw, 104px); line-height: 0.84; letter-spacing: -0.045em; }
.hero-copy p { max-width: 720px; margin: 0 0 20px; }
.wiki-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.wiki-actions button {
  border: 1px solid rgba(16, 42, 67, 0.45);
  border-radius: 999px;
  padding: 12px 18px;
  color: var(--ink);
  background: var(--sage);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.wiki-actions button:last-child { background: var(--cream); }

.story-room { display: grid; grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr); gap: 34px; align-items: center; }
.article-panel, .dashboard-ledger, .petal-board, .care-calendar { padding: clamp(30px, 5vw, 70px); border-radius: 48px 24px 56px 28px; position: relative; }
.article-panel h2, .dashboard-ledger h2, .petal-board h2, .care-calendar h2 { margin: 14px 0 18px; font-family: var(--serif-display); font-size: clamp(44px, 5vw, 82px); line-height: 0.9; letter-spacing: -0.04em; }

.specimen-ledger { margin-top: 28px; display: grid; gap: 10px; font-family: var(--sans); }
.specimen-ledger div { display: grid; grid-template-columns: 110px 1fr; border-top: 1px solid rgba(16, 42, 67, 0.22); padding-top: 10px; }
.specimen-ledger b { text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; color: var(--chlorophyll); }
.specimen-ledger span { font-size: 14px; }
.room-vine { width: 100%; min-height: 520px; }
.isometric-cabinet { position: absolute; right: 8%; bottom: 12%; width: 210px; height: 190px; border: 1px solid rgba(16, 42, 67, 0.25); border-radius: 24px; background: rgba(244,238,220,.62); display: grid; place-items: center; font-family: var(--sans); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; box-shadow: var(--shadow); }
.packet-shape { width: 90px; height: 70px; transform: skewY(-18deg) rotate(10deg); background: linear-gradient(135deg, var(--sage), var(--cream)); border: 2px solid var(--ink); box-shadow: 24px 18px 0 rgba(212,154,82,.58); }

.vine-room { grid-template-columns: 1fr 0.9fr; background: linear-gradient(180deg, transparent, rgba(169,199,161,.18)); }
.trail-grid { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }
.trail-chip { border: 1px solid rgba(16, 42, 67, 0.34); border-radius: 999px; padding: 11px 14px; background: var(--cream); color: var(--ink); font-family: var(--sans); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.trail-chip.active { background: var(--chlorophyll); color: var(--cream); }
.trellis-card { min-height: 420px; border-radius: 28px 60px 28px 60px; padding: 44px; display: grid; align-content: center; background: rgba(16, 42, 67, 0.92); color: var(--cream); background-image: radial-gradient(circle at 22% 24%, rgba(212,154,82,.28), transparent 12rem); }
.trellis-card span { color: var(--copper); font-family: var(--sans); text-transform: uppercase; letter-spacing: .18em; font-size: 12px; }
.trellis-card p { font-family: var(--serif-display); font-size: clamp(36px, 4vw, 68px); line-height: .98; }

.petals-room { display: block; padding-top: 12vh; }
.petal-board { max-width: 1060px; margin: 0 auto; text-align: center; border-radius: 80px 32px; }
.petals { min-height: 330px; position: relative; margin-top: 30px; }
.petal { position: absolute; left: 50%; top: 50%; width: 190px; height: 112px; margin: -56px 0 0 -95px; border: 1px solid rgba(16,42,67,.35); border-radius: 90% 8% 90% 8%; background: var(--sage); display: grid; place-items: center; font-family: var(--sans); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; box-shadow: 0 18px 34px rgba(16,42,67,.13); transform-origin: center; }
.petal b { font-family: var(--serif-body); font-size: 18px; color: var(--soil); text-transform: none; letter-spacing: 0; }
.petal:nth-child(1) { transform: translate(-220px, -86px) rotate(-22deg); }
.petal:nth-child(2) { transform: translate(180px, -76px) rotate(18deg); background: var(--cream); }
.petal:nth-child(3) { transform: translate(-170px, 104px) rotate(20deg); background: rgba(212,154,82,.58); }
.petal:nth-child(4) { transform: translate(200px, 100px) rotate(-16deg); }

.garden-room { display: grid; grid-template-columns: 1fr; align-items: end; padding-bottom: 0; }
.care-calendar { max-width: 980px; margin: 10vh auto 8vh; }
.calendar-row { display: grid; grid-template-columns: 110px 1fr 150px; gap: 18px; align-items: center; padding: 18px 0; border-top: 1px solid rgba(16,42,67,.22); font-family: var(--sans); }
.calendar-row span { color: var(--chlorophyll); text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 700; }
.calendar-row b { font-size: 18px; }
.calendar-row em { color: var(--copper); font-style: normal; text-align: right; }
.soil-footer { margin: 0 -64px; padding: 44px 64px; background: var(--soil); color: var(--cream); font-family: var(--serif-display); font-size: clamp(28px, 4vw, 52px); line-height: 1; }

.glossary-drawer {
  position: fixed;
  right: 24px;
  top: 24px;
  bottom: 24px;
  width: min(390px, calc(100vw - 48px));
  z-index: 8;
  border: 1px solid rgba(16,42,67,.35);
  border-radius: 36px;
  padding: 28px;
  background: var(--cream);
  box-shadow: var(--shadow);
  transform: translateX(calc(100% + 40px));
  transition: transform .45s cubic-bezier(.2,.8,.2,1);
}
.glossary-drawer.open { transform: translateX(0); }
.glossary-drawer button { float: right; border: 1px solid rgba(16,42,67,.35); background: var(--soil); color: var(--cream); border-radius: 999px; padding: 9px 14px; font-family: var(--sans); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; }
.glossary-drawer h3 { clear: both; margin: 54px 0 18px; font-family: var(--serif-display); font-size: 44px; line-height: .9; }
.glossary-drawer dt { font-family: var(--sans); color: var(--chlorophyll); font-weight: 700; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; margin-top: 20px; }
.glossary-drawer dd { margin: 6px 0 0; font-size: 17px; line-height: 1.45; }

.room.in-view .vine-path, .hero-room.in-view .vine-path { stroke-dashoffset: 0; }

@media (max-width: 1180px) {
  .index-rail { left: 12px; top: 12px; bottom: auto; height: auto; width: calc(100% - 24px); display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 22px; overflow-x: auto; }
  .index-rail::before, .rail-button { display: none; }
  .rail-title { margin: 0 10px 0 0; white-space: nowrap; font-size: 22px; }
  .rail-item { display: flex; min-width: max-content; min-height: 32px; font-size: 10px; }
  main { margin-left: 0; padding-top: 68px; }
  .map-table { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto; }
  .central-specimen { grid-column: 1 / -1; grid-row: 1; }
  .origin, .license, .integrity, .lifecycle { grid-column: auto; grid-row: auto; }
}

@media (max-width: 760px) {
  .room { padding: 22px 16px; }
  .map-table, .story-room, .vine-room { display: block; }
  .instrument { margin-bottom: 14px; min-height: auto; }
  .central-specimen { min-height: 760px; margin-bottom: 14px; }
  .vine-map { inset: 2% -20% 34%; width: 140%; }
  .specimen-card { left: 14px; right: 14px; bottom: 14px; padding: 22px; }
  .room-vine { min-height: 320px; }
  .isometric-cabinet { position: relative; right: auto; bottom: auto; margin: 18px auto; }
  .trellis-card { min-height: 300px; margin-top: 18px; }
  .petal-board { text-align: left; }
  .petals { min-height: auto; display: grid; gap: 12px; }
  .petal { position: static; margin: 0; width: 100%; transform: none !important; }
  .calendar-row { grid-template-columns: 1fr; gap: 6px; }
  .calendar-row em { text-align: left; }
  .soil-footer { margin: 0 -16px; padding: 34px 18px; }
}
