/* =====================================================================
 * kdd666.xyz —— 个人导航起始页样式
 * 设计原则：零外部请求（不引 CDN、不引字体文件），系统字体栈，深浅两色。
 * 想改配色，只改下面 --accent / --bg 这几行就够了。
 * ===================================================================== */

/* ---------- 1. 设计变量 ---------- */
:root {
  --bg: #f5f6fa;
  --bg-soft: #ffffff;
  --card: rgba(255, 255, 255, .74);
  --card-hover: rgba(255, 255, 255, .95);
  --border: rgba(15, 23, 42, .08);
  --border-strong: rgba(15, 23, 42, .14);
  --text: #101828;
  --text-soft: #475467;
  --muted: #8494ab;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, .12);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 10px 28px -12px rgba(16, 24, 40, .22);
  --shadow-lg: 0 22px 48px -20px rgba(16, 24, 40, .3);
  --glow-a: rgba(99, 102, 241, .24);
  --glow-b: rgba(236, 72, 153, .16);
  --ring: rgba(79, 70, 229, .35);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0a0e17;
  --bg-soft: #111725;
  --card: rgba(255, 255, 255, .045);
  --card-hover: rgba(255, 255, 255, .085);
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #e8ecf5;
  --text-soft: #b3bdd0;
  --muted: #7d8aa3;
  --accent: #8b8cff;
  --accent-soft: rgba(139, 140, 255, .16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 14px 34px -14px rgba(0, 0, 0, .7);
  --shadow-lg: 0 26px 56px -22px rgba(0, 0, 0, .8);
  --glow-a: rgba(99, 102, 241, .34);
  --glow-b: rgba(217, 70, 239, .2);
  --ring: rgba(139, 140, 255, .45);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0a0e17;
    --bg-soft: #111725;
    --card: rgba(255, 255, 255, .045);
    --card-hover: rgba(255, 255, 255, .085);
    --border: rgba(255, 255, 255, .08);
    --border-strong: rgba(255, 255, 255, .16);
    --text: #e8ecf5;
    --text-soft: #b3bdd0;
    --muted: #7d8aa3;
    --accent: #8b8cff;
    --accent-soft: rgba(139, 140, 255, .16);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 14px 34px -14px rgba(0, 0, 0, .7);
    --shadow-lg: 0 26px 56px -22px rgba(0, 0, 0, .8);
    --glow-a: rgba(99, 102, 241, .34);
    --glow-b: rgba(217, 70, 239, .2);
    --ring: rgba(139, 140, 255, .45);
    color-scheme: dark;
  }
}

/* ---------- 2. 基础 ---------- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .3s ease, color .3s ease;
}

a { color: inherit; }

button { font: inherit; color: inherit; }

:where(a, button, input):focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
  border-radius: 10px;
}

/* ---------- 3. 背景光晕 ---------- */
.glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.glow span {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(72px);
  opacity: .9;
}
.glow-a {
  width: 46vw; height: 46vw;
  min-width: 340px; min-height: 340px;
  top: -14vw; left: -10vw;
  background: var(--glow-a);
}
.glow-b {
  width: 40vw; height: 40vw;
  min-width: 300px; min-height: 300px;
  top: -6vw; right: -12vw;
  background: var(--glow-b);
}

/* ---------- 4. 布局容器 ---------- */
.hero,
.sections,
.footer {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 32px);
}

/* ---------- 5. 顶部 ---------- */
.hero { padding-top: clamp(24px, 5vh, 56px); }

.hero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.brand-mark {
  width: 38px; height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #a855f7 55%, #ec4899);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.brand-text strong {
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: .01em;
}
.brand-text small {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: .06em;
}

.theme-toggle {
  width: 38px; height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: background-color .2s ease, border-color .2s ease, transform .2s ease;
}
.theme-toggle:hover { background: var(--card-hover); border-color: var(--border-strong); transform: translateY(-1px); }
.theme-toggle svg {
  width: 19px; height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .theme-toggle .i-sun { display: none; }
  :root[data-theme="auto"] .theme-toggle .i-moon { display: block; }
}

/* ---------- 6. 时钟 ---------- */
.hero-clock {
  margin-top: clamp(28px, 7vh, 64px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.clock {
  font-size: clamp(46px, 10.5vw, 88px);
  font-weight: 600;
  letter-spacing: -.045em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--text), var(--text-soft));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.clock-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  font-size: 13.5px;
  color: var(--muted);
  letter-spacing: .02em;
}
.greeting { color: var(--text-soft); font-weight: 500; }
.date { font-variant-numeric: tabular-nums; }

/* ---------- 7. 搜索 ---------- */
.search {
  margin-top: clamp(22px, 4vh, 34px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px 7px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.search:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  background: var(--card-hover);
}
.search-icon {
  width: 19px; height: 19px;
  flex: none;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
}
#search-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 15.5px;
  outline: none;
}
#search-input::placeholder { color: var(--muted); }
#search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

.engines {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}
.engines button {
  padding: 6px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .18s ease, background-color .18s ease;
}
.engines button:hover { color: var(--text); background: var(--accent-soft); }
.engines button[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

/* ---------- 8. 快捷标签 ---------- */
.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  min-height: 28px;
}
.quick-tags:empty { display: none; }
.quick-tags button {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease, background-color .18s ease, transform .18s ease;
}
.quick-tags button:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--card);
  transform: translateY(-1px);
}

/* ---------- 9. 导航分组 ---------- */
.sections {
  display: grid;
  gap: clamp(26px, 4vh, 40px);
  padding-top: clamp(34px, 6vh, 56px);
  padding-bottom: clamp(40px, 7vh, 72px);
}
.noscript { color: var(--muted); }
/* 网格子项默认 min-width:auto，卡片名过长时会把整列顶宽，这里压掉 */
.section { min-width: 0; }

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.section-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.section-head::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, var(--border-strong), transparent);
}
.section-count {
  flex: none;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

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

.card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  transition: transform .18s ease, box-shadow .18s ease,
              background-color .18s ease, border-color .18s ease;
}
.card:hover,
.card:focus-visible {
  transform: translateY(-3px);
  background: var(--card-hover);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.card:active { transform: translateY(-1px); }

.card-icon {
  --h: 240;
  width: 38px; height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-size: 18px;
  line-height: 1;
  color: #fff;
  background: linear-gradient(140deg,
              hsl(var(--h) 82% 62%),
              hsl(calc(var(--h) + 34) 78% 52%));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 6px -2px hsl(var(--h) 80% 45% / .5);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .12);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.card-name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-desc {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 10. 页脚 ---------- */
.footer {
  padding-top: 22px;
  padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  text-align: center;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.footer-line {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .02em;
}
.footer-legal a {
  color: var(--text-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .18s ease, border-color .18s ease;
}
.footer-legal a:hover {
  color: var(--accent);
  border-bottom-color: currentColor;
}

/* ---------- 11. 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  max-width: min(92vw, 420px);
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 13px;
  text-align: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 12. 响应式 ---------- */
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); gap: 10px; }
  .search { flex-wrap: wrap; }
  .engines {
    border-left: 0;
    padding-left: 0;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .engines::-webkit-scrollbar { display: none; }
  .brand-text small { display: none; }
}

@media (max-width: 380px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 10px; gap: 9px; }
  .card-icon { width: 34px; height: 34px; font-size: 16px; }
  .card-name { font-size: 13.5px; }
}

/* ---------- 13. 可访问性 / 打印 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .glow, .theme-toggle, .engines, .quick-tags, .toast { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
