/* 琉璃书签 · 液态玻璃 UI
 * 玻璃三件套：backdrop 折射 + 上缘高光 + 指针镜面。降级：无 backdrop-filter 时退化为半透明面板 */

* { box-sizing: border-box; }
/* display 类样式会盖住 hidden 属性的 UA 样式，这里显式压回 */
[hidden] { display: none !important; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  font: 400 var(--text-base)/1.6 var(--font-body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: oklch(74% 0.140 35 / 35%); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- 光场 ---------- */
#lightfield, .lightfield-fallback { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
#lightfield { width: 100vw; height: 100vh; opacity: 0; transition: opacity 1.2s ease; }
#lightfield.on { opacity: 1; }
.lightfield-fallback i {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: .32;
  will-change: transform;
}
.lightfield-fallback i:nth-child(1) {
  width: 46vmax; height: 46vmax; left: -12vmax; top: -14vmax;
  background: var(--glow-coral); animation: drift1 26s ease-in-out infinite alternate;
}
.lightfield-fallback i:nth-child(2) {
  width: 40vmax; height: 40vmax; right: -10vmax; top: 22vh;
  background: var(--glow-teal); animation: drift2 32s ease-in-out infinite alternate;
}
.lightfield-fallback i:nth-child(3) {
  width: 34vmax; height: 34vmax; left: 30vw; bottom: -18vmax;
  background: var(--glow-amber); animation: drift3 38s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate(9vmax, 7vmax) scale(1.12); } }
@keyframes drift2 { to { transform: translate(-8vmax, -9vmax) scale(0.9); } }
@keyframes drift3 { to { transform: translate(-6vmax, -5vmax) scale(1.18); } }
@media (prefers-reduced-motion: reduce) {
  .lightfield-fallback i { animation: none; }
}

/* 纸面暗角，压住光场四角让前景可读 */
body::after {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 8%, transparent 55%, oklch(8% 0.010 55 / 55%) 100%),
    linear-gradient(oklch(10% 0.010 55 / 0%), oklch(10% 0.010 55 / 42%));
}

/* ---------- 玻璃基类 ---------- */
.glass {
  position: relative;
  background: linear-gradient(155deg, var(--glass-fill-deep), var(--glass-fill) 42%, oklch(60% 0.015 55 / 6%));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-panel);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-glow);
}
/* 上缘折射高光：一条细亮的弧 */
.glass::before {
  content: ''; position: absolute; inset: 0 12%; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-edge-lit), transparent);
  pointer-events: none;
}
.glass-inset {
  background: oklch(10% 0.010 55 / 34%);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-ctl);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: oklch(21% 0.012 55 / 88%); }
}

