/* 配色独立于布局。经典蓝沿用 style.css，其余皮肤只覆盖外观。 */
:root[data-skin="mist"], [data-preview="mist"] {
  color-scheme: dark;
  --bg: #14202B; --bg2: #1C2B38; --bg3: #263947;
  --line: #344858; --line2: #51687A;
  --fg: #E8EDF2; --muted: #A2B2C2; --fg3: #91A5B7;
  --accent: #80C7F2; --accent2: #AADCF8; --accent-dim: #243E50;
  --on-accent: #14202B; --gold: #E5BD70; --star-line: #806B42;
  --star-tint: #FFE5AE; --star-bg: #383426;
  --ok: #7BD3AD; --done: #7BD3AD; --warn: #E5BD70; --err: #FFAAA5;
  --error-bg: #402C31; --focus-bg: #3C2D38;
  --chart-1: #5FA8E8; --chart-2: #8FA8D8; --chart-3: #3FBFA0; --chart-4: #D8B36A;
}
:root[data-skin="porcelain"], [data-preview="porcelain"] {
  color-scheme: light;
  --bg: #EFF3F6; --bg2: #FFFFFF; --bg3: #E5ECF1;
  --line: #CED9E1; --line2: #A6B7C6;
  --fg: #243B4B; --muted: #526A7C; --fg3: #607487;
  --accent: #24658A; --accent2: #184E70; --accent-dim: #DCEBF4;
  --on-accent: #FFFFFF; --gold: #856014; --star-line: #BE9A50;
  --star-tint: #392A0A; --star-bg: #FAEFCF;
  --ok: #236F51; --done: #236F51; --warn: #855C10; --err: #A33737;
  --error-bg: #FBE9E8; --focus-bg: #F5E6EB;
  --chart-1: #24658A; --chart-2: #7A94B8; --chart-3: #1F8A70; --chart-4: #A8791F;
}
:root[data-skin="dusk"], [data-preview="dusk"] {
  color-scheme: dark;
  --bg: #231F30; --bg2: #2D293C; --bg3: #3A344A;
  --line: #4A435B; --line2: #6D627F;
  --fg: #EEEAF4; --muted: #BBB0CD; --fg3: #AB9FBF;
  --accent: #C2AFEA; --accent2: #D8C9F5; --accent-dim: #443852;
  --on-accent: #241C32; --gold: #E5C58C; --star-line: #887249;
  --star-tint: #F9E6C3; --star-bg: #3E352E;
  --ok: #8FD1B3; --done: #8FD1B3; --warn: #E5C58C; --err: #F2A7B3;
  --error-bg: #472F3C; --focus-bg: #493044;
  --chart-1: #B39DE8; --chart-2: #7FD1C0; --chart-3: #E0B64F; --chart-4: #F2A7B3;
}
:root[data-skin="pine"], [data-preview="pine"] {
  color-scheme: dark;
  --bg: #162A26; --bg2: #1E3832; --bg3: #2A4940;
  --line: #35554B; --line2: #527568;
  --fg: #DFE9E4; --muted: #A9BEB4; --fg3: #91AA9E;
  --accent: #9BCBB4; --accent2: #B7DCC7; --accent-dim: #29483D;
  --on-accent: #142820; --gold: #D8B36A; --star-line: #806B42;
  --star-tint: #F5E2B9; --star-bg: #3B3528;
  --ok: #8CCBA8; --done: #8CCBA8; --warn: #E6C078; --err: #F2A3A0;
  --error-bg: #472F32; --focus-bg: #3C3330;
  --chart-1: #9BCBB4; --chart-2: #5E9C7F; --chart-3: #D8B36A; --chart-4: #8FA6B5;
}
[data-preview="classic"] {
  --bg: #0E1621; --bg2: #17212B; --bg3: #202B36;
  --line: #263344; --fg: #F5F7FA; --muted: #A0B1C3; --accent: #64B5EF;
  --chart-1: #4f9cf9; --chart-2: #9aa7ff; --chart-3: #43c59e; --chart-4: #e0b64f;
}

