/* Video, audio and utility workspaces share the original app.css tokens. */
.creative-root { display: flex; flex: 1; min-height: 0; }
.creative-workspace { flex: 1; display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); width: 100%; min-height: 0; padding: 16px 24px 20px; gap: 20px; }
.creative-panel { display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--line-hairline); border-radius: var(--r-lg); background: var(--bg-surface); box-shadow: none; }
.creative-form { display: flex; min-height: 100%; flex-direction: column; }
.creative-form-heading { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 20px 20px 14px; }
.creative-tool-nav { display: flex; align-items: center; gap: 6px; min-width: 0; }
.creative-tool-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.creative-switch-btn { height: 28px; padding: 0 8px; font-size: var(--fs-xs); color: var(--fg-2); border-radius: var(--r-full); }
.creative-tool-cost { margin-left: auto; flex: none; }
.creative-form-heading h2, .creative-results-heading h2 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.creative-form-heading p { color: var(--fg-2); font-size: var(--fs-sm); margin-top: 2px; line-height: var(--lh-snug); }
.creative-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 112px;
  padding: 18px 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-2);
  text-align: center;
  transition: border-color var(--dur), background var(--dur), color var(--dur);
}
.creative-upload .i { width: 22px; height: 22px; color: var(--fg-3); margin-bottom: 2px; }
.creative-upload strong { font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--fg); }
.creative-upload span { font-size: var(--fs-xs); color: var(--fg-3); }
.creative-upload:hover, .creative-upload.is-dragover {
  border-color: var(--accent);
  background: var(--accent-weak);
  color: var(--accent);
}
.creative-upload:hover .i, .creative-upload.is-dragover .i { color: var(--accent); }
.creative-icon { width: 36px; height: 36px; display: grid; flex: 0 0 auto; place-items: center; color: var(--fg-2); background: var(--bg-muted); border-radius: var(--r-sm); }
.creative-icon .i { width: 18px; height: 18px; }
#creativeFields { padding: 0 20px 16px; }
.creative-field-grid, .creative-source-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.creative-source-grid { margin: 0 0 16px; }
.creative-source:only-child, .creative-wide, .creative-check { grid-column: 1 / -1; }
.creative-field, .creative-source { display: grid; align-content: start; gap: 6px; min-width: 0; }
.creative-field:has(.creative-segment) { margin-bottom: 16px; }
.creative-field label, .creative-field-label, .creative-source-title { color: var(--fg); font-size: var(--fs-sm); font-weight: var(--fw-semibold); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.creative-field small, .creative-mask-block small { color: var(--fg-2); font-size: var(--fs-xs); }
.creative-segment { width: 100%; min-width: 0; }
.creative-segment > button { flex: 1; min-width: 0; padding-inline: 5px; font-size: var(--fs-xs); white-space: nowrap; }
.creative-field select, .creative-field textarea, .creative-results-heading select, .creative-search input {
  width: 100%;
  min-width: 0;
  background: var(--bg-subtle);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--fg);
  font: inherit;
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur);
}
.creative-field select:focus, .creative-field textarea:focus, .creative-results-heading select:focus, .creative-search input:focus {
  background: var(--bg-elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.creative-field select, .creative-results-heading select { min-height: 36px; padding: 0 8px; font-size: var(--fs-sm); }
.creative-field textarea { min-height: 76px; padding: 9px 10px; resize: vertical; font-size: var(--fs-sm); line-height: var(--lh-normal); }
.creative-field textarea::placeholder, .creative-search input::placeholder { color: var(--fg-3); }
.creative-field [aria-invalid="true"], .creative-drop[aria-invalid="true"] { border-color: var(--danger); }
.creative-check { display: flex; gap: 8px; align-items: start; color: var(--fg-2); font-size: var(--fs-sm); cursor: pointer; }
.creative-check input { margin-top: 3px; accent-color: var(--accent); }
.creative-slider { min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--fg-2); font-size: var(--fs-xs); }
.creative-slider input { flex: 1; min-width: 40px; accent-color: var(--accent); }
.creative-slider output { white-space: nowrap; font-variant-numeric: tabular-nums; }
.creative-source-title { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.creative-source-title .muted { font-weight: var(--fw-regular); }
.creative-drop { display: flex; width: 100%; min-height: 78px; gap: 8px; align-items: center; justify-content: center; padding: 8px; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); background: var(--bg-subtle); color: var(--fg-2); text-align: left; font-size: var(--fs-sm); }
.creative-drop .i { flex: 0 0 auto; width: 17px; height: 17px; }
.creative-drop small { display: block; font-size: var(--fs-xs); color: var(--fg-3); }
.creative-drop.has-files { min-height: 46px; }
.creative-drop.has-files small { display: none; }
.creative-drop:hover, .creative-drop.is-dragover { background: var(--accent-weak); color: var(--accent); border-color: var(--accent); }
.creative-file-list { display: grid; gap: 5px; list-style: none; margin: 0; padding: 0; }
.creative-file-list li { display: flex; align-items: center; gap: 7px; padding: 5px 5px 5px 8px; border: 0; background: var(--bg-subtle); border-radius: var(--r-xs); font-size: var(--fs-xs); }
.creative-file-list img { width: 28px; height: 26px; object-fit: cover; border-radius: 4px; }
.creative-file-list li > span { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.creative-file-list .i { flex: 0 0 auto; width: 14px; height: 14px; }

/* Color swatches, voice cards, expand anchor preview */
.creative-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.creative-swatch {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 11px 0 8px;
  border: 0; border-radius: var(--r-sm); background: var(--bg-subtle);
  font-size: var(--fs-xs); color: var(--fg-2); transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.creative-swatch:hover { background: var(--bg-active); color: var(--fg); }
.creative-swatch[aria-pressed="true"] { background: var(--accent-weak); color: var(--accent-text); font-weight: var(--fw-semibold); box-shadow: inset 0 0 0 1.5px var(--accent); }
.creative-swatch-dot { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line-hairline); flex: none; }
.creative-swatch-dot[data-bg="transparent"] { background-color: #fff; background-image: repeating-conic-gradient(#d5d5d8 0% 25%, transparent 0% 50%); background-size: 8px 8px; }
.creative-swatch-dot[data-bg="white"] { background: #ffffff; }
.creative-swatch-dot[data-bg="black"] { background: #151517; }
.creative-swatch-dot[data-bg="blue"] { background: #2d78c9; }
.creative-swatch-dot[data-bg="red"] { background: #ce4545; }

.creative-voices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.creative-voice-card {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; text-align: left;
  border: 0; border-radius: var(--r-sm); background: var(--bg-subtle); transition: background var(--dur), box-shadow var(--dur);
}
.creative-voice-card:hover { background: var(--bg-active); }
.creative-voice-card[aria-pressed="true"] { background: var(--accent-weak); box-shadow: inset 0 0 0 1.5px var(--accent); }
.creative-voice-info { flex: 1; min-width: 0; }
.creative-voice-info strong { display: block; font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--fg); }
.creative-voice-info small { display: block; font-size: var(--fs-xs); color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.creative-voice-audition { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line-hairline); background: var(--bg-surface); box-shadow: none; color: var(--fg-2); display: grid; place-items: center; flex: none; }
.creative-voice-audition:hover { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-weak); }
.creative-voice-audition .i { width: 12px; height: 12px; }

.creative-expand-preview {
  display: grid; place-items: center; padding: 12px; border: 0; border-radius: var(--r-sm);
  background: var(--bg-subtle);
}
.creative-expand-frame {
  position: relative; max-width: 100%; max-height: 112px; width: 150px;
  border: 1.5px dashed var(--accent); border-radius: 6px; background: var(--accent-weak);
  display: grid; padding: 6px;
}
.creative-expand-inner {
  width: 58%; height: 58%; border-radius: 4px; background: var(--bg-surface);
  border: 1px solid var(--line-hairline); box-shadow: none;
  display: grid; place-items: center; font-size: var(--fs-2xs); color: var(--fg-2); font-weight: var(--fw-semibold);
}
.creative-expand-frame[data-anchor="center"] { place-items: center; }
.creative-expand-frame[data-anchor="left"] { place-items: center start; }
.creative-expand-frame[data-anchor="right"] { place-items: center end; }
.creative-expand-frame[data-anchor="top"] { place-items: start center; }
.creative-expand-frame[data-anchor="bottom"] { place-items: end center; }

/* Mask editor */
.creative-mask-block { display: grid; gap: 6px; margin-bottom: 14px; }
.creative-mask-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.creative-mask { position: relative; max-height: 196px; aspect-ratio: 16/9; background: var(--bg-muted); border: 0; border-radius: var(--r-sm); overflow: hidden; touch-action: none; cursor: crosshair; }
.creative-mask img, .creative-mask svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.creative-mask img { object-fit: cover; }
.creative-mask svg { fill: var(--accent); opacity: .65; }
.creative-feedback { margin: 0 24px 14px; padding: 8px 10px; border-radius: var(--r-xs); background: var(--bg-subtle); color: var(--fg-2); font-size: var(--fs-xs); }
.creative-submit { display: flex; position: sticky; z-index: 1; bottom: 0; gap: 10px; align-items: center; justify-content: space-between; margin-top: auto; padding: 14px 20px max(14px, env(safe-area-inset-bottom)); background: var(--bg-surface); border-top: 1px solid var(--line-hairline); }
.creative-submit strong, .creative-submit small { display: block; font-variant-numeric: tabular-nums; }
.creative-submit small { color: var(--fg-2); font-size: var(--fs-xs); }
.creative-submit .btn { flex-shrink: 0; }
.creative-results { display: flex; min-height: 0; min-width: 0; flex-direction: column; background: var(--bg-canvas); padding-top: 44px; }
.creative-results-heading { display: flex; height: 42px; justify-content: space-between; gap: 8px; align-items: center; padding: 0 4px; border-bottom: 1px solid var(--line-hairline); background: transparent; }
.creative-results-heading > div { display: flex; align-items: baseline; gap: 9px; }
.creative-results-heading .muted { font-size: var(--fs-xs); }
.creative-result-body { flex: 1; min-height: 0; padding: 16px 4px 48px; }
.creative-welcome, .creative-empty { text-align: center; padding: 44px 14px 25px; }
.creative-welcome h3, .creative-empty h3 { font-size: var(--fs-2xl); letter-spacing: var(--ls-tight); }
.creative-welcome p, .creative-empty p { margin-top: 5px; color: var(--fg-2); font-size: var(--fs-sm); }
.creative-empty-icon { display: grid; width: 50px; height: 50px; place-items: center; margin: 0 auto 14px; border: 1px solid var(--line-hairline); border-radius: 15px; background: var(--bg-surface); box-shadow: none; color: var(--accent-text); }
.creative-empty-icon .i { width: 24px; height: 24px; }

/* Custom interactive waveform audio player */
.creative-wave { display: flex; height: 42px; min-width: 0; gap: 2px; align-items: center; color: var(--accent); }
.creative-wave i { flex: 1; height: var(--bar); max-width: 6px; border-radius: 3px; background: currentColor; opacity: .58; }
.creative-audio { display: grid; gap: 10px; margin-top: 10px; padding: 12px 14px; border: 0; border-radius: var(--r-md); background: var(--bg-subtle); }
.creative-audio-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: var(--fs-sm); flex-wrap: wrap; }
.creative-audio-label > span { display: flex; gap: 6px; align-items: center; font-weight: var(--fw-semibold); }
.creative-audio-meta { display: flex; align-items: center; gap: 6px; color: var(--fg-2); font-size: var(--fs-xs); }
.creative-audio-player { display: flex; align-items: center; gap: 10px; min-width: 0; }
.creative-play-btn {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--accent-grad); color: #ffffff; box-shadow: none; transition: background var(--dur), transform .12s;
}
.creative-play-btn:hover { background: var(--accent-grad-hover); }
.creative-play-btn:active { transform: scale(.95); }
.creative-play-btn .i { width: 15px; height: 15px; }
.creative-wave-track {
  flex: 1; min-width: 0; height: 38px; display: flex; align-items: center; gap: 2px;
  cursor: pointer; padding: 4px 0; user-select: none;
}
.creative-wave-track i {
  flex: 1; height: var(--bar); min-width: 2px; border-radius: 2px;
  background: var(--line-strong); transition: background var(--dur-instant);
}
.creative-wave-track i.is-played { background: var(--accent); }
.creative-audio-time { font-size: var(--fs-2xs); color: var(--fg-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.creative-audio-controls { display: flex; align-items: center; gap: 4px; flex: none; }
.creative-audio audio { display: none; }
.creative-audio-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 7px; }
.creative-stem-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--bg-subtle); border: 0; }
.creative-stem-mix { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.creative-stem-mix .chip { height: 28px; padding: 0 9px; font-size: var(--fs-2xs); }
.creative-stem-vol { width: 72px; accent-color: var(--accent); }

/* Result task card & comparison */
.creative-task { max-width: 900px; margin: 0 auto 14px; padding: 18px; border: 1px solid var(--line-hairline); border-radius: var(--r-lg); background: var(--bg-surface); box-shadow: none; }
.creative-task-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; margin-bottom: 12px; }
.creative-task-head > div { min-width: 0; overflow-wrap: anywhere; }
.creative-task-head h3 { font-size: var(--fs-md); }
.creative-task-head p, .creative-task-note { margin-top: 4px; color: var(--fg-2); font-size: var(--fs-xs); }
.creative-task-actions, .creative-media-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.creative-media-foot { justify-content: space-between; }
.creative-media-foot small { color: var(--fg-2); font-size: var(--fs-xs); }
.creative-progress { height: 7px; margin: 9px 0; overflow: hidden; border-radius: 20px; background: var(--bg-muted); }
.creative-progress span { display: block; width: var(--progress); height: 100%; border-radius: inherit; background: var(--accent); transition: width var(--dur-base) linear; }

.creative-view-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.creative-view-bar .seg > button { height: 28px; padding: 0 10px; font-size: var(--fs-xs); }
.creative-image-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.creative-image-pair figure { min-width: 0; margin: 0; }
.creative-image-stage { position: relative; display: grid; height: clamp(130px, 24vw, 280px); place-items: center; overflow: hidden; background: var(--bg-muted); border: 1px solid var(--line); border-radius: var(--r-sm); }
.creative-image-stage img, .creative-image-stage svg { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.creative-image-pair figcaption { margin-top: 5px; color: var(--fg-2); font-size: var(--fs-xs); }

.creative-compare-wrap { max-width: 560px; }
.creative-compare-wrap .compare { aspect-ratio: 4 / 3; border: 1px solid var(--line); }
.creative-compare-wrap .compare img { object-fit: contain; }
.creative-compare-wrap .compare .before { filter: none; }
.creative-compare-wrap .compare[data-tool="restore"] .before { filter: sepia(.55) contrast(.88) brightness(.9); }
.creative-compare-wrap .compare[data-tool="denoise"] .before { filter: contrast(.92) saturate(.9) blur(.4px); }
.creative-compare-wrap .compare[data-tool="upscale"] .before { filter: blur(.7px); }
.creative-compare-wrap .compare[data-tool="erase"] .before { filter: brightness(.95); }
.creative-compare-wrap .compare[data-tool="cutout"] .after-stage { background-color: var(--bg); }

.creative-image-result[data-result-bg="transparent"] { background-color: var(--bg); background-image: repeating-conic-gradient(var(--bg-muted) 0% 25%, transparent 0% 50%); background-size: 16px 16px; }
.creative-image-result[data-result-bg="white"] { background: #fff; }
.creative-image-result[data-result-bg="black"] { background: #151517; }
.creative-image-result[data-result-bg="blue"] { background: #2d78c9; }
.creative-image-result[data-result-bg="red"] { background: #ce4545; }
.creative-image-result[data-result-tool="denoise"] img { filter: contrast(1.07) saturate(1.12); }
.creative-image-result[data-result-tool="restore"] img { filter: contrast(1.05) saturate(1.18); }
.creative-image-result[data-result-tool="upscale"] img { transform: scale(1.13); }
.creative-image-result.is-wireframe svg * { fill: none !important; stroke: var(--fg) !important; stroke-width: 2px !important; }

/* Specialized tool sub-panels */
.creative-subpanel { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-subtle); display: grid; gap: 10px; }
.creative-subpanel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--fg); }
.creative-layer-list { display: grid; gap: 6px; }
.creative-layer-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-xs); background: var(--bg-elevated); border: 1px solid var(--line); font-size: var(--fs-xs); }
.creative-layer-thumb { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--line); overflow: hidden; background-image: repeating-conic-gradient(var(--bg-muted) 0% 25%, transparent 0% 50%); background-size: 8px 8px; flex: none; }
.creative-layer-thumb img { width: 100%; height: 100%; object-fit: cover; }
.creative-layer-row.is-hidden { opacity: .45; }
.creative-layer-info { flex: 1; min-width: 0; }
.creative-layer-info strong { display: block; font-size: var(--fs-xs); }
.creative-layer-info small { color: var(--fg-3); font-size: var(--fs-xs); }

.creative-translate-rows { display: grid; gap: 8px; }
.creative-translate-row { display: grid; grid-template-columns: 1fr 18px 1fr; align-items: center; gap: 8px; font-size: var(--fs-xs); }
.creative-translate-row input { min-height: 32px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: var(--r-xs); background: var(--bg); font-size: var(--fs-xs); }
.creative-translate-overlay { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; }
.creative-translate-overlay span { padding: 3px 8px; border-radius: 6px; background: rgba(20,20,24,.78); color: #fff; font-size: var(--fs-2xs); backdrop-filter: blur(4px); }

.creative-id-sheet { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); max-width: 420px; }
.creative-id-sheet img { width: 100%; aspect-ratio: 295 / 413; object-fit: cover; border-radius: 2px; padding: 3px; }
.creative-id-sheet[data-bg="blue"] img { background: #2d78c9; }
.creative-id-sheet[data-bg="red"] img { background: #ce4545; }
.creative-id-sheet[data-bg="white"] img { background: #f3f3f3; }

.creative-sample { display: flex; gap: 14px; max-width: none; margin: 12px 0 0; padding: 12px; align-items: center; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-elevated); }
.creative-sample > img, .creative-sample-audio { flex: 0 0 auto; width: 108px; height: 90px; border-radius: var(--r-sm); }
.creative-sample > img { object-fit: cover; }
.creative-sample-audio { display: grid; place-items: center; padding: 10px; overflow: hidden; background: var(--accent-weak); }
.creative-sample h3 { font-size: var(--fs-md); }
.creative-sample p { margin: 2px 0 7px; color: var(--fg-2); font-size: var(--fs-xs); }
.creative-back { width: 30px; height: 30px; margin-left: -4px; }
.creative-missing { margin: 54px auto; padding: 14px; text-align: center; }
.creative-missing p { margin: 8px 0 16px; color: var(--fg-2); }

/* Tool catalog — Jimeng-inspired clean card grid */
.creative-catalog-scroll { flex: 1; min-height: 0; }
.tools-catalog { position: relative; }
.tools-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 36px 72px;
}
.tools-hero-title {
  padding: 62px 0 34px;
  text-align: center;
  font-size: clamp(20px, 2.2vw, var(--fs-2xl));
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
  color: var(--fg);
}
.tools-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.tools-tab {
  height: 34px;
  padding: 0 16px;
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg-2);
  background: transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tools-tab:hover {
  color: var(--fg);
  background: var(--bg-hover);
}
.tools-tab[aria-pressed="true"] {
  background: var(--bg-active);
  color: var(--fg);
  font-weight: var(--fw-semibold);
}
[data-theme="dark"] .tools-tab[aria-pressed="true"] {
  background: var(--bg-active);
  color: var(--fg);
}
.tools-sections {
  display: flex;
  flex-direction: column;
  gap: 34px;
}
.tools-section-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--fg-2);
  margin-bottom: 14px;
}
.tools-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}
.tools-sections.is-filtered {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}
.tools-sections.is-filtered .tools-section,
.tools-sections.is-filtered .tools-grid {
  display: contents;
}
.tools-sections.is-filtered .tools-section-title {
  display: none;
}
.tools-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
  color: var(--fg);
  text-decoration: none;
  transition: transform var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.tools-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-card-hover);
}
[data-theme="dark"] .tools-card {
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
}
[data-theme="dark"] .tools-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-card-hover);
}
.tools-card-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-muted);
  overflow: hidden;
}
.tools-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease-out);
}
.tools-card:hover .tools-card-media img {
  transform: scale(1.04);
}
.tools-card-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--fg-inverse);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-wide);
}
.tools-card-badge.is-hot { background: var(--brand-hot); }
.tools-card-badge.is-free { background: var(--success); }
.tools-card-badge.is-new { background: var(--accent); }
[data-theme="dark"] .tools-card-badge.is-hot { background: color-mix(in srgb, var(--brand-hot) 84%, var(--bg-canvas)); }
[data-theme="dark"] .tools-card-badge.is-free { background: color-mix(in srgb, var(--success) 74%, var(--bg-canvas)); }
.tools-card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px 14px;
}
.tools-card-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tools-card-desc {
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Video and audio reuse the AI image feed and dock. */
.creative-studio { min-width: 0; }
.creative-studio .feed-inner { padding-bottom: var(--creative-dock-space, 200px); }
.creative-studio .dock { z-index: 20; }
.creative-studio .composer .textarea { max-height: 144px; resize: none; }
.creative-studio .composer-bar { position: relative; }
.creative-studio .composer-bar .chip { white-space: nowrap; }
.creative-composer-actions { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; }
.creative-studio .composer-refs { flex-wrap: nowrap; overflow-x: auto; padding-top: 12px; }
.creative-studio .composer-refs[hidden] { display: none; }
.creative-ref { display: inline-flex; flex: 0 0 auto; max-width: 180px; height: 36px; align-items: center; gap: 6px; padding: 3px 4px 3px 6px; border: 0; border-radius: var(--r-sm); background: var(--bg-subtle); font-size: var(--fs-xs); }
.creative-ref > img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; }
.creative-ref > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.creative-ref > .i { flex: 0 0 auto; width: 16px; height: 16px; }
.creative-ref .icon-btn { flex: 0 0 auto; }
.creative-studio .creative-feedback { margin: 0 16px 4px; }
.creative-studio .creative-sheet { position: static; }
.creative-studio .creative-sheet-panel { left: 12px; width: min(392px, calc(100% - 24px)); max-height: min(390px, 48dvh); padding: 14px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.creative-studio #creativeFields { padding: 8px 0 0; }
.creative-studio .creative-source-grid { margin: 0; }
.creative-studio .creative-choice-panel { min-width: 240px; }
#creativeHeader #creative-status-options { min-width: 150px; }
.creative-studio-task .task-prompt { padding: 0; text-align: start; overflow-wrap: anywhere; white-space: pre-wrap; }
.creative-studio-task .task-actions .pop-panel { min-width: 168px; }
.creative-studio-preview { width: min(100%, 460px); }
body[data-creative="video"] .creative-studio-preview { width: min(100%, calc(var(--creative-preview-height, 248px) * var(--creative-ratio))); }
.creative-video-wrap { position: relative; border-radius: var(--r-md); overflow: hidden; background: #151517; }
.creative-video-preview { display: block; width: 100%; aspect-ratio: var(--creative-ratio); object-fit: contain; background: #151517; }
.creative-video-badges { position: absolute; left: 8px; top: 8px; display: flex; flex-wrap: wrap; gap: 4px; pointer-events: none; }
.creative-video-badges span { padding: 2px 7px; border-radius: 6px; background: rgba(20,20,24,.68); color: #fff; font-size: var(--fs-2xs); backdrop-filter: blur(4px); }
.creative-studio-preview .creative-audio { margin: 0; border-radius: var(--r-md); }
.creative-studio-preview .progress { display: block; width: min(120px, 82%); height: 3px; margin: 0; }
.creative-studio-preview .progress > span { background: var(--accent-grad); }
.creative-studio-preview .pending-label { width: 100%; }
.creative-studio-preview .creative-task-note { margin: 0; }
body[data-creative="audio"] .creative-studio-preview.is-pending { height: 132px; }
.creative-studio-empty { padding: 18vh 0 0; }
.creative-studio-empty h3 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); letter-spacing: normal; }

@media (max-width: 1359px) {
  .tools-grid,
  .tools-sections.is-filtered { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
}
@media (max-width: 1279px) {
  .creative-workspace { grid-template-columns: minmax(295px, 350px) minmax(0, 1fr); }
}
@media (max-width: 1079px) {
  .tools-grid,
  .tools-sections.is-filtered { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
}
@media (max-width: 899px) {
  .creative-workspace { flex: 1; display: flex; flex-direction: column; overflow: auto; padding: 8px 12px 16px; gap: 12px; }
  .creative-panel { flex: 0 0 auto; border-radius: var(--r-md); overflow: visible; }
  .creative-results { flex: 0 0 auto; min-height: 320px; padding-top: 0; }
  .creative-result-body { flex: none; overflow: visible; }
  .creative-welcome { padding-top: 28px; }
}
@media (max-width: 767px) {
  .creative-form-heading { padding: 16px 14px 13px; }
  #creativeFields { padding: 0 14px 13px; }
  .creative-feedback { margin-inline: 14px; }
  .creative-submit { position: static; padding: 10px 14px; }
  .creative-results-heading, .creative-result-body { padding-inline: 2px; }
  .tools-container { padding: 0 16px 48px; }
  .tools-hero-title { padding: 18px 0 14px; font-size: var(--fs-xl); }
  .tools-tabs {
    margin-bottom: 14px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .tools-tabs::-webkit-scrollbar { display: none; }
  .tools-tab { flex: none; white-space: nowrap; height: 32px; padding: 0 12px; font-size: var(--fs-sm); }
  .tools-grid,
  .tools-sections.is-filtered { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .creative-voices { grid-template-columns: 1fr; }
  .creative-translate-row { grid-template-columns: 1fr; gap: 4px; }
  .creative-translate-row > .i { display: none; }
  .creative-composer-actions { margin-left: auto; gap: 0; }
  .creative-studio .composer-bar .grow { min-width: 0; }
  body[data-creative="video"] .creative-studio-preview { --creative-preview-height: 168px; }
  .creative-studio-task .task-head { gap: 8px; }
  .creative-studio-task .task-error { flex-wrap: wrap; }
  .task-meta { font-size: var(--fs-xs); gap: 4px 8px; }
  .task-meta .task-group-conv-link { display: none; }
  #studioScrollBottomBtn { width: 32px; padding: 0; justify-content: center; gap: 0; }
  #studioScrollBottomBtn span { display: none; }
}
@media (max-width: 479px) {
  .tools-card-body { padding: 8px 10px 10px; }
  .tools-card-desc {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}
@media (max-width: 359px) {
  .tools-grid,
  .tools-sections.is-filtered { grid-template-columns: 1fr; }
}

.studio.creative-studio .feed-inner { padding-bottom: 24px; }
.studio.creative-studio .dock { position: relative; flex: 0 0 auto; }
.studio.creative-studio .dock::before { inset: -12px 0 0; }
.studio .task-head, .studio .task-actions { flex-wrap: wrap; }
.studio .task-prompt, .studio .task-error p { overflow-wrap: anywhere; }
.studio .thumb { max-width: 100%; }
.studio-empty { padding: 40px 16px; text-align: center; }
.studio-preview-image { display: block; width: 100%; height: 100%; }
.studio-preview-image:focus-visible { outline-offset: -3px; }
.studio-video-result { display: grid; width: min(100%, 460px); gap: 6px; justify-items: start; }
.studio-video-result video { display: block; width: 100%; max-height: min(50dvh, 400px); border-radius: var(--r-md); background: #151517; }
.studio-audio-result { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.studio-audio-result audio { flex: 1 1 220px; min-width: 0; max-width: 100%; }
.studio-media-unavailable { color: var(--fg-2); font-size: var(--fs-sm); padding: 12px; }
.thumb .studio-media-unavailable { display: grid; width: 100%; height: 100%; place-items: center; }
#statusFilter { height: 34px; }
.tool-source-stage { display: grid; place-items: center; position: relative; overflow: hidden; border-radius: var(--r-md); background: var(--bg-muted); }
.tool-source-stage img { display: block; max-width: 100%; max-height: 240px; object-fit: contain; }
.tool-source-eraser { width: fit-content; max-width: 100%; margin-inline: auto; }
.creative-task-head h3 { overflow-wrap: anywhere; }
.creative-image-result > button { cursor: zoom-in; }

@media (max-width: 767px) {
  #statusFilter { max-width: 115px; }
  #studioPage .param-panel, #composer .param-panel { width: min(348px, calc(100vw - 16px)); }
  #studioPage .mp-panel, #composer .mp-panel { width: min(368px, calc(100vw - 16px)); }
  #studioPage .model-panel { min-width: 0; width: min(320px, calc(100vw - 16px)); }
}

@media (max-width: 899px) {
  #ecomWorkspace .er-head .tabs { min-width: 0; height: auto; flex-wrap: wrap; }
  #ecomWorkspace .er-head { min-height: 52px; height: auto; padding-block: 5px; }
  #ecomWorkspace .er-head .tab { white-space: normal; text-align: start; }
  #ecomWorkspace .ep-foot { flex-wrap: wrap; gap: 8px; }
  #ecomWorkspace .ep-title { min-width: 0; }
}

/* ============================================================================
   Global AI Tool Modal (#toolModal) — Split Studio Inspector
   ============================================================================ */
.tool-modal {
  width: min(1180px, calc(100vw - 32px));
  height: min(780px, calc(100dvh - 32px));
  margin: auto;
  overflow: visible;
}
.tool-modal.is-audio-compact {
  width: min(640px, calc(100vw - 32px));
  height: min(540px, calc(100dvh - 32px));
}
.tool-modal.is-fullscreen,
.tool-modal.is-audio-compact.is-fullscreen {
  width: 100vw;
  height: 100dvh;
  margin: 0;
}
.tool-modal.is-fullscreen .tm-shell {
  border-radius: 0;
  box-shadow: none;
}
.tool-modal.is-fullscreen .tm-lib-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.tool-modal.is-fullscreen .tm-batch-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.tm-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-elevated);
  border: 0;
  border-radius: 20px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.tm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line-hairline);
  background: var(--bg-elevated);
  flex: none;
}
.tm-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.tm-head-left > .pop { flex: none; margin-left: -4px; }
.tm-head-right { display: flex; align-items: center; gap: 6px; flex: none; }
.tm-title-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 8px 0 6px;
  border-radius: 9px;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--fg);
  white-space: nowrap;
  transition: background var(--dur);
}
.tm-title-ic {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--bg-subtle);
  color: var(--fg);
  display: grid;
  place-items: center;
  flex: none;
}
.tm-title-switch > .i { flex: none; color: var(--fg-3); }
.tm-title-switch:hover { background: var(--bg-hover); }
.tm-head-sep {
  width: 1px;
  height: 14px;
  background: var(--line);
  flex: none;
}
.tm-head-desc {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tm-head-action { height: 30px; font-size: var(--fs-sm); }
.tm-head-right .icon-btn.is-active {
  background: var(--accent-weak);
  color: var(--accent);
}
.tm-close-guard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--fg);
}
.tm-workspace {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 384px;
}
.tm-workspace.is-stage-full,
.tm-workspace.is-audio {
  grid-template-columns: minmax(0, 1fr);
}
.tm-canvas-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 14px;
  gap: 10px;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
}
.tm-audio-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 20px 18px;
  gap: 12px;
}
.tm-stage {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  border-radius: 14px;
  background-color: var(--bg-subtle);
  background-image: radial-gradient(circle, rgba(15, 35, 66, .065) 1px, transparent 1px);
  background-size: 18px 18px;
  border: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
}
[data-theme="dark"] .tm-stage {
  background-image: radial-gradient(circle, rgba(214, 228, 255, .07) 1px, transparent 1px);
}
.tm-stage.is-dragover {
  border-color: var(--accent);
  background-color: var(--accent-weak);
}
.tm-empty-stage, .tm-audio-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  height: 100%;
  padding: 24px;
}
.tm-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: min(460px, 100%);
  min-height: 184px;
  padding: 26px 24px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  color: var(--fg-2);
  text-align: center;
  transition: border-color var(--dur), background var(--dur);
}
.tm-upload-zone:hover { border-color: var(--accent-line); background: var(--bg-elevated); }
.tm-upload-ic {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-subtle);
  color: var(--fg-2);
  display: grid;
  place-items: center;
  margin-bottom: 2px;
  transition: background var(--dur), color var(--dur);
}
.tm-upload-zone:hover .tm-upload-ic { background: var(--accent-weak); color: var(--accent-text); }
.tm-upload-ic .i { width: 20px; height: 20px; color: inherit; }
.tm-upload-zone strong { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--fg); }
.tm-upload-zone span:not(.tm-upload-ic) { font-size: var(--fs-xs); color: var(--fg-3); }
.tm-empty-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tm-empty-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.tm-empty-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--r-full);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}
.tm-empty-chip.is-free {
  background: var(--success-weak);
  border-color: transparent;
  color: var(--success);
  font-weight: var(--fw-semibold);
}
.tm-audio-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: var(--fg-2);
  font-size: var(--fs-sm);
}
.tm-audio-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--accent);
}
.tm-audio-loaded {
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Annotator canvas & Floating frosted rails */
.tm-canvas-host {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  user-select: none;
}
.tm-annotator-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.tm-annotator-text-layer { position: absolute; inset: 0; pointer-events: none; }
.tm-annotator-text-inp {
  position: absolute;
  pointer-events: auto;
  min-width: 170px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1.5px solid var(--accent);
  background: rgba(15, 16, 20, 0.9);
  color: #fff;
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-pop);
}
.tm-rail {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px;
  border-radius: 14px;
  background: var(--bg-glass-strong);
  border: 1px solid var(--line-hairline);
  box-shadow: var(--shadow-pop);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
[data-theme="dark"] .tm-rail,
[data-theme="dark"] .tm-zoom-pill {
  background: var(--bg-glass-strong);
  border: 1px solid var(--line-hairline);
  box-shadow: var(--shadow-pop);
}
.tm-rail-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--fg-2);
  transition: background var(--dur), color var(--dur);
}
.tm-rail-btn .i { width: 16px; height: 16px; }
.tm-rail-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--fg); }
.tm-rail-btn.is-active { background: var(--bg-active); color: var(--fg); }
.tm-rail-btn:disabled { opacity: .36; cursor: not-allowed; }
.tm-rail-sep { width: 20px; height: 1px; background: var(--line); margin: 3px 0; }

