/* ===== 极简出片台 · 深色极简 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b0d12;
  --panel: #12151d;
  --panel2: #171b25;
  --line: #232939;
  --txt: #e8edf7;
  --dim: #8b95ab;
  --acc: #7a45ff;
  --acc2: #38bdf8;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--txt);
  font-family: "Microsoft YaHei UI", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* ---------- 顶栏 ---------- */
.topbar {
  height: 52px;
  flex: 0 0 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.topright { display: flex; align-items: center; gap: 10px; }

.pill {
  font-size: 11px;
  padding: 4px 11px;
  border-radius: 20px;
  background: #1c2230;
  color: var(--dim);
  border: 1px solid var(--line);
  transition: .25s;
  white-space: nowrap;
  min-width: 52px;
  text-align: center;
}
.pill.run { color: var(--acc2); border-color: #1e4b63; background: #0e2a37; }
.pill.done { color: var(--ok); border-color: #1c5137; background: #0d2a1e; }
.pill.err { color: var(--err); border-color: #5c2626; background: #2a1113; }

/* ---------- 冷却倒计时表 ---------- */
.gapMeter { display: flex; align-items: center; }
.gmRing { position: relative; width: 36px; height: 36px; }
.gmRing svg { width: 36px; height: 36px; transform: rotate(-90deg); }
.gmRing circle { fill: none; stroke-width: 3; }
.gmBg { stroke: #232939; }
.gmFg {
  stroke: var(--acc2);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset .35s linear, stroke .3s;
}
.gmTxt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--dim);
  letter-spacing: -.3px;
}
.gapMeter.cooling .gmFg { stroke: var(--warn); }
.gapMeter.ready .gmFg { stroke: var(--ok); }
.gapMeter.ready .gmTxt { color: var(--ok); font-size: 10px; }
.gapMeter.cooling .gmTxt { color: var(--warn); }

/* ---------- 主体 ---------- */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

/* ===== 手机竖屏（安卓）=====
   桌面是左右两栏固定高度，手机上挤不下，改成上下排列、整页滚动。 */
@media (max-width: 760px) {
  /* ⚠️ 关键：桌面用的是「固定视口 + 面板内部滚动」，
     手机要改成「整页滚动」，否则 textarea 会被压扁 */
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body { display: block; }
  .app, #app { display: block; }

  main {
    display: block;
    gap: 0;
    padding: 10px;
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .panel {
    padding: 12px;
    margin-bottom: 10px;
    height: auto;
    max-height: none;
    overflow: visible;
    min-height: 0;
  }
  .panel.tasks {
    min-height: 320px;
    overflow: visible;
  }
  /* 头部：小屏收紧，别把「通道测试」挤出去 */
  .topbar {
    height: auto;
    flex: 0 0 auto;
    min-height: 46px;
    padding: 8px 10px;
    gap: 8px;
  }
  .brand span { font-size: 14px; }
  .brand svg { width: 22px; height: 22px; }
  .topright { gap: 6px; }
  .pill, .topright button { font-size: 11px; padding: 4px 8px; }
  .gapMeter .gmRing { width: 30px; height: 30px; }
  .taskList { max-height: none; }
  /* 手机上把成品/清空按钮缩小 */
  .headBtns { gap: 6px; }
  .headBtns button { font-size: 11px; padding: 4px 8px; }

  /* 素材缩略图小屏换行 */
  .thumbList { flex-wrap: wrap; }

  /* 统计栏：手机上四个指标挤在一行会竖排，缩小间距并禁止折行 */
  .tasksHead {
    padding: 8px 10px;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .stats {
    gap: 8px;
    font-size: 10.5px;
    flex-wrap: nowrap;
    min-width: 0;
  }
  .stats .st {
    white-space: nowrap;
    gap: 3px;
    flex: 0 0 auto;
  }
  .stats .st i { width: 5px; height: 5px; flex: 0 0 auto; }

  /* 头部按钮：禁止折行，图标文字同行 */
  .headBtns { flex: 0 0 auto; }
  .headBtns button, .topright button, .pill {
    white-space: nowrap;
    word-break: keep-all;
  }

  /* 提示词框：手机上给足高度，别被压成两行 */
  .field.grow {
    min-height: 200px;
    flex: 0 0 auto;
  }
  textarea {
    min-height: 170px;
    flex: 0 0 auto;
  }

  /* 开始生成按钮：手机上更好点 */
  .primary { padding: 14px 16px; font-size: 14px; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: auto;
}
.panel.tasks { padding: 0; overflow: hidden; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1; min-height: 120px; }
.field label { font-size: 11px; color: var(--dim); letter-spacing: .4px; display: flex; justify-content: space-between; }
.hint { color: #5b6479; font-size: 10px; }

select, textarea, input[type=text] {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--txt);
  padding: 9px 11px;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: .18s;
  width: 100%;
}
select:focus, textarea:focus { border-color: #3d3559; background: #1a1f2c; }
select { cursor: pointer; }
textarea { resize: none; flex: 1; line-height: 1.65; user-select: text; }
textarea::placeholder { color: #4a5163; }

/* 锁定字段（模型） */
.locked {
  background: #0f1219;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12.5px;
  color: #9aa6bd;
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: .3px;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row .field { gap: 5px; }

/* 模式说明 */
.modeDesc {
  font-size: 10.5px;
  color: #6d7789;
  line-height: 1.6;
  background: #0f1219;
  border-left: 2px solid #2f3a52;
  border-radius: 0 6px 6px 0;
  padding: 6px 9px;
  min-height: 30px;
}

/* ---------- 素材区（上下分行） ---------- */
.mediaRow {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.mediaRow:last-child { margin-bottom: 0; }
.mediaRow.hidden { display: none; }

.drop {
  flex: 0 0 106px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #2c3446;
  border-radius: 9px;
  padding: 8px 6px;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--dim);
  cursor: pointer;
  transition: .18s;
  overflow: hidden;
}
.drop:hover { border-color: var(--acc); color: #b9a6ff; background: #161226; }
.drop.has { border-color: #2a6b4a; color: var(--ok); border-style: solid; background: #0d1f18; }
.drop.hidden { display: none; }

/* 卡片列表容器 */
.thumbList {
  display: flex;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
}
.thumbList:empty { display: none; }

/* 单张素材卡 */
.thumbCard {
  position: relative;
  width: 92px;
  flex: 0 0 auto;
  background: #0f131b;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
  transition: .18s;
  user-select: none;
}
.thumbCard:hover { border-color: #3d4a66; transform: translateY(-1px); }

.thumbImg {
  width: 100%;
  height: 62px;
  object-fit: cover;
  display: block;
  background: #0a0d13;
  pointer-events: none;
}
.thumbImg.audio {
  height: 62px;
  background: linear-gradient(135deg, #16283a, #0e1723);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #4f9fc4;
}

.thumbName {
  font-size: 9.5px;
  color: #8b95ab;
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #0c0f16;
  border-top: 1px solid var(--line);
  pointer-events: none;
}

/* 删除按钮 */
.thumbDel {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(20, 8, 10, .85);
  border: 1px solid #5c2626;
  color: #f87171;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: .15s;
  padding: 0;
  font-family: inherit;
  z-index: 2;
}
.thumbDel:hover { background: #b91c1c; color: #fff; border-color: #ef4444; }

/* @ 提示角标 */
.thumbAt {
  position: absolute;
  left: 3px;
  top: 3px;
  font-size: 9.5px;
  font-weight: 700;
  color: #c4b5fd;
  background: rgba(20, 14, 40, .85);
  border: 1px solid #4c3a7a;
  border-radius: 4px;
  padding: 0 3px;
  opacity: 0;
  transition: .15s;
  pointer-events: none;
}
.thumbCard:hover .thumbAt { opacity: 1; }

/* 音频卡片 */
.thumbCard.audioCard { width: 112px; }
.thumbCard.audioCard .thumbImg { height: 44px; }

/* 空行隐藏 */
.mediaRow.emptyRow { display: none; }

/* ---------- 按钮 ---------- */
.primary {
  background: linear-gradient(135deg, var(--acc), var(--acc2));
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  transition: .2s;
  font-family: inherit;
  letter-spacing: .5px;
}
.primary:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }
.primary:disabled { opacity: .42; cursor: not-allowed; transform: none; }

.ghost {
  background: #1a1f2c;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--dim);
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: .18s;
}
.ghost:hover { color: var(--txt); border-color: #3a445c; }
.ghost.sm { padding: 5px 10px; font-size: 11px; }

/* ---------- 任务区 ---------- */
.tasksHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  gap: 10px;
}

.stats { display: flex; gap: 12px; font-size: 11px; color: var(--dim); }
.stats .st { display: flex; align-items: center; gap: 4px; }
.stats .st i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.stats .st b { color: var(--txt); font-weight: 600; }
.stats .que i { background: var(--warn); }
.stats .gen i { background: var(--acc2); }
.stats .don i { background: var(--ok); }
.stats .err i { background: var(--err); }

.headBtns { display: flex; gap: 6px; }

.taskList { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.empty {
  text-align: center;
  color: #464e61;
  margin: auto;
  font-size: 12.5px;
  line-height: 2.1;
}
.empty small { font-size: 11px; color: #383f50; }

/* ---------- 任务卡 ---------- */
.card {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
  animation: in .25s ease;
}
@keyframes in { from { opacity: 0; transform: translateY(6px); } }

.cardTop { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 7px; }
.cardPrompt {
  font-size: 12px;
  color: #c3cbdc;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  flex: 1;
  user-select: text;
}
.badge { font-size: 10px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; flex: 0 0 auto; }
.badge.que { background: #2a2110; color: var(--warn); }
.badge.sub { background: #1e2a3d; color: #7fb3e8; }
.badge.grab { background: #3a1f08; color: #fb923c; animation: grabPulse 1.6s ease-in-out infinite; }
@keyframes grabPulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.badge.run { background: #0e2a37; color: var(--acc2); }
.badge.done { background: #0d2a1e; color: var(--ok); }
.badge.err { background: #2a1113; color: var(--err); }

.bar { height: 3px; background: #1d2331; border-radius: 3px; overflow: hidden; margin: 7px 0 5px; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--acc), var(--acc2)); transition: width .5s ease; }

/* ---------- 抢位信息块（照官方界面） ---------- */
.grabBox {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 7px 0 4px;
  padding: 6px 9px;
  background: #101720;
  border: 1px solid #1e2a3a;
  border-radius: 7px;
  font-size: 11px;
}
.grabLeft, .grabRight { display: flex; align-items: center; gap: 5px; }
.grabLabel { color: #5b6479; font-size: 10.5px; }
.grabTime { color: #fbbf24; font-weight: 600; font-variant-numeric: tabular-nums; }
.grabPct {
  color: #fb923c;
  font-weight: 700;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  animation: grabPulse 1.6s ease-in-out infinite;
}
.grabErr {
  color: #f87171;
  font-size: 10px;
  background: #2a1113;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 3px;
}

/* 取消按钮 */
.cardCancel {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}
.cardCancel button {
  background: transparent;
  border: 1px solid #3a2028;
  border-radius: 7px;
  color: #c47b86;
  font-size: 11px;
  padding: 4px 12px;
  cursor: pointer;
  font-family: inherit;
  transition: .15s;
}
.cardCancel button:hover { background: #2a1113; color: #f87171; border-color: #5c2626; }

.cardMeta { font-size: 10.5px; color: #5b6479; display: flex; justify-content: space-between; gap: 8px; }

.cardVideo { margin-top: 9px; }
.cardVideo video {
  width: 100%;
  max-width: 620px;
  max-height: 340px;
  border-radius: 9px;
  background: #000;
  display: block;
  object-fit: contain;
}
.cardActions { display: flex; gap: 7px; margin-top: 8px; max-width: 620px; }
.cardActions a, .cardActions button {
  flex: 1;
  text-align: center;
  text-decoration: none;
  font-size: 11.5px;
  padding: 7px;
  border-radius: 8px;
  background: #1e2432;
  border: 1px solid var(--line);
  color: #a9b4c8;
  cursor: pointer;
  font-family: inherit;
  transition: .18s;
}
.cardActions a:hover, .cardActions button:hover { background: #252c3d; color: #fff; border-color: #3a445c; }

.errMsg { font-size: 11px; color: var(--err); line-height: 1.6; margin-top: 6px; user-select: text; word-break: break-all; }

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

/* ============ KEY 设置弹窗 ============ */
.hidden { display: none !important; }

.modalMask {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, .72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.modalBox {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .55);
}

.modalTitle {
  font-size: 15px;
  font-weight: 700;
  color: var(--txt);
  letter-spacing: .3px;
}

.modalDesc {
  font-size: 11.5px;
  color: var(--dim);
  margin-top: 6px;
  line-height: 1.6;
}

.keyInput {
  width: 100%;
  box-sizing: border-box;
  margin-top: 14px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--txt);
  padding: 11px 12px;
  font-family: Consolas, ui-monospace, monospace;
  font-size: 12.5px;
  letter-spacing: .2px;
  outline: none;
}
.keyInput:focus { border-color: #3d3559; background: #1a1f2c; }
.keyInput::placeholder { color: #4a5163; letter-spacing: .5px; }

.keyMsg {
  font-size: 11.5px;
  min-height: 17px;
  margin-top: 9px;
  line-height: 1.5;
  word-break: break-word;
}
.keyMsg.ok  { color: var(--ok); }
.keyMsg.err { color: var(--err); }
.keyMsg.run { color: var(--warn); }

.modalBtns {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 16px;
}
.modalBtns button { min-width: 88px; }

/* 手机端弹窗：撑满宽度更好点 */
@media (max-width: 760px) {
  .modalBox { max-width: 100%; padding: 16px; }
  .modalBtns button { flex: 1; min-width: 0; }
}