/* 所有皮肤共用：搜索、筛选、显示操作分层，内容左右对齐。 */
#view-messages .message-toolbar { display: flex; flex-direction: column; gap: 10px; }
#view-messages[data-browse="masonry"] :is(.filters, .filter-chips, .search-history, .list-head) { max-width: none; }
#view-messages[data-browse="masonry"] .chat-flow { padding-inline: 0; }
#view-messages .message-toolbar #q {
  flex: none; width: 100%; min-width: 0; height: 42px; padding: 9px 13px; font-size: 14px;
}
.filter-actions, .filter-controls, .view-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-actions { justify-content: space-between; gap: 10px 18px; }
.view-controls { margin-left: auto; }
.filter-actions .btn, .filter-actions .sel { min-height: 36px; font-size: 13px; }
.filter-actions #btnReset { background: transparent; border-color: transparent; color: var(--muted); }
.filter-actions #btnReset:hover { color: var(--fg); border-color: var(--line2); }
#view-messages .top { gap: 12px; }
#view-messages .top h1 { min-width: 0; overflow-wrap: anywhere; }
#view-messages .top-a { flex-wrap: wrap; justify-content: flex-end; }
.bub-text { font-size: 15px; line-height: 1.8; }
.wf-body { padding: 12px 14px 8px; }
.bub.wf { width: 100%; align-self: stretch; grid-template-columns: minmax(120px, 42%) minmax(0, 1fr); }
.wf-excerpt { margin: 0; font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; white-space: pre-wrap;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; overflow: hidden; }
.bub.wf:has(.wf-none) { grid-template-columns: minmax(0, 1fr); }
.bub.wf:has(.wf-none) .wf-media { display: none; }
.bub.wf:has(.wf-none) :is(.wf-body, .wf-bar) { grid-column: 1; }
.wf-kv { gap: 5px 14px; }
.wf-kv span { font-size: 13px; }
.wf-bar { padding: 8px 12px; }
.wf-bar .fav-add, .wf-bar .pd-open { min-height: 32px; display: inline-flex; align-items: center; }
.panel-h { font-size: 14px; letter-spacing: 0; color: var(--fg); }
.hero-line { font-size: clamp(18px, 2vw, 23px); font-weight: 600; }
.hero-sub { line-height: 1.8; }
.stat-card { gap: 8px; }
.stat-card i { letter-spacing: 0; font-size: 12px; }
.brand-t, .top h1, .panel-h, .skin-choice-title { text-wrap: balance; }
.status { flex-wrap: wrap; }
.sync-summary { border-left: 3px solid var(--accent); }
.sync-summary .sync-channels:empty { display: none; }
.chart { margin-block: 18px 24px; }
.chart .col i { position: absolute; top: calc(100% + 5px); left: 50%; transform: translateX(-50%);
  color: var(--muted); font-style: normal; font-size: 10px; white-space: nowrap; }
.chart .col:not(:nth-child(5n+1)):not(:last-child) i { display: none; }