.tm-zoom-pill {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--bg-glass-strong);
  border: 1px solid var(--line-hairline);
  box-shadow: var(--shadow-pop);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.tm-zoom-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--fg-2);
  transition: background var(--dur), color var(--dur);
}
.tm-zoom-btn:hover { background: var(--bg-hover); color: var(--fg); }
.tm-zoom-pct {
  min-width: 44px;
  height: 28px;
  padding: 0 6px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  color: var(--fg-2);
  border-radius: 999px;
}
.tm-zoom-pct:hover { background: var(--bg-hover); color: var(--fg); }

.tm-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg-2);
  transition: background var(--dur), color var(--dur);
}
.tm-bar-btn.is-icon { padding: 0; width: 30px; justify-content: center; }
.tm-bar-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--fg); }
.tm-bar-btn.is-active { background: var(--bg-surface); color: var(--fg); box-shadow: var(--shadow-sm); font-weight: var(--fw-semibold); }
.tm-bar-btn.is-fav { color: #f59e0b; }
.tm-bar-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Right Inspector Sidebar */
.tm-inspector {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line-hairline);
  background: var(--bg-elevated);
}
.tm-insp-body {
  flex: 1;
  min-height: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.tm-insp-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tm-insp-section + .tm-insp-section {
  padding-top: 14px;
  border-top: 1px solid var(--line-hairline);
}
.tm-insp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--fg);
}
.tm-insp-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: var(--fw-medium);
}
.tm-insp-badge {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent-text);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}
.tm-link-btn {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  transition: color var(--dur);
}
.tm-link-btn:hover { color: var(--danger); }
.tm-link-btn.is-accent { color: var(--accent-text); }
.tm-link-btn.is-accent:hover { color: var(--accent); }
.tm-insp-textarea,
.tm-insp-input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--bg-subtle);
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur);
}
.tm-insp-textarea {
  min-height: 104px;
  max-height: 160px;
  padding: 10px 12px;
  line-height: var(--lh-normal);
  resize: vertical;
}
.tm-insp-input {
  height: 36px;
  padding: 0 12px;
}
.tm-insp-textarea::placeholder,
.tm-insp-input::placeholder { color: var(--fg-3); }
.tm-insp-textarea.is-compact { min-height: 74px; }
.tm-insp-textarea:focus,
.tm-insp-input:focus {
  border-color: var(--accent);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.tm-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tm-quick-chip {
  height: 26px;
  padding: 0 10px;
  border-radius: 8px;
  border: 0;
  background: var(--bg-subtle);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  transition: background var(--dur), color var(--dur);
}
.tm-quick-chip:hover {
  background: var(--bg-active);
  color: var(--fg);
}
.tm-annot-style-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 0;
}
.tm-color-row, .tm-range-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tm-sub-lbl { font-size: var(--fs-xs); color: var(--fg-2); white-space: nowrap; }
.tm-color-dots { display: inline-flex; align-items: center; gap: 7px; }
.tm-color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--dot);
  border: 1px solid rgba(0, 0, 0, .18);
  transition: transform var(--dur-instant) var(--ease-out), box-shadow var(--dur-instant);
}
[data-theme="dark"] .tm-color-dot { border-color: rgba(255, 255, 255, .24); }
.tm-color-dot.is-active {
  transform: scale(1.12);
  box-shadow: 0 0 0 2px var(--bg-subtle), 0 0 0 3.5px var(--accent);
}
.tm-range-row .range { flex: 1; min-width: 0; }
.tm-range-val {
  min-width: 34px;
  text-align: right;
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--fg-2);
}
#tmModelSlot .mp-pop.is-block > .mp-panel { max-height: min(340px, 50dvh); }
#tmModelSlot .mp-trigger.is-block {
  height: 38px;
  border-color: transparent;
  background: var(--bg-subtle);
}
#tmModelSlot .mp-trigger.is-block:hover {
  border-color: transparent;
  background: var(--bg-active);
}
#tmModelSlot .mp-pop.is-open > .mp-trigger.is-block {
  border-color: var(--accent);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.tm-model-hint {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--fg-3);
  line-height: var(--lh-snug);
}
.pop-panel.tm-tool-menu { min-width: 196px; }
.pop-panel.tm-tool-menu.is-grid:not([hidden]) {
  width: min(440px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 6px;
}
.tm-tool-menu .menu-item {
  padding: 7px 10px;
  font-size: var(--fs-sm);
  white-space: nowrap;
  gap: 6px;
}
.tm-tool-menu .menu-item .mi-body {
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tm-tool-menu .menu-item .mi-check {
  margin-left: auto;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.tm-tool-menu .menu-item:not([aria-checked="true"]) .mi-check {
  display: none;
}
.tm-title-switch .nav-badge,
.tm-tool-menu .nav-badge {
  margin-left: 0;
  flex: none;
  overflow: visible;
}

/* Unified Studio Segmented Control & Choice Tile Grid */
.tm-seg {
  display: flex;
  width: 100%;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 0;
}
.tm-seg > button {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--dur), color var(--dur);
}
.tm-seg > button:hover:not(:disabled) { color: var(--fg); }
.tm-seg > button[aria-pressed="true"] {
  background: var(--bg-surface);
  color: var(--fg);
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .tm-seg > button[aria-pressed="true"] {
  background: rgba(255, 255, 255, .11);
  color: var(--fg);
  box-shadow: none;
}

.tm-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: 6px;
}
.tm-choice-grid.is-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tm-choice-grid.is-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tm-choice-grid.is-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.tm-choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--bg-subtle);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--dur), border-color var(--dur), color var(--dur);
}
.tm-choice:hover {
  background: var(--bg-active);
  color: var(--fg);
}
.tm-choice[aria-pressed="true"],
.tm-choice[aria-checked="true"] {
  background: var(--bg-surface);
  border-color: var(--accent-line);
  color: var(--accent-text);
  font-weight: var(--fw-semibold);
}
[data-theme="dark"] .tm-choice[aria-pressed="true"],
[data-theme="dark"] .tm-choice[aria-checked="true"] {
  background: var(--accent-weak);
  border-color: var(--accent-line);
  color: var(--accent-text);
}
.tm-choice.is-spec {
  height: auto;
  padding: 7px 10px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
}
.tm-choice.is-spec strong {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: inherit;
  line-height: var(--lh-tight);
}
.tm-choice.is-spec small {
  font-size: var(--fs-2xs);
  color: var(--fg-3);
  line-height: var(--lh-none);
}
.tm-choice.is-spec[aria-pressed="true"] small {
  color: var(--accent-text);
  opacity: .85;
}
.tm-choice.is-ratio {
  gap: 5px;
  padding: 0 6px;
}
.tm-ratio-glyph {
  display: inline-block;
  flex: none;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  opacity: .68;
}
.tm-choice.is-ratio[aria-pressed="true"] .tm-ratio-glyph { opacity: 1; }
.tm-choice.is-swatch {
  gap: 5px;
  padding: 0 6px;
}

