/* ============================================================
   Spine 动画预览器 — 深色工具风
   ============================================================ */

:root {
  --bg: #16181d;
  --bg-panel: #1c1f26;
  --bg-panel-2: #22262e;
  --bg-input: #12141a;
  --bg-hover: #2a2f39;
  --bg-active: #2f3b52;
  --border: #2c313b;
  --border-strong: #3a4150;
  --text: #d7dbe3;
  --text-dim: #8b93a3;
  --text-faint: #626a7a;
  --accent: #4c8dff;
  --accent-dim: #2f5da8;
  --ok: #3ecf8e;
  --warn: #e2b341;
  --err: #ef5f6b;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

/* author 样式的 display 会覆盖 UA 的 [hidden]，这里统一压制 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
}

code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--bg-input);
  border-radius: 3px;
  padding: 1px 4px;
}

.mono {
  font-family: var(--mono);
  font-size: 11.5px;
}
.dim {
  color: var(--text-dim);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ------------------------------------------------------- 顶栏 */

#topbar {
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.brand-ver {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0 6px;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 9px;
  max-width: 320px;
}
.chip-label {
  color: var(--text-faint);
  font-size: 11px;
}
.chip-value {
  color: var(--text);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------- 按钮/表单 */

.btn {
  background: var(--bg-panel-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px 11px;
  cursor: pointer;
  font-size: 12.5px;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover {
  background: var(--bg-hover);
  border-color: #4a5265;
}
.btn:active {
  background: var(--bg-active);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-sm {
  padding: 3px 8px;
  font-size: 12px;
}
.btn-icon {
  padding: 5px 9px;
  font-weight: 700;
}
.btn.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}
.btn.recording {
  background: #6b2029;
  border-color: var(--err);
  color: #ffd7db;
}

input[type="text"],
input[type="search"],
select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px 8px;
  font-size: 12.5px;
  font-family: inherit;
  width: 100%;
  outline: none;
}
input[type="text"]:focus,
input[type="search"]:focus,
select:focus {
  border-color: var(--accent);
}

input[type="color"] {
  width: 30px;
  height: 26px;
  padding: 1px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  flex: 0 0 auto;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0d0f13;
}
input[type="range"]:disabled::-webkit-slider-thumb {
  background: var(--text-faint);
}

.mini-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.mini-check input {
  accent-color: var(--accent);
  margin: 0;
}
.mini-label {
  font-size: 12px;
  color: var(--text-dim);
  flex: 0 0 auto;
  white-space: nowrap;
}

/* ------------------------------------------------------- 主体三栏 */

main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.panel {
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
#left {
  flex: 0 0 296px;
  border-right: 1px solid var(--border);
}
#right {
  flex: 0 0 312px;
  border-left: 1px solid var(--border);
}

/* 滚动条 */
.panel::-webkit-scrollbar,
.list::-webkit-scrollbar,
.slot-list::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
.panel::-webkit-scrollbar-thumb,
.list::-webkit-scrollbar-thumb,
.slot-list::-webkit-scrollbar-thumb {
  background: #333a47;
  border-radius: 5px;
  border: 2px solid var(--bg-panel);
}

/* ------------------------------------------------------- 左栏 */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel-2);
  position: sticky;
  top: 0;
  z-index: 2;
}
.tab {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 9px 4px;
  cursor: pointer;
  font-size: 12.5px;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: #fff;
  border-bottom-color: var(--accent);
}

.tab-pane {
  display: none;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px;
  gap: 8px;
}
.tab-pane.active {
  display: flex;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row-between {
  justify-content: space-between;
}
.row-play {
  gap: 6px;
}

.list-meta {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--mono);
  margin-left: auto;
}

.list {
  flex: 1 1 auto;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  min-height: 120px;
  outline: none;
}

.item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  cursor: pointer;
  border-bottom: 1px solid #1e222a;
  font-size: 12.5px;
}
.item:hover {
  background: var(--bg-hover);
}
.item.active {
  background: var(--bg-active);
}
.item.active .item-name {
  color: #fff;
}

.item-thumb {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  background: #0e1015 center/contain no-repeat;
  border: 1px solid var(--border);
}
.item-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 14px;
}

