/* WeixinBox 管理面板（WeUI 风格）：浅色为主，跟随系统深色模式 */
:root {
  --bg: #ededed; --bg2: #fff; --bg3: #f7f7f7;
  --fg0: rgba(0, 0, 0, .9); --fg1: rgba(0, 0, 0, .55); --fg2: rgba(0, 0, 0, .3);
  --hair: rgba(0, 0, 0, .1); --press: rgba(0, 0, 0, .05);
  --brand: #07c160; --brand-press: #06ad56; --brand-soft: rgba(7, 193, 96, .1);
  --red: #fa5151; --orange: #fa9d3b; --link: #576b95;
  --mask: rgba(0, 0, 0, .6); --shadow: 0 8px 32px rgba(0, 0, 0, .12);
  --font: system-ui, -apple-system, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111; --bg2: #191919; --bg3: #202020;
    --fg0: rgba(255, 255, 255, .85); --fg1: rgba(255, 255, 255, .5); --fg2: rgba(255, 255, 255, .3);
    --hair: rgba(255, 255, 255, .08); --press: rgba(255, 255, 255, .06);
    --brand-soft: rgba(7, 193, 96, .16); --link: #7d90a9; --mask: rgba(0, 0, 0, .75); --shadow: 0 8px 32px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg0); font: 17px/1.4 var(--font); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
svg { flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------------------------------------------------------------- 页面骨架 */
.page { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: env(safe-area-inset-top) 16px 0; }
.topbar-row { display: flex; align-items: center; gap: 12px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 600; flex: 1; min-width: 0; }
.brand .logo { width: 32px; height: 32px; border-radius: 8px; }
.brand .logo svg { width: 20px; height: 20px; }
.avatar { width: 32px; height: 32px; border-radius: 6px; border: 0; background: var(--link); color: #fff; font-size: 15px; font-weight: 600; display: grid; place-items: center; cursor: pointer; text-transform: uppercase; }

.logo { background: var(--brand); display: grid; place-items: center; }

/* 顶部导航（WeUI navbar） */
.navbar { display: flex; border-bottom: 1px solid var(--hair); margin: 0 -16px; padding: 0 8px; overflow-x: auto; scrollbar-width: none; }
.navbar button { flex: 1 0 auto; border: 0; background: none; padding: 12px 12px 10px; color: var(--fg1); font-size: 15px; cursor: pointer; position: relative; white-space: nowrap; }
.navbar button[aria-selected="true"] { color: var(--brand); font-weight: 600; }
.navbar button[aria-selected="true"]::after { content: ""; position: absolute; left: 50%; bottom: -1px; width: 24px; height: 3px; margin-left: -12px; border-radius: 2px; background: var(--brand); }

/* ---------------------------------------------------------------- 列表（cells） */
.section-title { padding: 24px 16px 8px; color: var(--fg1); font-size: 14px; display: flex; justify-content: space-between; align-items: baseline; }
.section-title .aside { font-size: 13px; color: var(--fg2); }
.cells { background: var(--bg2); position: relative; }
@media (min-width: 480px) { .cells { margin: 0 16px; border-radius: 12px; overflow: hidden; } }
@media (max-width: 479px) { .cells { border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); } }
.cell { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 16px; position: relative; width: 100%; border: 0; background: none; text-align: left; }
.cell + .cell::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--hair); }
.cell.with-icon + .cell.with-icon::before { left: 76px; }
button.cell, .cell.tap { cursor: pointer; }
button.cell:active, .cell.tap:active { background: var(--press); }
.cell .bd { flex: 1; min-width: 0; }
.cell .t { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .d { font-size: 14px; color: var(--fg1); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cell .ft { color: var(--fg1); font-size: 15px; display: flex; align-items: center; gap: 8px; }
.cell .arrow { width: 8px; height: 14px; color: var(--fg2); }
.cell label, .cell .label { width: 96px; flex: none; }
.cell input[type=text], .cell input[type=password], .cell input[type=number] { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; height: 32px; caret-color: var(--brand); }
.cell input::placeholder { color: var(--fg2); }
.cells-tips { padding: 8px 16px 0; color: var(--fg1); font-size: 14px; line-height: 1.6; }
@media (min-width: 480px) { .cells-tips { padding: 8px 32px 0; } }

/* 实例图标 */
.inst-icon { width: 48px; height: 48px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--brand); position: relative; }
.inst-icon svg { width: 30px; height: 30px; }
.inst-icon.off { background: #b2b2b2; }
@media (prefers-color-scheme: dark) { .inst-icon.off { background: #3e3e3e; } }

/* 状态 */
.status { display: inline-flex; align-items: center; gap: 4px; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--fg2); }
.status.running::before { background: var(--brand); }
.status.starting::before { background: var(--orange); }
.tag { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 12px; line-height: 20px; background: var(--bg3); color: var(--fg1); }
.tag.brand { background: var(--brand-soft); color: var(--brand); }
.tag.red { background: rgba(250, 81, 81, .1); color: var(--red); }

/* ---------------------------------------------------------------- 按钮 */
.weui-btn { display: block; width: 100%; max-width: 184px; margin: 0 auto; padding: 10px 24px; border: 0; border-radius: 8px; font-size: 17px; font-weight: 600; line-height: 1.4; text-align: center; cursor: pointer; background: var(--bg3); color: var(--brand); }
.weui-btn + .weui-btn { margin-top: 16px; }
.weui-btn:active { filter: brightness(.95); }
.weui-btn_primary { background: var(--brand); color: #fff; }
.weui-btn_primary:active { background: var(--brand-press); filter: none; }
.weui-btn_warn { color: var(--red); }
.weui-btn[disabled] { opacity: .5; cursor: default; }
.weui-btn_mini { display: inline-flex; align-items: center; width: auto; max-width: none; margin: 0; padding: 0 12px; height: 32px; font-size: 14px; border-radius: 6px; }
.btn-area { padding: 32px 16px 0; }

/* 开关 */
.switch { appearance: none; -webkit-appearance: none; width: 52px; height: 32px; border-radius: 16px; background: var(--hair); position: relative; cursor: pointer; flex: none; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(20px); }
input[type=checkbox].check { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--fg2); margin: 0; flex: none; cursor: pointer; display: grid; place-items: center; }
input[type=checkbox].check:checked { background: var(--brand); border-color: var(--brand); }
input[type=checkbox].check:checked::after { content: ""; width: 10px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }

/* 步进器（配额） */
.stepper { display: inline-flex; align-items: center; border-radius: 6px; background: var(--bg3); }
.stepper button { width: 32px; height: 32px; border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--fg0); }
.stepper span { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 空状态、加载 */
.empty { text-align: center; padding: 64px 32px 24px; color: var(--fg1); }
.empty .inst-icon { margin: 0 auto 16px; width: 64px; height: 64px; border-radius: 14px; }
.empty .inst-icon svg { width: 40px; height: 40px; }
.empty h2 { margin: 0 0 8px; font-size: 17px; font-weight: 500; color: var(--fg0); }
.empty p { margin: 0; font-size: 14px; }
.loading { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--hair); border-top-color: var(--brand); animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { height: 72px; }

/* ---------------------------------------------------------------- 浮层：遮罩、对话框、操作菜单、半屏、提示 */
.mask { position: fixed; inset: 0; z-index: 100; background: var(--mask); animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; } }

.dialog { position: fixed; z-index: 101; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(320px, calc(100vw - 64px)); background: var(--bg2); border-radius: 12px; overflow: hidden; text-align: center; animation: pop .2s ease-out; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -50%) scale(.94); } }
.dialog .hd { padding: 32px 24px 16px; font-size: 17px; font-weight: 600; }
.dialog .bd { padding: 0 24px 32px; font-size: 17px; color: var(--fg1); word-break: break-word; line-height: 1.5; }
.dialog .hd + .bd { font-size: 15px; }
.dialog .bd input { width: 100%; margin-top: 4px; padding: 10px 12px; border: 0; border-radius: 6px; background: var(--bg3); outline: 0; color: var(--fg0); text-align: left; font-size: 16px; }
.dialog .bd input:focus { box-shadow: 0 0 0 2px var(--brand); }
.dialog .secret { margin-top: 12px; padding: 10px 12px; border-radius: 6px; background: var(--bg3); color: var(--fg0); font: 16px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; user-select: all; word-break: break-all; }
.dialog .ft { display: flex; border-top: 1px solid var(--hair); }
.dialog .ft button { flex: 1; height: 56px; border: 0; background: none; font-size: 17px; font-weight: 600; color: var(--brand); cursor: pointer; }
.dialog .ft button + button { border-left: 1px solid var(--hair); }
.dialog .ft button.default { color: var(--fg0); font-weight: 400; }
.dialog .ft button.warn { color: var(--red); }
.dialog .ft button:active { background: var(--press); }