/* Custom Popover Select (.tm-select-pop) */
.tm-select-pop {
  width: 100%;
  display: block;
}
.tm-select-trigger {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--bg-subtle);
  color: var(--fg);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background var(--dur), border-color var(--dur), box-shadow var(--dur);
}
.tm-select-trigger:hover { background: var(--bg-active); }
.tm-select-pop.is-open > .tm-select-trigger {
  border-color: var(--accent);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.tm-select-lead {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}
.tm-select-lead .i { color: var(--fg-2); flex: none; }
.tm-select-val {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.tm-select-trigger .chev { color: var(--fg-3); flex: none; }
.pop-panel.tm-select-menu {
  width: 100%;
  min-width: 0;
  max-height: min(300px, 44dvh);
  overflow-y: auto;
}
.pop-panel.tm-select-menu.is-grid:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
}
.tm-select-menu .menu-item {
  padding: 7px 10px;
  font-size: var(--fs-xs);
  gap: 6px;
}
.tm-select-menu .menu-item .mi-body {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-insp-foot {
  flex: none;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line-hairline);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tm-foot-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--fs-xs);
}
.tm-foot-lbl { color: var(--fg-3); }
.tm-foot-split-acts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
}
.tm-foot-sub {
  height: 40px;
  padding: 0 14px;
  border-radius: 11px;
  font-size: var(--fs-sm);
}
.tm-insp-submit {
  width: 100%;
  height: 40px;
  border-radius: 11px;
  font-weight: var(--fw-semibold);
  justify-content: center;
}

