/* ============================================================
   音频裁切（录音剪切 / 录音合并）—— 工具 106 专属样式
   ------------------------------------------------------------
   约定：
   - 所有类名以 at- 开头，避免与公共样式冲突（工具页会同时加载
     base/header/tools-grid/layui-embed/dark.css）；
   - 颜色优先用公共 CSS 变量（--card/--border/--text/--primary…），
     这样 body.dark 下自动跟随日/夜模式；确实需要写死的地方
     在文件末尾的 body.dark 段里补一份；
   - 不用 grid 的 gap（老浏览器兼容，项目里统一用 margin 兜底，见 compat-polyfills.js）。
   ============================================================ */

.at-tool {
  --at-blue: #1677ff;
  --at-blue-soft: rgba(22, 119, 255, .10);
  --at-radius: 12px;
  color: var(--text, #1d2129);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------------- 模式切换 ---------------- */
.at-modebar {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 14px -10px;
}
.at-mode {
  flex: 1 1 220px;
  min-width: 200px;
  margin: 0 0 10px 10px;
  padding: 12px 14px;
  text-align: left;
  border: 1px solid var(--border, #e5e6eb);
  border-radius: 10px;
  background: var(--card, #fff);
  color: var(--text, #1d2129);
  cursor: pointer;
  transition: border-color .18s, background .18s, box-shadow .18s;
  font-family: inherit;
}
.at-mode:hover { border-color: var(--at-blue); }
.at-mode.active {
  border-color: var(--at-blue);
  background: var(--at-blue-soft);
  box-shadow: 0 0 0 2px var(--at-blue-soft);
}
.at-mode-t {
  display: flex;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
}
.at-mode-t svg { flex: none; margin-right: 8px; }
.at-mode-s {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-3, #86909c);
  font-weight: 400;
}

/* ---------------- 上传区 ---------------- */
.at-drop {
  border: 2px dashed var(--border-2, #d9d9d9);
  border-radius: var(--at-radius);
  background: var(--bg-2, #f7f8fa);
  padding: 34px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s;
}
.at-drop:hover,
.at-drop.dragover {
  border-color: var(--at-blue);
  background: var(--at-blue-soft);
}
.at-drop-icon { color: var(--at-blue); margin-bottom: 10px; }
.at-drop-t { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.at-drop-link { color: var(--at-blue); text-decoration: underline; }
.at-drop-h {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-3, #86909c);
  line-height: 1.7;
}

/* ---------------- 工作区 ---------------- */
.at-work { margin-top: 16px; }
.at-panel {
  border: 1px solid var(--border, #e5e6eb);
  border-radius: var(--at-radius);
  background: var(--card, #fff);
  margin-bottom: 14px;
  overflow: hidden;
}
.at-panel-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, #e5e6eb);
  background: var(--bg-2, #fafafa);
}
.at-panel-t { font-size: 14px; font-weight: 600; }
.at-panel-a { display: flex; flex-wrap: wrap; margin-left: -8px; }
.at-panel-a .at-btn { margin-left: 8px; }
.at-panel-b { padding: 14px; }

/* ---------------- 按钮 ---------------- */
.at-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border, #e5e6eb);
  border-radius: 8px;
  background: var(--card, #fff);
  color: var(--text, #1d2129);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  text-decoration: none;
  white-space: nowrap;
}
.at-btn:hover:not(:disabled) { border-color: var(--at-blue); color: var(--at-blue); }
.at-btn:disabled { opacity: .5; cursor: not-allowed; }
.at-btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.at-btn-primary {
  background: var(--at-blue);
  border-color: var(--at-blue);
  color: #fff;
  font-weight: 600;
}
.at-btn-primary:hover:not(:disabled) { background: #0e5fd8; border-color: #0e5fd8; color: #fff; }
.at-btn-ghost { background: transparent; }
.at-btn-danger:hover:not(:disabled) { border-color: #f5222d; color: #f5222d; }

/* ---------------- 文件列表 ---------------- */
.at-list { list-style: none; margin: 0; padding: 0; }
.at-row {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border, #f0f1f3);
  cursor: pointer;
  transition: background .15s;
}
.at-row:last-child { border-bottom: none; }
.at-row:hover { background: var(--bg-2, #f7f8fa); }
.at-row.active { background: var(--at-blue-soft); }
.at-row-idx {
  flex: none;
  width: 22px;
  height: 22px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--bg-3, #f0f1f3);
  color: var(--text-2, #4e5969);
  font-size: 12px;
  line-height: 22px;
  text-align: center;
  font-weight: 600;
}
.at-row.active .at-row-idx { background: var(--at-blue); color: #fff; }
.at-row-main { flex: 1; min-width: 0; }
.at-row-name {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.at-row-meta {
  font-size: 12px;
  color: var(--text-3, #86909c);
  margin-top: 1px;
}
.at-row-meta b { color: var(--at-blue); font-weight: 600; }
.at-row-ops { flex: none; display: flex; margin-left: 8px; }
.at-row-ops button {
  width: 26px;
  height: 26px;
  margin-left: 2px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3, #86909c);
  cursor: pointer;
  line-height: 26px;
  text-align: center;
  font-size: 15px;
  font-family: inherit;
}
.at-row-ops button:hover { background: var(--bg-3, #eef0f3); color: var(--at-blue); }
.at-row-ops button.at-op-del:hover { color: #f5222d; }
.at-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--at-blue-soft);
  color: var(--at-blue);
  font-size: 11px;
  line-height: 16px;
  vertical-align: 1px;
}
.at-list-tip {
  margin: 0;
  padding: 8px 14px 10px;
  font-size: 12px;
  color: var(--text-3, #86909c);
  border-top: 1px dashed var(--border, #e5e6eb);
}

/* ---------------- 波形 / 选区 ---------------- */
.at-editor-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.at-editor-name {
  font-size: 13.5px;
  font-weight: 600;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.at-editor-time { font-size: 12.5px; color: var(--text-3, #86909c); }

.at-wave {
  position: relative;
  height: 74px;
  border-radius: 8px;
  border: 1px solid var(--border, #e5e6eb);
  background:
    linear-gradient(180deg, rgba(22, 119, 255, .06), rgba(22, 119, 255, .02));
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.at-wave canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.at-sel {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(22, 119, 255, .16);
  border-left: 1px solid rgba(22, 119, 255, .55);
  border-right: 1px solid rgba(22, 119, 255, .55);
  pointer-events: none;
}
.at-handle {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 34px;
  margin-top: -17px;
  margin-left: -6px;
  border-radius: 6px;
  background: var(--at-blue);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  cursor: ew-resize;
  z-index: 3;
}
.at-handle::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 7px;
  width: 2px;
  height: 16px;
  background: rgba(255, 255, 255, .85);
  border-radius: 1px;
}
.at-head {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #f5222d;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.at-wave.playing .at-head { opacity: .85; }
.at-wave-loading::before {
  content: '正在解析波形…';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: var(--text-3, #86909c);
  z-index: 4;
}

.at-times {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  margin: 10px 0 0 -10px;
}
.at-time-field { margin: 0 0 8px 10px; }
.at-time-field > span {
  display: block;
  font-size: 12px;
  color: var(--text-2, #4e5969);
  margin-bottom: 3px;
}
.at-input {
  height: 32px;
  width: 118px;
  padding: 0 9px;
  border: 1px solid var(--border, #e5e6eb);
  border-radius: 8px;
  background: var(--bg-input, #fff);
  color: var(--text, #1d2129);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.at-input:focus { border-color: var(--at-blue); }
.at-input-w { width: 100%; }
.at-time-btns { display: flex; margin: 0 0 8px 10px; }
.at-time-btns .at-btn { margin-right: 8px; }

.at-sel-tip {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-3, #86909c);
}
.at-sel-tip b { color: var(--at-blue); font-weight: 600; }

/* ---------------- 输出设置 ---------------- */
.at-out-grid {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 4px -12px;
}
.at-field {
  flex: 1 1 200px;
  min-width: 180px;
  margin: 0 0 12px 12px;
}
.at-field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2, #4e5969);
  margin-bottom: 4px;
}
.at-select {
  width: 100%;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border, #e5e6eb);
  border-radius: 8px;
  background: var(--bg-input, #fff);
  color: var(--text, #1d2129);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.at-select:focus { border-color: var(--at-blue); }
.at-hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--text-3, #86909c);
  line-height: 1.7;
}
.at-run {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.at-run .at-btn { margin-right: 10px; }
.at-run-tip { font-size: 12.5px; color: var(--text-3, #86909c); }

.at-progress-wrap { margin-top: 12px; }
.at-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--bg-3, #eef0f3);
  overflow: hidden;
}
.at-bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #1677ff, #52c41a);
  transition: width .25s;
}
.at-log {
  margin-top: 8px;
  max-height: 112px;
  overflow: auto;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-code, #f7f8fa);
  border: 1px solid var(--border, #eef0f3);
  font-family: Consolas, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-3, #86909c);
  word-break: break-all;
}
.at-log:empty { display: none; }
.at-log .err { color: #f5222d; }

.at-result {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(82, 196, 26, .45);
  border-radius: 10px;
  background: rgba(82, 196, 26, .07);
}
.at-result-ico { color: #52c41a; margin-right: 10px; flex: none; }
.at-result-text { flex: 1; min-width: 200px; font-size: 13px; }
.at-result-text b { font-weight: 600; }
.at-result .at-btn { margin-left: 10px; }

.at-foot {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--text-3, #86909c);
  text-align: center;
  line-height: 1.8;
}

/* ---------------- 暗色补充（变量没覆盖到的写死颜色） ---------------- */
body.dark .at-mode,
body.dark .at-panel,
body.dark .at-btn,
body.dark .at-drop { border-color: #334155; }
body.dark .at-row { border-bottom-color: #263449; }
body.dark .at-row-idx { background: #2a3a4f; color: #94a3b8; }
body.dark .at-panel-h { background: rgba(255, 255, 255, .03); }
body.dark .at-wave {
  border-color: #334155;
  background: linear-gradient(180deg, rgba(96, 165, 250, .10), rgba(96, 165, 250, .03));
}
body.dark .at-handle { border-color: #0f172a; }
body.dark .at-log { background: #0f172a; border-color: #263449; }
body.dark .at-bar { background: #2a3a4f; }
body.dark .at-result {
  border-color: rgba(74, 222, 128, .35);
  background: rgba(74, 222, 128, .08);
}

/* ---------------- 小屏 ---------------- */
@media screen and (max-width: 760px) {
  .at-mode { flex: 1 1 100%; min-width: 0; }
  .at-field { flex: 1 1 100%; min-width: 0; }
  .at-input { width: 100px; }
  .at-row-name { font-size: 13px; }
  .at-wave { height: 64px; }
}