.actionsheet { position: fixed; z-index: 101; left: 0; right: 0; bottom: 0; background: var(--bg); border-radius: 12px 12px 0 0; overflow: hidden; padding-bottom: env(safe-area-inset-bottom); animation: up .25s ease-out; }
@media (min-width: 480px) { .actionsheet { left: 50%; right: auto; width: 400px; margin-left: -200px; bottom: 16px; border-radius: 12px; } }
@keyframes up { from { transform: translateY(100%); } }
.actionsheet .title { background: var(--bg2); padding: 16px 24px; font-size: 13px; color: var(--fg1); text-align: center; line-height: 1.5; border-bottom: 1px solid var(--hair); }
.actionsheet .menu button, .actionsheet .cancel { display: block; width: 100%; height: 56px; border: 0; background: var(--bg2); font-size: 17px; cursor: pointer; color: var(--fg0); }
.actionsheet .menu button + button { border-top: 1px solid var(--hair); }
.actionsheet .menu button.warn { color: var(--red); }
.actionsheet .menu button:active, .actionsheet .cancel:active { background: var(--press); }
.actionsheet .cancel { margin-top: 8px; }

.half { position: fixed; z-index: 101; left: 0; right: 0; bottom: 0; max-height: 85vh; background: var(--bg); border-radius: 12px 12px 0 0; display: flex; flex-direction: column; animation: up .25s ease-out; padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 560px) { .half { left: 50%; right: auto; top: 50%; bottom: auto; width: 480px; transform: translate(-50%, -50%); border-radius: 12px; animation: pop .2s ease-out; } }
.half .hd { display: flex; align-items: center; height: 56px; padding: 0 8px; flex: none; }
.half .hd strong { flex: 1; text-align: center; font-size: 17px; font-weight: 600; }
.half .hd .x { width: 40px; height: 40px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; color: var(--fg0); border-radius: 8px; }
.half .hd .x:active { background: var(--press); }
.half .hd .spacer { width: 40px; }
.half .bd { overflow: auto; padding-bottom: 8px; }
.half .bd .cells { margin: 0; border-radius: 0; }
@media (min-width: 480px) { .half .bd .cells { margin: 0 16px; border-radius: 12px; } }
.half .ft { padding: 16px 16px 24px; flex: none; }

