/* ============================================================
   transcend —— 2026 重构版样式
   设计基调：浅色、纸感、信息密度高但不挤；只有一个强调色，
   状态一律用色点 + 文字，不靠颜色单独表意。
   ============================================================ */

:root {
  --bg: #f4f5f7;
  --bg-soft: #eceef2;
  --card: #ffffff;
  --ink: #15171c;
  --ink-2: #3d434e;
  --muted: #767d8a;
  --faint: #9aa1ad;
  --line: #e5e7eb;
  --line-2: #d6d9df;
  --accent: #3a4bdd;
  --accent-soft: #eef0ff;
  --accent-ink: #2b39b8;
  --ok: #12855f;
  --ok-soft: #e6f6ef;
  --warn: #a96a00;
  --warn-soft: #fdf3e2;
  --bad: #c33a3a;
  --bad-soft: #fdeceb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }

.num { font-variant-numeric: tabular-nums; }

/* ---------------- 布局骨架 ---------------- */
.app { max-width: 1180px; margin: 0 auto; padding: 0 16px 90px; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  margin: 0 -16px; padding: 12px 16px 10px;
  background: rgba(244, 245, 247, .88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.stuck { border-bottom-color: var(--line); }

.brand { display: flex; align-items: baseline; gap: 8px; }
.brand h1 {
  margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.3px;
}
.brand .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); transform: translateY(-1px); }
.brand .sub { font-size: 11.5px; color: var(--faint); letter-spacing: .2px; }

.topbar .grow { flex: 1; }

.iconbtn {
  width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2); font-size: 17px; line-height: 1;
  background: var(--card); border: 1px solid var(--line);
  transition: background .15s, border-color .15s, transform .12s;
}
.iconbtn:hover { background: #fafbfc; border-color: var(--line-2); }
.iconbtn:active { transform: scale(.96); }

.tabs {
  position: sticky; top: 57px; z-index: 35;
  display: flex; gap: 2px; padding: 6px;
  margin: 0 -4px 14px;
  background: var(--bg-soft);
  border-radius: 12px;
}
.tab {
  flex: 1; min-width: 0; padding: 8px 6px; border-radius: 9px;
  font-size: 13.5px; color: var(--ink-2); font-weight: 520;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: background .16s, color .16s, box-shadow .16s;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
  background: var(--card); color: var(--ink); font-weight: 600;
  box-shadow: var(--shadow);
}
.tab .cnt {
  font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums;
  padding: 1px 5px; border-radius: 6px; background: var(--bg-soft);
}
.tab[aria-selected="true"] .cnt { background: var(--accent-soft); color: var(--accent-ink); }

.view { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------------- 通用控件 ---------------- */
.searchrow { display: flex; gap: 8px; margin-bottom: 10px; }
.search {
  position: relative; flex: 1; display: flex; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  padding: 0 10px 0 34px; transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search::before {
  content: ""; position: absolute; left: 11px; top: 50%; width: 14px; height: 14px;
  transform: translateY(-50%);
  background: currentColor; color: var(--faint);
  -webkit-mask: no-repeat center/contain;
  mask: no-repeat center/contain;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.6-3.6'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.6-3.6'/%3E%3C/svg%3E");
}
.search input {
  flex: 1; min-width: 0; height: 38px; border: 0; outline: 0; background: none;
  font-size: 13.5px;
}
.search input::placeholder { color: var(--faint); }
.search .clear {
  display: none; width: 20px; height: 20px; border-radius: 50%; color: var(--muted);
  font-size: 15px; line-height: 1; background: var(--bg-soft);
}
.search.has .clear { display: inline-flex; align-items: center; justify-content: center; }

.select {
  height: 38px; padding: 0 28px 0 10px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card) no-repeat right 9px center/10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23767d8a' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  font-size: 13px; appearance: none; outline: 0;
}
.select:focus { border-color: var(--accent); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 5px 11px; border-radius: 999px; font-size: 12.5px;
  color: var(--ink-2); background: var(--card); border: 1px solid var(--line);
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  transition: all .14s;
}
.chip:hover { border-color: var(--line-2); }
.chip .n { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] {
  background: var(--ink); color: #fff; border-color: var(--ink);
}
.chip[aria-pressed="true"] .n { color: rgba(255, 255, 255, .6); }

.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px;
  background: var(--bg-soft);
}
.seg button {
  padding: 6px 12px; border-radius: 8px; font-size: 12.5px; color: var(--ink-2);
  transition: all .15s; white-space: nowrap;
}
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); font-weight: 560; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px; border-radius: 9px; font-size: 13px; font-weight: 520;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  transition: all .15s;
}
.btn:hover { border-color: var(--line-2); background: #fafbfc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--ink); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.meta { margin: 0 0 10px; font-size: 12px; color: var(--faint); }
.meta b { color: var(--ink-2); font-weight: 560; }

.empty {
  padding: 40px 20px; text-align: center; color: var(--faint); font-size: 13px;
}

/* ---------------- 站点卡片 ---------------- */
.grid { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1040px) { .grid { grid-template-columns: 1fr 1fr 1fr; } }

.site {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 13px;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.site:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.site.dim { opacity: .55; }

.site-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.site-name {
  font-size: 14px; font-weight: 600; letter-spacing: -.1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.site-host { font-size: 11.5px; color: var(--faint); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-head .grow { flex: 1; min-width: 0; }

.star { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; color: var(--line-2); font-size: 15px; transition: all .15s; flex: 0 0 auto; }
.star:hover { background: var(--bg-soft); color: var(--warn); }
.star.on { color: #e0a018; }

.site-note {
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.site-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 7px; border-radius: 6px;
  background: var(--bg-soft); color: var(--muted); white-space: nowrap;
  font-weight: 500;
}
.badge.auto { background: var(--ok-soft); color: var(--ok); }
.badge.manual { background: var(--accent-soft); color: var(--accent-ink); }
.badge.unknown { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.price { background: #f1f5f9; color: #475569; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; }
.dot.auto { background: var(--ok); }
.dot.manual { background: var(--accent); }
.dot.none { background: var(--faint); }
.dot.bad { background: var(--bad); }

.site-actions { display: flex; gap: 6px; margin-top: 2px; }
.site-actions .btn { flex: 1; }
.site-actions .btn.primary { flex: 0 0 auto; min-width: 84px; }
.site-actions .btn.ghost { flex: 0 0 auto; }

/* 详情抽屉 */
.detail {
  border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 10px;
  display: grid; gap: 8px; animation: fade .16s ease;
}
.detail .kv { display: flex; gap: 8px; font-size: 12px; color: var(--muted); align-items: baseline; }
.detail .kv span:first-child { flex: 0 0 62px; color: var(--faint); }
.detail .kv span:last-child { color: var(--ink-2); word-break: break-all; }
.detail .row-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- 签到 ---------------- */
.ck-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px;
}
.stat .k { font-size: 11.5px; color: var(--faint); margin-bottom: 2px; }
.stat .v { font-size: 19px; font-weight: 620; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 11.5px; font-weight: 500; color: var(--faint); margin-left: 3px; letter-spacing: 0; }

.ck-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px;
}
.ck-row + .ck-row { margin-top: 6px; }
.ck-row .ck-main { flex: 1; min-width: 0; }
.ck-row .ck-name { font-size: 13.5px; font-weight: 560; display: flex; align-items: center; gap: 6px; }
.ck-row .ck-sub { font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-row .ck-side { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.ck-row .ck-val { flex: 0 0 auto; text-align: right; min-width: 76px; }
.ck-row .ck-val .num { font-size: 15px; font-weight: 650; color: var(--ok); font-variant-numeric: tabular-nums; }
.ck-row .ck-name .rank {
  font-size: 11px; color: var(--faint); background: var(--bg-soft); border-radius: 6px;
  padding: 1px 5px; font-variant-numeric: tabular-nums; flex: 0 0 auto; min-width: 20px; text-align: center;
}
.ck-row .ck-name .badge.manual { font-size: 10.5px; background: var(--warn-soft); color: var(--warn); border-radius: 5px; padding: 1px 5px; }

.mark {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 14px; transition: all .15s; flex: 0 0 auto;
}
.mark:hover { border-color: var(--ok); color: var(--ok); }
.mark.on { background: var(--ok); border-color: var(--ok); color: #fff; }

.progress { height: 6px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; margin: 4px 0 14px; }
.progress i { display: block; height: 100%; background: var(--ok); border-radius: 999px; transition: width .4s cubic-bezier(.2,.8,.2,1); }

.note-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 13px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6;
  margin-bottom: 12px;
}
.note-box b { font-weight: 600; color: var(--ink); }
.note-box code {
  font-family: var(--mono); font-size: 11.5px; background: var(--bg-soft);
  padding: 1px 5px; border-radius: 5px; color: var(--ink-2);
}
.note-box ol, .note-box ul { margin: 6px 0 0; padding-left: 18px; }
.note-box li { margin: 3px 0; }
.note-box.warn {
  background: var(--bad-soft);
  border-color: #f3c4c2;
  color: #8f2f2f;
}
.note-box.warn b { color: var(--bad); }
.note-box .cmds { display: flex; align-items: center; gap: 6px; margin-top: 8px; background: var(--bg-soft); border-radius: 8px; padding: 7px 9px; }
.note-box .cmds code { background: none; padding: 0; flex: 1; overflow-x: auto; white-space: nowrap; }

/* ---------------- 价格 ---------------- */
.price-layout { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .price-layout { grid-template-columns: 268px 1fr; align-items: start; } }

.model-list {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.model-list .ml-head { padding: 9px 12px; font-size: 11.5px; color: var(--faint); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 6px; }
.ml-scroll { max-height: 66vh; overflow: auto; }
@media (max-width: 899px) { .ml-scroll { max-height: none; } }

.mrow {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid #f1f2f4; cursor: pointer; transition: background .1s;
}
.mrow:last-child { border-bottom: 0; }
.mrow:hover { background: #fafbfc; }
.mrow[aria-selected="true"] { background: var(--accent-soft); }
.mrow .mname { flex: 1; min-width: 0; font-size: 12.8px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .mcnt { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.mrow .mprice { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); }

.price-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pp-head { padding: 13px 14px 11px; border-bottom: 1px solid var(--line); }
.pp-title { font-size: 15px; font-weight: 620; font-family: var(--mono); letter-spacing: -.2px; word-break: break-all; }
.pp-sub { font-size: 12px; color: var(--faint); margin-top: 3px; }
.pp-stats { display: flex; gap: 14px; margin-top: 9px; flex-wrap: wrap; }
.pp-stat { font-size: 12px; color: var(--muted); }
.pp-stat b { color: var(--ink); font-weight: 620; font-variant-numeric: tabular-nums; }

.ptable { width: 100%; border-collapse: collapse; }
.ptable th {
  text-align: right; font-size: 11px; font-weight: 500; color: var(--faint);
  padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0; background: var(--card); z-index: 1;
}
.ptable th:first-child, .ptable td:first-child { text-align: left; }
.ptable td { padding: 8px 12px; font-size: 12.8px; border-bottom: 1px solid #f4f5f7; vertical-align: middle; }
.ptable tr:last-child td { border-bottom: 0; }
.ptable tr:hover td { background: #fafbfc; }
.ptable .pnum { text-align: right; font-variant-numeric: tabular-nums; font-weight: 560; }
.ptable .psite { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ptable .psite a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptable .psite a:hover { color: var(--accent); text-decoration: underline; }
.ptable .low { color: var(--ok); }
.ptable .high { color: var(--muted); }
.rank-badge {
  font-size: 10.5px; padding: 1px 5px; border-radius: 5px; font-variant-numeric: tabular-nums;
  background: var(--bg-soft); color: var(--muted);
}
.rank-badge.best { background: var(--ok-soft); color: var(--ok); }

.price-note { padding: 10px 14px; font-size: 11.5px; color: var(--faint); border-top: 1px solid var(--line); line-height: 1.6; }

/* ---------------- 抽屉 / 弹层 ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(16, 24, 40, .38);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .16s ease;
}
@media (min-width: 640px) { .overlay { align-items: center; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.panel {
  background: var(--card); width: 100%; max-width: 560px; max-height: 88vh;
  border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slideup .22s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 640px) { .panel { border-radius: 18px; max-height: 82vh; animation: pop .18s ease; } }
@keyframes slideup { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

.panel-head { display: flex; align-items: center; gap: 10px; padding: 15px 16px 11px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15.5px; font-weight: 620; flex: 1; }
.panel-body { padding: 14px 16px; overflow: auto; }
.panel-foot { padding: 11px 16px 15px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

.field { margin-bottom: 11px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line);
  background: #fbfcfd; font-size: 13.5px; outline: 0; transition: border-color .15s, background .15s;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; min-height: 76px; font-family: var(--mono); font-size: 12.5px; }
.field .hint { font-size: 11.5px; color: var(--faint); margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: #fff; font-size: 13px; padding: 9px 16px; border-radius: 10px;
  box-shadow: var(--shadow-lg); z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--bad); }

.foot { text-align: center; font-size: 11.5px; color: var(--faint); padding: 26px 0 0; line-height: 1.7; }
.foot code { font-family: var(--mono); }

.loading { padding: 30px; text-align: center; color: var(--faint); font-size: 12.5px; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d8dbe1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #c3c7cf; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 480px) {
  .brand .sub { display: none; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 1 0 auto; padding: 7px 11px; }
  .iconbtn { width: 31px; height: 31px; font-size: 15px; }
}

@media (max-width: 420px) {
  .app { padding: 0 11px 84px; }
  .topbar { margin: 0 -11px; padding: 10px 11px 8px; }
  .tab { font-size: 13px; padding: 7px 9px; }
  .tab .cnt { display: none; }
  .ck-summary { gap: 6px; }
  .stat { padding: 9px 10px; }
  .stat .v { font-size: 17px; }
}
