:root{
  --bg:#14120f;
  --bg-alt:#1c1913;
  --bg-alt-2:#221e17;
  --iron:#4a4740;
  --iron-soft:#33302a;
  --patina:#7c8f6a;
  --patina-dim:#5c6b4f;
  --rust:#a8503a;
  --rust-bright:#c96a4f;
  --spark:#7fa8b8;
  --bone:#e8e2d4;
  --bone-dim:#a39c8c;
  --font-display:'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-body:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:ui-monospace, 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

*{box-sizing:border-box; margin:0; padding:0;}
html{scroll-behavior:smooth;}
body{
  background:var(--bg);
  color:var(--bone);
  font-family:var(--font-body);
  line-height:1.55;
  min-height:100vh;
  display:flex;
  flex-direction:column;
}
a{color:inherit; text-decoration:none;}
img{display:block; max-width:100%;}
.wrap{max-width:1180px; margin:0 auto; padding:0 20px; width:100%;}
.muted{color:var(--bone-dim); font-size:.85rem;}

.topbar{
  position:sticky; top:0; z-index:40;
  background:rgba(20,18,15,.92);
  backdrop-filter:blur(8px);
  border-bottom:1px solid var(--iron-soft);
}
.topbar-inner{
  max-width:1180px; margin:0 auto;
  display:flex; align-items:center; gap:16px;
  padding:12px 20px;
}
.brand img{height:34px; width:auto;}
.nav-links{
  display:flex; flex-wrap:wrap; gap:4px 12px;
  flex:1; font-size:.82rem; letter-spacing:.02em;
}
.nav-links a{
  color:var(--bone-dim);
  padding:6px 2px;
  border-bottom:2px solid transparent;
}
.nav-links a:hover,
.nav-links a.active{color:var(--patina); border-bottom-color:var(--patina);}
.topbar-actions{display:flex; align-items:center; gap:10px;}
.lang-switch{
  display:inline-flex;
  border:1px solid var(--iron);
  border-radius:2px;
  overflow:hidden;
}
.lang-switch button{
  font-family:var(--font-mono);
  font-size:.7rem;
  letter-spacing:.1em;
  padding:7px 9px;
  background:transparent;
  border:none;
  color:var(--bone-dim);
  cursor:pointer;
}
.lang-switch button + button{border-left:1px solid var(--iron);}
.lang-switch button.active{background:var(--iron-soft); color:var(--patina);}
.btn{
  display:inline-block;
  font-weight:600;
  font-size:.8rem;
  padding:8px 14px;
  border-radius:2px;
  border:1px solid var(--iron);
}
.btn-ghost{color:var(--bone-dim);}
.btn-ghost:hover{border-color:var(--patina); color:var(--bone);}
.btn-primary{background:var(--rust); border-color:var(--rust); color:var(--bone);}

main.wrap{flex:1; padding:28px 20px 48px;}
.loading{padding:48px 0; color:var(--bone-dim); text-align:center;}

.hero-wiki{
  text-align:center;
  padding:28px 0 36px;
  border-bottom:1px solid var(--iron-soft);
  margin-bottom:28px;
  background:
    radial-gradient(ellipse 55% 80% at 50% 0%, rgba(124,143,106,.12), transparent 70%);
}
.hero-wiki h1{
  font-family:var(--font-display);
  font-size:clamp(2rem, 4vw, 2.8rem);
  font-weight:600;
  letter-spacing:.04em;
  margin-bottom:8px;
}
.hero-wiki p{color:var(--bone-dim); max-width:520px; margin:0 auto 18px;}
.search-bar{
  display:flex; gap:8px; max-width:560px; margin:0 auto;
}
.search-bar input{
  flex:1;
  background:var(--bg-alt);
  border:1px solid var(--iron);
  color:var(--bone);
  padding:12px 14px;
  border-radius:2px;
  font-size:.95rem;
}
.search-bar input:focus{outline:none; border-color:var(--patina);}
.search-bar button{
  background:var(--rust);
  border:1px solid var(--rust);
  color:var(--bone);
  padding:0 18px;
  border-radius:2px;
  font-weight:600;
  cursor:pointer;
}

.cat-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(160px, 1fr));
  gap:12px;
  margin-top:8px;
}
.cat-card{
  background:var(--bg-alt);
  border:1px solid var(--iron-soft);
  border-radius:3px;
  padding:18px 14px;
  text-align:center;
  transition:border-color .15s, transform .15s;
}
.cat-card:hover{
  border-color:var(--patina);
  transform:translateY(-2px);
}
.cat-card .count{
  display:block;
  font-family:var(--font-mono);
  font-size:.75rem;
  color:var(--patina);
  margin-top:6px;
}
.cat-card .label{
  font-weight:600;
  font-size:.95rem;
}

.toolbar{
  display:flex; flex-wrap:wrap; gap:10px; align-items:center;
  margin-bottom:16px;
}
.toolbar input,
.toolbar select{
  background:var(--bg-alt);
  border:1px solid var(--iron);
  color:var(--bone);
  padding:9px 12px;
  border-radius:2px;
  font-size:.9rem;
}
.toolbar input{flex:1; min-width:180px;}
.crumb{font-size:.82rem; color:var(--bone-dim); margin-bottom:14px;}
.crumb a{color:var(--patina);}
.crumb a:hover{text-decoration:underline;}