/* ---------- 布局 ---------- */
#app { position: relative; z-index: 1; }
.topbar {
  position: sticky; top: 12px; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  margin: 12px auto 0; padding: 8px 10px 8px 14px;
  max-width: 1440px; width: calc(100% - 24px);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: var(--text-md); letter-spacing: .02em; white-space: nowrap; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  max-width: 560px; margin-inline: auto; padding: 7px 12px;
  color: var(--muted);
  transition: border-color var(--dur-short) var(--ease-out);
}
.search:focus-within { border-color: oklch(74% 0.140 35 / 55%); color: var(--ink-2); }
.search input {
  flex: 1; background: none; border: 0; outline: none; color: var(--ink);
  font-size: var(--text-base); min-width: 0;
}
.search input::placeholder { color: var(--muted); }
.search kbd {
  font: 600 var(--text-xs)/1 var(--font-mono); color: var(--muted);
  border: 1px solid var(--rule); border-radius: 6px; padding: 3px 6px;
  background: oklch(14% 0.010 55 / 60%); white-space: nowrap;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.layout {
  display: grid; grid-template-columns: 292px minmax(0, 1fr); gap: 16px;
  max-width: 1440px; margin: 16px auto 24px; padding: 0 12px;
  align-items: start;
}
.side {
  position: sticky; top: 78px; max-height: calc(100vh - 100px);
  display: flex; flex-direction: column; padding: 12px 10px;
}
.side-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 2px 8px 10px; font-size: var(--text-xs); font-weight: 700;
  letter-spacing: .14em; color: var(--muted);
}
.tree { overflow-y: auto; overscroll-behavior: contain; padding: 2px; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
.side-foot { padding: 10px 8px 2px; font-size: var(--text-xs); color: var(--muted); border-top: 1px solid var(--rule-2); margin-top: 8px; }

/* ---------- 分类 ---------- */
.cats-head { margin-top: 10px; border-top: 1px solid var(--rule-2); padding-top: 12px; }
.cats {
  display: flex; flex-wrap: wrap; gap: 6px;
  overflow-y: auto; max-height: 168px; padding: 2px;
  scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
}
.cats-empty { font-size: var(--text-xs); color: var(--muted); padding: 4px 2px; line-height: 1.6; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: var(--r-chip);
  border: 1px solid var(--rule-2);
  background: oklch(14% 0.010 55 / 55%);
  color: var(--ink-2); font-size: var(--text-xs); font-weight: 600;
  transition: border-color var(--dur-micro) ease, color var(--dur-micro) ease, background var(--dur-micro) ease;
  max-width: 100%;
}
.cat-chip .cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-chip .cat-n {
  font: 600 var(--text-xs)/1 var(--font-mono); color: var(--muted);
  background: oklch(20% 0.012 55 / 70%); padding: 2px 6px; border-radius: var(--r-chip);
}
.cat-chip:hover { border-color: oklch(99% 0.008 65 / 28%); color: var(--ink); }
.cat-chip.active {
  background: oklch(74% 0.140 35 / 16%); border-color: oklch(74% 0.140 35 / 55%); color: var(--glint);
}
.cat-chip.active .cat-n { background: oklch(74% 0.140 35 / 22%); color: var(--glint); }
.card-cat {
  flex: none; font-size: var(--text-xs); font-weight: 600; color: var(--accent);
  background: oklch(74% 0.140 35 / 12%); border: 1px solid oklch(74% 0.140 35 / 28%);
  padding: 1px 8px; border-radius: var(--r-chip); max-width: 40%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 树 ---------- */
.tree-item { position: relative; }
.tree-row {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 6px 8px; border: 0; border-radius: 10px;
  background: none; text-align: left; color: var(--ink-2);
  font-size: var(--text-sm); line-height: 1.35;
  transition: background var(--dur-micro) ease, color var(--dur-micro) ease;
}
.tree-row:hover { background: oklch(60% 0.015 55 / 10%); color: var(--ink); }
.tree-row.active { background: oklch(74% 0.140 35 / 16%); color: var(--glint); font-weight: 600; }
.tree-row.drop-on { background: oklch(70% 0.140 200 / 22%); box-shadow: inset 0 0 0 1px oklch(70% 0.140 200 / 65%); }
.tree-caret {
  flex: none; width: 16px; height: 16px; display: grid; place-items: center;
  color: var(--muted); transition: transform var(--dur-short) var(--ease-out);
}
.tree-caret.leaf { visibility: hidden; }
.tree-item.open > .tree-row .tree-caret { transform: rotate(90deg); }
.tree-icon { flex: none; color: var(--accent); display: grid; place-items: center; }
.tree-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-count {
  flex: none; font: 600 var(--text-xs)/1 var(--font-mono); color: var(--muted);
  background: oklch(14% 0.010 55 / 55%); border: 1px solid var(--rule-2);
  padding: 3px 7px; border-radius: var(--r-chip);
}
.tree-kids { margin-left: 13px; border-left: 1px solid var(--rule-2); padding-left: 4px; display: none; }
.tree-item.open > .tree-kids { display: block; }

/* ---------- 主区 ---------- */
.crumb-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.crumb { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: var(--text-sm); color: var(--muted); min-width: 0; }
.crumb button {
  border: 0; background: none; color: var(--ink-2); padding: 3px 7px; border-radius: 7px;
}
.crumb button:hover { background: oklch(60% 0.015 55 / 10%); color: var(--ink); }
.crumb .cur { color: var(--glint); font-weight: 600; }
.crumb .sep { opacity: .5; }
.count-chip {
  margin-left: auto; font: 600 var(--text-xs)/1 var(--font-mono); color: var(--ink-2);
  background: oklch(14% 0.010 55 / 55%); border: 1px solid var(--rule-2);
  padding: 6px 11px; border-radius: var(--r-chip); white-space: nowrap;
}

/* ---------- 书签卡 ---------- */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
}
.card {
  --mx: 50%; --my: 0%;
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 14px 12px;
  border-radius: var(--r-card);
  background: linear-gradient(160deg, var(--glass-fill-deep), var(--glass-fill) 55%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--card-shadow), inset 0 1px 0 var(--glass-glow);
  transition: transform var(--dur-short) var(--ease-out), border-color var(--dur-short) ease,
              box-shadow var(--dur-short) ease;
  animation: card-rise var(--dur-long) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 26ms);
  cursor: pointer;
  user-select: none;
}
@keyframes card-rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.card:hover {
  transform: translateY(-3px);
  border-color: oklch(99% 0.008 65 / 26%);
  box-shadow: 0 16px 34px -14px oklch(5% 0.010 55 / 65%), inset 0 1px 0 var(--glass-glow);
}
.card:active { transform: translateY(-1px) scale(.975); }
/* 指针跟随镜面高光 */
.card::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(180px circle at var(--mx) var(--my),
              oklch(99% 0.008 65 / 13%), transparent 60%);
  opacity: 0; transition: opacity var(--dur-short) ease;
}
.card:hover::after { opacity: 1; }
.card.dragging { opacity: .45; transform: scale(.96); }
.card-head { display: flex; gap: 10px; align-items: flex-start; }
.fav {
  flex: none; width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; overflow: hidden;
  background: oklch(14% 0.010 55 / 65%);
  border: 1px solid var(--rule-2);
  box-shadow: inset 0 1px 0 var(--glass-glow);
}
.fav img { width: 20px; height: 20px; image-rendering: auto; }
.fav .letter { font-weight: 700; font-size: var(--text-base); }
.card-title {
  font-weight: 600; font-size: var(--text-sm); line-height: 1.45; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.9em;
}
.card-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--text-xs); color: var(--muted);
}
.card-domain {
  font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%;
}
.card-dot { opacity: .5; flex: none; }
.card-date { margin-left: auto; flex: none; font-family: var(--font-mono); }
.card-path {
  font-size: var(--text-xs); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-top: 2px; border-top: 1px dashed var(--rule-2);
}
.empty {
  grid-column: 1 / -1; text-align: center; color: var(--muted);
  padding: 64px 20px; border-radius: var(--r-card);
  border: 1px dashed var(--rule); font-size: var(--text-base);
}
.more-row { display: flex; justify-content: center; padding: 18px 0 6px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px; border-radius: var(--r-ctl);
  border: 1px solid var(--glass-edge);
  background: linear-gradient(160deg, oklch(60% 0.015 55 / 12%), oklch(40% 0.012 55 / 8%));
  color: var(--ink); font-size: var(--text-sm); font-weight: 600; letter-spacing: .02em;
  box-shadow: inset 0 1px 0 var(--glass-glow), 0 6px 16px -10px oklch(5% 0.010 55 / 60%);
  transition: transform var(--dur-micro) ease, border-color var(--dur-short) ease, background var(--dur-short) ease;
  white-space: nowrap;
}
.btn:hover { border-color: oklch(99% 0.008 65 / 30%); transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(160deg, oklch(76% 0.135 35), oklch(64% 0.150 30));
  color: var(--accent-ink); border-color: oklch(80% 0.120 35 / 60%);
  box-shadow: inset 0 1px 0 oklch(92% 0.060 35 / 80%), 0 10px 26px -12px oklch(64% 0.150 30 / 55%);
}
.btn.ghost { background: none; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); }
.btn.block { width: 100%; }
.btn.danger { color: oklch(80% 0.120 25); border-color: oklch(64% 0.190 25 / 40%); }
.btn:disabled { opacity: .5; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  border-radius: 8px; border: 0; background: none; color: var(--muted);
  transition: background var(--dur-micro) ease, color var(--dur-micro) ease;
}
.icon-btn:hover { background: oklch(60% 0.015 55 / 12%); color: var(--ink); }
.menu-toggle { display: none; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: var(--text-xs); font-weight: 700; letter-spacing: .1em; color: var(--muted); }
.field input, .field select {
  padding: 10px 12px; border-radius: var(--r-ctl);
  border: 1px solid var(--rule); background: oklch(12% 0.010 55 / 70%);
  color: var(--ink); outline: none; min-width: 0;
  transition: border-color var(--dur-short) ease;
}
.field input:focus, .field select:focus { border-color: oklch(74% 0.140 35 / 55%); }
.field select option { background: var(--paper-2); color: var(--ink); }