.toast { position: fixed; z-index: 200; left: 50%; top: 45%; transform: translate(-50%, -50%); min-width: 120px; max-width: calc(100vw - 64px); padding: 20px 20px 16px; border-radius: 12px; background: rgba(76, 76, 76, .95); color: rgba(255, 255, 255, .9); text-align: center; font-size: 15px; animation: fade .15s ease-out; pointer-events: none; }
.toast .ic { display: block; margin: 0 auto 8px; width: 40px; height: 40px; }
.toast .loading { width: 36px; height: 36px; border-width: 3px; border-color: rgba(255, 255, 255, .2); border-top-color: #fff; margin-bottom: 10px; }
.toast.text { padding: 12px 16px; top: auto; bottom: 20%; transform: translateX(-50%); }

/* ---------------------------------------------------------------- 登录页 */
.login { max-width: 420px; margin: 0 auto; padding: max(56px, 12vh) 0 32px; min-height: 100vh; display: flex; flex-direction: column; }
.login .head { text-align: center; padding: 0 32px 32px; }
.login .logo { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 16px; }
.login .logo svg { width: 40px; height: 40px; }
.login h1 { margin: 0; font-size: 22px; font-weight: 600; }
.login .head p { margin: 8px 0 0; color: var(--fg1); font-size: 14px; }
.login .err { margin: 12px 16px 0; padding: 10px 12px; border-radius: 8px; background: rgba(250, 81, 81, .1); color: var(--red); font-size: 14px; }
.login .foot { margin-top: auto; padding: 40px 16px 0; text-align: center; color: var(--fg2); font-size: 13px; }

/* 微信没在运行的说明页 */
.empty-page { max-width: 420px; margin: 0 auto; padding: 18vh 32px; text-align: center; }
.empty-page .icon-box { font-size: 48px; color: var(--fg2); }
.empty-page h1 { font-size: 20px; font-weight: 600; margin: 16px 0 8px; }
.empty-page p { color: var(--fg1); font-size: 14px; margin: 0 0 32px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; } .loading { animation: spin 2s linear infinite !important; } }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.center { text-align: center; }
.dialog:focus, .actionsheet:focus, .half:focus { outline: none; }