/* Preview & result stages */
.tm-preview-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
}
.tm-preview-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--r-sm);
}
.tm-preview-stage[data-result-bg="transparent"] {
  background-color: var(--bg);
  background-image: repeating-conic-gradient(var(--bg-muted) 0% 25%, transparent 0% 50%);
  background-size: 16px 16px;
}
.tm-preview-stage[data-result-bg="white"] { background: #ffffff; }
.tm-preview-stage[data-result-bg="blue"] { background: #2d78c9; }
.tm-preview-stage[data-result-bg="red"] { background: #ce4545; }
.tm-expand-frame {
  position: relative;
  max-width: min(82%, 440px);
  max-height: 92%;
  border: 1.5px dashed var(--accent-line);
  border-radius: 12px;
  background: var(--bg-surface);
  padding: 14px;
  display: grid;
  place-items: center;
}
.tm-expand-ratio-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--fg-2);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  display: inline-flex;
  align-items: center;
  pointer-events: none;
}
.tm-expand-frame[data-anchor="top-left"] { place-items: start start; }
.tm-expand-frame[data-anchor="top"] { place-items: start center; }
.tm-expand-frame[data-anchor="top-right"] { place-items: start end; }
.tm-expand-frame[data-anchor="left"] { place-items: center start; }
.tm-expand-frame[data-anchor="right"] { place-items: center end; }
.tm-expand-frame[data-anchor="bottom-left"] { place-items: end start; }
.tm-expand-frame[data-anchor="bottom"] { place-items: end center; }
.tm-expand-frame[data-anchor="bottom-right"] { place-items: end end; }
.tm-expand-frame img { max-width: 62%; max-height: 62%; border-radius: 6px; border: 1px solid var(--line-hairline); }
.tm-style-stage {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  height: 100%;
  padding: 20px;
}
.tm-style-slot {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--line-hairline);
  background: var(--bg-surface);
  box-shadow: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 14px;
}
.tm-style-slot img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.tm-style-tag {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(14, 22, 36, .72);
  color: #fff;
  font-size: var(--fs-xs);
}
.tm-slot-replace {
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
}
.tm-style-slot-actions {
  position: absolute;
  right: 10px;
  top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tm-style-empty-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.tm-style-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px;
  color: var(--fg-2);
  font-size: var(--fs-sm);
}

/* Param bar & audio dock */
.tm-param-bar { padding: 2px 0; }
.tm-param-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tm-param-group { display: flex; flex-direction: column; align-items: stretch; gap: 6px; width: 100%; }
.tm-param-lbl { font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--fg-2); }
.tm-bg-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1px solid var(--line-strong); }
.tm-bg-dot[data-bg="transparent"] { background: repeating-conic-gradient(#d5d5d8 0% 25%, #fff 0% 50%) 0/8px 8px; }
.tm-bg-dot[data-bg="white"] { background: #fff; }
.tm-bg-dot[data-bg="blue"] { background: #2d78c9; }
.tm-bg-dot[data-bg="red"] { background: #ce4545; }
.tm-consent-check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); color: var(--fg-2); cursor: pointer; }
.tm-dock-composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 16px;
  border-radius: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
}
.tm-prompt-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-md);
  line-height: var(--lh-snug);
  resize: none;
  outline: none;
  max-height: 96px;
}
.tm-dock-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.tm-cost-badge { font-size: var(--fs-sm); padding: 0; white-space: nowrap; }
.tm-submit-pill { height: 34px; border-radius: 999px; }