/* ---------- 弹层 ---------- */
.modal-veil {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: oklch(8% 0.010 55 / 55%);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  padding: 20px; animation: veil-in var(--dur-short) ease both;
}
@keyframes veil-in { from { opacity: 0; } }
.modal {
  width: min(560px, 100%); max-height: min(82vh, 720px); overflow-y: auto;
  padding: 24px; animation: card-rise var(--dur-long) var(--ease-out) both;
  scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
}
.modal h2 { margin: 0 0 18px; font-size: var(--text-lg); letter-spacing: .03em; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.modal .hint { font-size: var(--text-xs); color: var(--muted); margin: -10px 0 14px; }

/* 导入拖放区 */
.dropzone {
  display: grid; place-items: center; gap: 8px; text-align: center;
  padding: 36px 18px; border-radius: var(--r-card);
  border: 1.5px dashed var(--rule); color: var(--muted);
  transition: border-color var(--dur-short) ease, background var(--dur-short) ease, color var(--dur-short) ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone.over { border-color: oklch(74% 0.140 35 / 60%); background: oklch(74% 0.140 35 / 7%); color: var(--ink-2); }
.dropzone strong { color: var(--ink); }
.dropzone input { display: none; }
.report { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.report .stat {
  padding: 12px 8px; border-radius: 12px; text-align: center;
  background: oklch(14% 0.010 55 / 55%); border: 1px solid var(--rule-2);
}
.report .stat b { display: block; font-size: var(--text-lg); font-family: var(--font-mono); color: var(--glint); }
.report .stat span { font-size: var(--text-xs); color: var(--muted); }

/* 查重列表 */
.dup-url { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted);
  word-break: break-all; }
.dup-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 10px; border: 1px solid var(--rule-2); margin-top: 8px;
  background: oklch(12% 0.010 55 / 50%);
}
.dup-item .t { flex: 1; min-width: 0; }
.dup-item .t b { display: block; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dup-item .t span { font-size: var(--text-xs); color: var(--muted); }
.dup-group { margin-bottom: 14px; }

/* ---------- 右键菜单 ---------- */
.ctx {
  position: fixed; z-index: 70; min-width: 168px; padding: 5px;
  background: oklch(19% 0.012 55 / 92%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: var(--glass-shadow);
  border-radius: 14px;
  animation: ctx-in var(--dur-micro) ease both;
}
@keyframes ctx-in { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.ctx button {
  display: flex; width: 100%; align-items: center; gap: 8px;
  padding: 8px 12px; border: 0; border-radius: 9px; background: none;
  color: var(--ink-2); font-size: var(--text-sm); text-align: left;
}
.ctx button:hover { background: oklch(60% 0.015 55 / 12%); color: var(--ink); }
.ctx button.warn { color: oklch(78% 0.130 30); }
.ctx hr { border: 0; border-top: 1px solid var(--rule-2); margin: 5px 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 80; left: 50%; bottom: 26px;
  transform: translateX(-50%) translateY(20px); opacity: 0;
  padding: 11px 20px; border-radius: var(--r-chip);
  background: oklch(22% 0.015 55 / 92%);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
  font-size: var(--text-sm); color: var(--glint); pointer-events: none;
  transition: transform var(--dur-short) var(--ease-spring), opacity var(--dur-short) ease;
  max-width: min(86vw, 560px); text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .topbar { flex-wrap: wrap; top: 8px; margin-top: 8px; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  .menu-toggle { display: inline-grid; }
  .layout { grid-template-columns: 1fr; }
  .side {
    position: fixed; z-index: 50; left: 12px; top: 64px; bottom: 12px;
    width: min(300px, calc(100vw - 24px)); max-height: none;
    transform: translateX(-16px); opacity: 0; pointer-events: none;
    transition: transform var(--dur-short) var(--ease-out), opacity var(--dur-short) ease;
  }
  .side.open { transform: none; opacity: 1; pointer-events: auto; }
  .topbar-actions { margin-left: auto; }
  .topbar-actions .btn { padding: 8px 10px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 10px; }
  .report { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .topbar-actions .btn:not(.primary) { padding: 8px; }
  #btn-dup, #btn-export, #btn-new-bm span { display: none; }
}
