/* ============================================================
   极简导航 — 全部样式
   结构：顶栏（搜索 + 时间 + 主题） / 分组行 / 网址密排
   只用变量上色，浅色与深色共用一套规则
   ============================================================ */

/* ---------- 1. 变量 ---------- */

:root {
  --page: #fff;
  --ink: #121212;
  --ink-2: #454545;
  --dim: #777;
  --dim-2: #a3a3a3;
  --link: #0b3fbf;
  --link-hot: #c00;
  --line: #d8d8d8;
  --line-2: #ececec;
  --hover: #f2f6ff;
  --sel: #e3ebff;
  --row-h: 24px;
  --cat-w: 64px;

  --c1: #b00000;
  --c2: #0044bb;
  --c3: #006c37;
  --c4: #8a00a0;
  --c5: #a35400;
  --c6: #005f66;

  --pop: 0 6px 20px rgba(0, 0, 0, .12);
}

[data-theme="dark"] {
  --page: #101418;
  --ink: #e7ecf3;
  --ink-2: #b4becd;
  --dim: #7d8898;
  --dim-2: #5c6673;
  --link: #7fb0ff;
  --link-hot: #ff9c9c;
  --line: #2a323c;
  --line-2: #1e252d;
  --hover: #18202a;
  --sel: #1f2d3c;

  --c1: #ff8f8f;
  --c2: #8fbaff;
  --c3: #6ed49b;
  --c4: #d79cff;
  --c5: #f0bb7a;
  --c6: #6fd0d6;

  --pop: 0 8px 24px rgba(0, 0, 0, .5);
}

/* ---------- 2. 基础 ---------- */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  display: flex; flex-direction: column; min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 13px/1.5 "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hot); text-decoration: underline; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

input { font: inherit; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 14px; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  padding: 6px 12px; background: var(--ink); color: var(--page);
}
.skip:focus { left: 8px; top: 8px; }

