@font-face { font-family: 'Noto Sans Symbols'; font-weight: 500; font-display: swap; src: url(vendor/fonts/noto-sans-symbols-symbols-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 600; font-display: swap; src: url(vendor/fonts/cormorant-garamond-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 700; font-display: swap; src: url(vendor/fonts/cormorant-garamond-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-style: italic; font-weight: 500; font-display: swap; src: url(vendor/fonts/cormorant-garamond-latin-500-italic.woff2) format('woff2'); }

:root {
  --bg: #0b0a1f;
  --panel: rgba(17, 14, 40, 0.7);
  --panel-solid: #141030;
  --line: rgba(246, 227, 180, 0.14);
  --text: #f4efe3;
  --muted: #aca6c6;
  --accent: #e6bd6a;
  --gold: #d6aa5a;
  --cream: #f6e3b4;
  --emerald: #3fe08f;
  --violet: #a77bff;
  --serif: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --glass: blur(16px) saturate(150%);
  --glow: 0 0 0 1px rgba(246, 227, 180, 0.05), 0 8px 32px rgba(5, 3, 20, 0.55), 0 0 24px rgba(167, 123, 255, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none;
  background: linear-gradient(rgba(11, 10, 31, 0.85), transparent);
}
.brand {
  display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 14px 4px 4px; margin: -4px 0 0 -4px; border-radius: 999px;
  background: radial-gradient(closest-side, rgba(11, 10, 31, 0.75), rgba(11, 10, 31, 0.35) 70%, transparent);
}
.brand-logo { width: 48px; height: auto; flex: none; filter: drop-shadow(0 0 10px rgba(230, 189, 106, 0.45)); animation: breathe-glow 9s ease-in-out infinite; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1; }
.topbar h1 {
  margin: 0; font: 700 28px/1 var(--serif); letter-spacing: 0.3px; color: var(--cream);
  text-shadow: 0 1px 6px rgba(5, 3, 20, 0.9), 0 0 16px rgba(230, 189, 106, 0.45);
}
.brand-sub {
  margin-top: 4px; padding-top: 4px; border-top: 1.5px solid var(--gold);
  font: 700 14px/1.1 var(--serif); letter-spacing: 1.3px; text-transform: uppercase; color: var(--cream);
  text-shadow: 0 1px 5px rgba(5, 3, 20, 0.95);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@keyframes breathe-glow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(230, 189, 106, 0.3)); }
  50% { filter: drop-shadow(0 0 16px rgba(230, 189, 106, 0.7)); }
}
.still .brand-logo, .still .spinner { animation: none; }
@media (prefers-reduced-motion: reduce) { .brand-logo { animation: none; } }
.topbar-actions { display: flex; gap: 8px; pointer-events: auto; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--cream);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  display: grid; place-items: center; font-size: 16px; line-height: 1;
  transition: border-color 0.2s, box-shadow 0.2s, color 0.2s;
}
.icon-btn:hover { border-color: rgba(230, 189, 106, 0.6); box-shadow: 0 0 14px rgba(230, 189, 106, 0.35); color: #fff; }
#btn-scene { color: var(--accent); }
a.icon-btn { text-decoration: none; }
#btn-wellness { color: #9fe3c0; }
.icon-btn svg { display: block; }

.systems {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 10px 12px calc(var(--safe-bottom) + 12px);
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  background: linear-gradient(transparent, rgba(11, 10, 31, 0.9) 45%);
}
.systems::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  color: var(--muted); white-space: nowrap;
}
.chip-layers { color: var(--text); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); opacity: 0.35; }
.chip[aria-pressed="true"] { color: var(--text); border-color: color-mix(in srgb, var(--c) 70%, transparent); background: color-mix(in srgb, var(--c) 18%, var(--panel-solid)); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 35%, transparent); }
.chip[aria-pressed="true"] .dot { box-shadow: 0 0 8px var(--c); }
.chip[aria-pressed="true"] .dot { opacity: 1; }
.chip.busy .dot { animation: pulse 0.8s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: 0.2; } }