.item-body {
  min-width: 0;
  flex: 1 1 auto;
}
.item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-sub {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--mono);
}
.item-tags {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}
.tag {
  font-size: 10px;
  padding: 0 5px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  line-height: 15px;
}
.tag.frames {
  color: var(--ok);
  border-color: #2c5c46;
}
.tag.multipage {
  color: var(--warn);
  border-color: #5c4c2c;
}

.group-head {
  position: sticky;
  top: 0;
  background: var(--bg-panel-2);
  color: var(--text-dim);
  font-size: 11px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

.browse-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.browse-path {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
}
.icon-dir {
  color: var(--warn);
}
.icon-file {
  color: var(--text-faint);
}

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: 10px;
  padding: 20px 14px;
  text-align: center;
  background: var(--bg-input);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.hot {
  border-color: var(--accent);
  background: #1a2436;
}
.dropzone-icon {
  font-size: 26px;
  color: var(--text-faint);
  line-height: 1;
  margin-bottom: 8px;
}
.dropzone-title {
  font-size: 13.5px;
  margin-bottom: 6px;
}
.dropzone-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-bottom: 12px;
  line-height: 1.6;
}
.dropzone-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.hint {
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.6;
}
.import-result {
  font-size: 11.5px;
  color: var(--text-dim);
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ------------------------------------------------------- 中间画布 */

#center {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

#stage-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#checker {
  position: absolute;
  inset: 0;
  background-color: #4a4f59;
  background-image: linear-gradient(45deg, #3c414a 25%, transparent 25%),
    linear-gradient(-45deg, #3c414a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #3c414a 75%),
    linear-gradient(-45deg, transparent 75%, #3c414a 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#stage.panning {
  cursor: grabbing;
}

.hud {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(12, 14, 18, 0.78);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 9px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  pointer-events: none;
  backdrop-filter: blur(3px);
}
#hud-left {
  left: 10px;
  top: 10px;
}
#hud-right {
  right: 10px;
  top: 10px;
}
.hud .sep {
  width: 1px;
  height: 11px;
  background: var(--border-strong);
}
#hud-name {
  color: var(--text);
}

#stage-toolbar {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(12, 14, 18, 0.82);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 6px;
  backdrop-filter: blur(3px);
}
.toolbar-divider {
  width: 1px;
  height: 16px;
  background: var(--border-strong);
  margin: 0 2px;
}

#empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
  text-align: center;
}
.empty-title {
  font-size: 15px;
  color: var(--text-dim);
}
.empty-sub {
  font-size: 12.5px;
  color: var(--text-faint);
}

#drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(28, 44, 76, 0.72);
  border: 2px dashed var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.drop-overlay-inner {
  font-size: 16px;
  color: #fff;
}

/* ------------------------------------------------------- 右栏 */

.section {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  text-transform: none;
}
.section-head > span:first-child {
  color: var(--text);
  font-weight: 600;
}
.section-head .mini-check {
  margin-left: auto;
}
.badge {
  font-family: var(--mono);
  font-size: 10.5px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0 6px;
  color: var(--text-faint);
  margin-left: auto;
}

.anim-list {
  max-height: 208px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
}
.anim-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12.5px;
  border-bottom: 1px solid #1e222a;
}
.anim-item:hover {
  background: var(--bg-hover);
}
.anim-item.active {
  background: var(--bg-active);
  color: #fff;
}
.anim-item .dur {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
}
.anim-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.anim-item .tl {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
}

.debug-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
}
.debug-grid label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
}
.debug-grid input {
  accent-color: var(--accent);
  margin: 0;
}

.slot-list {
  max-height: 190px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  padding: 4px 6px;
}
.slot-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 0;
}
.slot-row input {
  accent-color: var(--accent);
  margin: 0;
}
.slot-row .slot-idx {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  min-width: 24px;
}
.slot-row .slot-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  font-size: 12px;
}
.info-grid dt {
  color: var(--text-faint);
  white-space: nowrap;
}
.info-grid dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warn-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.warn-item {
  font-size: 11.5px;
  border-left: 2px solid var(--warn);
  background: #2a2519;
  color: #e8d9a8;
  padding: 4px 7px;
  border-radius: 0 4px 4px 0;
  word-break: break-word;
}
.warn-item.error {
  border-color: var(--err);
  background: #2c1a1d;
  color: #f5c0c5;
}

/* ------------------------------------------------------- 提示与加载 */