/* Compare & Result Stage inside Modal */
.tm-stage-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
}
.tm-stage-status h4 { font-size: var(--fs-lg); }
.tm-stage-status p { font-size: var(--fs-sm); color: var(--fg-2); max-width: 420px; }
.tm-status-actions { display: flex; gap: 8px; margin-top: 6px; }
.tm-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.tm-result-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow: hidden;
}
.tm-compare-box {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  border: 1px solid var(--line-hairline);
  overflow: hidden;
  user-select: none;
  touch-action: none;
  cursor: ew-resize;
}
.tm-compare-box .tm-compare-after {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.tm-compare-before-wrap {
  position: absolute;
  inset: 0;
  clip-path: inset(0 calc(100% - var(--split, 50%)) 0 0);
  pointer-events: none;
}
.tm-compare-before-wrap .tm-compare-before {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.tm-expand-compare-canvas {
  position: absolute;
  inset: 0;
  background-color: var(--bg-subtle);
  background-image: repeating-conic-gradient(var(--bg-muted) 0% 25%, transparent 0% 50%);
  background-size: 16px 16px;
}
.tm-expand-compare-src {
  position: absolute;
  overflow: hidden;
  pointer-events: none;
}
.tm-expand-compare-src img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}
.tm-expand-compare-outline {
  position: absolute;
  inset: 0;
  border: 1.5px dashed var(--accent);
  pointer-events: none;
}
.tm-compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split, 50%);
  width: 2px;
  background: #fff;
  box-shadow: 0 0 8px rgba(0, 0, 0, .32);
  pointer-events: none;
}
.tm-compare-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--fg);
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-pop);
}
.tm-compare-tag {
  position: absolute;
  top: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: var(--fs-2xs);
  background: rgba(16, 16, 20, .68);
  color: #fff;
  pointer-events: none;
}
.tm-compare-tag.is-left { left: 10px; }
.tm-compare-tag.is-right { right: 10px; }
.tm-single-result {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tm-single-frame {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line-hairline);
  overflow: hidden;
}
.tm-single-frame img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
}
.tm-compare-box[data-result-bg="transparent"],
.tm-single-frame[data-result-bg="transparent"] {
  background-color: var(--bg);
  background-image: repeating-conic-gradient(var(--bg-muted) 0% 25%, transparent 0% 50%);
  background-size: 16px 16px;
}
.tm-compare-box[data-result-bg="white"],
.tm-single-frame[data-result-bg="white"] { background: #ffffff; }
.tm-compare-box[data-result-bg="dark"],
.tm-single-frame[data-result-bg="dark"] { background: #18191d; }
.tm-compare-box[data-result-bg="blue"],
.tm-single-frame[data-result-bg="blue"] { background: #2d78c9; }
.tm-compare-box[data-result-bg="red"],
.tm-single-frame[data-result-bg="red"] { background: #ce4545; }

/* Bottom result action dock (kept outside .tm-stage to prevent overflow clipping) */
.tm-result-dock {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 6;
}
.tm-result-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
}
.tm-result-thumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  min-width: 0;
  padding: 2px 0;
}
.tm-result-thumb {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 3px;
  border-radius: 9px;
  border: 0;
  background: var(--bg-subtle);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  transition: background var(--dur), color var(--dur);
}
.tm-result-thumb img {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
}
.tm-result-thumb:hover { background: var(--bg-active); color: var(--fg); }
.tm-result-thumb.is-active {
  background: var(--accent-weak);
  color: var(--accent-text);
  font-weight: var(--fw-semibold);
}
.tm-result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px 10px;
  border-radius: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
}
.tm-result-bar-left,
.tm-result-bar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.tm-view-seg {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 0;
}
.tm-view-btn {
  height: 26px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--fg-2);
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.tm-view-btn:hover { color: var(--fg); }
.tm-view-btn[aria-pressed="true"] {
  background: var(--bg-surface);
  color: var(--fg);
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .tm-view-btn[aria-pressed="true"] {
  box-shadow: none;
}
.tm-bg-swatches {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 9px;
  background: var(--bg-subtle);
  border: 0;
}
.tm-bg-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  transition: transform var(--dur-instant) var(--ease-out), box-shadow var(--dur-instant);
}
.tm-bg-swatch[data-tm-result-bg="transparent"] { background: repeating-conic-gradient(#d5d5d8 0% 25%, #fff 0% 50%) 0/8px 8px; }
.tm-bg-swatch[data-tm-result-bg="white"] { background: #ffffff; }
.tm-bg-swatch[data-tm-result-bg="dark"] { background: #18191d; }
.tm-bg-swatch.is-active {
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--bg-elevated), 0 0 0 3.5px var(--accent);
}
.tm-result-dock .pop-panel.tm-tool-menu { right: 0; left: auto; }

/* Audio multi-track result & library audio picker */
.tm-audio-results {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tm-audio-track-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-surface);
  box-shadow: none;
  border: 1px solid var(--line-hairline);
}
.tm-audio-track-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tm-audio-track-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--fg);
}
.tm-audio-track-ops {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tm-audio-track-card audio {
  width: 100%;
  height: 36px;
}
/* Audio multi-track result & library picker */
.tm-lib-picker {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
  border: 1px solid var(--line-hairline);
  border-radius: inherit;
  overflow: hidden;
}
.tm-lib-head {
  flex: none;
  padding: 14px 18px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--line-hairline);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tm-lib-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.tm-lib-head-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tm-lib-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tm-lib-count {
  flex: none;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}
.tm-lib-count[hidden] { display: none; }
.tm-lib-head-acts {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.tm-lib-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.tm-lib-pills { gap: 4px; }
.tm-lib-pills .pill {
  height: 30px;
  padding: 0 11px;
  font-size: var(--fs-xs);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tm-lib-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  width: 220px;
  max-width: 100%;
  padding: 0 8px 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-canvas);
  color: var(--fg-3);
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur);
}
.tm-lib-search:focus-within {
  border-color: var(--accent);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-weak);
  color: var(--fg-2);
}
.tm-lib-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font-size: var(--fs-xs);
}
.tm-lib-search input::placeholder { color: var(--fg-3); }
.tm-lib-search-clear {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: var(--fg-3);
  flex: none;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.tm-lib-search-clear:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
.tm-lib-search-clear[hidden] { display: none; }

.tm-lib-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px 20px;
}
.tm-lib-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
  align-content: start;
}
.tm-lib-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  padding: 0;
  text-align: left;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.tm-lib-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-card-hover);
}
.tm-lib-card.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-weak);
}
.tm-lib-card.is-skeleton {
  pointer-events: none;
  cursor: default;
}
.tm-lib-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  flex: none;
  background: var(--bg-muted);
  overflow: hidden;
}
.tm-lib-card:hover .tm-lib-media .bh-frame > img {
  transform: scale(1.03);
}
.tm-lib-current-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-none);
  pointer-events: none;
}
.tm-lib-fav-mark {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(16, 16, 20, .62);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #f59e0b;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}
.tm-lib-fav-mark svg { fill: currentColor; }
[data-theme="dark"] .tm-lib-fav-mark {
  background: rgba(16, 16, 20, .72);
  border-color: rgba(255, 255, 255, .16);
}
.tm-lib-badges {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}
.tm-lib-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  background: rgba(16, 16, 20, .62);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #fff;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-none);
  letter-spacing: var(--ls-wide);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
[data-theme="dark"] .tm-lib-badge {
  background: rgba(16, 16, 20, .72);
  border-color: rgba(255, 255, 255, .16);
}
.tm-lib-ratio {
  margin-left: auto;
  letter-spacing: var(--ls-normal);
  font-variant-numeric: tabular-nums;
}
.tm-lib-ratio[hidden] { display: none; }
.tm-lib-card-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-width: 0;
  padding: 8px 10px 9px;
}
.tm-lib-card-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tm-lib-card-meta {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.tm-lib-sk-media { width: 100%; aspect-ratio: 1 / 1; }
.tm-lib-sk-title { display: block; height: 13px; width: 72%; border-radius: 4px; }
.tm-lib-sk-meta { display: block; height: 11px; width: 48%; border-radius: 4px; margin-top: 4px; }

.tm-lib-audio-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}
.tool-modal.is-audio-compact .tm-lib-audio-list {
  grid-template-columns: 1fr;
}
.tm-lib-audio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-hairline);
  background: var(--bg-surface);
  box-shadow: none;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur);
}
.tm-lib-audio-item:hover {
  background: var(--bg-subtle);
  border-color: var(--accent);
}
.tm-lib-audio-item.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-weak);
}
.tm-lib-audio-item.is-skeleton {
  pointer-events: none;
  cursor: default;
}
.tm-lib-audio-ic {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  flex: none;
  background: var(--bg-subtle);
  color: var(--fg-2);
}
.tm-lib-audio-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tm-lib-audio-info strong {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tm-lib-audio-info small {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tm-lib-audio-end {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.tm-lib-audio-fav {
  color: #f59e0b;
  display: inline-grid;
  place-items: center;
}
.tm-lib-audio-fav svg { fill: currentColor; }
.tm-lib-audio-cur {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--accent-weak);
  color: var(--accent-text);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

.tm-lib-empty {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 16px;
  text-align: center;
  color: var(--fg-3);
}
.tm-lib-empty-ic {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
  color: var(--fg-2);
  margin-bottom: 2px;
}
.tm-lib-empty h4 {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--fg);
}
.tm-lib-empty p {
  margin: 0 0 6px;
  font-size: var(--fs-xs);
  color: var(--fg-2);
  max-width: 340px;
  line-height: var(--lh-snug);
}
.tm-lib-more {
  display: flex;
  justify-content: center;
  padding-top: 16px;
}

#tmHistorySlot:empty { display: none; }
.tm-history-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 384px;
  max-width: 100%;
  z-index: 8;
  border-left: 1px solid var(--line-hairline);
  background: var(--bg-elevated);
  box-shadow: -8px 0 28px rgba(15, 35, 66, .08);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tm-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-size: var(--fs-sm);
  border-bottom: 1px solid var(--line-hairline);
}
.tm-history-list { flex: 1; min-height: 0; padding: 8px; display: grid; gap: 6px; align-content: start; }
.tm-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px;
  border-radius: 10px;
  text-align: left;
  border: 0;
}
.tm-history-item:hover { background: var(--bg-hover); }
.tm-history-item img, .tm-history-ph {
  width: 44px;
  height: 44px;
  border-radius: 7px;
  object-fit: cover;
  flex: none;
  background: var(--bg-muted);
  display: grid;
  place-items: center;
}
.tm-history-info { flex: 1; min-width: 0; }
.tm-history-prompt {
  display: block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tm-history-info small { font-size: var(--fs-xs); color: var(--fg-3); }

@media (max-width: 1023px) {
  .tm-lib-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
}
@media (max-width: 859px) {
  .tm-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 1fr) auto;
    overflow-y: auto;
  }
  .tm-workspace.is-stage-full { grid-template-rows: minmax(0, 1fr); }
  .tm-inspector {
    border-left: 0;
    border-top: 1px solid var(--line-subtle);
  }
  .tm-insp-textarea { min-height: 76px; }
  .tm-history-drawer { width: 100%; border-left: 0; }
}
@media (max-width: 767px) {
  .tool-modal, .tool-modal.is-audio-compact {
    width: 100vw;
    height: 100dvh;
  }
  .tm-shell { border-radius: 0; }
  .tm-head { padding: 8px 10px; gap: 6px; }
  .tm-head-left > .pop { flex: 0 1 auto; min-width: 0; max-width: 100%; margin-left: -2px; }
  .tm-title-switch { font-size: var(--fs-md); padding: 0 6px; margin-left: 0; max-width: 100%; }
  .tm-title-switch > span:not(.tm-title-ic):not(.nav-badge) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .tm-head-sep,
  .tm-head-desc { display: none; }
  .tm-head-action { width: 32px; min-width: 32px; padding: 0; justify-content: center; gap: 0; }
  .tm-head-action > span { display: none; }
  .tm-fullscreen-btn { display: none; }
  .tm-close-guard { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .tm-style-stage { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .tm-canvas-pane { padding: 10px; gap: 8px; }
  .tm-result-stage { padding: 8px; }
  .tm-result-bar { padding: 8px 10px; gap: 8px; }
  .tm-result-bar-right .tm-bar-btn:not(#tmResultDownloadBtn):not(.is-primary) > span,
  .tm-audio-main .tm-result-bar-left .tm-bar-btn > span,
  .tm-audio-track-ops .tm-bar-btn > span { display: none; }
  .tm-result-bar-right .tm-bar-btn:not(#tmResultDownloadBtn):not(.is-primary),
  .tm-audio-main .tm-result-bar-left .tm-bar-btn,
  .tm-audio-track-ops .tm-bar-btn { width: 30px; min-width: 30px; padding: 0; justify-content: center; gap: 0; }
  .tm-audio-main { padding: 10px 12px calc(14px + env(safe-area-inset-bottom, 0px)); }
  .tm-insp-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .tm-rail { left: 8px; padding: 4px; gap: 2px; }
  .tm-rail-btn { width: 30px; height: 30px; }
  .tm-dock-composer { flex-wrap: wrap; padding: 10px 12px; }
  .tm-prompt-input { flex: 1 0 100%; }
  .tm-dock-right { width: 100%; justify-content: flex-end; }
  .tm-lib-head { padding: 10px 12px; gap: 8px; }
  .tm-lib-body { padding: 12px 12px 16px; }
  .tm-lib-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .tm-lib-pills::-webkit-scrollbar { display: none; }
  .tm-lib-pills .pill { flex: none; white-space: nowrap; }
  .tm-lib-search { width: 100%; }
  .tm-lib-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .tm-lib-audio-list { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .tm-lib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .tm-lib-card:hover .tm-lib-media .bh-frame > img { transform: none; }
}

/* ==========================================================================
   Explore Gallery (/explore) & Skills Center (/skills)
   ========================================================================== */

.explore-page, .skills-page { position: relative; }
.explore-container, .skills-container { padding-top: 52px; }

.explore-hero {
  text-align: center;
  padding: 10px 0 20px;
}
.explore-hero h1 {
  font-size: clamp(20px, 2.2vw, var(--fs-2xl));
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
}
.explore-hero p {
  margin-top: 8px;
  color: var(--fg-2);
  font-size: var(--fs-md);
}

.explore-controls, .skills-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.explore-controls .tools-tabs,
.skills-controls .tools-tabs {
  margin-bottom: 0;
}
.explore-tab-count {
  margin-left: 5px;
  font-size: var(--fs-2xs);
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--fg-3);
  font-weight: var(--fw-medium);
}
.tools-tab[aria-pressed="true"] .explore-tab-count {
  background: var(--bg-surface);
  color: var(--fg);
}
.explore-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.explore-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  min-width: 220px;
  padding: 0 8px 0 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--bg-surface);
  box-shadow: none;
  transition: border-color var(--dur), box-shadow var(--dur), background var(--dur);
}
.explore-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.explore-search > .i { width: 15px; height: 15px; color: var(--fg-3); flex: none; }
.explore-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--fg);
}
.explore-search input::placeholder { color: var(--fg-3); }

.explore-cat-bar {
  margin-bottom: 20px;
}

.explore-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.explore-grid.is-masonry {
  display: block;
  column-count: 4;
  column-gap: 16px;
}
.explore-grid.is-masonry .explore-card.is-image {
  break-inside: avoid;
  margin-bottom: 16px;
  position: relative;
  display: block;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-muted);
  cursor: zoom-in;
}
.explore-grid.is-masonry .explore-card.is-image > img {
  width: 100%;
  height: auto;
  display: block;
}
.explore-grid.is-masonry .explore-card.is-image:hover {
  transform: none;
  box-shadow: none;
}
[data-theme="dark"] .explore-grid.is-masonry .explore-card.is-image:hover {
  box-shadow: none;
}
.explore-grid.is-audio-only {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.explore-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.explore-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-card-hover);
}
[data-theme="dark"] .explore-card {
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
}
[data-theme="dark"] .explore-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-card-hover);
}

.explore-card-media {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--bg-muted);
  overflow: hidden;
}
.explore-card.is-video .explore-card-media {
  aspect-ratio: 16 / 10;
}
.explore-card-media img,
.explore-card-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.explore-card-video {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-standard);
}
.explore-card.is-video.is-previewing .explore-card-video {
  opacity: 1;
}
.explore-card.is-video.is-previewing .explore-play-pill {
  opacity: 0;
}

.explore-author-pill {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 4px;
  border-radius: 999px;
  background: rgba(12, 12, 16, .52);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: var(--fs-xs);
  opacity: 0;
  transition: opacity var(--dur);
}
.explore-author-pill .avatar { width: 18px; height: 18px; font-size: var(--fs-2xs); }
.explore-card:hover .explore-author-pill { opacity: 1; }

.explore-media-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(12, 12, 16, .62);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}
.explore-play-pill {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  z-index: 2;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(12, 12, 16, .58);
  backdrop-filter: blur(8px);
  color: #fff;
  transition: transform var(--dur), opacity var(--dur);
}
.explore-card:hover .explore-play-pill { transform: scale(1.06); }

.explore-like-btn {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(12, 12, 16, .56);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: var(--fs-xs);
  transition: background var(--dur), color var(--dur), transform var(--dur-fast);
}
.explore-like-btn:hover { background: rgba(12, 12, 16, .78); }
.explore-like-btn:active { transform: scale(.94); }
.explore-like-btn.is-liked { background: rgba(207, 52, 52, .9); color: #fff; }
.explore-like-btn.is-liked .i use { fill: currentColor; }
.explore-like-btn.is-inline,
.explore-like-btn.is-modal {
  position: static;
  background: var(--bg-subtle);
  color: var(--fg-2);
  border: 0;
}
.explore-like-btn.is-inline.is-liked,
.explore-like-btn.is-modal.is-liked {
  background: var(--danger-weak);
  color: var(--danger);
}

.explore-card-over {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 28px 10px 10px;
  background: linear-gradient(to top, rgba(10, 10, 14, .78), transparent);
  color: #fff;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease);
}
.explore-card:hover .explore-card-over,
.explore-card:focus-within .explore-card-over {
  opacity: 1;
}
.explore-card-prompt {
  flex: 1;
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.explore-remix-btn {
  flex: none;
}
.explore-card-over .explore-remix-btn {
  --h: 28px;
  padding: 0 10px;
  font-size: var(--fs-xs);
  background: rgba(255, 255, 255, .94);
  color: #162032;
  border-radius: 8px;
}

.explore-card-foot {
  padding: 11px 13px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.explore-card-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.explore-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--fg-3);
}
.explore-model-tag {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

/* Audio cards in Explore */
.explore-card.is-audio {
  padding: 14px;
  gap: 10px;
}
.explore-audio-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.explore-audio-play {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--accent-weak);
  color: var(--accent);
  transition: background var(--dur), color var(--dur), transform var(--dur-fast);
}
.explore-audio-play:hover,
.explore-audio-play.is-playing {
  background: var(--accent);
  color: #fff;
}
.explore-audio-play.is-playing {
  box-shadow: 0 0 0 4px var(--accent-weak);
}
.explore-audio-head {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.explore-audio-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.explore-audio-prompt {
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
  color: var(--fg-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 58px;
}
.explore-audio-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-hairline);
}
.explore-audio-foot .explore-card-meta {
  justify-content: flex-start;
  min-width: 0;
}

.explore-media-stage video {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--r-md);
  background: #000;
}
.explore-audio-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 28px;
  text-align: center;
  color: var(--fg);
}
.explore-audio-stage-cover {
  width: 180px;
  height: 180px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .2);
}
.explore-audio-stage-ic {
  width: 112px;
  height: 112px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: var(--accent-weak);
  color: var(--accent);
}
.explore-audio-stage-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.explore-empty, .skills-empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--fg-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Skills Center (/skills) */
.skills-container { padding-top: 48px; }
.skills-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 4px 0 22px;
}
.skills-hero-copy h1 {
  font-size: clamp(20px, 2.2vw, var(--fs-2xl));
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-tight);
}
.skills-hero-sub {
  margin-top: 6px;
  font-size: var(--fs-sm);
  color: var(--fg-3);
  line-height: var(--lh-snug);
  max-width: 620px;
}
.skills-create-btn {
  border-radius: var(--r-full);
  height: 38px;
  padding: 0 18px;
}
.btn-sm.skills-create-btn {
  height: 34px;
  padding: 0 14px;
}

.skills-controls {
  margin-bottom: 24px;
  padding-bottom: 8px;
  border-bottom: 0;
}
.skills-tab-count {
  margin-left: 5px;
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-weight: var(--fw-medium);
}
.tools-tab[aria-pressed="true"] .skills-tab-count {
  color: var(--fg-2);
}
.skills-search {
  border-radius: var(--r-full);
  min-width: 240px;
  width: 268px;
  height: 36px;
  padding: 0 8px 0 14px;
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}
.skills-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
  overflow: hidden;
  transition: transform var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.skills-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-card-hover);
}
[data-theme="dark"] .skills-card {
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
}
[data-theme="dark"] .skills-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-card-hover);
}

