/*
 * 批量主图内容区组件：不影响应用壳、侧边菜单、顶部栏或三栏尺寸。
 * 使用 .generic-production-form 锁定批量主图，避免影响 SKU / 白底 / 详情等生产页面。
 */
@supports selector(.production-workspace:has(.generic-production-form)) {
  .production-workspace:has(.generic-production-form) {
    --batch-blue: #1760ff;
    --batch-blue-soft: #eaf0ff;
    --batch-coral: #ff5c3a;
    --batch-lime: #c4f34d;
    --batch-violet: #8056ef;
    --batch-card-line: #e3eaf6;
    --batch-card-shadow: 0 10px 28px rgb(32 73 145 / 7%);
    --batch-copy: #171b31;
    --batch-muted: #6e7894;
  }

  /* 内容区三类承载组件：历史、制作参数和生成画布。 */
  html[data-theme="light"] .production-workspace:has(.generic-production-form) .production-history:not(.collapsed),
  html[data-theme="light"] .production-workspace:has(.generic-production-form) .production-rail,
  html[data-theme="light"] .production-workspace:has(.generic-production-form) .production-stage-body {
    border: 1px solid var(--batch-card-line) !important;
    border-radius: 17px;
    box-shadow: var(--batch-card-shadow);
  }

  html[data-theme="light"] .production-workspace:has(.generic-production-form) .production-history:not(.collapsed),
  html[data-theme="light"] .production-workspace:has(.generic-production-form) .production-rail {
    background: rgb(255 255 255 / 92%);
  }

  html[data-theme="light"] .production-workspace:has(.generic-production-form) .production-stage-body {
    position: relative;
    isolation: isolate;
    background-color: #fbfcff !important;
    background-image:
      radial-gradient(circle at 1px 1px, rgb(23 96 255 / 7%) 1px, transparent 1.15px),
      linear-gradient(180deg, rgb(23 96 255 / 3%), transparent 32%) !important;
    background-size: 18px 18px, 100% 100% !important;
  }

  html[data-theme="light"] .production-workspace:has(.generic-production-form) :is(.production-history, .production-rail-scroll) {
    color-scheme: light;
    scrollbar-color: #b8c5dc transparent;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) :is(.production-history:not(.collapsed), .production-rail) {
    border-color: rgb(165 172 188 / 24%);
  }

  .production-workspace:has(.generic-production-form) .production-history h2,
  .production-workspace:has(.generic-production-form) .production-rail-scroll::before,
  .production-workspace:has(.generic-production-form) .production-result-empty h2 {
    color: var(--batch-copy);
    font-weight: 750;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) :is(.production-history h2, .production-rail-scroll::before, .production-result-empty h2) {
    color: #f4f6fc;
  }

  /*
   * 批量主图与 SKU 场景图共用 ManagedTaskHistory 的数据、搜索、选中、删除与结果加载。
   * 此处仅让批量主图回用 SKU 的任务列表视觉规格，避免留下另一套卡片和检索控件。
   */
  .production-workspace:has(.generic-production-form) .production-history {
    --production-history-card: var(--surface-alt);
    --production-history-card-hover: #eef1f5;
    --production-history-line: #dde3eb;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-history {
    --production-history-card: #242424;
    --production-history-card-hover: #2b2b2b;
    --production-history-line: #3f3f3f;
  }

  .production-workspace:has(.generic-production-form) .production-history-list {
    row-gap: 10px;
  }

  .production-workspace:has(.generic-production-form) .production-history-item {
    border-color: var(--production-history-line);
    border-radius: 6px;
    background: var(--production-history-card);
    box-shadow: none;
    transition: border-color .2s ease, background-color .2s ease;
  }

  .production-workspace:has(.generic-production-form) .production-history-item.active {
    border-color: color-mix(in srgb, var(--production-accent) 35%, var(--production-history-line));
    background: var(--production-selected);
    box-shadow: inset 3px 0 0 var(--production-accent);
  }

  .production-workspace:has(.generic-production-form) .production-history-item:hover:not(.active) {
    border-color: var(--line-strong);
    background: var(--production-history-card-hover);
    transform: none;
  }

  /* SKU 同款搜索栏：保持图标与占位文案在同一基线，给列表保留清晰间距。 */
  .production-workspace:has(.generic-production-form) .production-history-toolbar {
    margin: 14px 0 16px !important;
  }

  .production-workspace:has(.generic-production-form) .production-history-search {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    gap: 7px;
    height: 36px;
    min-height: 36px;
    padding: 0 9px;
    border-radius: 6px;
  }

  .production-workspace:has(.generic-production-form) .production-history-search svg {
    align-self: center;
    flex: 0 0 auto;
    margin: 0;
  }

  .production-workspace:has(.generic-production-form) .production-history-search input {
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    font-size: 12px;
  }

  .production-workspace:has(.generic-production-form) .production-history-search:focus-within {
    border-color: var(--production-accent) !important;
    box-shadow: none;
  }

  /* 右侧字段统一为轻量组件；字段、顺序和事件均由既有运行时控制。 */
  .production-workspace:has(.generic-production-form) .production-rail .production-panel > summary {
    color: var(--batch-copy);
    font-weight: 730;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .production-panel > summary {
    color: #f4f6fc;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-history-search:focus-within {
    border-color: var(--production-accent) !important;
    box-shadow: none;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail :is(input:not([type="file"]), select, textarea):focus {
    border-color: var(--production-accent) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--production-accent) 18%, transparent);
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) :is(button, input, select, textarea):focus-visible {
    outline-color: var(--production-accent);
  }

  .production-workspace:has(.generic-production-form) .production-rail :is(input:not([type="file"]), select, textarea) {
    border-color: color-mix(in srgb, var(--batch-card-line) 88%, var(--batch-blue));
    border-radius: 10px;
    transition: border-color .2s ease, box-shadow .2s ease;
  }

  .production-workspace:has(.generic-production-form) .production-rail :is(input:not([type="file"]), select, textarea):focus {
    border-color: var(--batch-blue);
    box-shadow: 0 0 0 3px rgb(23 96 255 / 12%);
  }

  .production-workspace:has(.generic-production-form) .production-rail .template-picker-trigger {
    border-color: rgb(23 96 255 / 46%);
    border-radius: 10px;
    background: linear-gradient(135deg, rgb(23 96 255 / 11%), rgb(128 86 239 / 8%));
    color: var(--batch-copy);
    font-weight: 680;
    transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .template-picker-trigger {
    color: #f4f6fc;
  }

  .production-workspace:has(.generic-production-form) .production-rail .template-picker-trigger:hover {
    border-color: var(--batch-blue);
    box-shadow: 0 7px 18px rgb(23 96 255 / 14%);
    transform: translateY(-2px);
  }

  .production-workspace:has(.generic-production-form) .production-rail .production-clear-row > button:not(.template-picker-trigger) {
    border: 1px solid rgb(255 92 58 / 44%);
    border-radius: 9px;
    background: rgb(255 92 58 / 8%);
    color: var(--batch-coral);
    font-weight: 700;
    transition: border-color .2s ease, background-color .2s ease, transform .2s ease;
  }

  .production-workspace:has(.generic-production-form) .production-rail .production-clear-row > button:not(.template-picker-trigger):hover {
    border-color: var(--batch-coral);
    background: rgb(255 92 58 / 15%);
    transform: translateY(-2px);
  }

  .production-workspace:has(.generic-production-form) .production-rail .production-upload-single-entry {
    border-color: rgb(23 96 255 / 34%);
    background: linear-gradient(145deg, rgb(23 96 255 / 4%), transparent 54%);
  }

  .production-workspace:has(.generic-production-form) .production-rail .production-upload-add {
    border-color: rgb(23 96 255 / 66%);
    border-radius: 12px;
    background: var(--batch-blue);
    color: #fff;
    box-shadow: 0 8px 18px rgb(23 96 255 / 21%);
    transition: transform .2s ease, background-color .2s ease, box-shadow .2s ease;
  }

  .production-workspace:has(.generic-production-form) .production-rail .production-upload-add:hover {
    background: #2e72ff;
    box-shadow: 0 11px 24px rgb(23 96 255 / 30%);
    transform: translateY(-2px);
  }

  .production-workspace:has(.generic-production-form) .production-rail .production-submit .primary.production-top-action:not(:disabled) {
    border-color: var(--batch-blue) !important;
    border-radius: 11px;
    background: var(--batch-blue) !important;
    color: #fff !important;
    box-shadow: 0 9px 21px rgb(23 96 255 / 25%);
  }

  .production-workspace:has(.generic-production-form) .production-rail .production-submit .primary.production-top-action:not(:disabled):hover {
    background: #2e72ff !important;
    transform: translateY(-2px);
  }

  /* 生成空状态为独立组件，不改变中间画布的尺寸或位置。 */
  .production-workspace:has(.generic-production-form) .production-result-empty .production-empty-art {
    position: relative;
    z-index: 1;
    width: 76px;
    height: 76px;
    border-color: rgb(23 96 255 / 52%);
    border-radius: 16px;
    background: linear-gradient(145deg, rgb(23 96 255 / 16%), rgb(128 86 239 / 12%));
    color: var(--batch-blue);
    box-shadow: 0 10px 26px rgb(23 96 255 / 12%);
  }

  .production-workspace:has(.generic-production-form) .production-result-empty {
    position: relative;
    isolation: isolate;
  }

  html[data-theme="light"] .production-workspace:has(.generic-production-form) .production-result-empty::before {
    position: absolute;
    z-index: 0;
    width: min(460px, calc(100% - 44px));
    height: min(292px, calc(100% - 52px));
    border: 1px solid rgb(23 96 255 / 10%);
    border-radius: 24px;
    background:
      radial-gradient(circle at 15% 20%, rgb(196 243 77 / 24%) 0 11px, transparent 12px),
      radial-gradient(circle at 84% 77%, rgb(255 92 58 / 17%) 0 13px, transparent 14px),
      rgb(255 255 255 / 74%);
    box-shadow: 0 16px 34px rgb(48 72 126 / 7%);
    content: '';
    pointer-events: none;
  }

  .production-workspace:has(.generic-production-form) .production-result-empty :is(.production-empty-copy, .production-empty-steps) {
    position: relative;
    z-index: 1;
  }

  .production-workspace:has(.generic-production-form) .production-result-empty h2 {
    margin-top: 4px;
    font-size: 22px;
    line-height: 1.35;
    letter-spacing: -.02em;
  }

  .production-workspace:has(.generic-production-form) .production-result-empty p { font-size: 13px; }
  .production-workspace:has(.generic-production-form) .production-result-empty .production-empty-steps { font-size: 12px; }

  .production-workspace:has(.generic-production-form) .production-result-empty .production-empty-steps span:first-child { color: var(--batch-blue); }
  .production-workspace:has(.generic-production-form) .production-result-empty .production-empty-steps span:last-child { color: #65a51e; }
  .production-workspace:has(.generic-production-form) .production-result-empty .production-empty-steps i { color: var(--batch-violet); font-style: normal; }

  .production-workspace:has(.generic-production-form) :is(button, input, select, textarea):focus-visible,
  .template-picker-dialog--main :is(button, input):focus-visible {
    outline: 2px solid var(--batch-lime);
    outline-offset: 2px;
  }

  .production-workspace:has(.generic-production-form) button:active:not(:disabled) { transform: translateY(1px); }

  /* 深色批量主图：沿用系统暗色表面，只收敛右侧参数组件与生成空状态。 */
  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail {
    background: var(--surface, #191919) !important;
    border-color: var(--line, #363636) !important;
    border-radius: 10px;
    box-shadow: none;
    color: var(--ink, #f4f6fc);
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail-scroll {
    color-scheme: dark;
    scrollbar-color: var(--line-strong, #4a4a4a) transparent;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail-scroll::before {
    margin-bottom: 14px;
    color: var(--ink, #f4f6fc);
    font-size: 16px;
    font-weight: 700;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .production-panel {
    border-bottom-color: var(--line, #363636) !important;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .production-panel > summary {
    color: var(--ink, #f4f6fc);
    font-weight: 700;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail :is(label, p, .production-reference-note) {
    color: var(--muted, #a5acbc);
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail :is(input:not([type="file"]), select, textarea) {
    border-color: var(--line-strong, #4a4a4a);
    background: var(--panel-soft, #141414);
    box-shadow: none;
    color: var(--ink, #f4f6fc);
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail :is(input:not([type="file"]), select, textarea)::placeholder {
    color: color-mix(in srgb, var(--muted, #a5acbc) 74%, transparent);
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail :is(input:not([type="file"]), select, textarea):focus {
    border-color: var(--production-accent, #fa6f08) !important;
    box-shadow: 0 0 0 1px var(--production-accent, #fa6f08) !important;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .template-picker-trigger {
    border-color: var(--line-strong, #4a4a4a);
    background: var(--panel-soft, #141414);
    box-shadow: none;
    color: var(--ink, #f4f6fc);
    font-weight: 600;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .template-picker-trigger:hover {
    border-color: var(--production-accent, #fa6f08);
    box-shadow: none;
    transform: none;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .production-clear-row > button:not(.template-picker-trigger) {
    border-color: transparent;
    background: transparent;
    color: var(--production-accent, #fa6f08);
    box-shadow: none;
    font-weight: 650;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .production-clear-row > button:not(.template-picker-trigger):hover {
    border-color: transparent;
    background: color-mix(in srgb, var(--production-accent, #fa6f08) 10%, transparent);
    transform: none;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .production-upload-single-entry {
    border-color: var(--line, #363636);
    background: var(--panel-soft, #141414);
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .production-upload-add {
    border-color: var(--line-strong, #4a4a4a);
    border-radius: 8px;
    background: var(--surface-alt, #242424);
    box-shadow: none;
    color: var(--muted, #a5acbc);
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .production-upload-add:hover {
    border-color: var(--production-accent, #fa6f08);
    background: var(--surface-alt, #242424);
    box-shadow: none;
    color: var(--ink, #f4f6fc);
    transform: none;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .production-submit {
    border-top-color: var(--line, #363636);
    background: var(--surface, #191919);
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .production-submit .primary.production-top-action:not(:disabled) {
    border-color: var(--batch-blue) !important;
    background: var(--batch-blue) !important;
    box-shadow: none;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .production-submit .primary.production-top-action:not(:disabled):hover {
    background: #2e72ff !important;
    transform: none;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-rail .production-submit .primary.production-top-action:disabled {
    border-color: var(--ui-disabled-bg, #2b2b2b) !important;
    background: var(--ui-disabled-bg, #2b2b2b) !important;
    box-shadow: none;
    color: var(--muted, #a5acbc) !important;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-result-empty .production-empty-art {
    width: 68px;
    height: 68px;
    border-color: var(--line, #363636);
    border-radius: 16px;
    background: var(--surface-alt, #242424);
    box-shadow: none;
    color: var(--muted, #a5acbc);
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-result-empty h2 {
    margin-top: 8px;
    color: var(--ink, #f4f6fc);
    font-size: 20px;
    letter-spacing: 0;
  }

  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-result-empty p,
  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-result-empty .production-empty-steps,
  html[data-theme="dark"] .production-workspace:has(.generic-production-form) .production-result-empty .production-empty-steps :is(span:first-child, span:last-child, i) {
    color: var(--muted, #a5acbc);
  }
}

/* 批量主图专用模板选择器。SKU 继续使用原有的选择弹窗与行为。 */
.template-picker-dialog--main {
  --batch-blue: #1760ff;
  --batch-coral: #ff5c3a;
  --batch-lime: #c4f34d;
  --batch-violet: #8056ef;
  --template-panel: #fff;
  --template-soft: #f7f9fe;
  --template-line: #e3eaf6;
  --template-ink: #171b31;
  --template-muted: #6e7894;
  display: flex;
  flex-direction: column;
  width: min(980px, calc(100vw - 48px));
  height: min(640px, calc(100dvh - 32px));
  min-height: 0;
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--template-line);
  border-radius: 17px;
  background: var(--template-panel);
  color: var(--template-ink);
  box-shadow: 0 26px 82px rgb(19 34 65 / 24%);
}

.template-picker-dialog--main::backdrop {
  background: rgb(36 48 70 / 22%);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

html[data-theme="dark"] .template-picker-dialog--main {
  /* 深色模式沿用全局系统表面色，不在弹窗中另起一套黑灰。 */
  --template-panel: var(--surface);
  --template-soft: var(--surface-alt);
  --template-line: var(--line);
  --template-ink: var(--ink);
  --template-muted: var(--muted);
  box-shadow: 0 24px 90px var(--shadow-color);
}

html[data-theme="dark"] .template-picker-dialog--main::backdrop { background: var(--overlay); }

/* 弹窗属于生产页面的选择器，深色态仍使用产品现有的系统橙色。 */
html[data-theme="dark"] .template-picker-dialog--main .template-library-filter[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
}

html[data-theme="dark"] .template-picker-dialog--main .template-library-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

html[data-theme="dark"] .template-picker-dialog--main .template-library-item[aria-selected="true"] {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--template-line));
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}

html[data-theme="dark"] .template-picker-dialog--main :is(button, input):focus-visible {
  outline-color: var(--accent);
}

.template-library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--template-line);
}

.template-library-header > div { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.template-library-header h2 { margin: 0; color: var(--template-ink); font-size: 20px; line-height: 1.35; }
.template-library-total { color: var(--template-muted); font-size: 13px; white-space: nowrap; }
.template-library-close { width: 34px; min-width: 34px; min-height: 34px; padding: 0; border-color: transparent; background: transparent; color: var(--template-muted); font-size: 25px; font-weight: 300; line-height: 1; }
.template-library-close:hover { background: var(--template-soft); color: var(--template-ink); }

.template-library-body { display: grid; grid-template-columns: 310px minmax(0, 1fr); flex: 1 1 auto; min-height: 0; max-height: none; }
.template-library-sidebar { display: flex; flex-direction: column; min-width: 0; padding: 16px; border-right: 1px solid var(--template-line); background: color-mix(in srgb, var(--template-soft) 62%, transparent); }
.template-library-filter-group + .template-library-filter-group { margin-top: 10px; }
.template-library-filter-group > span { display: block; margin: 0 0 6px; color: var(--template-muted); font-size: 11px; font-weight: 700; }
.template-library-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.template-library-filter { min-height: 28px; padding: 4px 8px; border: 1px solid var(--template-line); border-radius: 8px; background: var(--template-panel); color: var(--template-muted); font-size: 11px; line-height: 1.2; }
.template-library-filter:hover { border-color: rgb(23 96 255 / 45%); color: var(--template-ink); }
.template-library-filter[aria-pressed="true"] { border-color: var(--batch-blue, #1760ff); background: var(--batch-blue, #1760ff); color: #fff; font-weight: 700; }
.template-picker-dialog--main .template-library-search { display: flex; flex-direction: row !important; align-items: center !important; justify-content: flex-start; box-sizing: border-box; gap: 7px; height: 38px; min-height: 38px; margin: 14px 0 10px; padding: 0 10px; border: 1px solid var(--template-line); border-radius: 10px; background: var(--template-panel); color: var(--template-muted); }
.template-library-search:focus-within { border-color: var(--batch-lime, #c4f34d); box-shadow: 0 0 0 3px rgb(196 243 77 / 18%); }
.template-library-search svg { align-self: center; flex: 0 0 auto; width: 15px; height: 15px; margin: 0; stroke: currentColor; stroke-width: 1.8; }
.template-picker-dialog--main .template-library-search input { width: 100%; min-width: 0; min-height: 0 !important; height: auto !important; margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; outline: 0; box-shadow: none !important; background: transparent !important; color: var(--template-ink); font: inherit; font-size: 12px; line-height: 18px; }
.template-library-search input:focus-visible { outline: 0 !important; }
.template-library-search input::placeholder { color: var(--template-muted); }
.template-library-list { display: grid; align-content: start; gap: 7px; min-height: 0; overflow: auto; padding: 2px 3px 6px 0; }
.template-library-item { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: start; gap: 10px; width: 100%; padding: 10px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--template-ink); text-align: left; transition: background-color .2s ease, border-color .2s ease, transform .2s ease; }
.template-library-item:hover { border-color: var(--template-line); background: var(--template-panel); transform: translateY(-1px); }
.template-library-item[aria-selected="true"] { border-color: rgb(23 96 255 / 38%); background: rgb(23 96 255 / 8%); box-shadow: inset 3px 0 0 var(--batch-blue, #1760ff); }
.template-library-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; }
.template-library-icon svg { width: 19px; height: 19px; }
.template-icon--blue { background: #e7efff; color: var(--batch-blue, #1760ff); }
.template-icon--violet { background: #eee9ff; color: var(--batch-violet, #8056ef); }
.template-icon--lime { background: #edf9cc; color: #629c18; }
.template-icon--coral { background: #ffebe6; color: var(--batch-coral, #ff5c3a); }
.template-library-item-copy { display: grid; min-width: 0; gap: 2px; }
.template-library-item strong { overflow: hidden; color: var(--template-ink); font-size: 13px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.template-library-item small { overflow: hidden; color: var(--template-muted); font-size: 11px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.template-library-item-excerpt { display: -webkit-box; overflow: hidden; color: var(--template-muted); font-size: 11px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.template-library-empty { margin: 24px 0; padding: 18px 10px; border: 1px dashed var(--template-line); border-radius: 10px; color: var(--template-muted); font-size: 12px; text-align: center; }

.template-library-detail { display: flex; flex-direction: column; min-width: 0; padding: 22px; }
.template-library-detail > header > span { color: var(--batch-blue, #1760ff); font-size: 12px; font-weight: 750; }
.template-library-detail h3 { margin: 6px 0 0; color: var(--template-ink); font-size: 22px; line-height: 1.35; }
.template-library-tags { display: flex; flex-wrap: wrap; gap: 7px; min-height: 30px; margin: 16px 0; }
.template-library-tag { display: inline-flex; align-items: center; min-height: 27px; padding: 4px 9px; border-radius: 8px; font-size: 11px; font-weight: 700; }
.template-library-tag--0 { background: #e7efff; color: var(--batch-blue, #1760ff); }
.template-library-tag--1 { background: #edf9cc; color: #629c18; }
.template-library-tag--2 { background: #ffebe6; color: var(--batch-coral, #ff5c3a); }
.template-library-tag--3 { background: #eee9ff; color: var(--batch-violet, #8056ef); }
.template-library-prompt-panel { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; overflow: hidden; border: 1px solid var(--template-line); border-radius: 12px; background: var(--template-soft); }
.template-library-prompt-panel > strong { display: block; padding: 12px 14px; border-bottom: 1px solid var(--template-line); color: var(--template-ink); font-size: 12px; }
.template-library-prompt-panel pre { flex: 1 1 auto; min-height: 210px; margin: 0; overflow: auto; padding: 14px; color: var(--template-ink); white-space: pre-wrap; font: 13px/1.8 var(--font, inherit); }
.template-library-detail-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; }
.template-library-status { min-width: 0; color: var(--template-muted); font-size: 11px; line-height: 1.5; }
.template-library-detail-footer > div { display: flex; flex: 0 0 auto; gap: 9px; }
.template-library-detail-footer button { min-width: 104px; min-height: 36px; border-radius: 10px; font-size: 12px; font-weight: 700; }
.template-library-cancel { border-color: var(--template-line); background: var(--template-panel); color: var(--template-ink); }
.template-library-cancel:hover { border-color: rgb(23 96 255 / 40%); background: var(--template-soft); }
.template-library-apply { border-color: var(--batch-blue, #1760ff) !important; background: var(--batch-blue, #1760ff) !important; color: #fff !important; box-shadow: 0 7px 18px rgb(23 96 255 / 20%); }
.template-library-apply:hover:not(:disabled) { background: #2e72ff !important; }
.template-library-apply:disabled { box-shadow: none; }

html[data-theme="dark"] .template-picker-dialog--main .template-icon--blue,
html[data-theme="dark"] .template-picker-dialog--main .template-library-tag--0 { background: rgb(23 96 255 / 20%); color: #a9c2ff; }
html[data-theme="dark"] .template-picker-dialog--main .template-icon--violet,
html[data-theme="dark"] .template-picker-dialog--main .template-library-tag--3 { background: rgb(128 86 239 / 20%); color: #c7b5ff; }
html[data-theme="dark"] .template-picker-dialog--main .template-icon--lime,
html[data-theme="dark"] .template-picker-dialog--main .template-library-tag--1 { background: rgb(196 243 77 / 15%); color: #d9f99d; }
html[data-theme="dark"] .template-picker-dialog--main .template-icon--coral,
html[data-theme="dark"] .template-picker-dialog--main .template-library-tag--2 { background: rgb(255 92 58 / 16%); color: #ffb4a3; }

@media (max-width: 760px) {
  .template-picker-dialog--main { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .template-library-header { min-height: 58px; padding: 12px 16px; }
  .template-library-header h2 { font-size: 17px; }
  .template-library-body { display: flex; flex-direction: column; min-height: 0; max-height: none; overflow: auto; }
  .template-library-sidebar { border-right: 0; border-bottom: 1px solid var(--template-line); }
  .template-library-list { max-height: 210px; }
  .template-library-detail { min-height: 410px; padding: 18px 16px; }
  .template-library-detail h3 { font-size: 19px; }
  .template-library-prompt-panel pre { min-height: 160px; }
  .template-library-detail-footer { align-items: flex-end; flex-direction: column; }
  .template-library-status { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .production-workspace:has(.generic-production-form) :is(.production-history-item, button, input, select, textarea),
  .template-picker-dialog--main :is(button, input) { transition: none; }
}