/* MCP 接入（半屏） */
.mcp-url { display: flex; align-items: center; gap: 8px; margin: 12px 16px 0; padding: 10px 12px; background: var(--bg3); border-radius: 8px; }
.mcp-url code { flex: 1; min-width: 0; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; user-select: all; }
.mcp-tabs { display: flex; gap: 2px; margin: 20px 16px 8px; padding: 2px; background: var(--bg3); border-radius: 8px; width: fit-content; }
.mcp-tabs button { border: 0; background: none; padding: 4px 12px; border-radius: 6px; font-size: 14px; color: var(--fg1); cursor: pointer; }
.mcp-tabs button[aria-pressed="true"] { background: var(--bg2); color: var(--brand); font-weight: 600; }
.mcp-snippet { margin: 0 16px; padding: 10px 12px; background: var(--bg3); border-radius: 8px; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.mcp-snippet-ft { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 16px 0; font-size: 13px; color: var(--fg1); }
.mcp-actions { display: flex; gap: 12px; }
.mcp-actions .weui-btn { flex: 1; margin: 0; max-width: none; }
@media (min-width: 480px) { .mcp-url, .mcp-tabs, .mcp-snippet, .mcp-snippet-ft { margin-left: 32px; margin-right: 32px; } }

/* ---------------------------------------------------------------- 与 Windows 面板共用的模块
   视频号下载页（finder.js + finder.css）与 MCP 调试工具（mcp.js + mcp.css）用 Windows 面板的变量名与基础组件：
   在这里把变量映射到本面板的色值，并补上它们用到的按钮、顶栏、进度条。 */
:root {
  --bg-0: var(--bg); --bg-1: var(--bg3); --bg-2: var(--bg2); --bg-btn: #f2f2f2;
  --bg-active: var(--press); --bg-press: rgba(0, 0, 0, .1);
  --fg-0: var(--fg0); --fg-1: var(--fg1); --fg-2: var(--fg2);
  --brand-text: #06ae56; --on-brand: #fff; --blue: #10aeff;
  --sans: var(--font); --mono: "Cascadia Mono", Consolas, ui-monospace, monospace; --ease: cubic-bezier(.16, 1, .3, 1);
}
@media (prefers-color-scheme: dark) {
  :root { --bg-btn: #2c2c2c; --bg-press: rgba(255, 255, 255, .1); --brand-text: #07c160; }
}
.fd-host, .mcp-panel { font-size: 15px; line-height: 1.5; }
.fd-host svg, .mcp-panel svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.fd-host .btn, .mcp-panel .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 20px;
  background: var(--bg-btn); color: var(--brand-text); border: 0; border-radius: 8px; cursor: pointer;
  font-size: 16px; font-weight: 500; line-height: 1.4; white-space: nowrap; text-decoration: none; transition: background-color .15s;
}
.fd-host .btn:hover, .mcp-panel .btn:hover { background: color-mix(in srgb, var(--bg-btn), var(--fg-0) 5%); }
.fd-host .btn:active, .mcp-panel .btn:active { background: color-mix(in srgb, var(--bg-btn), var(--fg-0) 10%); }
.fd-host .btn.primary { background: var(--brand); color: var(--on-brand); }
.fd-host .btn.primary:active { background: var(--brand-press); }
.fd-host .btn.quiet, .mcp-panel .btn.quiet { color: var(--fg-0); }
.fd-host .btn.danger { color: var(--red); }
.fd-host .btn:disabled, .fd-host .btn[aria-busy="true"] { opacity: .45; pointer-events: none; }
.fd-host input[type="text"] { border: 0; outline: 0; color: var(--fg-0); caret-color: var(--brand); }
.fd-host input:focus-visible { box-shadow: inset 0 0 0 1.5px var(--brand); }
.fd-host input::placeholder { color: var(--fg-2); }
.fd-host .bar {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--bg-2); border-bottom: 1px solid var(--hair);
}
.fd-host .bar h1 { margin: 0 auto 0 0; font-size: 17px; font-weight: 600; }
.fd-host .bar .btn { min-height: 32px; padding: 4px 14px; font-size: 14px; border-radius: 6px; }
.fd-host .bar .fd-back { margin-left: -6px; padding-inline: 8px; background: none; color: var(--link); font-weight: 400; }
.fd-host .connect-who { color: var(--fg-1); font-size: 14px; }
.fd-host p { margin: 0; }
.fd-host h2 { margin: 0; }
.meter { height: 3px; background: var(--hair); border-radius: 2px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 2px; transition: width .3s linear; }
.meter.busy i { width: 32%; animation: slide 1.3s ease-in-out infinite alternate; }
@keyframes slide { from { translate: -20% 0; } to { translate: 230% 0; } }

