@font-face { font-family: 'IM Fell English'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/im-fell-english-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'IM Fell English'; font-style: italic; font-weight: 400; font-display: swap; src: url(/fonts/im-fell-english-400-italic.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/jetbrains-mono-400-normal.woff2) format('woff2'); }

:root {
  --bg: #07050b; --ink: #ece4d6; --dim: #9a8f9f; --faint: #5d5466; --line: rgba(236, 228, 214, .12);
  --glass: rgba(14, 10, 20, .78); --spore: #c9ff6a; --accent: #3ee0c5;
  --f-text: 'IM Fell English', Georgia, serif; --f-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; }
body { font: 14px/1.45 var(--f-mono); -webkit-font-smoothing: antialiased; touch-action: none; }
canvas#sky { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
canvas#sky.drag { cursor: grabbing; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; gap: 18px; padding: 16px 18px 0; pointer-events: none; z-index: 5; }
.top > * { pointer-events: auto; }
.mark h1 { font: italic 400 30px/1 var(--f-text); margin: 0; letter-spacing: .01em; text-shadow: 0 0 18px rgba(201, 255, 106, .25); }
.mark p { margin: 4px 0 0; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.mark p.homage { text-transform: none; letter-spacing: .02em; font-size: 10.5px; color: var(--faint); }
.mark p.homage a { color: var(--dim); }
.modes { display: flex; gap: 2px; margin-left: auto; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 3px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.modes button, .lenses button, .matrixtabs button { padding: 6px 12px; border-radius: 999px; font-size: 12px; color: var(--dim); letter-spacing: .02em; }
.modes button.on, .lenses button.on, .matrixtabs button.on { background: rgba(236, 228, 214, .1); color: var(--ink); }
.modes button:hover, .lenses button:hover, .matrixtabs button:hover { color: var(--ink); }
.find { position: relative; width: 240px; }
.find input { width: 100%; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); color: var(--ink); font: 13px var(--f-mono); outline: none; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.find input:focus { border-color: rgba(201, 255, 106, .45); }
.find input::placeholder { color: var(--faint); }
#hits { position: absolute; top: 40px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none; background: rgba(14, 10, 20, .95); border: 1px solid var(--line); border-radius: 12px; max-height: 50vh; overflow: auto; }
#hits li { padding: 7px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
#hits li.on, #hits li:hover { background: rgba(236, 228, 214, .08); }
#hits i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
#hits small { margin-left: auto; color: var(--faint); font-size: 10.5px; }

.lenses, .matrixtabs { position: fixed; top: 64px; right: 18px; display: flex; align-items: center; gap: 2px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 3px; z-index: 4; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.lenses .sep { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
#drift.on { color: var(--spore); background: rgba(201, 255, 106, .1); }

.time { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 6px 14px 6px 6px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; z-index: 4; width: min(520px, calc(100% - 36px)); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.time button { padding: 5px 12px; border-radius: 999px; background: rgba(201, 255, 106, .12); color: var(--spore); font-size: 12px; }
.time input { flex: 1; accent-color: #c9ff6a; }
#yr { font: italic 18px var(--f-text); min-width: 44px; text-align: right; }

.legend { position: fixed; left: 18px; bottom: 70px; display: flex; flex-direction: column; gap: 1px; z-index: 3; }
.legend button { display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 4px; border-radius: 6px; font-size: 11px; color: var(--dim); text-align: left; }
.legend button:hover, .legend button.on { color: var(--ink); background: rgba(236, 228, 214, .06); }
.legend i { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.legend.dim button:not(.on) { opacity: .45; }

.card { position: fixed; top: 112px; right: 18px; width: 340px; max-height: calc(100% - 200px); overflow: auto; padding: 18px 18px 16px; background: rgba(12, 9, 18, .9); border: 1px solid var(--line); border-radius: 16px; z-index: 6; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); overscroll-behavior: contain; touch-action: pan-y; }
.card .x { position: absolute; top: 12px; right: 12px; font-size: 11px; color: var(--faint); }
.card .x:hover { color: var(--ink); }
.card h2 { font: 400 28px/1.05 var(--f-text); margin: 0 50px 6px 0; }
.card .meta { color: var(--dim); font-size: 12px; margin-bottom: 12px; }
.card .fam { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--dim); margin-bottom: 8px; }
.card .fam i { width: 8px; height: 8px; border-radius: 50%; }
.card h3 { font: 400 10.5px var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--faint); margin: 14px 0 6px; }
.card .chips { display: flex; flex-wrap: wrap; gap: 5px; }
.card .chips button { padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--ink); display: inline-flex; gap: 6px; align-items: center; }
.card .chips button:hover { border-color: rgba(236, 228, 214, .35); }
.card .chips button i { width: 6px; height: 6px; border-radius: 50%; }
.card .chips button em { font-style: normal; color: var(--faint); font-size: 10.5px; }
.card .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.card .acts button, .card .acts a { padding: 7px 12px; border-radius: 999px; background: rgba(236, 228, 214, .07); font-size: 12px; color: var(--ink); text-decoration: none; }
.card .acts button.hot { background: rgba(201, 255, 106, .14); color: var(--spore); }
.card .acts button:hover, .card .acts a:hover { background: rgba(236, 228, 214, .14); }
.card .route { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(201, 255, 106, .06); border: 1px dashed rgba(201, 255, 106, .3); font-size: 12px; color: var(--dim); }
.card .route b { color: var(--spore); font-weight: 400; }
.card .links { margin-top: 14px; font-size: 11px; color: var(--faint); }
.card .links a { color: var(--dim); }
.card .note { font-size: 11px; color: var(--faint); margin-top: 10px; }
.card p.blurb { font: 16px/1.4 var(--f-text); color: #d8cfc2; margin: 0 0 6px; }

.tip { position: fixed; z-index: 7; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: rgba(12, 9, 18, .95); border: 1px solid var(--line); font-size: 12px; max-width: 280px; }
.now { position: fixed; left: 18px; bottom: 18px; z-index: 6; display: flex; gap: 10px; align-items: center; padding: 7px 8px 7px 14px; border-radius: 999px; background: var(--glass); border: 1px solid rgba(201, 255, 106, .3); font-size: 12px; max-width: min(420px, calc(100% - 36px)); }
.now span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now button { padding: 3px 10px; border-radius: 999px; background: rgba(236, 228, 214, .08); font-size: 11px; }
.toast { position: fixed; left: 50%; top: 110px; transform: translateX(-50%); z-index: 8; padding: 8px 14px; border-radius: 999px; background: rgba(12, 9, 18, .95); border: 1px solid var(--line); font-size: 12px; color: var(--dim); }

body.matrix .legend, body.matrix .time, body.web .time { display: none; }
body.web .lenses button[data-lens].on { background: none; color: var(--dim); }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 10px; padding: 12px 14px 0; }
  .mark h1 { font-size: 24px; }
  .mark p { font-size: 9.5px; }
  .modes { margin-left: auto; }
  .modes button { padding: 5px 9px; font-size: 11.5px; }
  .find { order: 3; width: 100%; }
  .lenses, .matrixtabs { top: auto; bottom: 66px; right: 50%; transform: translateX(50%); }
  .time { bottom: 14px; }
  .legend { display: none; }
  .card { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 52vh; border-radius: 18px 18px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .now { bottom: auto; top: 112px; left: 14px; }
  .toast { top: 150px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- language switcher + script/RTL support ---------- */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lang { position: relative; flex: none; }
.lang select { appearance: none; -webkit-appearance: none; padding: 8px 26px 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); color: var(--dim); font: 12px var(--f-mono); cursor: pointer; outline: none; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.lang select:hover, .lang select:focus { color: var(--ink); border-color: rgba(201, 255, 106, .45); }
.lang::after { content: ""; position: absolute; right: 12px; top: 50%; width: 5px; height: 5px; border-right: 1px solid var(--dim); border-bottom: 1px solid var(--dim); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.lang option { background: #120d18; color: var(--ink); }
/* Fonts: IM Fell and JetBrains Mono are Latin-only, so other scripts fall through to good system faces. */
/* For non-Latin scripts the body serif skips IM Fell entirely: its old-style figures and Latin glyphs look
   broken mid-sentence in CJK, Devanagari and Arabic. The Hyphae wordmark keeps IM Fell in every language. */
:root:lang(ru) { --f-text: Georgia, 'Times New Roman', serif; }
:root:lang(zh-Hans) { --f-text: 'Songti SC', 'Noto Serif CJK SC', 'Source Han Serif SC', serif; --f-mono: 'JetBrains Mono', 'PingFang SC', 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif; }
:root:lang(ja) { --f-text: 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif CJK JP', serif; --f-mono: 'JetBrains Mono', 'Hiragino Sans', 'Yu Gothic', 'Noto Sans CJK JP', sans-serif; }
:root:lang(ko) { --f-text: 'AppleMyungjo', 'Noto Serif CJK KR', 'Batang', serif; --f-mono: 'JetBrains Mono', 'Apple SD Gothic Neo', 'Noto Sans CJK KR', 'Malgun Gothic', sans-serif; }
:root:lang(hi) { --f-text: 'Kohinoor Devanagari', 'Noto Serif Devanagari', 'Mangal', serif; --f-mono: 'JetBrains Mono', 'Kohinoor Devanagari', 'Noto Sans Devanagari', sans-serif; }
:root:lang(ar) { --f-text: 'Geeza Pro', 'Noto Naskh Arabic', 'Traditional Arabic', serif; --f-mono: 'JetBrains Mono', 'Geeza Pro', 'Noto Sans Arabic', 'Segoe UI', sans-serif; }
.mark h1, #yr { font-family: 'IM Fell English', Georgia, serif; }
/* Uppercase tracking is a Latin idiom; drop it where it does nothing or hurts. */
.noital .mark p, .noital .card h3 { letter-spacing: .04em; text-transform: none; }
.noital #yr, .noital .card p.blurb { font-style: normal; }
.noital .card p.blurb { line-height: 1.6; }
/* RTL (Arabic): the map canvas stays as-is; panels and text mirror. */
[dir=rtl] .modes { margin-left: 0; margin-right: auto; }
[dir=rtl] .lenses, [dir=rtl] .matrixtabs { right: auto; left: 18px; }
[dir=rtl] .card { right: auto; left: 18px; }
[dir=rtl] .card .x { right: auto; left: 12px; }
[dir=rtl] .card h2 { margin: 0 0 6px 50px; }
[dir=rtl] .legend { left: auto; right: 18px; }
[dir=rtl] .legend button { text-align: right; }
[dir=rtl] .now { left: auto; right: 18px; }
[dir=rtl] #hits small { margin-left: 0; margin-right: auto; }
[dir=rtl] #yr { text-align: left; }
[dir=rtl] .lang select { padding: 8px 12px 8px 26px; }
[dir=rtl] .lang::after { right: auto; left: 12px; }
[dir=rtl] .time { direction: ltr; } /* the year slider runs past-to-present left-to-right in every language */
[dir=rtl] .time button { direction: rtl; }
@media (max-width: 760px) {
  .lang { order: 2; }
  .lang select { padding: 6px 22px 6px 10px; font-size: 11px; }
  [dir=rtl] .lenses, [dir=rtl] .matrixtabs { left: auto; right: 50%; }
  [dir=rtl] .card { left: 0; right: 0; }
  [dir=rtl] .now { right: auto; left: 14px; }
}

/* ---------- final design pass: tools, themes, new lenses ---------- */
:root[data-theme=ink] { --bg: #04070f; --spore: #8fb8ff; --glass: rgba(8, 12, 24, .8); }
:root[data-theme=burn] { --bg: #070403; --spore: #ff9a4a; --glass: rgba(20, 10, 6, .8); }
html, body { background: var(--bg); }
.mark h1 { text-shadow: 0 0 18px color-mix(in srgb, var(--spore) 30%, transparent); }
.time button, #drift.on, .tools button.on { color: var(--spore); background: color-mix(in srgb, var(--spore) 13%, transparent); }
.time input { accent-color: var(--spore); }
.now { border-color: color-mix(in srgb, var(--spore) 35%, transparent); }
.card .acts button.hot { color: var(--spore); background: color-mix(in srgb, var(--spore) 14%, transparent); }
.card .route b { color: var(--spore); }
.tools { position: fixed; left: 18px; top: 104px; z-index: 4; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: 220px; }
.tools button, .tools label { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); font-size: 11.5px; color: var(--dim); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.tools button:hover { color: var(--ink); }
.tools label { display: inline-flex; gap: 6px; align-items: center; }
.tools select, #speed { appearance: none; -webkit-appearance: none; background: none; border: 0; color: var(--ink); font: 11.5px var(--f-mono); cursor: pointer; outline: none; padding: 0 2px; }
.tools select option, #speed option { background: #120d18; color: var(--ink); }
.tools .axes { display: flex; flex-direction: column; gap: 4px; }
.cleg { margin: 2px 0 0; font-size: 11px; color: var(--dim); line-height: 1.4; }
#speed { border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; }
.lenses { max-width: calc(100% - 36px); overflow-x: auto; scrollbar-width: none; }
.lenses::-webkit-scrollbar { display: none; }
.lenses button { flex: none; }
.legend { bottom: 70px; }
body.lens-tunnel .legend, body.lens-sky .legend { opacity: .7; }
@media (max-width: 760px) {
  .lenses { right: 14px; left: 14px; transform: none; justify-content: flex-start; }
  .tools { top: auto; bottom: 112px; left: 14px; right: 14px; max-width: none; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tools::-webkit-scrollbar { display: none; }
  .tools > * { flex: none; }
  .tools #fly, .tools #scope { display: none; }
  .tools .axes { flex-direction: row; }
  .cleg { display: none; }
  .now { top: 118px; }
}
[dir=rtl] .tools { left: auto; right: 18px; align-items: flex-end; }
.card ul.lore { margin: 0; padding: 0 0 0 14px; display: grid; gap: 6px; font-size: 12.5px; color: #d8cfc2; }
.card ul.lore li::marker { color: var(--faint); }
.card ul.lore b { font-weight: 400; color: var(--ink); }
.card ul.deep button { padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--ink); }
.card ul.deep button em { font-style: normal; color: var(--faint); font-size: 10.5px; }
.card a.src { color: var(--dim); font-size: 10.5px; text-decoration: none; border-bottom: 1px dotted var(--faint); white-space: nowrap; }
.card a.src:hover { color: var(--spore); }
.card .fix { margin-top: 12px; padding: 9px 11px; border-radius: 10px; border: 1px dashed var(--line); font-size: 12px; color: var(--dim); }
.card .fix b { font-weight: 400; color: var(--spore); }
.lcap { position: fixed; left: 50%; bottom: 66px; transform: translateX(-50%); z-index: 3; width: min(560px, calc(100% - 36px)); margin: 0; padding: 8px 14px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); font-size: 11.5px; line-height: 1.45; color: var(--dim); text-align: center; pointer-events: none; }
@media (max-width: 760px) { .lcap { bottom: auto; top: 200px; font-size: 10.5px; } }
