/* docinn — styles */
:root {
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-hover: #ffffff;
  --text: #1a1d29;
  --text-soft: #5b6072;
  --text-faint: #8b90a3;
  --border: #e7e9f0;
  --border-strong: #d7dae6;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef0ff;
  --accent: #06b6d4;
  --chip-bg: #eef0f6;
  --chip-text: #4a4f63;
  --shadow-sm: 0 1px 2px rgba(20, 24, 50, .06), 0 1px 3px rgba(20, 24, 50, .05);
  --shadow-md: 0 6px 20px rgba(20, 24, 50, .10);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1180px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}
[data-theme="dark"] {
  --bg: #0d0f17;
  --bg-elev: #141826;
  --card: #161a28;
  --card-hover: #1c2133;
  --text: #e8eaf2;
  --text-soft: #a6abc0;
  --text-faint: #6e7490;
  --border: #242a3d;
  --border-strong: #313850;
  --brand: #818cf8;
  --brand-2: #a78bfa;
  --brand-soft: #1d2138;
  --accent: #22d3ee;
  --chip-bg: #1e2435;
  --chip-text: #b8bdd2;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
a { color: inherit; text-decoration: none; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg-elev) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 40%, transparent);
}
.brand-mark.small { width: 28px; height: 28px; font-size: 16px; border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; font-weight: 800; font-size: 19px; letter-spacing: -.3px; }
.brand-text small { font-weight: 500; font-size: 11px; color: var(--text-faint); letter-spacing: .5px; }

.search-wrap { position: relative; flex: 1; max-width: 560px; margin: 0 auto; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-faint); pointer-events: none; }
#search {
  width: 100%; height: 42px; padding: 0 42px 0 42px;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 999px;
  color: var(--text); font-size: 14.5px; font-family: inherit; outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
#search::placeholder { color: var(--text-faint); }
#search:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); background: var(--bg-elev); }
.search-kbd {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: var(--text-faint); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 1px 7px; background: var(--bg-elev);
}
.header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.ghost-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text-soft); cursor: pointer;
  display: grid; place-items: center; transition: background .2s, color .2s, border-color .2s;
}
.ghost-btn:hover { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* language switcher */
.header-actions { align-items: center; }
.lang-switch { position: relative; }
.lang-btn { display: inline-flex; align-items: center; gap: 6px; width: auto; min-width: 40px; padding: 0 11px; font-size: 13px; font-weight: 700; }
.lang-cur { letter-spacing: .3px; }
.lang-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 70;
  min-width: 172px; padding: 6px; border-radius: 12px;
  background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 2px;
}
.lang-menu[hidden] { display: none; }
.lang-opt {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: none; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--text); font-family: inherit; font-size: 14px; text-align: left;
  transition: background .14s, color .14s;
}
.lang-opt:hover { background: var(--brand-soft); color: var(--brand); }
.lang-opt .lo-code {
  display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 4px;
  font-size: 11px; font-weight: 800; border-radius: 6px; background: var(--chip-bg); color: var(--text-soft);
}
.lang-opt.active { color: var(--brand); font-weight: 700; }
.lang-opt.active .lo-code { background: var(--brand); color: #fff; }
.lang-opt .lo-tick { margin-left: auto; opacity: 0; color: var(--brand); font-weight: 800; }
.lang-opt.active .lo-tick { opacity: 1; }

/* ===== Hero ===== */
.hero { text-align: center; padding: 48px 0 24px; }
.hero h1 { font-size: clamp(28px, 5vw, 46px); font-weight: 850; letter-spacing: -1px; margin: 0 0 12px; }
.grad { background: linear-gradient(120deg, var(--brand), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--text-soft); font-size: 15px; margin: 0 0 28px; }
.hero-sub strong { color: var(--brand); }

.region-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.region-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: 999px; cursor: pointer;
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text-soft); font-size: 13.5px; font-weight: 600; font-family: inherit;
  transition: all .18s ease; white-space: nowrap;
}
.region-tab:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.region-tab.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 38%, transparent); }
.region-tab .emoji { font-size: 15px; }
.region-tab .count { font-size: 11px; opacity: .7; font-weight: 700; }

