/* 自用导航站 — 柔和圆角 + 两栏布局 */
* { box-sizing: border-box; }
:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #232730;
  --surface-3: #2a2f3a;
  --border: #2c313c;
  --border-soft: #232830;
  --text: #e7e9ee;
  --muted: #8a91a0;
  --primary: #4f8cff;
  --primary-hover: #6a9fff;
  --primary-soft: rgba(79, 140, 255, .12);
  --danger: #ff5a5a;
  --warn: #ffb84d;
  --ok: #3ecf8e;
  --ok-soft: rgba(62, 207, 142, .14);
  --redirect: #f0c419;
  --warn-soft: rgba(255, 184, 77, .18);
  --err: #e53e3e;
  --err-soft: rgba(229, 62, 62, .12);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.18);
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.45);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --surface: #fff;
    --surface-2: #f0f2f5;
    --surface-3: #e6e9ef;
    --border: #dde1e7;
    --border-soft: #e9ecf0;
    --text: #1c1f25;
    --muted: #6b7280;
    --primary-soft: rgba(79, 140, 255, .10);
    --ok-soft: rgba(62, 207, 142, .12);
    --err-soft: rgba(229, 62, 62, .10);
    --shadow-sm: 0 2px 8px rgba(0,0,0,.05);
    --shadow: 0 8px 24px rgba(0,0,0,.08);
    --shadow-lg: 0 16px 40px rgba(0,0,0,.12);
  }
}
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.view { padding: 20px 24px 32px; max-width: 1400px; margin: 0 auto; }

/* 登录 */
#view-login .card { margin: 60px auto; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: var(--r-xl); padding: 32px; box-shadow: var(--shadow); }
#view-login h1 { margin: 0 0 22px; font-size: 22px; }
label { display: block; margin: 12px 0; font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input[type=url], input[type=number], input[type=search], textarea {
  width: 100%; padding: 10px 12px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm); font: inherit; outline: none;
  transition: border-color .15s, background .15s;
}
input:focus, textarea:focus { border-color: var(--primary); background: var(--surface); }
button {
  padding: 9px 16px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; font: inherit;
  transition: background .12s, border-color .12s, transform .05s;
}
button:hover { background: var(--surface-3); }
button:active { transform: scale(0.97); }
button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--surface-2); }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.hint.err { color: var(--danger); }

/* 顶栏 */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 20px; flex: 0 0 auto; letter-spacing: .2px; }
.topbar .actions { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.topbar input[type=search] { max-width: 260px; }

/* 下拉菜单 */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow); padding: 6px; z-index: 50; }
.dropdown-menu button { display: block; width: 100%; text-align: left;
  background: transparent; border: 0; padding: 8px 10px; border-radius: var(--r-sm); }
.dropdown-menu button:hover { background: var(--surface-2); }

/* 进度条 */
#check-progress { background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--r-md); padding: 12px 16px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
#check-bar-fill { height: 100%; background: var(--primary); width: 0; transition: width .2s; }

/* 两栏布局 */
.layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; min-height: calc(100vh - 140px); }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static !important; }
}

/* 侧边栏 */
.sidebar { background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--r-lg); padding: 12px 8px; box-shadow: var(--shadow-sm);
  position: sticky; top: 12px; align-self: start; max-height: calc(100vh - 140px); overflow-y: auto; }
.sidebar-head { padding: 6px 10px; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px;
  display: flex; align-items: center; justify-content: space-between; }
.sidebar-add { width: 22px; height: 22px; padding: 0; border: 0; background: transparent;
  border-radius: 50%; color: var(--muted); font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s; }
.sidebar-add:hover { background: var(--primary-soft); color: var(--primary); }
.sidebar-list { list-style: none; margin: 0; padding: 0; }
.sidebar-list li { margin: 1px 0; position: relative; display: flex; align-items: center; gap: 2px; }
.sidebar-list li:hover .cat-actions { opacity: 1; }
.sidebar-list .cat-btn { display: flex; align-items: center; justify-content: space-between;
  flex: 1; min-width: 0; padding: 7px 10px; background: transparent; border: 0; color: var(--text);
  border-radius: var(--r-sm); cursor: pointer; font: inherit; text-align: left;
  transition: background .12s; }