#toast-host {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
  max-width: 420px;
}
.toast {
  background: #232833;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12.5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease-out;
  word-break: break-word;
}
.toast-error {
  border-left-color: var(--err);
}
.toast-ok {
  border-left-color: var(--ok);
}
.toast-warn {
  border-left-color: var(--warn);
}
.toast.out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s, transform 0.25s;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

#loading {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.62);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 90;
  font-size: 13px;
  color: var(--text);
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #333a47;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------- 帮助弹层 */

#help-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 110;
  padding: 24px;
}
.modal-inner {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 20px 24px;
  max-width: 620px;
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.modal-inner h3 {
  margin: 0 0 12px;
  font-size: 16px;
}
.modal-inner h4 {
  margin: 18px 0 7px;
  font-size: 13px;
  color: var(--accent);
}
.modal-inner ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-dim);
  line-height: 1.75;
  font-size: 12.5px;
}
.modal-inner p {
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.7;
}
table.keys {
  border-collapse: collapse;
  font-size: 12.5px;
}
table.keys td {
  padding: 3px 12px 3px 0;
  color: var(--text-dim);
}
table.keys td:first-child {
  white-space: nowrap;
}
.modal-inner .btn {
  margin-top: 18px;
}

/* 舞台模式下画布上的选中框 */
.actor-outline {
  position: absolute;
  border: 1.5px dashed var(--accent);
  pointer-events: none;
  border-radius: 3px;
}

/* ------------------------------------------------------- 自检报告 */

#selftest {
  position: fixed;
  inset: 0;
  background: #12141a;
  z-index: 200;
  overflow-y: auto;
  padding: 24px 28px;
  font: 13px/1.6 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}
#selftest h2 {
  margin: 0 0 6px;
  font-size: 18px;
}
#selftest .st-summary {
  display: flex;
  gap: 22px;
  margin: 14px 0 18px;
  flex-wrap: wrap;
}
#selftest .st-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  min-width: 108px;
}
#selftest .st-card b {
  display: block;
  font-size: 22px;
  font-family: var(--mono);
}
#selftest .st-card span {
  color: var(--text-faint);
  font-size: 11.5px;
}
#selftest table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
#selftest th,
#selftest td {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
#selftest th {
  color: var(--text-faint);
  font-weight: 500;
  position: sticky;
  top: 0;
  background: #12141a;
}
#selftest td.path {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  word-break: break-all;
}
#selftest td.err {
  color: #f5b0b6;
}
#selftest tr.ok td.status {
  color: var(--ok);
}
#selftest tr.fail td.status {
  color: var(--err);
}
#selftest .st-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
#selftest .st-progress {
  flex: 1 1 auto;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}
#selftest .st-progress i {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0%;
}

/* ==========================================================
   应用级菜单与工具视图（视频转帧表 / 帧表转Spine）
   ========================================================== */

.apps {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  margin-left: 10px;
}
.apps .app-btn {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  padding: 5px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12.5px;
  white-space: nowrap;
}
.apps .app-btn:hover {
  color: var(--text);
}
.apps .app-btn.active {
  background: var(--accent-dim);
  color: #fff;
}

/* 工具模式下隐藏预览器专属的顶栏元素 */
#topbar.tool-mode .pv-only {
  display: none !important;
}

/* 工具视图容器：与 main 互斥，占满剩余空间 */
.tool-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.tool-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 22px 60px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tool-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.tool-head h2 {
  margin: 0;
  font-size: 17px;
}
.tool-sub {
  font-size: 12px;
  color: var(--text-faint);
}

.tsection {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.ts-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.ts-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.ts-hint {
  font-size: 11.5px;
  color: var(--text-faint);
}

.trow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 6px 0;
}
.tlabel {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}
.tval {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}
.tval.dim {
  color: var(--text-faint);
}
.trow input[type='range'] {
  flex: 1 1 120px;
  min-width: 100px;
  max-width: 260px;
}
.num {
  width: 76px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 12.5px;
}
.num:disabled {
  opacity: 0.45;
}

.prog {
  flex: 1 1 160px;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}
.prog > i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.12s;
}

