:root{
  --bg:#1a1510;
  --panel:rgba(255,255,255,.045);
  --panel-2:rgba(255,255,255,.08);
  --line:rgba(232,217,184,.14);
  --line-2:rgba(232,217,184,.30);
  --text:#f3ecda;
  --text-2:#c9b89a;
  --text-3:#9c8a6d;
  --text-4:#6b5c45;
  --accent:#d9953d;
  --accent-2:#c47f2a;
  --gold:#e3b23c;
  --ink:#1c1309;
  --sans:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  --serif:'Instrument Serif',Georgia,'Times New Roman',serif;
  --mono:'IBM Plex Mono',ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  --dev:'Noto Serif Devanagari','Noto Sans Devanagari',var(--serif);
}
*{margin:0;padding:0;box-sizing:border-box}
[hidden]{display:none !important}
body.boot *{transition:none !important; animation:none !important}
html,body{height:100%}
body{
  background:var(--bg); color:var(--text); font-family:var(--sans);
  -webkit-font-smoothing:antialiased;
  background-image:radial-gradient(130% 95% at 50% -8%, #26200f 0%, #1d1710 52%, #130f08 100%);
  background-attachment:fixed;
}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:6px}
button{font-family:inherit; color:inherit; background:none; border:none}
input{font-family:inherit; color:inherit}

.page{display:flex; flex-direction:column; min-height:100vh}

/* ---------- top bar ---------- */
.bar{
  display:flex; justify-content:space-between; align-items:center; gap:12px;
  padding:max(14px, env(safe-area-inset-top)) 20px 0; flex:none;
}
.home,.icon{
  display:inline-flex; align-items:center; gap:7px; height:38px;
  color:var(--text); text-decoration:none; font:500 14px/1 var(--sans);
  background:var(--panel); border:1px solid var(--line); border-radius:999px;
  cursor:pointer; transition:background .15s, border-color .15s;
}
.home{padding:0 14px 0 10px}
.home span{font-family:var(--serif); font-size:18px; letter-spacing:.01em}
.icon{width:38px; justify-content:center; padding:0}
.home:hover,.icon:hover{background:var(--panel-2); border-color:var(--line-2)}

/* ---------- layout ---------- */
main{
  flex:1; display:grid; grid-template-columns:minmax(0,1fr) 280px;
  gap:24px; padding:10px 20px max(22px, env(safe-area-inset-bottom));
  align-items:start; align-content:start;
  width:100%; max-width:1128px; margin:0 auto;
}
.stage{display:flex; flex-direction:column; gap:16px; min-width:0}
.titleblock{max-width:700px; padding:6px 2px 2px}
.kicker{font-size:11.5px; font-weight:600; letter-spacing:.15em; text-transform:uppercase; color:var(--text-3)}
h1{
  font-family:var(--serif); font-weight:400; font-size:clamp(32px, 4.2vw, 54px);
  line-height:1; letter-spacing:-.01em; margin:4px 0 8px;
}
.sub{font-size:14.5px; line-height:1.55; color:var(--text-2); max-width:68ch}
.sub b{font-weight:600; color:var(--text)}
.lbl{
  font-size:11px; font-weight:600; letter-spacing:.12em; text-transform:uppercase;
  color:var(--text-3); display:flex; justify-content:space-between; align-items:baseline; gap:8px;
}
.sr{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap}

/* ---------- tabs ---------- */
.tabs{display:flex; gap:6px; border-bottom:1px solid var(--line); padding-bottom:0}
.tab{
  padding:9px 15px; font:600 13.5px/1 var(--sans); color:var(--text-3);
  border-bottom:2px solid transparent; cursor:pointer; margin-bottom:-1px;
  transition:color .14s, border-color .14s;
}
.tab:hover{color:var(--text-2)}
.tab.active{color:var(--accent); border-bottom-color:var(--accent)}

