/* ============================================================
 * 字彚文化 · 網絡導航 —— 樣式
 * 宣紙底、墨色字、朱砂點綴，簡潔大氣
 * ============================================================ */

:root {
  --paper: #f6f3ec;        /* 宣紙底色 */
  --card: #fffdf8;         /* 卡片底 */
  --ink: #2b2824;          /* 墨色 */
  --ink-soft: #6b6459;     /* 次級文字 */
  --muted: #a09686;        /* 弱化文字 */
  --line: #e4dccd;         /* 分隔線 */
  --accent: #9c3825;       /* 朱砂 */
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "KaiTi", serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #fff; }

/* ---------- 頁首 ---------- */

.site-header {
  padding: 72px 20px 8px;
  text-align: center;
}

.brand { margin-bottom: 36px; }

.seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: var(--accent);
  color: #fff;
  font-family: "KaiTi", "STKaiti", serif;
  font-size: 30px;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(156, 56, 37, .28);
  margin-bottom: 18px;
}

.site-title {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: .35em;
  text-indent: .35em;   /* 抵消最後一字的字間距，視覺居中 */
}

.site-motto {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .4em;
}

/* ---------- 搜尋框 ---------- */

.search-box {
  position: relative;
  width: min(560px, 100%);
  margin: 0 auto 24px;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 12px 46px 12px 42px;
  font: inherit;
  font-size: 15px;
  letter-spacing: .05em;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

#search::placeholder { color: var(--muted); }

#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(156, 56, 37, .10);
}

.search-kbd {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 8px;
  background: var(--paper);
}

/* ---------- 分類錨點 ---------- */

.quick-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 26px;
  padding: 10px 20px 6px;
}

.chip {
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  letter-spacing: .18em;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color .2s, border-color .2s;
}

.chip:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- 主體 ---------- */

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.nav-section { padding: 34px 0 6px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}

.section-title {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .14em;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-title::before {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--accent);
  flex-shrink: 0;
}

.section-count {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .1em;
}

.section-note {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 0 22px;
}

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

/* ---------- 卡片 ---------- */

.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px 14px;
  color: var(--ink);
  text-decoration: none;
  transition: transform .18s, border-color .18s, box-shadow .18s;
}

.card.is-link:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(84, 60, 35, .10);
}

.card.is-link:hover .card-name { color: var(--accent); }

.card.is-info {
  background: transparent;
  border-style: dashed;
}

.card.is-info:hover { border-color: var(--accent); }

.card-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: .05em;
  transition: color .18s;
}

.card-tag {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 400;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 1px 9px;
  letter-spacing: .12em;
  opacity: .85;
  white-space: nowrap;
}

.card-desc {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.7;
}

.card-url {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--muted);
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 漢學參考書 ---------- */

.ref-panel {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 26px 14px;
}

.ref-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 44px;
}

.ref-sub {
  grid-column: 1 / -1;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: .3em;
  margin: 14px 0 2px;
}

.ref-sub:first-child { margin-top: 0; }

.ref-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}

.ref-item::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent);
  flex-shrink: 0;
}

/* ---------- 空狀態 / 頁尾 ---------- */

.empty {
  display: none;
  text-align: center;
  color: var(--muted);
  letter-spacing: .2em;
  padding: 40px 20px;
}

.empty.visible { display: block; }

.site-footer {
  margin-top: 56px;
  padding: 34px 20px 44px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.footer-line {
  font-size: 14px;
  color: var(--ink-soft);
  letter-spacing: .3em;
}

.footer-meta {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .2em;
}

/* ---------- 過濾隱藏 ---------- */

.hidden { display: none !important; }

/* ---------- 我的書籤 ---------- */

.head-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  font: inherit;
  font-size: 13px;
  letter-spacing: .1em;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: background .18s, color .18s;
}

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #822e1e; }
.btn.ghost:hover { background: rgba(156, 56, 37, .08); }
.btn:disabled { opacity: .55; cursor: wait; }

.link-btn {
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  letter-spacing: .1em;
  border-bottom: 1px solid transparent;
  transition: color .18s;
}

.link-btn:hover { color: var(--accent); }

.card { position: relative; }

.card.is-mine .card-name { padding-right: 48px; }

.card-tools {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
}

.card-tool {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: color .15s, background .15s;
}

.card-tool:hover {
  color: #fff;
  background: var(--accent);
}

.mine-empty {
  font-size: 13.5px;
  color: var(--muted);
  letter-spacing: .05em;
  padding: 14px 2px 4px;
}

/* ---------- 書籤分組 ---------- */

.group-block { margin-top: 24px; }
.group-block:first-child { margin-top: 0; }

.group-head {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .12em;
}

.group-head::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--accent);
  flex-shrink: 0;
}

.group-count {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: .08em;
}

.grid.is-sub { margin-top: 12px; }

/* ---------- 對話框 ---------- */

.dlg {
  margin: auto;          /* 恢復被全域重置覆蓋的原生居中 */
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  padding: 26px 28px 24px;
  width: min(420px, 92vw);
  max-height: min(84vh, 640px);
  overflow: auto;
  box-shadow: 0 18px 60px rgba(50, 35, 20, .25);
}

.dlg::backdrop {
  background: rgba(43, 40, 36, .45);
  backdrop-filter: blur(2px);
}

.dlg h3 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: .14em;
}

.dlg-hint {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
  margin-top: 6px;
}

.dlg label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-soft);
  letter-spacing: .1em;
  margin-top: 16px;
}

.dlg input,
.dlg select {
  display: block;
  width: 100%;
  margin-top: 6px;
  font: inherit;
  font-size: 14.5px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .18s;
}

.dlg select { cursor: pointer; }

.dlg input:focus,
.dlg select:focus { border-color: var(--accent); }
.dlg input[readonly] { color: var(--ink-soft); background: var(--paper); }

.dlg .err {
  font-size: 12.5px;
  color: var(--accent);
  margin-top: 12px;
  min-height: 1.2em;
}

/* 分組管理對話框 */

.group-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.group-row input { flex: 1; margin-top: 0; }
.group-row .btn { flex-shrink: 0; padding: 6px 13px; }

.group-new {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.group-new input { flex: 1; margin-top: 0; }
.group-new .btn { flex-shrink: 0; }

.btn.danger {
  border-color: #a5432f;
  color: #a5432f;
}

.btn.danger:hover { background: rgba(165, 67, 47, .10); }

.code-row {
  display: flex;
  gap: 8px;
}

.code-row input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.code-row .btn { flex-shrink: 0; padding: 6px 14px; }

.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ---------- 提示條 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(8px);
  background: #3a352e;
  color: #f6f3ec;
  font-size: 13.5px;
  letter-spacing: .08em;
  padding: 10px 22px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 99;
  max-width: 86vw;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* ---------- 響應式 ---------- */

@media (max-width: 640px) {
  .site-header { padding-top: 48px; }
  .site-title { font-size: 26px; }
  .ref-cols { grid-template-columns: 1fr; }
  .ref-sub { margin-top: 16px; }
  .quick-nav { gap: 6px 16px; }
}