.skills-card-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-muted);
  border-bottom: 0;
  overflow: hidden;
  cursor: pointer;
}
.skills-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--dur-slow) var(--ease-out);
}
.skills-card:hover .skills-card-cover img { transform: scale(1.035); }
.skills-card-cover.is-placeholder {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 0%, var(--accent-weak), transparent 68%),
    radial-gradient(var(--line) 1px, transparent 1px),
    var(--bg-subtle);
  background-size: 100% 100%, 16px 16px, 100% 100%;
}
.skills-card-placeholder-ic {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
  color: var(--accent-text);
  transition: transform var(--dur-base) var(--ease-out), color var(--dur);
}
.skills-card-placeholder-ic .i { width: 22px; height: 22px; }
.skills-card:hover .skills-card-placeholder-ic {
  transform: scale(1.06);
  color: var(--accent);
}

.skills-card-body {
  flex: 1;
  padding: 15px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.skills-card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.skills-card-head .nav-badge {
  margin-left: 0;
  flex: none;
}
.skills-card-head .skill-badge {
  flex: none;
}
.skills-card-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-normal);
  line-height: var(--lh-tight);
  color: var(--fg);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--dur);
}
.skills-card-title:hover { color: var(--accent); }
.skills-card-desc {
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
  color: var(--fg-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(12.5px * 1.58 * 2);
}

.skills-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 16px 15px;
}
.skills-card-ops {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: -8px;
}
.skills-card-op {
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg-3);
  white-space: nowrap;
  transition: background var(--dur), color var(--dur);
}
.skills-card-op:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
.skills-card-op.is-danger {
  color: var(--danger);
  background: var(--danger-weak);
}

.skills-card-use {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  background: var(--bg-subtle);
  color: var(--fg);
  border: 0;
  white-space: nowrap;
  transition: background var(--dur), color var(--dur), transform var(--dur-fast);
}
[data-theme="dark"] .skills-card-use {
  background: var(--bg-subtle);
  color: var(--fg);
  border: 0;
}
.skills-card:hover .skills-card-use,
.skills-card-use:hover,
.skills-card-use:focus-visible {
  background: var(--accent);
  color: #ffffff;
  box-shadow: none;
}
[data-theme="dark"] .skills-card:hover .skills-card-use,
[data-theme="dark"] .skills-card-use:hover,
[data-theme="dark"] .skills-card-use:focus-visible {
  background: var(--accent);
  color: #ffffff;
  box-shadow: none;
}
.skills-card-use:active {
  transform: scale(.97);
}
.skills-card-use .i {
  width: 13px;
  height: 13px;
  transition: transform var(--dur) var(--ease-out);
}
.skills-card:hover .skills-card-use .i,
.skills-card-use:hover .i {
  transform: translateX(2px);
}

.skills-empty-ic {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
  color: var(--fg-3);
  margin-bottom: 4px;
}

/* Skill Detail & Editor Extensions */
.skill-detail-modal { max-width: 680px; }
.sd-head-left { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.sd-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sd-body { display: flex; flex-direction: column; gap: 14px; max-height: 60vh; }
.sd-cover {
  border-radius: 12px;
  overflow: hidden;
  border: 0;
  aspect-ratio: 16 / 9;
}
.sd-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sd-section { display: flex; flex-direction: column; gap: 6px; }
.sd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sd-row-head { display: flex; align-items: center; justify-content: space-between; }
.sd-starter-box {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 0;
  background: var(--bg-subtle);
  font-size: var(--fs-sm);
  color: var(--fg);
}
.sd-sop {
  border: 0;
  border-radius: var(--r-sm);
  padding: 10px 12px;
  background: var(--bg-subtle);
}
.sd-sop summary { cursor: pointer; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--fg-2); }
.sd-sop-pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font);
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
  color: var(--fg-2);
}
.sd-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-hairline);
}
.sd-foot-left, .sd-foot-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.skill-cat-field { width: 160px; flex: none; }
.skill-icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.skill-icon-opt {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 0;
  background: var(--bg-subtle);
  color: var(--fg-2);
  display: grid;
  place-items: center;
  transition: background var(--dur), color var(--dur);
}
.skill-icon-opt:hover { background: var(--bg-active); color: var(--fg); }
.skill-icon-opt.is-selected {
  background: var(--accent-weak);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

@media (max-width: 1180px) {
  .explore-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .skills-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .explore-grid.is-masonry { column-count: 3; }
}
@media (max-width: 860px) {
  .explore-container, .skills-container { padding-top: 24px; }
  .explore-grid, .explore-grid.is-audio-only { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skills-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .explore-grid.is-masonry { column-count: 2; column-gap: 12px; }
  .explore-grid.is-masonry .explore-card.is-image { margin-bottom: 12px; }
}
@media (max-width: 767px) {
  .explore-container { padding-top: 10px; }
  .explore-hero { padding: 4px 0 10px; }
  .explore-tab-count { display: none; }
  .explore-controls { gap: 8px; margin-bottom: 10px; }
  .explore-toolbar { width: 100%; flex-wrap: nowrap; gap: 6px; }
  .explore-search { flex: 1 1 0; min-width: 0; width: auto !important; height: 34px; }
  #exploreRatioPop .chip, #exploreSortPop .chip { width: 34px; min-width: 34px; height: 34px; padding: 0; gap: 0; justify-content: center; }
  #exploreRatioPop .chip > span, #exploreRatioPop .chip .chev,
  #exploreSortPop .chip > span, #exploreSortPop .chip .chev { display: none; }
  .explore-cat-bar { margin-bottom: 12px; }
  .explore-cat-bar .pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; width: 100%; }
  .explore-cat-bar .pills::-webkit-scrollbar { display: none; }
  .explore-cat-bar .pill { flex: none; white-space: nowrap; height: 30px; padding: 0 12px; font-size: var(--fs-sm); }
  .explore-audio-foot .explore-card-meta > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .skills-hero { flex-wrap: nowrap; align-items: center; padding: 0 0 14px; gap: 10px; }
  .skills-hero-sub { display: none; }
  .skills-hero h1 { font-size: var(--fs-xl); white-space: nowrap; }
  .skills-create-btn { height: 34px; padding: 0 12px; font-size: var(--fs-sm); flex: none; }
  .skills-tab-count { display: none; }
  .skills-controls { gap: 8px; }
  .skills-search { width: 100%; height: 36px; }
  .skills-card-use { padding: 0 11px; }
  .sd-foot { gap: 6px; }
  .sd-foot .btn { --h: 34px; padding: 0 10px; font-size: var(--fs-sm); }
}
@media (max-width: 720px) {
  .skill-cat-field { width: 100%; }
}
@media (max-width: 540px) {
  .explore-grid, .explore-grid.is-audio-only, .skills-grid { grid-template-columns: 1fr; }
  .explore-grid.is-masonry { column-count: 2; column-gap: 8px; }
  .explore-grid.is-masonry .explore-card.is-image { margin-bottom: 8px; }
  .skills-search { width: 100%; min-width: 0; }
}

/* ── AI Tools Real Stages (DESIGN v3.1) ──────────────────────────────────────────────────── */
.tm-anchor-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 0;
}
.tm-anchor-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tm-anchor-info strong {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--fg);
}
.tm-anchor-info small {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  line-height: var(--lh-snug);
}
.tm-anchor-pad {
  display: grid;
  grid-template-columns: repeat(3, 28px);
  gap: 4px;
  flex: none;
}
.tm-anchor-cell {
  width: 28px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--line-hairline);
  background: var(--bg-surface);
  color: var(--fg-3);
  font-size: var(--fs-xs);
  display: grid;
  place-items: center;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.tm-anchor-cell:hover {
  border-color: var(--line);
  color: var(--fg);
}
.tm-anchor-cell[aria-pressed="true"] {
  background: var(--bg-surface);
  border-color: var(--accent-line);
  color: var(--accent-text);
  font-weight: var(--fw-semibold);
}
[data-theme="dark"] .tm-anchor-cell[aria-pressed="true"] {
  background: var(--accent-weak);
  border-color: var(--accent-line);
  color: var(--accent-text);
}

/* ── Interactive AI Outpaint Stage & Inspector Controls (DESIGN v3.1) ─────────────────────── */
.tm-expand-stage-host {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  user-select: none;
}
.tm-expand-hud-wrap {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  pointer-events: none;
}
.tm-expand-hud-pill,
.tm-expand-warn-pill {
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-full);
  background: var(--bg-glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line-hairline);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.tm-expand-warn-pill {
  background: var(--warning-weak, rgba(217, 119, 6, .12));
  border-color: rgba(217, 119, 6, .32);
  color: var(--warning);
  font-weight: var(--fw-medium);
}
[data-theme="dark"] .tm-expand-warn-pill {
  background: rgba(251, 191, 36, .14);
  border-color: rgba(251, 191, 36, .35);
}
.tm-expand-hud-pill[hidden],
.tm-expand-warn-pill[hidden] {
  display: none;
}

.tm-expand-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  cursor: default;
}
.tm-expand-viewport.is-pan-ready { cursor: grab; }
.tm-expand-viewport.is-panning { cursor: grabbing; }

.tm-expand-canvas-box {
  position: absolute;
  border-radius: var(--r-sm);
  background-color: var(--bg-surface);
  background-image:
    linear-gradient(var(--accent-weak), var(--accent-weak)),
    repeating-conic-gradient(var(--bg-muted) 0% 25%, transparent 0% 50%);
  background-size: 100% 100%, 16px 16px;
  border: 1.5px dashed var(--accent-line);
  transition: border-color var(--dur-fast) var(--ease-out);
}
.tm-expand-canvas-box.is-dragging {
  border-color: var(--accent);
}
.tm-expand-src-wrap {
  position: absolute;
  z-index: 2;
  cursor: grab;
  overflow: hidden;
  border-radius: 2px;
  outline: 1px solid var(--line-strong);
}
.tm-expand-src-wrap:hover {
  outline: 1.5px solid var(--accent);
}
.tm-expand-src-wrap.is-dragging {
  cursor: grabbing;
  outline: 1.5px solid var(--accent);
}
.tm-expand-src-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.tm-expand-thirds {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.tm-expand-thirds[hidden] { display: none; }
.tm-expand-thirds i,
.tm-expand-thirds s {
  position: absolute;
  background: var(--accent-line);
  opacity: .55;
  text-decoration: none;
}
.tm-expand-thirds i { top: 0; bottom: 0; width: 1px; }
.tm-expand-thirds i:first-child { left: 33.333%; }
.tm-expand-thirds i:nth-child(2) { left: 66.666%; }
.tm-expand-thirds s { left: 0; right: 0; height: 1px; }
.tm-expand-thirds s:nth-of-type(1) { top: 33.333%; }
.tm-expand-thirds s:nth-of-type(2) { top: 66.666%; }

.tm-expand-guide-line {
  position: absolute;
  z-index: 4;
  pointer-events: none;
}
.tm-expand-guide-line[hidden] { display: none; }
.tm-expand-guide-line.is-v {
  top: 0;
  bottom: 0;
  width: 1px;
  border-left: 1px dashed var(--accent);
}
.tm-expand-guide-line.is-h {
  left: 0;
  right: 0;
  height: 1px;
  border-top: 1px dashed var(--accent);
}

.tm-expand-handle {
  position: absolute;
  z-index: 5;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  touch-action: none;
}
.tm-expand-handle::after {
  content: "";
  display: block;
  background: var(--bg-surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--r-full);
  transition: transform var(--dur-instant) var(--ease-out), background var(--dur-instant) var(--ease-out);
}
.tm-expand-handle:hover::after {
  background: var(--accent);
  transform: scale(1.12);
}
.tm-expand-handle.is-n { top: 0; left: 50%; cursor: ns-resize; }
.tm-expand-handle.is-s { top: 100%; left: 50%; cursor: ns-resize; }
.tm-expand-handle.is-e { top: 50%; left: 100%; cursor: ew-resize; }
.tm-expand-handle.is-w { top: 50%; left: 0; cursor: ew-resize; }
.tm-expand-handle.is-n::after,
.tm-expand-handle.is-s::after { width: 22px; height: 6px; }
.tm-expand-handle.is-e::after,
.tm-expand-handle.is-w::after { width: 6px; height: 22px; }

.tm-expand-handle.is-nw { top: 0; left: 0; cursor: nwse-resize; }
.tm-expand-handle.is-se { top: 100%; left: 100%; cursor: nwse-resize; }
.tm-expand-handle.is-ne { top: 0; left: 100%; cursor: nesw-resize; }
.tm-expand-handle.is-sw { top: 100%; left: 0; cursor: nesw-resize; }
.tm-expand-handle.is-nw::after,
.tm-expand-handle.is-se::after,
.tm-expand-handle.is-ne::after,
.tm-expand-handle.is-sw::after {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.tm-expand-delta-tip {
  position: absolute;
  left: 50%;
  bottom: -34px;
  transform: translateX(-50%);
  z-index: 6;
  padding: 3px 9px;
  border-radius: var(--r-full);
  background: var(--bg-glass-strong);
  border: 1px solid var(--line-hairline);
  box-shadow: var(--shadow-pop);
  color: var(--fg);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  pointer-events: none;
}
.tm-expand-delta-tip[hidden] { display: none; }
.tm-expand-delta-tip[data-pos*="n"] { bottom: auto; top: -34px; }

.tm-expand-bar {
  gap: 2px;
  padding: 4px 6px;
}
.tm-expand-bar-sep {
  width: 1px;
  height: 14px;
  margin: 0 3px;
  background: var(--line-hairline);
  flex: none;
}
.tm-expand-bar .tm-zoom-btn.is-active {
  background: var(--bg-active);
  color: var(--fg);
}
.tm-expand-bar .tm-zoom-btn:disabled {
  opacity: .36;
  cursor: not-allowed;
}

.tm-expand-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tm-expand-swap-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--r-xs);
  background: var(--bg-subtle);
  border: 1px solid var(--line-hairline);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.tm-expand-swap-btn:hover:not(:disabled) {
  background: var(--bg-active);
  color: var(--fg);
  border-color: var(--line);
}
.tm-expand-swap-btn:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.tm-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-subtle);
  cursor: pointer;
}
.tm-switch-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tm-switch-text strong {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--fg);
  line-height: var(--lh-tight);
}
.tm-switch-text small {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  line-height: var(--lh-snug);
}
.tm-switch {
  display: inline-flex;
  align-items: center;
  flex: none;
}
.tm-switch input {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  border-radius: var(--r-full);
  background: var(--bg-muted);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tm-switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tm-switch input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.tm-switch input:checked::after {
  transform: translateX(16px);
  border-color: transparent;
}

.tm-slider-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 0;
}
.tm-slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.tm-slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tm-inspector .range {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: var(--r-full);
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--pct, 50%),
    var(--line-strong) var(--pct, 50%),
    var(--line-strong) 100%
  );
  cursor: pointer;
  outline: none;
}
.tm-inspector .range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--accent);
  cursor: pointer;
  transition: transform var(--dur-instant) var(--ease-out);
}
.tm-inspector .range::-webkit-slider-thumb:hover {
  transform: scale(1.14);
}
.tm-inspector .range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--accent);
  cursor: pointer;
}