/* ---------- chain stage ---------- */
.chainGrp{display:flex; flex-direction:column; gap:10px}
.chainHead{display:flex; justify-content:space-between; align-items:baseline; gap:12px; flex-wrap:wrap}
#wordTitle{font-family:var(--serif); font-weight:400; font-size:clamp(26px,3.4vw,38px); letter-spacing:.01em}
.wordNote{font-size:13px; line-height:1.5; color:var(--text-3); max-width:72ch; min-height:1.2em}
.btn{
  display:flex; align-items:center; justify-content:center; text-align:center; gap:7px;
  padding:0 14px; height:38px; border-radius:11px; cursor:pointer; flex:none;
  background:var(--panel-2); border:1px solid var(--line);
  font:600 13px/1 var(--sans); color:var(--text-2); white-space:nowrap;
  transition:background .14s, border-color .14s, transform .08s, color .14s;
}
.btn:hover{background:rgba(255,255,255,.12); border-color:var(--line-2); color:var(--text)}
.btn:active{transform:translateY(1px)}

.chainWrap{
  border-radius:14px; background:#120d07; border:1px solid var(--line);
  box-shadow:0 22px 46px -30px #000, 0 1px 0 rgba(240,230,210,.05) inset;
  padding:20px 16px; overflow-x:auto;
}
.chain{display:flex; align-items:stretch; gap:2px; min-width:min-content}
.hop{
  flex:none; width:168px; display:flex; flex-direction:column; gap:6px;
  padding:14px 13px; border-radius:12px; background:var(--panel);
  border:1px solid var(--line); border-top:3px solid var(--fam, var(--accent));
}
.hop .lang{
  font:700 10px/1.1 var(--sans); letter-spacing:.07em; text-transform:uppercase;
  color:var(--fam, var(--accent));
}
.hop .form{font-family:var(--serif); font-size:21px; line-height:1.15; color:var(--text)}
.hop .script{font-family:var(--dev); font-size:17px; color:var(--text-2); margin-top:-2px}
.hop .gloss{font-size:11.5px; line-height:1.4; color:var(--text-3); flex:1}
.hop .era{font:600 10.5px/1 var(--mono); color:var(--text-4)}
.hop.english{border-top-color:var(--gold); background:rgba(227,178,60,.08)}
.hop.english .lang{color:var(--gold)}
.arrow{
  flex:none; display:flex; align-items:center; justify-content:center;
  width:30px; color:var(--text-4); font-size:16px;
}

/* ---------- browse grid ---------- */
.browseGrp{display:flex; flex-direction:column; gap:10px}
#search{
  height:42px; padding:0 14px; border-radius:11px;
  background:var(--panel); border:1px solid var(--line); color:var(--text);
  font:500 14px/1 var(--sans);
}
#search::placeholder{color:var(--text-4)}
#search:focus{border-color:var(--accent-2)}
.grid{display:flex; flex-wrap:wrap; gap:7px; max-height:220px; overflow-y:auto; padding:2px}
.wordchip{
  padding:7px 13px; border-radius:999px; background:var(--panel); border:1px solid var(--line);
  border-left:3px solid var(--fam, var(--line));
  font:600 13px/1 var(--sans); color:var(--text-2); cursor:pointer;
  transition:background .14s, border-color .14s, color .14s;
}
.wordchip:hover{background:var(--panel-2); color:var(--text)}
.wordchip.active{background:rgba(217,149,61,.18); color:var(--text); border-color:var(--accent-2)}
.grid .empty{font-size:13px; color:var(--text-3); padding:6px}