/* ===== Category bar ===== */
.cat-bar {
  position: sticky; top: 64px; z-index: 40;
  display: flex; gap: 8px; overflow-x: auto; padding: 16px 4px; margin: 8px 0 4px;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.cat-bar::-webkit-scrollbar { height: 6px; }
.cat-bar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 7px 14px; border-radius: 10px; cursor: pointer; font-family: inherit;
  background: var(--chip-bg); color: var(--chip-text); border: 1px solid transparent;
  font-size: 13px; font-weight: 600; transition: all .16s ease;
}
.cat-chip:hover { color: var(--brand); }
.cat-chip.active { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }

/* ===== Results ===== */
.results { display: flex; flex-direction: column; gap: 36px; padding: 12px 0 60px; }
.region-group > h2 {
  display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 800;
  margin: 0 0 16px; padding-bottom: 4px;
}
.region-group > h2 .g-emoji { font-size: 22px; }
.region-group > h2 .g-en { font-size: 12px; color: var(--text-faint); font-weight: 600; }
.region-group > h2 .g-count { margin-left: auto; font-size: 12px; color: var(--text-faint); font-weight: 600; }

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(244px, 1fr));
}

.card {
  position: relative; display: flex; gap: 13px; align-items: flex-start;
  padding: 15px; border-radius: var(--radius); background: var(--card);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(var(--brand), var(--brand-2)); opacity: 0; transition: opacity .16s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-strong); background: var(--card-hover); }
.card:hover::before { opacity: 1; }

.card-logo {
  position: relative; width: 44px; height: 44px; border-radius: 11px; flex-shrink: 0;
  overflow: hidden; background: var(--brand-soft); border: 1px solid var(--border);
}
.card-logo::before {
  content: attr(data-letter); position: absolute; inset: 0;
  display: grid; place-items: center;
  font-weight: 800; font-size: 19px; color: var(--brand);
}
.card-logo img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; padding: 7px; background: #fff; display: block;
}
.card-body { min-width: 0; flex: 1; }
.card-title { display: flex; align-items: center; gap: 6px; }
.card-title .name { font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-arrow { color: var(--text-faint); flex-shrink: 0; transition: transform .16s, color .16s; }
.card:hover .card-arrow { color: var(--brand); transform: translate(2px, -2px); }
.card-desc { font-size: 12.5px; color: var(--text-soft); margin: 3px 0 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { font-size: 11px; color: var(--text-faint); background: var(--chip-bg); padding: 1px 8px; border-radius: 6px; }
.card-host { display: block; font-size: 11px; color: var(--text-faint); margin-top: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ===== Empty ===== */
.empty { text-align: center; padding: 70px 0; color: var(--text-soft); }
.empty-emoji { font-size: 44px; margin-bottom: 10px; }
.reset-btn {
  margin-top: 14px; padding: 9px 20px; border-radius: 10px; cursor: pointer; font-family: inherit;
  background: var(--brand); color: #fff; border: none; font-weight: 600; font-size: 14px;
}
.reset-btn:hover { filter: brightness(1.08); }

/* ===== Footer ===== */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-elev); margin-top: 20px; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 20px; justify-content: space-between; align-items: center; padding: 28px 20px; }
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand p { margin: 2px 0 0; font-size: 12px; color: var(--text-faint); }
.footer-links { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; font-size: 13px; color: var(--text-soft); }
.footer-links a:hover { color: var(--brand); }
#footer-updated { color: var(--text-faint); }

/* ===== Back to top ===== */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  width: 46px; height: 46px; border-radius: 50%; cursor: pointer; font-size: 20px;
  background: var(--brand); color: #fff; border: none; box-shadow: var(--shadow-md);
  transition: transform .2s, opacity .2s; opacity: .92;
}
.to-top:hover { transform: translateY(-3px); opacity: 1; }

/* ===== Responsive ===== */
@media (max-width: 720px) {
  .brand-text small { display: none; }
  .search-kbd { display: none; }
  .hero { padding: 30px 0 18px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .cat-bar { top: 64px; }
  .search-wrap { max-width: none; }
}
@media (max-width: 460px) {
  .header-inner { gap: 10px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .card { padding: 12px; flex-direction: column; }
  .card-logo { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