.sidebar-list .cat-btn:hover { background: var(--surface-2); }
.sidebar-list .cat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-list li.active .cat-btn { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.sidebar-list li.empty .cat-name { color: var(--muted); font-style: italic; }
.sidebar-list .count { font-size: 11px; background: var(--surface-2);
  padding: 1px 7px; border-radius: 10px; min-width: 30px; text-align: center; flex: 0 0 auto; margin-left: 6px;
  display: inline-flex; align-items: center; gap: 2px; }
.sidebar-list .count .alive { color: var(--ok); font-weight: 500; }
.sidebar-list .count .sep { color: var(--muted); opacity: .4; }
.sidebar-list .count .total { color: var(--muted); }
.sidebar-list li.active .count { background: var(--primary); }
.sidebar-list li.active .count .alive,
.sidebar-list li.active .count .total,
.sidebar-list li.active .count .sep { color: #fff; opacity: 1; }
.sidebar-list li.empty .count { background: transparent; border: 1px dashed var(--border); }
.sidebar-list li.empty .count .alive { color: var(--muted); opacity: .5; }
/* 操作按钮组（hover 显示） */
.sidebar-list .cat-actions { display: flex; gap: 1px; opacity: 0;
  transition: opacity .12s; flex: 0 0 auto; }
.sidebar-list .cat-action { width: 22px; height: 22px; padding: 0; border: 0; background: transparent;
  border-radius: 50%; color: var(--muted); flex: 0 0 22px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px;
  transition: background .12s, color .12s; }
.sidebar-list .cat-action:hover { background: var(--surface-2); color: var(--text); }
.sidebar-list .cat-del:hover { background: var(--err-soft); color: var(--err); }
.sidebar-list li.editing .cat-btn { background: var(--surface-2); }
.sidebar-list .cat-rename-input { width: 100%; padding: 4px 8px; font: inherit;
  background: var(--surface); color: var(--text); border: 1px solid var(--primary);
  border-radius: var(--r-sm); outline: none; }

/* 内容区 */
.content { background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.content-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.content-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.content-count { color: var(--muted); font-size: 12px; }

/* 书签网格 — 默认 4 列，窄屏自动减列 */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px)  { .grid { grid-template-columns: repeat(2, 1fr); } }

/* 书签卡片 */
.bm { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--r-md);
  text-decoration: none; color: var(--text); transition: border-color .12s, background .12s, transform .08s;
  min-height: 64px; }
/* 状态底色 */
.bm.bm-ok, .bm.bm-redirect { background: var(--ok-soft); border-color: rgba(62, 207, 142, .25); }
.bm.bm-dead { background: var(--surface-3); }
.bm.bm-unknown { background: var(--surface-2); }
.bm:hover { border-color: var(--primary); }
.bm.bm-ok:hover, .bm.bm-redirect:hover { background: rgba(62, 207, 142, .22); }
.bm.bm-dead:hover { background: var(--surface-3); }
.bm .fav { width: 18px; height: 18px; flex: 0 0 18px; border-radius: 4px; background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted);
  margin-top: 1px; }
.bm .fav img { width: 18px; height: 18px; border-radius: 4px; }
.bm .title { flex: 1; min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word; line-break: anywhere;
  font-size: 14px; line-height: 1.4; }

/* 状态徽章 — ✓绿 / ✗灰红 / ?灰 */
.bm .status { width: 18px; height: 18px; flex: 0 0 18px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; line-height: 1; transition: transform .12s; }
.bm .status.ok { background: var(--ok-soft); color: var(--ok); }
.bm .status.redirect { background: rgba(240, 196, 25, .15); color: var(--redirect); }
.bm .status.dead { background: var(--err-soft); color: var(--err); }
.bm .status.unknown { background: var(--surface-3); color: var(--muted); border: 1px dashed var(--border); }
.bm:hover .status { transform: scale(1.08); }

/* 操作按钮（删除常显，编辑 hover） */
.bm .bm-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.bm .icon-btn { width: 20px; height: 20px; padding: 0; border: 0; background: transparent;
  border-radius: 50%; color: var(--muted); display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; transition: background .12s, color .12s, opacity .12s; }
.bm .icon-btn:hover { background: var(--surface); color: var(--text); }
.bm .icon-btn.del { opacity: 0; }
.bm:hover .icon-btn.del { opacity: 1; }
.bm.bm-dead .icon-btn.del { opacity: 1; color: var(--err); }
.bm .icon-btn.del:hover { background: var(--err-soft); color: var(--err); }

/* 空 */
.empty { text-align: center; padding: 60px 0; color: var(--muted); }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
.modal-box { background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--r-xl); padding: 28px; width: min(520px, 94vw); box-shadow: var(--shadow-lg); }
.modal-box h2 { margin: 0 0 16px; font-size: 19px; }
.modal-box label { margin: 14px 0; font-size: 13.5px; }
.modal-box input[type=text], .modal-box input[type=password], .modal-box input[type=url],
.modal-box input[type=number], .modal-box input[type=search], .modal-box textarea {
  padding: 13px 15px; font-size: 14.5px; border-radius: var(--r-sm);
}
.modal-box textarea { min-height: 64px; resize: vertical; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.modal-actions button { padding: 10px 18px; font-size: 14px; }
.import-options { margin: 14px 0; font-size: 13.5px; color: var(--muted); }
.import-options label { display: flex; gap: 6px; align-items: center; margin: 0; color: var(--muted); }
.import-options input { width: auto; }
#import-preview { max-height: 200px; overflow: auto; background: var(--surface-2); padding: 10px 12px; border-radius: var(--r-sm); margin-top: 10px; font-size: 12.5px; }
#import-preview ul { margin: 4px 0; padding-left: 18px; }