/* 棋盘格透明底（画布 / 预览图共用） */
.checker-bg {
  background-color: #4a4f59;
  background-image: linear-gradient(45deg, #3c414a 25%, transparent 25%),
    linear-gradient(-45deg, #3c414a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #3c414a 75%),
    linear-gradient(-45deg, transparent 75%, #3c414a 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* 视频预览 */
.video-preview {
  width: 320px;
  max-width: 100%;
  border-radius: 8px;
  background: #000;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.preview-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.clip-panel {
  flex: 1 1 320px;
  min-width: 260px;
}
.key-preview {
  flex: 1 1 55%;
  min-width: 300px;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  cursor: crosshair;
}
.color-swatch {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: transparent;
}

/* 帧网格 */
/* 帧网格：每行最多约 5 帧，格子更大更清晰 */
.frame-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.frame-cell {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #0e1015;
}
.frame-cell:hover {
  border-color: var(--border-strong);
}
/* 勾选保留用加宽亮色边框表达，帧多时也能一眼分辨 */
.frame-cell.sel {
  border-color: var(--accent);
  border-width: 3px;
  box-shadow: 0 0 0 1px rgba(76, 141, 255, 0.4);
}
.frame-thumb {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.frame-thumb img {
  max-width: 100%;
  max-height: 100%;
  image-rendering: auto;
}
.frame-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 11px;
  font-family: var(--mono);
  text-align: center;
  background: rgba(12, 14, 18, 0.78);
  color: var(--text-dim);
  padding: 2px 0;
}
/* 相似帧提示：只用序号底色，不动边框。绿=关键帧（建议保留），黄=冗余帧 */
.frame-label.dup {
  background: rgba(226, 179, 65, 0.92);
  color: #241b06;
  font-weight: 600;
}
.frame-label.key {
  background: rgba(62, 207, 142, 0.92);
  color: #06251a;
  font-weight: 600;
}
.sel-player {
  width: 420px;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  flex-shrink: 0;
}
.frame-star {
  position: absolute;
  top: 2px;
  left: 5px;
  color: var(--warn);
  font-size: 12px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.frame-pos {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--warn);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* 帧表成品预览 */
.sheet-preview {
  max-width: 100%;
  max-height: 300px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}

/* 帧表转Spine 动画组 */
.group-card {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--bg-panel-2);
  margin-bottom: 12px;
}
.gc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.gc-name {
  width: 180px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 12.5px;
}
.gc-remove {
  color: var(--err);
  margin-left: auto;
}
.dropzone-sm {
  padding: 12px;
}
.gc-frame-canvas {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  flex-shrink: 0;
}
.gc-ev-name {
  width: 160px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 12.5px;
}
.gc-ev-name:disabled,
.gc-ev-frame:disabled {
  opacity: 0.45;
}

/* 生成结果 */
.result-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.result-files-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 240px;
}
.result-file-row {
  margin: 0;
  justify-content: space-between;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 4px;
}
.result-png-col {
  flex: 1 1 320px;
  min-width: 280px;
  text-align: center;
}

/* 工具视图内收窄全局通栏输入框（覆盖上面 width:100%，同特异性靠后生效） */
.tool-view input[type="text"],
.tool-view select {
  width: auto;
  flex: 0 1 auto;
  max-width: 320px;
}

/* 相似帧检测图例：用与真实帧卡片相同的视觉语言做示意 */
.sim-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin: 10px 0 4px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.sim-legend .legend-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend-cell {
  position: relative;
  width: 46px;
  height: 46px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: #0e1015;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.legend-cell.sel {
  border-width: 3px;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(76, 141, 255, 0.4);
}
.legend-label {
  width: 100%;
  text-align: center;
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--text-dim);
  background: rgba(12, 14, 18, 0.78);
  padding: 2px 0;
}
.legend-label.key {
  background: rgba(62, 207, 142, 0.92);
  color: #06251a;
  font-weight: 600;
}
.legend-label.dup {
  background: rgba(226, 179, 65, 0.92);
  color: #241b06;
  font-weight: 600;
}
.legend-star {
  position: absolute;
  top: 1px;
  left: 4px;
  color: var(--warn);
  font-size: 11px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.legend-desc {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.4;
  max-width: 250px;
}

/* 批量队列面板 */
.queue-panel {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}
.queue-list {
  max-height: 180px;
  overflow-y: auto;
  margin: 6px 0;
}
.queue-row {
  margin: 2px 0;
  gap: 8px;
}
.queue-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