/* ---------- myths ---------- */
.mythIntro{font-size:14px; line-height:1.55; color:var(--text-2); max-width:72ch}
.myths{display:flex; flex-direction:column; gap:10px}
.mythcard{
  border-radius:13px; background:var(--panel); border:1px solid var(--line); padding:14px 16px;
}
.mythcard .claim{display:flex; align-items:flex-start; gap:9px; font-family:var(--serif); font-size:18px; line-height:1.3}
.mythcard .badge{flex:none; width:22px; height:22px; border-radius:50%; display:flex; align-items:center; justify-content:center; font:700 12px/1 var(--mono); margin-top:3px}
.mythcard.false .badge{background:rgba(196,86,74,.2); color:#e08a7d}
.mythcard.false .claim{color:var(--text-3); text-decoration:line-through; text-decoration-color:rgba(196,86,74,.5)}
.mythcard.true .badge{background:rgba(92,158,99,.2); color:#8fcb9a}
.mythcard.true .claim{color:var(--text)}
.mythcard .text{font-size:13.5px; line-height:1.6; color:var(--text-2); margin-top:9px; padding-left:31px}

/* ---------- panel ---------- */
.panel{
  display:flex; flex-direction:column; gap:14px; position:sticky; top:12px;
  background:var(--panel); border:1px solid var(--line); border-radius:16px;
  padding:14px 15px 13px;
}
.grp{display:flex; flex-direction:column; gap:8px}
.readout{
  border-radius:11px; padding:10px 12px; border:1px solid var(--line);
  background:var(--panel-2); font-size:12.5px; line-height:1.5; color:var(--text-2);
}
.readout .big{display:block; font:400 24px/1.1 var(--serif); color:var(--text); margin-bottom:2px}
.readout .dim{color:var(--text-3); font-size:12px}
.fams{display:flex; flex-direction:column; gap:5px}
.famchip{
  display:flex; align-items:center; gap:8px; padding:7px 10px; border-radius:9px;
  background:transparent; border:1px solid transparent; cursor:pointer;
  font:500 12.5px/1.2 var(--sans); color:var(--text-2); text-align:left;
  transition:background .14s, border-color .14s, color .14s;
}
.famchip .dot{width:9px; height:9px; border-radius:50%; flex:none; background:var(--fam)}
.famchip .n{margin-left:auto; font:600 11px/1 var(--mono); color:var(--text-4)}
.famchip:hover{background:var(--panel-2)}
.famchip.active{background:rgba(217,149,61,.15); border-color:var(--line-2); color:var(--text)}
.foot{font-size:11.5px; line-height:1.6; color:#cfbfa0; border-top:1px solid var(--line); padding-top:12px}
.link{color:var(--accent); cursor:pointer; font:inherit; font-weight:600; text-align:left; text-decoration:underline; text-underline-offset:2px}
.link:hover{color:#f0b35a}

/* ---------- about ---------- */
dialog{border:none; padding:0; background:transparent; max-width:min(706px, 92vw); max-height:86vh; margin:auto}
dialog::backdrop{background:rgba(10,8,3,.68); backdrop-filter:blur(3px)}
.about{
  position:relative; background:#1c1309; border:1px solid rgba(232,217,184,.2);
  border-radius:18px; padding:26px 28px 24px; overflow-y:auto; max-height:86vh;
  box-shadow:0 30px 60px -28px #000;
}
.about h2{font-family:var(--serif); font-weight:400; font-size:30px; line-height:1.07; margin:4px 0 14px; color:var(--text)}
.about h3{font-family:var(--serif); font-weight:400; font-size:21px; line-height:1.1; margin:20px 0 10px; color:var(--text)}
.about p{font-size:14.5px; line-height:1.68; color:var(--text-2); margin-bottom:12px}
.about p i{font-style:italic; color:var(--text)}
.about .fine{font-size:12.5px; color:var(--text-3); border-top:1px solid var(--line); padding-top:12px; margin-top:4px; margin-bottom:0}
.x{
  position:absolute; top:14px; right:14px; width:32px; height:32px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; color:var(--text-3);
  background:var(--panel-2); border:1px solid var(--line); border-radius:999px;
}
.x:hover{color:var(--text); border-color:var(--line-2)}

/* ---------- narrow ---------- */
@media (max-width:920px){
  main{grid-template-columns:minmax(0,1fr); gap:16px; padding:8px 14px max(20px, env(safe-area-inset-bottom))}
  .panel{position:static}
  h1{font-size:clamp(28px, 7.6vw, 40px)}
  .sub{font-size:14px}
  .about{padding:22px 20px 20px; border-radius:15px}
  .about h2{font-size:25px}
  .about h3{font-size:19px}
}
@media (max-width:420px){
  .chainHead{flex-direction:column; align-items:flex-start}
  .hop{width:150px}
  #wordTitle{font-size:26px}
}
