/* 语声工坊 网页版样式。
   刻意不引任何外部资源：CSP 是 default-src 'self'，CDN 一律加载不到。 */

:root {
  --bg: #f4f7fe;
  --panel: #ffffff;
  --line: #e3e9f5;
  --text: #1f2a44;
  --dim: #6b7794;
  --brand: #3f6ae0;
  --brand-dark: #2f55c4;
  --ok: #1f9d63;
  --warn: #d98220;
  --err: #d2453c;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(31, 42, 68, .07);
}

* { box-sizing: border-box; }

/* 必须放在所有布局规则之前，而且要带 !important。
   浏览器内置的 [hidden] { display: none } 优先级比任何带类名的作者规则都低，
   所以 .modal { display: grid } 这种写法会把 hidden 直接盖掉 —— 四个弹窗
   就变成铺满整屏的透明遮罩，页面上什么都点不动。同理影响 .field、.warn-row。 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB",
        system-ui, sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }
code { background: #eef2fb; padding: 1px 5px; border-radius: 4px; }

/* ---------------- 顶栏 ---------------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.logo {
  width: 28px; height: 28px; border-radius: 8px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-size: 15px;
}
.tag {
  font-size: 11px; font-weight: 400; color: var(--brand);
  background: #eaf0ff; padding: 1px 7px; border-radius: 20px;
}
.top-right { display: flex; align-items: center; gap: 10px; }
.quota-chip { font-size: 12px; color: var(--dim); }
.quota-chip.low { color: var(--warn); }
.vip-badge {
  font-size: 11px; background: linear-gradient(100deg, #f0b23c, #e08a1e);
  color: #fff; padding: 1px 7px; border-radius: 20px; margin-left: 5px;
}

.notice {
  padding: 8px 20px; background: #eaf0ff; color: var(--brand-dark);
  font-size: 13px; border-bottom: 1px solid var(--line);
}
.notice.warn { background: #fdf3e6; color: #8a5a12; }

/* ---------------- 骨架 ---------------- */
.shell { display: flex; align-items: flex-start; gap: 16px; padding: 16px; }
.side {
  width: 132px; flex: 0 0 132px; display: flex; flex-direction: column; gap: 2px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow);
  position: sticky; top: 72px;
}
.nav-item {
  text-align: left; padding: 9px 11px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; color: var(--dim);
}
.nav-item:hover { background: #f2f5fd; color: var(--text); }
.nav-item.on { background: var(--brand); color: #fff; }
.side-sep { height: 1px; background: var(--line); margin: 6px 4px; }

.work { flex: 1; min-width: 0; }
.jobs {
  width: 268px; flex: 0 0 268px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto;
}
.jobs-h {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 13px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.jobs ul { list-style: none; margin: 0; padding: 8px; }
.jobs li { padding: 9px 8px; border-radius: 8px; }
.jobs li + li { border-top: 1px solid var(--line); }
.jobs li.empty { color: var(--dim); text-align: center; padding: 22px 8px; }

.job-t { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
/* min-width:0 是必需的：flex 子项默认不肯缩到内容以下，长标题会把状态挤到换行 */
.job-t b { font-weight: 600; min-width: 0; overflow: hidden;
           text-overflow: ellipsis; white-space: nowrap; }
.job-t .sz { flex: 0 0 auto; white-space: nowrap; font-size: 12px; color: var(--dim); }
.job-m { font-size: 12px; color: var(--dim); margin-top: 2px;
         overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 4px; background: #eef1f8; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); transition: width .3s; }
.job.done .bar i { background: var(--ok); }
.job.error .bar i { background: var(--err); }
.job-acts { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }

/* ---------------- 面板 ---------------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.modes { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.mode {
  padding: 6px 13px; border: 1px solid var(--line); background: #fff;
  border-radius: 20px; cursor: pointer; color: var(--dim);
}
.mode.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.cols { display: flex; gap: 16px; align-items: flex-start; }
.col-main { flex: 1; min-width: 0; }
.col-side { width: 244px; flex: 0 0 244px; display: flex; flex-direction: column; gap: 12px; }

.editor {
  width: 100%; min-height: 300px; resize: vertical; padding: 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fcfdff;
}
.editor.sm { min-height: 140px; }
.editor:focus { outline: 2px solid #cfdcff; border-color: var(--brand); }
.trans .editor { min-height: 168px; }
.editor-bar { display: flex; align-items: center; gap: 7px; margin: 7px 0 12px; }
.count { font-size: 12px; color: var(--dim); }
.count.over { color: var(--err); }
.grow { flex: 1; }

/* ---------------- 卡片 / 表单 ---------------- */
.card { border: 1px solid var(--line); border-radius: 8px; padding: 11px; }
.card-h { font-weight: 600; margin-bottom: 9px; }
.card-h.sub { font-size: 12px; color: var(--dim); font-weight: 400; margin-top: 11px; }
.field { display: block; font-size: 12px; color: var(--dim); margin-bottom: 9px; }
.field select, .field input {
  display: block; width: 100%; margin-top: 4px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff;
}
.pair { display: flex; gap: 7px; }
.pair input { flex: 1; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; margin: 7px 0; }
.slider { display: grid; grid-template-columns: 32px 1fr 40px; align-items: center;
          gap: 7px; font-size: 12px; color: var(--dim); margin-bottom: 8px; }
.slider b { font-weight: 500; color: var(--text); text-align: right; font-size: 11px; }

/* 滑块必须自己画：实测某些 Chromium 构建给 input[type=range] 算出的
   appearance 就是 none，于是轨道和滑块头一起消失，页面上只剩
   「语速 …… 正常」，根本没法拖。
   轨道画在 input 自己的 background 上，不用 ::-webkit-slider-runnable-track
   那类厂商伪元素 —— 各引擎对它们的支持差异太大，只有 thumb 是到处都认的。 */
.slider input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%; height: 5px; border-radius: 5px;
  background: #dfe6f5; cursor: pointer; margin: 0;
}
.slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--brand); border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(31, 42, 68, .35);
}
.slider input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--brand); border: 2px solid #fff;
}
.slider input[type=range]:focus-visible { outline: 2px solid #cfdcff; outline-offset: 3px; }

.voice-pick {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; text-align: left;
}
.voice-pick:hover { border-color: var(--brand); }
.caret { color: var(--dim); }
.warn-row {
  display: flex; gap: 7px; align-items: flex-start; margin-top: 8px;
  background: #fdf3e6; color: #8a5a12; padding: 7px 9px;
  border-radius: 7px; font-size: 12px;
}
.warn-dot {
  flex: 0 0 16px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--warn); color: #fff; display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
}