.info {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--safe-bottom) + 70px);
  max-width: 420px; margin: 0 auto;
  padding: 14px 16px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--glow);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
}
.info-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.info h2 { margin: 2px 0 0; font: 700 23px/1.15 var(--serif); color: var(--cream); }
.info-system { font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--accent); }
.info-path { margin-top: 6px; color: var(--muted); font-size: 13px; }
.info-path button {
  padding: 0; border: 0; background: none; color: var(--muted); font-size: 13px;
  text-decoration: underline; text-decoration-color: rgba(255, 255, 255, 0.25); text-underline-offset: 3px;
}
.info-path button:hover { color: var(--accent); }
.info-actions { display: flex; gap: 8px; margin-top: 12px; }
.info-actions button, .restore button, dialog button {
  flex: 1; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(246, 227, 180, 0.06);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.info-actions button:hover, .restore button:hover, dialog button:hover {
  border-color: rgba(230, 189, 106, 0.55); background: rgba(230, 189, 106, 0.12); box-shadow: 0 0 12px rgba(230, 189, 106, 0.25);
}

.restore {
  position: fixed; top: calc(var(--safe-top) + 56px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: var(--muted);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
}
.restore button { flex: none; padding: 5px 12px; border-radius: 999px; color: var(--text); }
.restore { max-width: calc(100vw - 32px); }
#restore-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.ghost { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.ghost input { width: 90px; }

/* Systems & layers panel: a side column on computers, a bottom sheet on phones. */
.panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  max-height: 70vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 12px 12px calc(var(--safe-bottom) + 16px);
  background: var(--panel-solid); border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
}
.panel.closed { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-head h2 { margin: 0; font: 700 20px/1.2 var(--serif); color: var(--cream); letter-spacing: 0.3px; }
.sys { border-bottom: 1px solid var(--line); }
.sys-row { display: flex; align-items: center; gap: 4px; }
.sys-toggle {
  flex: 1; display: flex; align-items: center; gap: 10px; padding: 9px 6px;
  border: 0; background: none; color: var(--muted); text-align: left;
}
.sys-toggle .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); opacity: 0.3; flex: none; }
.sys-toggle[aria-pressed="true"] { color: var(--text); }
.sys-toggle[aria-pressed="true"] .dot { opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent), 0 0 10px var(--c); }
.sys-toggle:hover { color: var(--text); }
.sys-toggle kbd { margin-left: auto; opacity: 0.6; }
.sys.busy .dot, .sys-toggle.busy .dot { animation: pulse 0.8s ease-in-out infinite alternate; }
.sys-expand { width: 32px; height: 32px; border: 0; background: none; color: var(--muted); border-radius: 8px; transition: transform 0.15s; }
.sys-expand[aria-expanded="true"] { transform: rotate(180deg); }
.sys-expand:hover { background: rgba(255, 255, 255, 0.06); }
.sys-body { padding: 2px 6px 12px 28px; }
.opacity { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.opacity input { flex: 1; accent-color: var(--c); }
.opacity output { width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.facet { margin-top: 8px; }
.facet-head { display: flex; align-items: center; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 6px; }
.facet-head span { flex: 1; }
.facet-head button { border: 0; background: none; color: var(--accent); font-size: 12px; padding: 2px 4px; text-transform: none; letter-spacing: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 4px 10px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--line); background: none; color: var(--muted);
}
.pill[aria-pressed="true"] { color: var(--text); background: color-mix(in srgb, var(--c) 22%, transparent); border-color: color-mix(in srgb, var(--c) 55%, transparent); }
input[type=range] { accent-color: var(--accent); }

/* Colour swatches wrap a native colour picker. */
.swatch {
  position: relative; display: inline-block; flex: none; cursor: pointer;
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px dashed rgba(255, 255, 255, 0.35);
}
.swatch.set, .swatch.big { border: 1.5px solid rgba(255, 255, 255, 0.6); }
.swatch.big { width: 22px; height: 22px; }
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.pill-wrap { display: inline-flex; align-items: center; gap: 4px; }
.colors, .info-color { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.info-color { margin: 12px 0 0; }
.colors button, .info-color button { border: 0; background: none; color: var(--accent); font-size: 13px; padding: 2px 4px; }

.loading {
  position: fixed; top: calc(var(--safe-top) + 56px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line);
  font-size: 13px; color: var(--cream);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass); box-shadow: var(--glow);
}
.restore:not([hidden]) ~ .loading { top: calc(var(--safe-top) + 100px); }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, var(--violet), var(--accent), transparent 80%);
  -webkit-mask: radial-gradient(circle, transparent 5px, #000 5.5px); mask: radial-gradient(circle, transparent 5px, #000 5.5px);
  animation: spin 1.1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

dialog {
  max-width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; border-radius: 18px;
  border: 1px solid rgba(230, 189, 106, 0.3); color: var(--text);
  background: linear-gradient(160deg, rgba(30, 22, 66, 0.92), rgba(12, 10, 32, 0.94));
  box-shadow: var(--glow), 0 0 40px rgba(230, 189, 106, 0.12);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
}
dialog::backdrop { background: rgba(5, 3, 18, 0.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
dialog h2 { margin-top: 0; font: 700 26px/1.15 var(--serif); color: var(--cream); }
.about-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; margin-bottom: 6px; }
.about-head img { width: 132px; height: 132px; filter: drop-shadow(0 0 18px rgba(230, 189, 106, 0.45)); }
.about-head h2 { margin: 0; outline: none; }
.about-head h2 span { display: block; margin-top: 4px; font-size: 15px; letter-spacing: 1.4px; text-transform: uppercase; opacity: 0.85; }
.switch { display: flex; align-items: center; gap: 12px; padding: 9px 0; cursor: pointer; }
.switch input {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; cursor: pointer;
  width: 40px; height: 22px; border-radius: 999px; position: relative;
  background: rgba(255, 255, 255, 0.12); border: 1px solid var(--line); transition: background 0.2s, box-shadow 0.2s;
}
.switch input::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--cream); transition: transform 0.2s;
}
.switch input:checked { background: linear-gradient(90deg, var(--violet), var(--accent)); box-shadow: 0 0 12px rgba(230, 189, 106, 0.45); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#saves { width: min(440px, calc(100vw - 32px)); box-sizing: border-box; }
.save-form { display: flex; gap: 8px; margin: 14px 0 10px; }
.save-form button { flex: none; }
.save-form input {
  flex: 1; min-width: 0; padding: 9px 12px; border-radius: 10px; font: inherit; font-size: 15px; color: var(--cream);
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06);
}
.save-form input:focus { outline: none; border-color: rgba(230, 189, 106, 0.6); }
.save-list { list-style: none; margin: 0; padding: 0; }
.save-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.save-list .save-text { flex: 1 1 100%; min-width: 0; }
.save-list .save-del { margin-left: auto; }
.save-list .save-name { display: block; color: var(--cream); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-list .save-when { display: block; font-size: 12px; color: var(--muted); }
.save-list button { padding: 6px 10px; font-size: 13px; }
.save-list button.save-del { border: 0; background: none; color: var(--muted); padding: 6px; }
.save-list button.save-del:hover { color: #ff8a8a; box-shadow: none; }
dialog button:disabled { opacity: 0.5; cursor: default; }
.account { margin: 12px 0 4px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(246, 227, 180, 0.04); }
.account p { margin: 0 0 10px; }
.acct-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.acct-who { flex: 1 1 auto; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.acct-who b { color: var(--cream); font-weight: 600; }
.acct-email { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.acct-email input {
  padding: 9px 12px; border-radius: 10px; font: inherit; font-size: 15px; color: var(--cream);
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06);
}
.acct-email input:focus { outline: none; border-color: rgba(230, 189, 106, 0.6); }
dialog button.link-btn { border: 0; background: none; color: var(--accent); padding: 6px 4px; }
dialog button.link-btn:hover { box-shadow: none; text-decoration: underline; }
.account .acct-msg { margin: 8px 0 0; }
.account .acct-msg:empty { display: none; }
.account .acct-msg.err { color: #ffb3b3; }
.start-over { margin: 16px 0 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.start-over p { margin: 6px 0 0; }
#btn-start-over.confirm { border-color: rgba(255, 120, 120, 0.7); color: #ffb3b3; }
dialog .small { font-size: 13px; color: var(--muted); }
dialog a { color: var(--accent); }
[hidden] { display: none !important; }

kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 6px;
  border: 1px solid var(--line); border-bottom-width: 2px; background: rgba(255, 255, 255, 0.06);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; color: var(--text);
}
.chip kbd { margin-left: auto; opacity: 0.6; }
table.keys { border-collapse: collapse; margin-bottom: 16px; }
table.keys th { text-align: left; font-weight: 500; color: var(--muted); padding: 5px 16px 5px 0; white-space: nowrap; }
table.keys td { padding: 5px 0; }
.desktop-only, .chip kbd { display: none; }
@media (hover: hover) and (pointer: fine) {
  .desktop-only { display: grid; }
  .chip kbd { display: inline-block; }
}

@media (min-width: 800px) {
  .systems { display: none; }
  .panel, .panel.closed {
    display: block; left: auto; top: 64px; right: 16px; bottom: auto; width: 300px; max-height: calc(100vh - 80px);
    border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--glow);
    backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  }
  #panel-close { display: none; }
  .info { left: 16px; right: auto; bottom: 16px; width: 380px; margin: 0; }
  .restore { left: calc(50% - 160px); }
}

/* ---------- Occult anatomy ---------- */
.occ-title { display: flex; align-items: baseline; gap: 8px; margin: 18px 0 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.occ-title h3 { margin: 0; font: 700 19px/1.2 var(--serif); color: var(--cream); }
.occ-title span { font-size: 12px; color: var(--muted); }
.occ-icon { width: 20px; height: 20px; flex: none; object-fit: contain; opacity: 0.45; }
.sys-toggle[aria-pressed="true"] .occ-icon { opacity: 1; }
.occ-glyph { display: grid; place-items: center; font: 500 16px/1 'Noto Sans Symbols', sans-serif; }
.occ-dot { width: 12px; height: 12px; border-radius: 50%; }
.occ-about { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.occ-pill { font-family: 'Noto Sans Symbols', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.occ-pill:hover { border-color: color-mix(in srgb, var(--c) 55%, transparent); }
.occ-pill-icon { width: 16px; height: 16px; object-fit: contain; flex: none; }
.occ-pill-icon.occ-glyph { font-size: 13px; }
.occ-pill-icon.occ-dot { width: 9px; height: 9px; }
.occ-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.occ-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

.info { max-height: calc(100vh - 150px); overflow-y: auto; }
.info-extra { margin-top: 8px; font-size: 13px; color: var(--text); white-space: pre-line; }
.info-title { flex: 1; min-width: 0; }
.occ-card-icon-wrap { flex: none; display: grid; place-items: center; width: 52px; height: 52px; }
.occ-card-icon { width: 52px; height: 52px; object-fit: contain; }
.occ-card-icon.occ-glyph { font-size: 38px; }
.occ-fields { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 10px 0 0; font-size: 13px; }
.occ-fields dt { color: var(--muted); }
.occ-fields dd { margin: 0; font-family: 'Noto Sans Symbols', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.occ-fields dd small { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.occ-fields dd small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.q, .occ-fields dd.q { color: #e8b04a; }
.occ-fields dd.q b { margin-left: 2px; }
.occ-note, .occ-place { clear: both; margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.occ-note { color: #e8b04a; }
.occ-foot { margin: 10px 0 0; font-size: 11px; color: var(--muted); }
.occ-foot:empty { display: none; }

@media (max-width: 480px) {
  .topbar h1 { font-size: 21px; }
  .brand { gap: 8px; }
  .brand-logo { width: 36px; }
  .brand-sub { font-size: 10.5px; letter-spacing: 0.6px; white-space: normal; }
}

/* ---------- Path tracing ---------- */
.trace { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.trace-head { font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--accent); }
.trace-about { margin: 4px 0 0; font-size: 13px; color: var(--text); }
.trace-facts { margin: 4px 0 0; font-size: 12px; color: var(--cream); }
.trace-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.trace-actions button {
  flex: 1 1 auto; padding: 7px 10px; border-radius: 10px; font-size: 13px;
  border: 1px solid var(--line); background: rgba(246, 227, 180, 0.06);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.trace-actions button:hover { border-color: rgba(230, 189, 106, 0.55); background: rgba(230, 189, 106, 0.12); }
.trace-actions button.on { border-color: var(--accent); background: rgba(230, 189, 106, 0.2); box-shadow: 0 0 12px rgba(230, 189, 106, 0.3); }
.trace-msg { margin: 8px 0 0; font-size: 13px; color: var(--emerald); }
.trace-route { margin-top: 10px; font-size: 13px; max-height: 38vh; overflow-y: auto; }
.trace-words { margin: 0 0 8px; color: var(--text); }
.trace-name { border: 0; background: none; padding: 2px 0; color: var(--text); text-align: left; font-size: 13px; }
.trace-name:hover { color: var(--accent); }
.trace-name.marked { color: #ff5fae; }
.trace-name.virtual { font-style: italic; color: var(--muted); }
.trace-name small { color: var(--muted); font-size: 11px; }
.trace-route summary { cursor: pointer; }
.trace-route summary::marker { color: var(--muted); }
.trace-kids { margin-left: 5px; padding-left: 10px; border-left: 1px solid var(--line); }
.trace-kids[data-dir]::before { content: attr(data-dir); display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.trace-node > .trace-name { padding-left: 14px; }
.trace-list { margin: 0; padding-left: 22px; }
.trace-list li::marker { color: var(--muted); font-size: 11px; }
.trace-legend { margin: 8px 0 0; font-size: 11px; color: var(--muted); }
.trace-route summary .trace-name { display: inline; }
.trace-sub { margin: 10px 0 2px; font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.6px; }
.trace-words + .trace-sub { margin-top: 0; }
.trace-steps > summary { margin-bottom: 6px; font-size: 12px; color: var(--accent); }
@media (max-width: 799px) {
  /* Keep the card clear of the focus bar at the top. */
  .info { max-height: calc(100vh - 200px - var(--safe-top) - var(--safe-bottom)); }
  .trace-route { max-height: none; }
}

/* ---------- Conditions ---------- */
.cond-icon { width: 20px; height: 20px; flex: none; color: #ff8fa8; }
.cond-entry .sys-toggle[aria-pressed="true"] { color: var(--text); }
.cond { z-index: 6; }
@media (min-width: 800px) {
  .cond { left: auto; right: 16px; top: 64px; bottom: auto; width: 380px; max-height: calc(100vh - 80px); margin: 0; }
}
@media (max-width: 799px) {
  #info:not([hidden]) ~ #cond { display: none; } /* a part's card takes the same spot */
  .cond { max-height: 46vh; } /* leave the shoulder visible above the card */
}
.cond-about { margin: 6px 0 0; font-size: 13px; color: var(--text); }
.cond-types { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cond-types button, .cond-seg button, .cond-play, .cond-effect-foot button {
  padding: 6px 11px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--line); background: rgba(246, 227, 180, 0.06);
}
.cond-types button.on, .cond-seg button.on, .cond-effect-foot button.on { border-color: var(--accent); background: rgba(230, 189, 106, 0.2); color: var(--cream); }
.cond-group { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.cond-group b { color: var(--accent); font-weight: 600; }
.cond-controls { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(246, 227, 180, 0.04); border: 1px solid var(--line); }
.cond-slider { display: grid; grid-template-columns: 92px 1fr 42px; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.cond-slider input { width: 100%; accent-color: var(--accent); }
.cond-slider output { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.cond-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.cond-play { border-color: rgba(230, 189, 106, 0.55); color: var(--cream); }
.cond-seg { display: inline-flex; gap: 4px; }
.cond-label { font-size: 13px; color: var(--muted); }
.cond-cap { margin: 8px 0 0; font-size: 12px; color: #ffb3c4; }
.cond-facts { display: grid; grid-template-columns: max-content 1fr; gap: 5px 12px; margin: 12px 0 0; font-size: 13px; }
.cond-facts dt { color: var(--muted); }
.cond-facts dd { margin: 0; }
.cond-sub { margin: 12px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--accent); }
.cond-list, .cond-inj { margin: 0; padding-left: 20px; font-size: 13px; }
.cond-inj li::marker { color: #ff6b8a; font-weight: 700; }
.cond-note { margin: 8px 0 0; font-size: 13px; color: var(--text); }
.cond-caveat { color: #e8b04a; }
.cond-src { font-size: 11px; color: var(--muted); }
.cond-src a { color: var(--muted); }
.cond-src a:hover { color: var(--accent); }
p.cond-src { margin: 8px 0 0; }
.cond-effects { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.cond-effects summary { cursor: pointer; font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--accent); }
.cond-effects ul { list-style: none; margin: 8px 0 0; padding: 0; }
.cond-effect { margin-bottom: 12px; font-size: 13px; }
.cond-effect b { font-weight: 600; color: var(--cream); }
.cond-effect p { margin: 4px 0 0; }
.cond-effect-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.3px; vertical-align: 1px; }
.badge-documented { background: rgba(63, 224, 143, 0.16); color: #6ff0ad; border: 1px solid rgba(63, 224, 143, 0.4); }
.badge-weak { background: rgba(232, 176, 74, 0.16); color: #f2c46d; border: 1px solid rgba(232, 176, 74, 0.45); }
.badge-none { background: rgba(172, 166, 198, 0.12); color: var(--muted); border: 1px solid rgba(172, 166, 198, 0.35); }
.cond-foot { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }

/* ---------- Search ---------- */
.search {
  position: fixed; z-index: 1300; top: calc(var(--safe-top) + 62px); left: 12px; right: 12px;
  max-width: 460px; margin: 0 auto;
  padding: 8px; border-radius: 18px;
  background: linear-gradient(160deg, rgba(30, 22, 66, 0.94), rgba(12, 10, 32, 0.96));
  border: 1px solid rgba(230, 189, 106, 0.3); box-shadow: var(--glow), 0 0 40px rgba(230, 189, 106, 0.12);
  backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
}
.search-bar { display: flex; align-items: center; gap: 8px; padding-left: 8px; color: var(--accent); }
.search-bar svg { flex: none; }
#search-input {
  flex: 1; min-width: 0; padding: 10px 4px; border: 0; outline: 0; background: none;
  color: var(--text); font: 17px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; /* 16px+ so phones don't zoom */
}
#search-input::placeholder { color: var(--muted); }
#search-input::-webkit-search-cancel-button { display: none; }
.search-hint { margin: 4px 10px 6px; font-size: 13px; color: var(--muted); }
.search-hint b { color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; font-size: 11px; }
.search-hint i { color: var(--cream); }
.search-results { list-style: none; margin: 0; padding: 0; overflow-y: auto; overscroll-behavior: contain; max-height: 60vh; }
.search-results:empty { display: none; }
.search-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; cursor: pointer;
  border: 1px solid transparent;
}
.search-row[aria-selected="true"] { background: rgba(230, 189, 106, 0.1); border-color: rgba(230, 189, 106, 0.35); }
.search-dot { width: 12px; height: 12px; flex: none; margin: 0 4px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.search-icon { width: 20px; height: 20px; flex: none; object-fit: contain; }
.search-icon.occ-glyph { font-size: 15px; }
.search-icon.occ-dot { width: 12px; height: 12px; margin: 0 4px; }
.search-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.search-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-name mark { background: none; color: var(--cream); font-weight: 700; }
.search-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-kind {
  flex: none; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--accent);
  padding: 2px 7px; border: 1px solid rgba(230, 189, 106, 0.3); border-radius: 999px;
}
.chip-search { gap: 6px; color: var(--cream); }
/* The search button stays in the top bar on phones too. */
@media (max-width: 699px) {
  #hub-nav .hub-tools { display: flex; }
  #hub-nav .hub-tools .hub-tool:not(#btn-search) { display: none; }
}
@media (min-width: 800px) { .search { top: 64px; } }
.search-sides { flex: none; display: flex; gap: 4px; }
.search-sides button {
  min-width: 34px; height: 30px; padding: 0 8px; border-radius: 999px; font-size: 12px; color: var(--cream);
  border: 1px solid rgba(230, 189, 106, 0.3); background: rgba(246, 227, 180, 0.05);
}
.search-sides button:hover, .search-sides button[aria-pressed="true"] { border-color: rgba(230, 189, 106, 0.7); background: rgba(230, 189, 106, 0.16); }
.toast {
  position: fixed; z-index: 1350; left: 50%; transform: translateX(-50%); top: calc(var(--safe-top) + 110px);
  max-width: min(420px, calc(100vw - 32px)); padding: 10px 14px; border-radius: 14px; font-size: 13.5px; color: var(--text);
  background: var(--panel-solid); border: 1px solid rgba(230, 189, 106, 0.35); box-shadow: var(--glow);
}