.tm-advanced-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tm-advanced-details > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 2px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--fg-2);
  cursor: pointer;
  user-select: none;
  transition: color var(--dur);
}
.tm-advanced-details > summary::-webkit-details-marker { display: none; }
.tm-advanced-details > summary:hover { color: var(--fg); }
.tm-advanced-details > summary .i {
  color: var(--fg-3);
  transition: transform var(--dur) var(--ease);
}
.tm-advanced-details[open] > summary .i { transform: rotate(180deg); }

.tm-soft-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-hairline);
  background: var(--bg-surface);
  color: var(--fg);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur), color var(--dur);
}
.tm-soft-action-btn:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--line);
}
.tm-soft-action-btn:disabled { opacity: .45; cursor: not-allowed; }

.tm-info-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-subtle);
  color: var(--fg-2);
}
.tm-info-card .i {
  flex: none;
  margin-top: 2px;
  color: var(--accent-text);
}
.tm-info-card p {
  margin: 0;
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
  color: var(--fg-2);
}

.tm-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 0;
}
.tm-file-ic {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--fg-2);
  display: grid;
  place-items: center;
  flex: none;
}
.tm-file-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tm-file-info strong {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tm-file-info small {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}
.tm-file-acts {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.tm-field { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.tm-field-full { grid-column: 1 / -1; }
.tm-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tm-label { font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--fg-2); }
.tm-slider-val { font-size: var(--fs-xs); color: var(--fg-2); font-variant-numeric: tabular-nums; font-weight: var(--fw-medium); }
.tm-hint { font-size: var(--fs-xs); color: var(--fg-2); line-height: var(--lh-normal); margin: 0; }
.tm-hint-warn {
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--warning-weak);
  border: 0;
  font-size: var(--fs-xs);
  color: var(--warning);
  line-height: var(--lh-snug);
}

/* Interactive Layers Workbench */
.tm-layers-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 316px;
  gap: 14px;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 14px;
}
.tm-layers-canvas-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}
.tm-layers-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  max-height: 100%;
  margin: auto;
  max-width: 100%;
  border-radius: var(--r-md);
  border: 1px solid var(--line-hairline);
  overflow: hidden;
  background-color: var(--bg-surface);
  background-image:
    linear-gradient(45deg, var(--bg-subtle) 25%, transparent 25%),
    linear-gradient(-45deg, var(--bg-subtle) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--bg-subtle) 75%),
    linear-gradient(-45deg, transparent 75%, var(--bg-subtle) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.tm-layer-node {
  position: absolute;
  cursor: grab;
  border: 1px solid transparent;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.tm-layer-node:active { cursor: grabbing; }
.tm-layer-node.is-selected { border: 1.5px solid var(--accent); }
.tm-layer-node.is-hidden { opacity: 0; pointer-events: none; }
.tm-layer-node img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  user-select: none;
}
.tm-layers-stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.tm-layers-dim { font-size: var(--fs-xs); color: var(--fg-2); font-variant-numeric: tabular-nums; }
.tm-layers-stage-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tm-layers-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
}
.tm-layers-list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px;
}
.tm-layers-list-head span { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--fg); }
.tm-layers-list-head small { font-size: var(--fs-xs); color: var(--fg-3); }
.tm-layers-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding-right: 2px;
}
.tm-layer-row {
  display: grid;
  grid-template-columns: auto 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 9px;
  background: var(--bg-subtle);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur);
}
.tm-layer-row:hover { background: var(--bg-active); }
.tm-layer-row.is-selected {
  background: var(--bg-active);
  border-color: var(--accent-line);
}
.tm-layer-row.is-hidden { opacity: 0.56; }
.tm-layer-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--bg-surface);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.tm-layer-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tm-layer-meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tm-layer-name-inp {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--fg);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  padding: 1px 4px;
}
.tm-layer-name-inp:focus {
  outline: none;
  background: var(--bg-surface);
  border-color: var(--accent);
}
.tm-layer-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}
.tm-layer-ocr {
  align-self: flex-start;
  max-width: 100%;
  padding: 2px 6px;
  border-radius: 4px;
  border: 0;
  background: var(--bg-surface);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Vectorizer Studio Stage */
.tm-vector-controls { display: flex; flex-direction: column; gap: 12px; }
.tm-vector-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-surface);
}
[data-theme="dark"] .tm-vector-stage {
  background: var(--bg-subtle);
}
.tm-vec-hud-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px 6px;
  z-index: 4;
}
.tm-vec-hud-status,
.tm-vec-hud-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 11px;
  background: var(--bg-glass-strong);
  border: 1px solid var(--line-hairline);
  box-shadow: var(--shadow-pop);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.tm-vec-hud-status {
  padding: 4px 10px 4px 6px;
}
.tm-vec-hud-tools {
  gap: 2px;
  max-width: 100%;
}
.tm-vec-hud-tools .tm-bar-btn {
  height: 28px;
  padding: 0 9px;
  font-size: var(--fs-xs);
  white-space: nowrap;
}
.tm-vec-hud-tools .tm-bar-btn[aria-pressed="true"] {
  background: var(--bg-active);
  color: var(--fg);
  box-shadow: none;
  font-weight: var(--fw-semibold);
}
.tm-vec-status-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 7px;
  background: var(--success-weak);
  color: var(--success);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}
.tm-vec-path-count {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  white-space: nowrap;
}
.tm-vector-viewport {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  padding: 8px 18px 50px;
  overflow: hidden;
}
.tm-vector-viewport.is-zoomed {
  overflow: auto;
}
.tm-vector-viewport svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
  transform-origin: center center;
  transition: transform var(--dur-fast) var(--ease-out);
}
.tm-vec-ai-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--fg-3);
  font-size: var(--fs-sm);
  text-align: center;
  max-width: 320px;
}
.tm-vec-ai-empty .i { width: 28px; height: 28px; opacity: .7; }
.tm-vector-viewport.is-wireframe svg path,
.tm-vector-viewport.is-wireframe svg polygon,
.tm-vector-viewport.is-wireframe svg rect,
.tm-vector-viewport.is-wireframe svg circle {
  fill: transparent !important;
  stroke: var(--accent) !important;
  stroke-width: 1.2px !important;
}
.tm-vector-viewport.is-pick-erase svg path:hover,
.tm-vector-viewport.is-pick-erase svg polygon:hover {
  cursor: crosshair;
  opacity: 0.45;
}

/* Client Audio Separation Stage */
.tm-audiosep-controls { display: flex; flex-direction: column; gap: 12px; }
.tm-audiosep-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.tm-audiosep-meta > div {
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tm-audiosep-meta span { font-size: var(--fs-xs); color: var(--fg-3); }
.tm-audiosep-meta b { font-size: var(--fs-sm); color: var(--fg); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.tm-audiosep-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  height: 100%;
  padding: 14px;
  overflow-y: auto;
}
.tm-audiosep-progress {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
}
.tm-audiosep-prog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--fg-2);
  margin-bottom: 6px;
}
.tm-audiosep-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}
.tm-audiosep-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
}
.tm-audiosep-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.tm-audiosep-card-head strong { font-size: var(--fs-sm); color: var(--fg); }
.tm-audiosep-card-head span { font-size: var(--fs-xs); color: var(--fg-3); }
.tm-audiosep-video {
  width: 100%;
  max-height: 260px;
  border-radius: var(--r-sm);
  background: #000;
}
.tm-audiosep-audio { width: 100%; }
.tm-audiosep-card-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: auto; }
.tm-audiosep-placeholder {
  flex: 1 1 auto;
  min-height: 120px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  color: var(--fg-3);
  font-size: var(--fs-xs);
  text-align: center;
  padding: 12px;
}

/* Batch HD-Denoise Queue Grid */
.tm-batch-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  height: 100%;
  padding: 14px;
}
.tm-batch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--fg);
}
.tm-batch-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.tm-batch-item {
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.tm-batch-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-subtle);
}
.tm-batch-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tm-batch-badge {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 2px 6px;
  border-radius: var(--r-full);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  color: var(--fg);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}
.tm-batch-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
}
.tm-batch-name {
  min-width: 0;
  font-size: var(--fs-xs);
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 900px) {
  .tm-layers-workbench { grid-template-columns: 1fr; }
  .tm-audiosep-cards { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .tm-batch-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tm-style-stage { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .tm-layers-workbench { padding: 10px; }
  .tm-vector-stage { min-height: 260px; }
  .tm-vec-hud-bar { padding: 8px 8px 4px; gap: 6px; }
  .tm-vec-hud-tools { overflow-x: auto; scrollbar-width: none; }
  .tm-vec-hud-tools::-webkit-scrollbar { display: none; }
  .tm-vector-viewport { padding: 6px 12px 46px; }
  .tm-expand-stage-host { min-height: 280px; }
  .tm-expand-handle { width: 32px; height: 32px; }
  .tm-expand-bar { max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none; }
  .tm-expand-bar::-webkit-scrollbar { display: none; }
  .pop-panel.tm-tool-menu.is-grid:not([hidden]) { gap: 2px; }
  .tm-tool-menu .menu-item { padding: 7px 8px; gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .tm-vector-viewport svg,
  .tm-layer-node,
  .tm-anchor-cell,
  .tm-expand-canvas-box,
  .tm-expand-handle::after,
  .tm-expand-swap-btn,
  .tm-choice,
  .tm-select-trigger,
  .tm-seg > button { transition: none !important; }
}

/* ============================================================
   Seed Audio 1.0 / 1.5 Workspace, Voice Picker & Result Cards
   ============================================================ */
.audio-ws-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 0;
}

.audio-action-chip {
  height: 30px;
  font-size: var(--fs-xs);
  border: 1px solid var(--line-hairline);
  background: var(--bg-surface);
  color: var(--fg);
}
.audio-action-chip:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--line);
}

.audio-ref-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 6px 0 10px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
  font-size: var(--fs-xs);
  color: var(--fg);
  max-width: 240px;
}
.audio-ref-card.is-video {
  height: 36px;
  padding: 0 6px 0 4px;
  max-width: 260px;
}
.audio-ref-preview {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 100%;
  cursor: pointer;
  border-radius: var(--r-full);
}
.audio-ref-preview:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.audio-ref-vthumb {
  position: relative;
  width: 34px;
  height: 26px;
  border-radius: var(--r-full);
  overflow: hidden;
  flex: none;
  background: #151517;
}
.audio-ref-vthumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.audio-ref-vplay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(24, 26, 31, .35);
  color: #fff;
  pointer-events: none;
}
.audio-ref-vplay .i { width: 10px; height: 10px; }
.audio-ref-card.is-image img {
  width: 20px;
  height: 20px;
  border-radius: var(--r-xs);
  object-fit: cover;
}
.audio-ref-kind {
  color: var(--fg-3);
  font-weight: var(--fw-medium);
  flex: none;
}
.audio-ref-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-ref-dur {
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: var(--bg-surface);
  border: 1px solid var(--line-hairline);
  font-size: var(--fs-2xs);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}

.audio-slot-chip {
  display: inline-flex;
  align-items: center;
  height: 30px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  border: 1px solid var(--line-hairline);
  overflow: hidden;
  max-width: 210px;
}
.audio-slot-insert {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 100%;
  padding: 0 6px 0 10px;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-size: var(--fs-xs);
  cursor: pointer;
  min-width: 0;
}
.audio-slot-insert b {
  color: var(--accent-text);
  font-weight: var(--fw-semibold);
  flex: none;
}
.audio-slot-insert span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-slot-insert:hover {
  background: var(--bg-active);
}
.audio-slot-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 100%;
  border: 0;
  border-left: 1px solid var(--line-hairline);
  background: transparent;
  color: var(--fg-3);
  cursor: pointer;
}
.audio-slot-del:hover {
  color: var(--fg);
  background: var(--bg-active);
}