:focus-visible { outline: 2px solid #6f9dff; outline-offset: 1px; }

/* ---------- 3. 顶栏 ---------- */

.bar {
  position: sticky; top: 0; z-index: 40;
  background: var(--page);
  border-bottom: 1px solid var(--line);
}

.bar-row {
  display: flex; align-items: center; gap: 14px;
  height: 46px;
}

/* 搜索：引擎 + 输入 + 按钮，合成一个方框 */
/* flex 子项的 min-width 默认是 auto（内容最小宽度）：320px 下输入长词、
   或引擎按钮变成「Google 一下」时，input 的固有宽度会把整行顶出屏幕。 */
.search, .find, .find input { min-width: 0; }

.search { position: relative; flex: 1 1 auto; max-width: 620px; }

.find {
  display: flex; align-items: stretch; height: 32px;
  border: 1px solid var(--line); background: var(--page);
  transition: border-color .12s, box-shadow .12s;
}
.find:focus-within { border-color: #6f9dff; box-shadow: 0 0 0 3px rgba(80, 140, 255, .13); }

.eng {
  display: flex; align-items: center; gap: 5px; flex: 0 0 auto;
  padding: 0 9px; border-right: 1px solid var(--line-2);
  font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
}
.eng:hover { color: var(--link); background: var(--hover); }

.caret {
  width: 0; height: 0;
  border-left: 3.5px solid transparent; border-right: 3.5px solid transparent;
  border-top: 4.5px solid currentColor; opacity: .65;
}

#q {
  flex: 1 1 auto; min-width: 0;
  padding: 0 10px; border: 0; outline: 0;
  background: transparent; color: var(--ink); font-size: 13.5px;
}
#q::placeholder { color: var(--dim-2); }

/* 宽度随文字自适应 —— 「Google 一下」不会再溢出 */
.go {
  flex: 0 0 auto; min-width: 76px; padding: 0 13px;
  border-left: 1px solid var(--line-2);
  font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
.go:hover { background: var(--hover); color: var(--link); }
.go:active { background: var(--sel); }

/* 引擎下拉 */
.eng-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 60;
  min-width: 120px; padding: 4px;
  background: var(--page); border: 1px solid var(--line); box-shadow: var(--pop);
}
.eng-menu[hidden] { display: none; }
.eng-menu button {
  display: block; width: 100%; padding: 5px 9px;
  text-align: left; font-size: 12.5px; color: var(--ink-2);
}
.eng-menu button:hover,
.eng-menu button.on { background: var(--hover); color: var(--link); }

/* 搜索联想 */
.sug {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 55;
  max-height: 340px; overflow: auto; padding: 4px 0;
  background: var(--page); border: 1px solid var(--line); box-shadow: var(--pop);
}
.sug[hidden] { display: none; }
.sug-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 0 10px; height: 29px;
  text-align: left; font-size: 13px; color: var(--ink);
}
.sug-item.on, .sug-item:hover { background: var(--sel); }
.sug-item .nm { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-item .nm b { color: var(--link-hot); font-weight: 700; }
.sug-item .where { margin-left: auto; flex: 0 0 auto; font-size: 11px; color: var(--dim-2); }
.sug-item.kw .nm { color: var(--ink-2); }
.sug-sep { height: 1px; margin: 4px 0; background: var(--line-2); }

/* 时间 · 农历 */
.when { position: relative; margin-left: auto; }

.clk {
  display: flex; align-items: baseline; gap: 8px;
  padding: 3px 5px; white-space: nowrap; line-height: 1.4;
}
.clk:hover { background: var(--hover); }
.when.open .clk { background: var(--sel); }

.clk-t {
  font: 600 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.clk-d { font-size: 12px; color: var(--ink-2); }
.clk-l { font-size: 12px; color: var(--c1); }
.clk-l.term { color: var(--c3); }
.clk-l.fest { font-weight: 700; }

/* 主题切换 */
.ico { flex: 0 0 auto; width: 28px; height: 28px; color: var(--dim); }
.ico svg { width: 17px; height: 17px; display: block; margin: 0 auto; }
.ico:hover { color: var(--ink); }
.ico .i-moon { display: none; }
[data-theme="dark"] .ico .i-sun { display: none; }
[data-theme="dark"] .ico .i-moon { display: block; }

/* 分组行：单行横向滚动，窄屏不换行撑高 sticky 头 */
.tabs {
  --fade-l: 0px; --fade-r: 0px;
  display: flex; flex-wrap: nowrap; align-items: center;
  padding-bottom: 5px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: 0 0 auto;
  padding: 1px 7px; font-size: 12.5px; color: var(--link); white-space: nowrap;
}
.tabs a:hover { background: var(--hover); text-decoration: none; }
.tabs a.on { background: var(--sel); color: var(--ink); font-weight: 700; }
.tabs a:focus-visible { outline-offset: -2px; }
.tabs a.util { color: var(--dim); }
.tabs-util { display: flex; flex: 0 0 auto; margin-left: 10px; }
.tabs a.util:hover { color: var(--link); }
.tabs a.util.on { color: var(--ink); }

/* ---------- 4. 内容 ---------- */

.board { flex: 1 0 auto; width: 100%; padding-top: 6px; padding-bottom: 28px; outline: 0; }

.grp { padding: 11px 0 4px; }
.grp + .grp { border-top: 1px solid var(--line-2); }
.grp-h {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 3px; font-size: 14px; font-weight: 700;
  color: var(--ink); letter-spacing: .2px;
}
/* 视图内的次级小按钮：平时极淡，悬停才显色 */
.mini {
  font-size: 11.5px; font-weight: 400; letter-spacing: 0;
  color: var(--dim-2);
}
.grp-h .mini { margin-left: -4px; }
.mini:hover { color: var(--link-hot); text-decoration: underline; }


/* 时间桶标签：今天 / 昨天 / 一周内 / 更早 */
.bkt {
  margin: 8px 0 2px; font-size: 11.5px; font-weight: 700;
  color: var(--dim); letter-spacing: .4px;
}
.grp-h + .bkt { margin-top: 1px; }

/* 一行 = 分类名 | 链接串 | 展开 */
.row {
  display: grid;
  grid-template-columns: var(--cat-w) minmax(0, 1fr) 22px;
  gap: 8px; align-items: start;
  padding: 0 6px; margin: 0 -6px;
}
.row:hover { background: var(--hover); }

.cat {
  font-size: 12px; font-weight: 700; line-height: var(--row-h);
  text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.cat.c1 { color: var(--c1); }
.cat.c2 { color: var(--c2); }
.cat.c3 { color: var(--c3); }
.cat.c4 { color: var(--c4); }
.cat.c5 { color: var(--c5); }
.cat.c6 { color: var(--c6); }
.cat:hover { text-decoration: underline; }

.links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  column-gap: 4px; align-content: start;
  max-height: var(--row-h); overflow: hidden;
}
.row.open .links { max-height: none; }

.links a {
  min-width: 0;
  line-height: var(--row-h); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.links a .pin { display: none; }
.links a[data-pin] .pin { display: inline; color: var(--c5); font-size: 10px; }

.more {
  width: 22px; line-height: var(--row-h); font-size: 11.5px; color: var(--dim-2);
  font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap;
  visibility: hidden;
}
.more.show { visibility: visible; }
.more:hover { color: var(--ink); }

/* 扁平列表：搜索结果 / 置顶，一条一行会浪费横向空间 */
.flat {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  column-gap: 10px;
  padding: 2px 6px 4px;
}
.flat a {
  display: flex; align-items: baseline; gap: 7px;
  min-width: 0; height: 26px; line-height: 26px;
  padding: 0 5px; margin: 0 -5px;
  text-decoration: none;
}
.flat a:hover { background: var(--hover); }
.flat a:hover .flat-nm { color: var(--link-hot); }
.flat-nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flat-nm b { color: var(--link-hot); font-weight: 700; }
.flat-where {
  flex: 0 0 auto;
  font-size: 11px; color: var(--dim-2); white-space: nowrap;
}
.flat-where::before { content: "· "; }
.flat-where b { color: var(--link-hot); font-weight: 700; }
.flat a .pin { display: none; }
.flat a[data-pin] .pin { display: inline; color: var(--c5); font-size: 10px; }

/* 空状态 */
.empty { padding: 44px 0; text-align: center; color: var(--dim); font-size: 13px; }
.empty b { color: var(--ink); }

/* ---------- 5. 月历 ---------- */

.cal {
  position: absolute; top: calc(100% + 5px); right: -6px; z-index: 50;
  width: 268px; max-width: calc(100vw - 20px); padding: 7px;
  background: var(--page); border: 1px solid var(--line); box-shadow: var(--pop);
}
.cal[hidden] { display: none; }

.cal-head { display: flex; align-items: center; gap: 3px; margin-bottom: 3px; }
.cal-head button {
  min-width: 21px; height: 21px; padding: 0 4px;
  border: 1px solid var(--line-2); font-size: 12.5px; color: var(--ink-2);
}
.cal-head button:hover { background: var(--hover); color: var(--link); }
.cal-title { flex: 1 1 auto; text-align: center; font-size: 12.5px; font-weight: 700; }

.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-week i {
  font-style: normal; text-align: center; font-size: 11px;
  color: var(--dim); padding: 1px 0 3px;
}
.cal-week i:first-child, .cal-week i:last-child { color: var(--c1); }
.cal-grid { gap: 1px; }

.cd {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 36px; border: 1px solid transparent;
}
.cd b { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.cd i { font-style: normal; font-size: 10px; line-height: 1.1; color: var(--dim-2); white-space: nowrap; }
.cd:hover { background: var(--hover); }
.cd.out b, .cd.out i { opacity: .32; }
.cd.fest i { color: var(--c1); }
.cd.term i { color: var(--c3); }
.cd.today { border-color: var(--c2); background: var(--sel); }
.cd.today b { color: var(--c2); }
.cd.sel { box-shadow: 0 0 0 1px var(--c2) inset; }

.cal-foot {
  margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line-2);
  font-size: 11px; line-height: 1.65; color: var(--dim);
}
.cal-foot b { display: block; font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.cal-foot i { font-style: normal; color: var(--c3); }

/* ---------- 6. 页脚 / 提示 ---------- */

.lnk { font-size: 11.5px; color: var(--dim); }
.lnk:hover { color: var(--link); text-decoration: underline; }

.foot { padding: 4px 14px 26px; text-align: center; }
.foot .lnk { color: var(--dim-2); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 200; padding: 7px 15px;
  background: rgba(18, 22, 28, .92); color: #fff;
  font-size: 12.5px; pointer-events: none;
}
.toast[hidden] { display: none; }

/* ---------- 7. 窄屏 ---------- */

/* 一行放不下时：第一行「时间 ……… 主题」，第二行搜索框独占 */
@media (max-width: 720px) {
  .bar-row { flex-wrap: wrap; height: auto; padding: 7px 0 4px; gap: 6px 10px; }
  .search { order: 3; flex: 1 1 100%; max-width: none; }
  .when { margin-left: 0; }
  .ico { margin-left: auto; }
  .tabs { margin: 0 -14px; padding: 0 14px 5px; }
}

@media (max-width: 620px) {
  .row {
    grid-template-columns: minmax(0, 1fr) 22px;
    grid-template-areas: "cat more" "links links";
    row-gap: 2px; padding: 3px 6px 4px;
  }
  .cat { grid-area: cat; text-align: left; line-height: 16px; font-size: 11.5px; }
  .more { grid-area: more; line-height: 16px; }
  .links { grid-area: links; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  .links a { font-size: 12.5px; }
  .flat { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); column-gap: 8px; }
  .flat a { height: 28px; line-height: 28px; }
  .cal { right: -4px; width: 248px; }
  .cd { height: 33px; }
}

@media (max-width: 440px) {
  .clk-d { display: none; }
  .go { min-width: 64px; padding: 0 10px; font-size: 12.5px; }
}

@media print {
  .bar { position: static; }
  .when, .ico, .tabs, .foot, .more { display: none; }
  .links { max-height: none; }
}
