/* ============================================================
   NavHub — Front-end Stylesheet
   Editorial / Swiss Style
   ============================================================ */

:root {
  --accent: #e85a2c;
  --accent-soft: rgba(232, 90, 44, 0.08);
  --bg: #ffffff;
  --bg-soft: #f7f7f6;
  --bg-mute: #efefee;
  --border: #e6e6e4;
  --text: #1a1a1a;
  --text-soft: #5a5a58;
  --text-mute: #8a8a86;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-hover: 0 2px 4px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.08);
  --radius: 4px;
  --radius-lg: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0f0f0e;
  --bg-soft: #18181a;
  --bg-mute: #22222a;
  --border: #2a2a32;
  --text: #f3f3f1;
  --text-soft: #b3b3b0;
  --text-mute: #7a7a78;
  --shadow: 0 1px 2px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.25);
  --shadow-hover: 0 2px 4px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; }
img { display: block; max-width: 100%; }
kbd {
  font-family: var(--font-sans);
  font-size: 10px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-mute);
  background: var(--bg-soft);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  border-radius: var(--radius);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-sub  { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

.header-actions { display: flex; align-items: center; gap: 8px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 10px;
  height: 36px;
  width: 280px;
  transition: border-color .15s, background .15s;
}

.search-box:focus-within {
  border-color: var(--text-mute);
  background: var(--bg);
}

.search-box svg { color: var(--text-mute); flex-shrink: 0; }
.search-box input {
  border: 0;
  background: transparent;
  flex: 1;
  font: inherit;
  color: inherit;
  outline: none;
  min-width: 0;
}
.search-box input::placeholder { color: var(--text-mute); }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--text-soft);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }

[data-theme="light"] .ic-moon { display: none; }
[data-theme="dark"]  .ic-sun  { display: none; }

/* ---------- Main ---------- */
.main-content {
  flex: 1;
  padding: 48px 24px 80px;
}

/* ---------- Section ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding-bottom: 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.group-ico { font-size: 18px; }

.section-meta, .section-sub {
  font-size: 13px;
  color: var(--text-mute);
}

.section-sub { margin-left: auto; }

/* ---------- Featured ---------- */
.featured-section { margin-bottom: 56px; }

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

.featured-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  transition: border-color .15s, transform .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}

.featured-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 1;
  transition: opacity .15s;
}

.featured-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.featured-icon {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--bg);
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}
.featured-icon img { width: 24px; height: 24px; }

.featured-body { flex: 1; min-width: 0; }
.featured-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}
.featured-desc {
  font-size: 13px;
  color: var(--text-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.featured-meta {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- Group ---------- */
.group-section { margin-bottom: 56px; }

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

.nav-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}

.nav-card:hover {
  border-color: var(--text-mute);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.nav-card-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  position: relative;
}

.nav-card-icon {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--bg-soft);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border);
}
.nav-card-icon img { width: 22px; height: 22px; }

.icon-fallback {
  position: absolute;
  font-weight: 700;
  color: var(--text-soft);
  font-size: 14px;
  display: block;
  pointer-events: none;
  user-select: none;
}
.featured-icon .icon-fallback { font-size: 16px; }
.nav-card-icon .icon-fallback { font-size: 13px; }

/* 当有 img 且加载成功时，隐藏 fallback */
.featured-icon img:not(.img-fail) ~ .icon-fallback,
.nav-card-icon img:not(.img-fail) ~ .icon-fallback {
  display: none;
}

img.img-fail { display: none !important; }
img.img-fail ~ .icon-fallback { display: block; }

/* fallback hover: 强调色 */
.nav-card:hover .nav-card-icon .icon-fallback { color: var(--accent); }
.featured-card:hover .featured-icon .icon-fallback { color: var(--accent); }

.nav-card-body { flex: 1; min-width: 0; }

.nav-card-title {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-card-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 2px;
  font-weight: 500;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.nav-card-desc {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-card-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s;
  flex-shrink: 0;
}

.nav-card:hover .nav-card-actions { opacity: 1; }

.icon-btn-mini {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--text-mute);
  transition: background .15s, color .15s;
}
.icon-btn-mini:hover {
  background: var(--bg-mute);
  color: var(--text);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 40px;
  background: var(--bg-soft);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.contact-item {
  display: flex;
  flex-direction: column;
  font-size: 13px;
}
.contact-label {
  color: var(--text-mute);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.contact-value {
  color: var(--text-soft);
  margin-top: 2px;
  font-size: 13px;
}

.copyright {
  font-size: 12px;
  color: var(--text-mute);
}

/* ---------- Empty / Search ---------- */
.search-empty {
  text-align: center;
  padding: 80px 0;
  color: var(--text-mute);
}

.empty-state {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 24px;
}
.empty-card {
  text-align: center;
  max-width: 400px;
  color: var(--text-mute);
}
.empty-card svg { color: var(--text-mute); margin-bottom: 16px; }
.empty-card h1 { font-size: 24px; margin-bottom: 8px; color: var(--text); font-weight: 700; }
.empty-card p  { margin-bottom: 24px; }

.btn-primary {
  display: inline-block;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: 0.85; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
}
.modal[hidden] { display: none; }
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 320px;
  max-width: 90vw;
  box-shadow: var(--shadow-hover);
  animation: scaleIn .2s cubic-bezier(.2,.7,.3,1.4);
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
.modal-body {
  padding: 24px;
  display: grid;
  place-items: center;
  min-height: 200px;
}
.modal-body canvas, .modal-body img {
  display: block;
  width: 200px;
  height: 200px;
}
.modal-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-mute);
}
.qr-url {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 200;
  animation: toastIn .2s ease;
  box-shadow: var(--shadow-hover);
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .header-inner { height: 56px; gap: 12px; }
  .search-box { width: 160px; }
  .search-box kbd { display: none; }
  .brand-sub { display: none; }
  .main-content { padding: 32px 16px 64px; }
  .featured-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .nav-card-link { padding: 12px; gap: 10px; }
  .nav-card-desc { display: none; }
  .nav-card-actions { opacity: 1; }
  .contacts { gap: 16px; }
  .section-head { flex-wrap: wrap; }
  .section-sub { margin-left: 0; width: 100%; order: 2; }
}

@media (max-width: 420px) {
  .search-box { display: none; }
  .card-grid { grid-template-columns: 1fr; }
}