.audio-lang-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 4px 0 10px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  border: 1px solid var(--line-hairline);
}
.audio-lang-lbl {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  white-space: nowrap;
}
.audio-lang-select {
  height: 24px;
  border: 0;
  background: transparent;
  font-size: var(--fs-xs);
  padding: 0 20px 0 4px;
  min-width: 112px;
}

.audio-stem-pills,
.tm-stem-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.audio-stem-chip,
.tm-stem-chip {
  height: 28px;
  padding: 0 10px;
  font-size: var(--fs-xs);
  border: 1px solid var(--line-hairline);
  background: var(--bg-surface);
  color: var(--fg-2);
}
.audio-stem-chip[aria-pressed="true"],
.tm-stem-chip[aria-pressed="true"] {
  background: var(--bg-active);
  color: var(--fg);
  border-color: var(--line);
  font-weight: var(--fw-medium);
}

/* Parameter Panel Controls */
.audio-param-section {
  display: grid;
  gap: 12px;
  min-width: 264px;
}
.audio-lock-note {
  font-size: var(--fs-2xs);
  color: var(--fg-3);
  font-weight: var(--fw-regular);
}
.audio-slider-grid {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
}
.audio-slider-row {
  display: grid;
  gap: 4px;
}
.audio-slider-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-xs);
  color: var(--fg-2);
}
.audio-slider-head b {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.audio-slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.audio-toggle-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.audio-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--fg-2);
  cursor: pointer;
}
.audio-check input[type="checkbox"] {
  accent-color: var(--accent);
}
.audio-glossary-list {
  display: grid;
  gap: 6px;
}
.audio-glossary-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center;
  gap: 6px;
}
.audio-glossary-row .input {
  height: 30px;
  font-size: var(--fs-xs);
}
.audio-gloss-arrow {
  font-size: var(--fs-xs);
  color: var(--fg-3);
}
.audio-hint-muted {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

/* Doubao Voice Picker Dialog */
.audio-voice-dialog {
  width: min(720px, calc(100vw - 24px));
  max-height: min(82vh, 720px);
  padding: 18px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-hairline);
  background: var(--bg-elevated);
  color: var(--fg);
  box-shadow: var(--shadow-pop);
  display: grid;
  grid-template-rows: auto auto auto minmax(180px, 1fr) auto;
  gap: 12px;
}
.audio-voice-dialog:not([open]) {
  display: none;
}
.audio-voice-dialog::backdrop {
  background: var(--overlay);
}
.audio-voice-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.audio-voice-head h3 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
}
.audio-voice-head p {
  margin: 4px 0 0;
  font-size: var(--fs-xs);
  color: var(--fg-3);
}
.audio-voice-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.audio-voice-search {
  flex: 1 1 200px;
  height: 34px;
  font-size: var(--fs-sm);
}
.audio-voice-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.audio-voice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-right: 4px;
}
.audio-voice-item {
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-hairline);
  background: var(--bg-surface);
  color: var(--fg);
  cursor: pointer;
  display: grid;
  gap: 4px;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.audio-voice-item:hover {
  background: var(--bg-subtle);
  border-color: var(--line);
}
.audio-voice-item.is-selected {
  background: var(--bg-active);
  border-color: var(--accent);
}
.avd-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: var(--fs-sm);
}
.avd-gender {
  font-size: var(--fs-2xs);
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-2);
}
.avd-item-desc {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-voice-empty {
  grid-column: 1 / -1;
  padding: 36px 12px;
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--fg-3);
}
.audio-voice-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line-hairline);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

/* Studio Audio Feed Result Cards */
.audio-result-wrap {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  max-width: 660px;
}
.audio-track-card {
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-hairline);
  background: var(--bg-surface);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.audio-track-card audio {
  display: none;
}
.audio-track-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.audio-track-ident {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.audio-track-ic {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--bg-subtle);
  color: var(--fg-2);
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}
.audio-track-card.is-playing .audio-track-ic {
  background: var(--accent-weak);
  color: var(--accent-text);
}
.audio-track-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.audio-track-name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--fg);
  line-height: var(--lh-tight);
}
.audio-meta-pill {
  padding: 2px 7px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  border: 0;
  font-size: var(--fs-2xs);
  line-height: var(--lh-tight);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}
.audio-track-tools {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
}
.audio-tool-pill {
  height: 26px;
  padding: 0 8px;
  border-radius: var(--r-xs);
  border: 0;
  background: transparent;
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}
.audio-tool-pill:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
.audio-wave-player {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.audio-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
  color: var(--fg);
  border: 1px solid var(--line-hairline);
  box-shadow: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}
.audio-play-btn:hover {
  background: var(--accent-weak);
  color: var(--accent-text);
  border-color: var(--accent-line);
}
.audio-track-card.is-playing .audio-play-btn {
  background: var(--accent);
  color: var(--fg-inverse);
  border-color: transparent;
}
.audio-play-btn .i {
  width: 14px;
  height: 14px;
}
.audio-wave-track {
  flex: 1 1 auto;
  min-width: 0;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}
.audio-wave-track i {
  flex: 1;
  height: var(--bar);
  min-width: 2px;
  border-radius: 2px;
  background: var(--line-strong);
  transition: background var(--dur-instant) var(--ease-standard);
}
.audio-wave-track i.is-played {
  background: var(--accent);
}
.audio-wave-time {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: none;
}
.audio-track-card .audio-result-actions {
  border-top: 1px solid var(--line-hairline);
  padding-top: 6px;
  margin-top: 0;
}
.audio-subtitles-row {
  display: grid;
  gap: 6px;
}
.audio-subtitle-card {
  border-radius: var(--r-md);
  border: 1px solid var(--line-hairline);
  background: var(--bg-surface);
  box-shadow: none;
  padding: 9px 12px;
}
.audio-subtitle-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-size: var(--fs-xs);
  color: var(--fg-2);
  list-style: none;
}
.audio-subtitle-card summary::-webkit-details-marker {
  display: none;
}
.audio-sub-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--fg);
  font-weight: var(--fw-medium);
}
.audio-sub-chev {
  color: var(--fg-3);
  flex: none;
  transition: transform var(--dur-fast) var(--ease-standard);
}
.audio-subtitle-card[open] .audio-sub-chev {
  transform: rotate(90deg);
}
.audio-sub-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.audio-sub-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 7px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--fg-2);
  font-size: var(--fs-xs);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}
.audio-sub-btn:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
.audio-subtitle-pre {
  margin: 8px 0 0;
  padding: 8px 10px;
  max-height: 180px;
  overflow: auto;
  border-radius: var(--r-xs);
  background: var(--bg-subtle);
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  color: var(--fg-2);
  white-space: pre-wrap;
}
.audio-settle-badge {
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}

/* Native Audio Composer Controls (Home & Studio) */
.audio-refs-row {
  padding-top: 10px;
}
.audio-toolbar-slot,
.audio-toolbar-inner {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}
.composer:has(.audio-at-menu:not([hidden])) {
  z-index: 30;
}
.audio-at-menu {
  position: absolute;
  left: 16px;
  bottom: calc(100% + 8px);
  z-index: 60;
  width: min(320px, calc(100% - 32px));
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  border: 1px solid var(--line-hairline);
  box-shadow: var(--shadow-pop);
}
.audio-at-menu[data-side="bottom"] {
  bottom: auto;
  top: calc(100% + 8px);
}
.audio-at-menu .menu-item.is-active {
  background: var(--bg-active);
  color: var(--fg);
}
.audio-at-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.audio-at-badge {
  flex: none;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--accent-weak);
  color: var(--accent-text);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
}
.audio-pop-empty {
  padding: 10px 12px;
  font-size: var(--fs-xs);
  color: var(--fg-3);
  text-align: center;
}
.audio-lang-pop {
  width: 248px;
  padding: 8px;
}
.audio-lang-search-wrap {
  padding-bottom: 6px;
}
.audio-lang-search {
  height: 32px;
  font-size: var(--fs-xs);
}
.audio-lang-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.audio-stem-pop {
  min-width: 184px;
}

@media (max-width: 767px) {
  .audio-ws-bar { padding: 8px 12px 0; gap: 6px; }
  .audio-voice-dialog { padding: 14px; }
  .audio-voice-grid { grid-template-columns: 1fr; }
  .audio-toolbar-slot,
  .audio-toolbar-inner { flex-wrap: nowrap; gap: 4px; }
  .audio-at-menu { left: 8px; width: calc(100% - 16px); }
}
@media (prefers-reduced-motion: reduce) {
  .audio-voice-item { transition: none !important; }
}

/* Cross-modal result action bars & Agent audio_result card */
.audio-result-actions,
.studio-video-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding-top: 2px;
}

.audio-result-actions .btn,
.studio-video-actions .btn {
  --h: 26px;
  padding: 0 8px;
  font-size: var(--fs-xs);
  gap: 4px;
  border-radius: var(--r-xs);
  color: var(--fg-2);
}

.audio-result-actions .btn .i,
.studio-video-actions .btn .i {
  width: 13px;
  height: 13px;
}

.audio-result-actions .btn:hover,
.studio-video-actions .btn:hover {
  color: var(--fg);
}

.tm-audiosep-stage-foot {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.agent-audio-card {
  max-width: 560px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-hairline);
  background: var(--bg-surface);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-audio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.agent-audio-ident {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.agent-audio-ic {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--bg-subtle);
  color: var(--fg-2);
}

.agent-audio-card.is-pending .agent-audio-ic {
  background: var(--accent-weak);
  color: var(--accent-text);
}

.agent-audio-card.is-failed .agent-audio-ic {
  background: var(--danger-weak);
  color: var(--danger);
}

.agent-audio-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.agent-audio-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  color: var(--fg);
}

.agent-audio-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-size: var(--fs-xs);
  line-height: var(--lh-tight);
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.agent-audio-cost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--fg-2);
}

.agent-audio-cost .credit-star {
  width: 12px;
  height: 12px;
}

.agent-audio-studio-link {
  flex: none;
}

.agent-audio-prompt {
  margin: 0;
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
  color: var(--fg-2);
}

.agent-audio-pending {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
}

.agent-audio-pending-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.agent-audio-pending-status {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex-wrap: wrap;
}

.agent-audio-eq {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 12px;
  flex: none;
}

.agent-audio-eq i {
  display: block;
  width: 2px;
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transform-origin: bottom center;
  animation: agentAudioEq 0.9s var(--ease-standard) infinite alternate;
}

.agent-audio-eq i:nth-child(1) { animation-delay: 0s; height: 55%; }
.agent-audio-eq i:nth-child(2) { animation-delay: 0.18s; height: 100%; }
.agent-audio-eq i:nth-child(3) { animation-delay: 0.36s; height: 70%; }
.agent-audio-eq i:nth-child(4) { animation-delay: 0.12s; height: 85%; }

@keyframes agentAudioEq {
  0% { transform: scaleY(0.35); opacity: 0.65; }
  100% { transform: scaleY(1); opacity: 1; }
}

.agent-audio-state {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--fg);
}

.agent-audio-elapsed {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.agent-audio-pending-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.agent-audio-pct {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}

.agent-audio-cancel {
  height: 24px;
  padding: 0 8px;
}

.agent-audio-bar {
  width: 100%;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--bg-muted);
  overflow: hidden;
}

.agent-audio-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease-standard);
}

.agent-audio-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--danger-weak);
  color: var(--danger);
  font-size: var(--fs-xs);
}

.agent-audio-error .i {
  flex: none;
  margin-top: 1px;
}

.agent-audio-error-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.agent-audio-error-body strong {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

.agent-audio-error p {
  margin: 0;
  color: var(--fg-2);
  line-height: var(--lh-snug);
}

.agent-audio-card .audio-result-wrap {
  margin-top: 0;
  max-width: none;
}

.agent-audio-card .audio-track-card,
.agent-audio-card .audio-subtitle-card {
  border: 0;
  background: var(--bg-subtle);
  padding: 10px 12px;
  border-radius: var(--r-sm);
}

.agent-audio-card .audio-track-ic,
.agent-audio-card .audio-meta-pill,
.agent-audio-card .audio-track-card:not(.is-playing) .audio-play-btn,
.agent-audio-card .audio-subtitle-pre {
  background: var(--bg-surface);
}

.cv-ai-drawer .agent-audio-card {
  max-width: 100%;
  padding: 10px 12px;
}

@media (max-width: 767px) {
  .audio-result-actions,
  .studio-video-actions {
    gap: 2px;
  }
  .audio-track-card {
    padding: 12px;
  }
  .audio-sub-btn span {
    display: none;
  }
  .agent-audio-card {
    max-width: 100%;
    padding: 10px 12px;
  }
  .agent-audio-studio-link span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .agent-audio-eq i {
    animation: none !important;
  }
  .agent-audio-bar > span,
  .audio-play-btn,
  .audio-wave-track i,
  .audio-sub-chev {
    transition: none !important;
  }
}

.skills-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.skills-card-cat {
  font-size: var(--fs-2xs);
  color: var(--fg-3);
  margin-top: 2px;
}
.skill-pkg-tag {
  flex: none;
  font-size: var(--fs-2xs);
  line-height: 16px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--line-hairline);
  color: var(--fg-3);
}
@media (max-width: 640px) {
  .skills-hero-actions { width: 100%; justify-content: flex-start; }
}