/* 整页浮层（视频号下载、日志）：盖住列表，自带返回 */
.fullpage { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow: auto; overscroll-behavior: contain; animation: fade .15s ease-out; }
body.has-fullpage { overflow: hidden; }
.fd-page .view-finder { overflow: visible; min-height: 100%; }
.fp-bar {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 8px;
  background: var(--bg2); border-bottom: 1px solid var(--hair);
}
.fp-bar strong { flex: 1; min-width: 0; text-align: center; font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-back, .fp-act { flex: none; min-width: 56px; height: 40px; border: 0; background: none; color: var(--link); font-size: 16px; cursor: pointer; border-radius: 8px; }
.fp-back:active, .fp-act:active { background: var(--press); }
.logs-page { display: flex; flex-direction: column; overflow: hidden; }
.logs { flex: 1; overflow: auto; padding: 8px 0 calc(16px + env(safe-area-inset-bottom)); background: var(--bg2); font: 12.5px/1.65 var(--mono); user-select: text; }
.logs > div { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 8px; padding: 0 16px; }
.logs time { color: var(--fg2); font-variant-numeric: tabular-nums; }
.logs span { white-space: pre-wrap; overflow-wrap: anywhere; }
.logs .empty { display: block; font-family: var(--font); }
@media (max-width: 480px) { .logs > div { grid-template-columns: 1fr; gap: 0; padding: 3px 12px; } .logs time { font-size: 11px; } }

/* 详情 */
.kv { background: var(--bg2); margin-bottom: 8px; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 13px 16px; font-size: 16px; position: relative; }
.kv > div + div::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--hair); }
.kv span:last-child { color: var(--fg1); text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
.svcs { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 16px; }
.svc { padding: 2px 10px; border-radius: 12px; background: var(--bg3); color: var(--fg1); font-size: 13px; }
.svc.on { background: var(--brand-soft); color: var(--brand); }