.entity-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(132px, 1fr));
  gap:10px;
}
.entity-card{
  background:var(--bg-alt);
  border:1px solid var(--iron-soft);
  border-radius:3px;
  padding:10px 8px 12px;
  text-align:center;
  transition:border-color .15s;
  min-height:148px;
}
.entity-card:hover{border-color:var(--patina);}
.entity-card .icon-wrap{
  width:64px; height:64px;
  margin:0 auto 8px;
  background:var(--bg-alt-2);
  border:1px solid var(--iron-soft);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
}
.entity-card .icon-wrap img{
  width:100%; height:100%;
  object-fit:contain;
}
.entity-card .icon-wrap .ph{
  font-size:.65rem;
  color:var(--iron);
  letter-spacing:.08em;
}
.entity-card .title{
  font-size:.8rem;
  font-weight:600;
  line-height:1.25;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}
.entity-card .meta{
  font-size:.68rem;
  color:var(--bone-dim);
  margin-top:4px;
}

.pager{
  display:flex; justify-content:center; align-items:center; gap:12px;
  margin-top:22px;
}
.pager button{
  background:var(--bg-alt);
  border:1px solid var(--iron);
  color:var(--bone);
  padding:8px 14px;
  border-radius:2px;
  cursor:pointer;
}
.pager button:disabled{opacity:.35; cursor:default;}

.detail{
  display:grid;
  grid-template-columns:200px 1fr;
  gap:24px;
  background:var(--bg-alt);
  border:1px solid var(--iron-soft);
  border-radius:4px;
  padding:22px;
}
.detail-rich{align-items:start;}
.detail-icon{
  width:180px; height:180px;
  background:var(--bg-alt-2);
  border:1px solid var(--iron);
  display:flex; align-items:center; justify-content:center;
  margin:0 auto;
  position:sticky;
  top:72px;
}
.detail-icon img{width:100%; height:100%; object-fit:contain;}
.detail-icon .ph{color:var(--iron); font-size:.8rem;}
.detail h1{
  font-family:var(--font-display);
  font-size:1.85rem;
  font-weight:600;
  margin-bottom:4px;
}
.detail .sub{color:var(--bone-dim); font-size:.85rem; margin-bottom:16px;}
.detail-section{
  margin:18px 0 8px;
  padding-top:14px;
  border-top:1px solid var(--iron-soft);
}
.detail-section h2{
  font-size:.72rem;
  letter-spacing:.12em;
  text-transform:uppercase;
  color:var(--patina);
  margin-bottom:10px;
  font-weight:600;
}
.stats,
.data-table{
  width:100%;
  border-collapse:collapse;
  font-size:.88rem;
}
.stats th,.stats td,
.data-table th,.data-table td{
  text-align:left;
  padding:7px 10px;
  border-bottom:1px solid var(--iron-soft);
  vertical-align:top;
}
.stats th{
  width:38%;
  color:var(--bone-dim);
  font-weight:500;
}
.data-table thead th{
  color:var(--bone-dim);
  font-weight:600;
  font-size:.75rem;
  letter-spacing:.04em;
  text-transform:uppercase;
}
.stats td,.data-table td{word-break:break-word;}
.wiki-link{color:var(--spark); border-bottom:1px solid transparent;}
.wiki-link:hover{border-bottom-color:var(--spark);}
.chip-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(200px, 1fr));
  gap:8px;
}
.entity-chip{
  display:flex;
  align-items:center;
  gap:10px;
  background:var(--bg-alt-2);
  border:1px solid var(--iron-soft);
  border-radius:3px;
  padding:8px 10px;
  min-height:52px;
  transition:border-color .15s;
}
.entity-chip:hover{border-color:var(--patina);}
.chip-icon{
  width:36px; height:36px;
  flex:0 0 36px;
  background:var(--bg);
  border:1px solid var(--iron-soft);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
}
.chip-icon img{width:100%; height:100%; object-fit:contain;}
.chip-icon .ph{font-size:.55rem; color:var(--iron);}
.chip-title{font-size:.82rem; font-weight:600; line-height:1.25;}
.chip-meta{display:block; font-size:.68rem; color:var(--bone-dim); margin-top:2px;}
.bullet-list{padding-left:18px; color:var(--bone-dim); font-size:.9rem;}
.bullet-list li{margin:4px 0;}
.raw-details{
  margin-top:18px;
  border-top:1px solid var(--iron-soft);
  padding-top:12px;
}
.raw-details summary{
  cursor:pointer;
  color:var(--bone-dim);
  font-size:.8rem;
  letter-spacing:.06em;
  text-transform:uppercase;
  margin-bottom:10px;
}
.detail-actions{margin-top:20px;}
.badge{
  display:inline-block;
  font-size:.7rem;
  letter-spacing:.06em;
  text-transform:uppercase;
  padding:3px 8px;
  border:1px solid var(--iron);
  color:var(--patina);
  margin-right:6px;
  margin-bottom:10px;
}

.footer{
  border-top:1px solid var(--iron-soft);
  padding:16px 0;
  margin-top:auto;
}
.footer-inner{
  display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap;
  font-size:.8rem; color:var(--bone-dim);
}

.empty{
  text-align:center;
  padding:40px 12px;
  color:var(--bone-dim);
}

@media (max-width:760px){
  .nav-links{display:none;}
  .detail{grid-template-columns:1fr;}
  .detail-icon{width:120px; height:120px;}
}