/* ---------------- 按钮 ---------------- */
.btn {
  padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer;
  /* 「下载桌面版」是个 <a>，得把链接的默认样式抹平才能和按钮长得一样 */
  display: inline-block; text-decoration: none; color: inherit; line-height: 1.5;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.big { padding: 11px; font-size: 15px; }
.btn.tiny { padding: 4px 10px; font-size: 12px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.danger:hover { border-color: var(--err); color: var(--err); }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; }
.link:hover { text-decoration: underline; }

/* ---------------- 上传 ---------------- */
.drop {
  border: 2px dashed #ccd6ee; border-radius: 10px; padding: 30px 16px;
  text-align: center; color: var(--dim); background: #fbfcff;
}
.drop.over { border-color: var(--brand); background: #eff4ff; }
.drop p { margin: 4px 0; }
.hint { font-size: 12px; color: var(--dim); }
.filelist { list-style: none; margin: 11px 0 0; padding: 0; }
.filelist li {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px;
}
.filelist .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist .sz { font-size: 12px; color: var(--dim); }
.filelist li.bad { border-color: #f3cfcb; background: #fdf4f3; }
.up-bar { height: 3px; background: #eef1f8; border-radius: 3px; overflow: hidden; margin-top: 5px; }
.up-bar i { display: block; height: 100%; background: var(--brand); }

/* ---------------- 角色 ---------------- */
.roles { display: flex; flex-direction: column; gap: 7px; margin-top: 11px; }
.role {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
}
.role b { flex: 0 0 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role select { flex: 1; padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; }

/* ---------------- 结果 ---------------- */
.res-head { display: flex; justify-content: space-between; align-items: flex-start; }
.res-head h2 { margin: 0 0 3px; font-size: 17px; }
.reslist { list-style: none; margin: 14px 0 0; padding: 0; }
.reslist li {
  display: flex; align-items: center; gap: 11px; padding: 11px;
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 7px;
}
.reslist .nm { flex: 1; min-width: 0; }
.reslist .nm b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reslist .nm span { font-size: 12px; color: var(--dim); }
.reslist .empty, .filelist .empty { justify-content: center; color: var(--dim); }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; background: rgba(24, 32, 52, .42);
  display: grid; place-items: center; z-index: 60; padding: 20px;
}
.modal-box {
  background: var(--panel); border-radius: 12px; width: 100%; max-width: 430px;
  max-height: 86vh; display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(20, 28, 48, .22);
}
.modal-box.wide { max-width: 760px; }
.modal-h {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--dim); }
.modal-body { padding: 16px; overflow: auto; }

.voice-tools { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.voice-tools input {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.chip {
  padding: 4px 11px; border: 1px solid var(--line); border-radius: 20px;
  background: #fff; cursor: pointer; font-size: 12px; color: var(--dim);
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.voice-grid {
  padding: 12px 16px; overflow: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px;
}
.vcard {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  cursor: pointer; text-align: left; background: #fff;
}
.vcard:hover { border-color: var(--brand); }
.vcard.on { border-color: var(--brand); background: #f4f7ff; }
.vcard b { display: block; }
.vcard span { font-size: 12px; color: var(--dim); }

/* ---------------- 账号 / 会员 ---------------- */
.acc-row { display: flex; gap: 9px; margin-bottom: 11px; }
.acc-row input {
  flex: 1; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
}
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 11px; }
.plan {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  cursor: pointer; text-align: center;
}
.plan.on { border-color: var(--brand); background: #f4f7ff; }
.plan b { display: block; font-size: 15px; }
.plan .price { font-size: 24px; color: var(--err); font-weight: 700; margin: 7px 0 2px; }
.plan .was { font-size: 12px; color: var(--dim); text-decoration: line-through; }
.pay-box { text-align: center; padding: 12px 0; }
.pay-box img { width: 190px; height: 190px; border: 1px solid var(--line); border-radius: 8px; }
.perks { list-style: none; padding: 0; margin: 12px 0 0; font-size: 13px; }
.perks li { padding: 3px 0; color: var(--dim); }
.perks li::before { content: "✓ "; color: var(--ok); }
table.limits { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
table.limits th, table.limits td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.limits th { color: var(--dim); font-weight: 400; }
table.limits td.vip { color: var(--brand); font-weight: 600; }

/* ---------------- 提示 ---------------- */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
          display: flex; flex-direction: column; gap: 8px; z-index: 90; align-items: center; }
.toast {
  background: #26314e; color: #fff; padding: 9px 16px; border-radius: 22px;
  box-shadow: 0 4px 18px rgba(20, 28, 48, .28); font-size: 13px; max-width: 76vw;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }
.toast.out { opacity: 0; transition: opacity .25s; }
.spin {
  display: inline-block; width: 11px; height: 11px; margin-right: 7px;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 窄屏 ---------------- */
@media (max-width: 1180px) {
  .jobs { position: static; width: 100%; flex: 1 1 100%; max-height: none; }
  .shell { flex-wrap: wrap; }
  .work { flex: 1 1 100%; order: 2; }
  .side { position: static; }
  .jobs { order: 3; }
}
@media (max-width: 760px) {
  .cols { flex-direction: column; }
  .col-side { width: 100%; flex: 1 1 auto; }
  .side { width: 100%; flex: 1 1 100%; flex-direction: row; overflow-x: auto; }
  .shell { padding: 10px; }
}