/* 外观选择使用原生单选框：键盘方向键可切换，选中状态不只依赖颜色。 */
.settings-wrap { width: min(900px, 100%); }
.settings-head { gap: 12px; margin-bottom: 20px; }
.settings-head .back-btn { margin-right: 0; }
.settings-head h1 { margin-right: auto; }
.appearance-panel {
  margin-bottom: 22px; padding: 20px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 12px;
}
.appearance-panel h2 { margin: 0; font-size: 16px; }
.appearance-note { margin: 5px 0 16px; font-size: 13px; color: var(--muted); }
.skin-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; border: 0; padding: 0; margin: 0; min-width: 0; }
.skin-legend { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skin-choice {
  display: flex; flex-direction: column; min-width: 0; padding: 8px; gap: 8px;
  border: 2px solid var(--line); border-radius: 10px; cursor: pointer;
  background: var(--bg); color: var(--fg);
}
.skin-choice:has(input:checked) { border-color: var(--accent); }
.skin-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.skin-preview { display: grid; grid-template-columns: 25% 1fr; gap: 9px; height: 80px; border-radius: 5px; background: var(--bg); overflow: hidden; }
.skin-preview > i { display: block; background: var(--bg2); border-right: 1px solid var(--line); }
.skin-preview > i::before { content: ''; display: block; margin: 12px 5px; height: 5px; border-radius: 2px; background: var(--accent); }
.skin-preview > span { display: grid; gap: 6px; align-content: center; padding-right: 7px; }
.skin-preview b { display: block; height: 6px; width: 65%; border-radius: 2px; background: var(--accent); }
.skin-preview em { display: block; height: 20px; border-radius: 3px; background: var(--bg2); border: 1px solid var(--line); }
.skin-choice-title { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.skin-choice input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.skin-choice-title small { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 400; }
.skin-description { font-size: 12px; line-height: 1.6; color: var(--muted); }
.skin-status { margin: 12px 0 0; min-height: 21px; font-size: 12px; color: var(--muted); }

/* 新皮肤统一使用语义色，补齐旧样式中写死的深色表面。 */
html[data-skin]:not([data-skin="classic"]) {
  --sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --serif: var(--sans);
}
html[data-skin]:not([data-skin="classic"]) body { font-family: var(--sans); }
html[data-skin]:not([data-skin="classic"]) ::selection { background: var(--accent); color: var(--on-accent); }
html[data-skin]:not([data-skin="classic"]) ::-webkit-scrollbar-thumb { background: var(--line2); }
html[data-skin]:not([data-skin="classic"]) .logo { background: var(--accent); color: var(--on-accent); box-shadow: none; }
html[data-skin]:not([data-skin="classic"]) .nav-i.active,
html[data-skin]:not([data-skin="classic"]) .chat-item.active {
  background: var(--accent-dim); color: var(--accent); box-shadow: inset 3px 0 var(--accent);
}
html[data-skin]:not([data-skin="classic"]) .chat-item.active :is(.ci-n, .ci-m) { color: var(--fg); }
html[data-skin]:not([data-skin="classic"]) .chat-item { border-bottom-color: var(--line); }
html[data-skin]:not([data-skin="classic"]) .userbox .ub-av { border-color: var(--line2); }
html[data-skin]:not([data-skin="classic"]) :is(.starred-item, .starred-item.active, .star-toggle.on) {
  background: var(--star-bg); border-color: var(--star-line); color: var(--gold); box-shadow: none;
}
html[data-skin]:not([data-skin="classic"]) .starred-item.active { box-shadow: inset 3px 0 var(--gold); }
html[data-skin]:not([data-skin="classic"]) .starred-item.active :is(.ci-n, .ci-m) { color: var(--gold); }
html[data-skin]:not([data-skin="classic"]) .btn:hover { background: var(--line); }
html[data-skin]:not([data-skin="classic"]) .btn.primary:hover { background: var(--accent2); color: var(--on-accent); }
html[data-skin]:not([data-skin="classic"]) :is(.btn.danger, .err, .set-msg.err, .ua-table .ua-act, #btnFocusView.on) {
  color: var(--err); border-color: var(--err); background: var(--error-bg);
}
html[data-skin]:not([data-skin="classic"]) .dot.err { padding: 0; margin: 0; border: 0; background: var(--err); }
html[data-skin]:not([data-skin="classic"]) :is(.focus-add.on, .focus-add:hover) { color: var(--err); }
html[data-skin]:not([data-skin="classic"]) :is(.stat-card b, .hero-line b) { color: var(--fg); }
html[data-skin]:not([data-skin="classic"]) :is(.pd-card, .toast, .day-sep span, #view-media .list-head, .pd-open) { background: var(--bg2); }
html[data-skin]:not([data-skin="classic"]) :is(.pd-stage, .pdg-item) { background: var(--bg3); }
html[data-skin]:not([data-skin="classic"]) .bub.out .bub-card { background: var(--accent-dim); border-color: var(--line2); }
html[data-skin]:not([data-skin="classic"]) .bub-card { box-shadow: none; }
html[data-skin]:not([data-skin="classic"]) .unread-sep span { background: var(--accent); color: var(--on-accent); box-shadow: none; }
html[data-skin]:not([data-skin="classic"]) .dup-badge { background: var(--star-bg); color: var(--gold); }
html[data-skin]:not([data-skin="classic"]) :is(.from-chat, .new-badge) { border-color: var(--line2); }
html[data-skin]:not([data-skin="classic"]) .skel-card { background: var(--bg2); }
html[data-skin]:not([data-skin="classic"]) .skel-card i { background: var(--bg3); }
html[data-skin="porcelain"] .post-detail { background: rgba(36, 59, 75, .55); }
html[data-skin="porcelain"] :is(.sel-bar, .toast) { box-shadow: 0 4px 18px rgba(36, 59, 75, .14); }
html[data-skin="porcelain"] .mark { background: var(--star-bg); color: var(--star-tint); }

/* 登录页沿用浏览器选择；经典皮肤保留原登录页配色。 */
html[data-skin]:not([data-skin="classic"]) .login-page { background: var(--bg); color: var(--fg); }
html[data-skin]:not([data-skin="classic"]) .login-page .card { background: var(--bg2); border-color: var(--line); }
html[data-skin]:not([data-skin="classic"]) .login-page h1 { color: var(--fg); }
html[data-skin]:not([data-skin="classic"]) .login-page :is(.sub, label) { color: var(--muted); }
html[data-skin]:not([data-skin="classic"]) .login-page input { background: var(--bg); color: var(--fg); border-color: var(--line2); }
html[data-skin]:not([data-skin="classic"]) .login-page input:focus { border-color: var(--accent); }
html[data-skin]:not([data-skin="classic"]) .login-page button { background: var(--accent); color: var(--on-accent); }

/* Shared archive reading-room refinements: layout and states stay skin-agnostic. */
html { scrollbar-color: var(--line2) var(--bg2); }
body { font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif; }
:is(.ci-n, .ci-m,  .bub-time, .wf-count, .pd-pos, .pf-size, .stat-card b) {
  font-variant-numeric: tabular-nums;
}
.side { width: 252px; border-right-color: var(--line2); }
.brand { padding: 18px 16px 15px; }
.brand-t { letter-spacing: 0; }
.nav { gap: 4px; padding-inline: 12px; }
.nav-i { min-height: 40px; border-radius: 9px; }
.side-h { letter-spacing: .04em; }
.chat-item { min-height: 48px; border-bottom-color: var(--line); }
.chat-item.active { background: var(--accent-dim); color: var(--accent); box-shadow: inset 3px 0 var(--accent); }
.chat-item.active :is(.ci-n, .ci-m) { color: var(--fg); }
.top { min-height: 52px; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.top h1, .settings-head h1 { font-size: clamp(20px, 2vw, 24px); letter-spacing: -.02em; }
.top-a { gap: 8px; }
.panel, .stat-card, .appearance-panel, .set-card { border-color: var(--line); }
.panel { border-radius: 12px; }
.stat-card { border-radius: 12px; }
.stat-card b { font-size: clamp(22px, 2.4vw, 30px); }
.btn, .sel, input:not([type="radio"]):not([type="checkbox"]) { border-radius: 9px; }
:is(button, input, select, a, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skin-choice { min-height: 148px; }
.skin-choice:has(input:checked) { box-shadow: inset 0 0 0 1px var(--accent-dim); }
.skin-preview { min-height: 72px; }
.chat-flow  .dup-badge { font-variant-numeric: tabular-nums; }
.dup-badge { border: 1px solid var(--star-line); }
.unread-sep span { border-radius: 999px; padding: 3px 12px; font-size: 12px; font-weight: 600; }
.mi, .wf { border: 1px solid var(--line); border-radius: 12px; }
.mi { background: var(--bg2); }
.mi-c { color: #fff; }
.view#view-collect > .panel { border-radius: 12px; }
.workflow-row { gap: 14px; }
.set-card h2, .appearance-panel h2, .panel-h { letter-spacing: 0; }

@media (max-width: 1000px) { .skin-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .side { width: auto; padding-top: env(safe-area-inset-top); }
  .top {
    position: sticky; top: 0; z-index: 10;
    margin: -12px -14px 10px; padding: calc(8px + env(safe-area-inset-top)) 14px 9px;
    border-bottom: 1px solid var(--line); background: var(--bg);
  }
  #view-settings .settings-wrap { width: 100%; }
  #view-settings .settings-head {
    position: sticky; top: 0; z-index: 10;
    margin: -12px -14px 14px; padding: calc(8px + env(safe-area-inset-top)) 14px 9px;
    border-bottom: 1px solid var(--line); background: var(--bg);
  }
  .btn, .sel, .mtab, .chip { min-height: 44px; }
  .appearance-panel { padding: 14px; }
  .set-card { padding: 14px; }
  .skin-choices { gap: 10px; }
  .skin-preview { height: 68px; }
  #view-messages .message-toolbar #q { font-size: 16px; height: 44px; }
  #view-messages .top h1 { flex: 1; }
  #view-messages .top-a { width: 100%; }
  #view-messages .top-a .muted { flex: 1; min-width: 0; font-size: 12px; }
  #view-messages .top-a .sel { max-width: 110px; font-size: 12px; }
  #view-messages .top-a .btn { font-size: 12px; padding-inline: 10px; }
  #view-messages .filter-actions { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; gap: 8px; }
  #view-messages .filter-controls, #view-messages .view-controls { width: 100%; margin-left: 0; }
  #view-messages .filter-controls .sel { flex: 1 1 130px; max-width: none; }
  #view-messages .view-controls #btnBrowseMode { flex: 1 1 auto; }
  #view-messages .filter-chips { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  #view-messages .filter-chips .chip { flex: none; }
  #view-messages .day-sep, #view-messages .unread-sep { position: relative; top: auto; }
  .filter-actions .btn, .filter-actions .sel { min-height: 44px; }
  .filter-actions .sel { max-width: 130px; }
  .wf-body { padding: 9px 10px 6px; }
  .wf-bar { padding: 6px; flex-wrap: wrap; }
  .wf-bar .fav-add, .wf-bar .pd-open { min-height: 40px; }
  .settings-head h1 { font-size: 22px; }
  .skin-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view { padding-inline: 14px; }
  .media-tabs { gap: 6px; padding: 8px 0 0; }
  .media-tabs .mtab { flex: 1 1 0; min-width: 0; padding-inline: 6px; white-space: nowrap; }
  #view-media .list-head { top: 62px; }
  #view-collect .panel { padding: 14px; }
  #view-collect .steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  #view-collect .step { min-width: 0; flex-direction: column; justify-content: center; gap: 5px; padding: 8px 4px; text-align: center; font-size: 12px; line-height: 1.35; }
  #view-collect .row-a { align-items: stretch; }
  #view-collect .row-a > .btn { flex: 1 1 auto; }
  #view-collect .row-a > .sel { flex: 1 1 140px; max-width: none; }
  #view-collect .row-a > input.grow { flex: 1 1 100%; }
  #view-collect .sync-summary .status { flex-wrap: wrap; }
  #view-collect .workflow-toolbar { align-items: flex-start; }
  .ua-table { display: block; width: 100%; overflow-x: auto; overscroll-behavior-x: contain; white-space: nowrap; }
  .ua-table th, .ua-table td { padding-inline: 10px; }
  .ua-row input { flex: 1 1 100%; min-width: 0; }
  .ua-row .ua-admin { flex: 1; }
  .ua-row button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* 登录页 .err 提示框皮肤化（审查 M7）：login.html 内联写死深红底，
   月白（浅色）皮肤下刺眼且对比失衡——统一走语义变量 */
html[data-skin]:not([data-skin="classic"]) .login-page .err {
  color: var(--err, #ff9b95);
  background: color-mix(in srgb, var(--err, #f85149) 14%, var(--bg2, #161b22));
  border-color: color-mix(in srgb, var(--err, #f85149) 45%, transparent);
}
