:root {
  --primary: #5e6ad2;
  --primary-hover: #4f58c9;
  --primary-focus: #4f58c9;
  --on-primary: #ffffff;
  --canvas: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #f1f3f7;
  --hairline: #e6e8ee;
  --hairline-strong: #d5d9e4;
  --hairline-tertiary: #c7ccd8;
  --text: #0f1117;
  --muted: #6b7280;
  --muted-strong: #374151;
  --success: #27a644;
  --danger: #f87171;
  --accent: var(--primary);
  --accent-2: var(--primary-hover);
  --bg: var(--canvas);
  --border: var(--hairline);
  --control: rgba(255, 255, 255, 0.96);
  --control-hover: rgba(94, 106, 210, 0.12);
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --page-gutter: clamp(14px, 1.8vw, 28px);
  --panel-padding: clamp(18px, 1.7vw, 24px);
  --panel-radius: clamp(14px, 1.2vw, 18px);
  --thumb-size: clamp(150px, 14vw, 190px);
  --modal-thumb-size: clamp(170px, 18vw, 240px);
  --sans: "Inter", "SF Pro Display", "PingFang SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-width: 320px;
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -0.05px;
  background:
    radial-gradient(circle at 8% 0%, rgba(94, 106, 210, 0.1), transparent 28%),
    radial-gradient(circle at 92% 12%, rgba(130, 143, 255, 0.08), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #f8f9fc 52%, #ffffff 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.workspace {
  width: min(100%, 1920px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
  gap: var(--page-gutter);
  padding: var(--page-gutter);
}

.panel {
  padding: var(--panel-padding);
  border: 1px solid var(--hairline);
  border-radius: var(--panel-radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 249, 252, 0.98) 100%);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-header.compact { margin-bottom: 12px; }

.top-action-group {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.top-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid rgba(94, 106, 210, 0.24);
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 10px 26px rgba(94, 106, 210, 0.2);
  text-decoration: none;
  white-space: nowrap;
}

.top-action-button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.top-action-button.secondary {
  background: var(--surface);
  color: var(--primary);
  box-shadow: none;
}

.top-action-button.secondary:hover {
  background: var(--surface-2);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
}

h1, h2, h3 { margin: 0; }
h1 {
  font-size: clamp(34px, 3.4vw, 58px);
  font-weight: 650;
  line-height: 1.02;
  letter-spacing: -2.2px;
}
h2 {
  font-size: clamp(24px, 2.1vw, 34px);
  font-weight: 650;
  letter-spacing: -1px;
}

.subtitle {
  max-width: 680px;
  margin-top: 10px;
  color: var(--muted-strong);
  line-height: 1.65;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 14px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

select, textarea, button { font: inherit; }
select, textarea {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--control);
  color: var(--text);
  padding: 13px 14px;
}

select {
  appearance: auto;
  -webkit-appearance: menulist;
  cursor: pointer;
}

select:hover, textarea:hover { border-color: var(--hairline-strong); }
select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-focus);
  box-shadow: 0 0 0 3px rgba(94, 105, 209, 0.22);
}

.select-shell { display: block; }
.field-help {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}
.is-hidden { display: none !important; }

.mode-note {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid rgba(94, 106, 210, 0.28);
  border-radius: 14px;
  background: rgba(94, 106, 210, 0.08);
}

.mode-note strong {
  display: block;
  margin-bottom: 10px;
  color: var(--text);
  font-size: 16px;
}

.mode-note p {
  margin: 0;
  color: var(--muted-strong);
  line-height: 1.7;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 34px 20px;
  overflow: hidden;
  border: 1px dashed rgba(94, 106, 210, 0.38);
  border-radius: 14px;
  background: rgba(94, 106, 210, 0.06);
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.dropzone:hover {
  border-color: rgba(130, 143, 255, 0.72);
  background: rgba(94, 106, 210, 0.1);
  transform: translateY(-1px);
}

.dropzone.is-dragging {
  border-color: rgba(130, 143, 255, 0.9);
  background: rgba(94, 106, 210, 0.16);
  transform: translateY(-1px) scale(1.01);
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone .file-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 14px;
  font-weight: 650;
  box-shadow: none;
}

.dropzone .file-action:hover { background: var(--primary-hover); }
.dropzone strong { color: var(--text); font-size: 15px; }
.dropzone small { color: var(--muted); }

.file-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 160px));
  gap: 14px;
  margin-top: 16px;
}

.file-preview-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  text-align: left;
}

.file-preview-card:hover {
  border-color: rgba(130, 143, 255, 0.46);
  background: rgba(94, 106, 210, 0.1);
}

.file-preview-index {
  padding-right: 28px;
  color: var(--primary-hover);
  font-size: 12px;
  font-weight: 650;
}

.file-preview-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
  background: rgba(15, 17, 23, 0.72);
  color: #ffffff;
  font-size: 18px;
  line-height: 1;
  box-shadow: none;
}

.file-preview-remove:hover { background: rgba(248, 113, 113, 0.9); }

.file-preview-image {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  background: var(--canvas);
}

.file-preview-name {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(1, 1, 2, 0.84);
  backdrop-filter: blur(12px);
}

.image-preview-large {
  display: block;
  max-width: min(92vw, 1200px);
  max-height: calc(100vh - 64px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.image-compare-large {
  width: min(96vw, 1380px);
  max-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 1.6vw, 22px);
}

.image-compare-large figure {
  min-width: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.image-compare-large figcaption {
  color: var(--primary-hover);
  font-size: 13px;
  font-weight: 700;
}

.image-compare-large img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 110px);
  object-fit: contain;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.batch-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(1, 1, 2, 0.78);
  backdrop-filter: blur(12px);
}

.batch-modal-dialog {
  position: relative;
  width: min(1120px, calc(100vw - var(--page-gutter) * 2));
  min-width: 0;
  max-width: min(1120px, calc(100vw - var(--page-gutter) * 2));
  max-height: calc(100vh - 56px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--hairline-strong);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99) 0%, rgba(248, 249, 252, 0.99) 100%);
  box-shadow: var(--shadow);
}

.batch-modal-dialog.is-loading {
  width: min(720px, calc(100vw - var(--page-gutter) * 2));
  max-width: min(720px, calc(100vw - var(--page-gutter) * 2));
}

.batch-modal-dialog.is-single {
  width: min(720px, calc(100vw - var(--page-gutter) * 2));
  max-width: min(720px, calc(100vw - var(--page-gutter) * 2));
}

.batch-modal-dialog.is-multi {
  width: min(1280px, calc(100vw - var(--page-gutter) * 2));
  max-width: min(1280px, calc(100vw - var(--page-gutter) * 2));
}

.team-excel-dialog {
  position: relative;
  width: min(560px, calc(100vw - var(--page-gutter) * 2));
  max-height: calc(100vh - 56px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--hairline-strong);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99) 0%, rgba(248, 249, 252, 0.99) 100%);
  box-shadow: var(--shadow);
}

.team-excel-modal-header {
  padding-right: 46px;
  margin-bottom: 18px;
}

.team-excel-modal-header h2 {
  margin-bottom: 10px;
  color: var(--text);
}

.team-excel-modal-header p:not(.eyebrow),
.team-excel-hint {
  margin: 0;
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.7;
}

.team-excel-picker {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 650;
}

.team-excel-picker input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted-strong);
}

.team-excel-modal-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.team-excel-modal-actions button {
  flex: 1 1 0;
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  box-shadow: none;
}

.modal-close:hover { background: rgba(248, 113, 113, 0.88); }
.batch-modal-header { margin-bottom: 18px; padding-right: 46px; }
.batch-modal-header h2 { margin-bottom: 12px; }

.batch-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.batch-summary span {
  padding: 7px 10px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface-2);
}

.history-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: flex-start;
  gap: 18px;
  width: 100%;
}

.batch-modal-dialog.is-single .history-result-grid {
  grid-template-columns: minmax(0, 1fr);
}

.batch-modal-dialog.is-multi .history-result-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-result-card {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
}

.history-compare-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 10px 10px;
}

.history-compare-pair figure {
  min-width: 0;
  margin: 0;
}

.history-compare-pair figcaption {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.history-compare-image {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface-2);
  box-shadow: none;
  cursor: zoom-in;
}

.history-compare-image:hover {
  border-color: rgba(94, 106, 210, 0.42);
  background: var(--surface-2);
}

.history-compare-image img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.history-compare-image:hover img {
  transform: scale(1.015);
  filter: brightness(1.04);
}

.history-compare-open-button {
  margin-top: 0;
}

.prompt-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.prompt-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--surface-2);
}
.prompt-mode-switch label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}
.prompt-mode-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.prompt-mode-switch label:has(input:checked) {
  background: #ffffff;
  color: var(--primary-hover);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}
.auto-prompt-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(94, 106, 210, 0.24);
  border-radius: 12px;
  background: rgba(94, 106, 210, 0.08);
}
.auto-prompt-panel strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}
.auto-prompt-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.auto-prompt-preview {
  padding: 14px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--surface-2);
}
.auto-prompt-preview strong {
  display: block;
  margin-bottom: 8px;
  color: var(--muted-strong);
  font-size: 13px;
}
.auto-prompt-preview p {
  margin: 0;
  color: var(--text);
  line-height: 1.75;
}
.auto-prompt-token {
  color: #dc2626;
  font-weight: 750;
}
.prompt-box textarea { min-height: 220px; resize: vertical; }
.composer-tools { display: flex; align-items: center; gap: 12px; }
.model-picker { width: 100%; }
.model-picker span { margin-bottom: 8px; }

.submit-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 13px 18px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 650;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

button:hover { background: var(--primary-hover); }
button:disabled { cursor: wait; opacity: 0.82; }

.secondary-action-button {
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--muted-strong);
}
.secondary-action-button:hover {
  border-color: rgba(94, 106, 210, 0.46);
  background: rgba(94, 106, 210, 0.1);
  color: var(--primary-hover);
}

button.is-loading {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

button.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: var(--on-primary);
  animation: button-spin 0.7s linear infinite;
}

.meta-card, .task-status {
  padding: 18px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
}

.current-compare {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-color: rgba(94, 106, 210, 0.38);
  background: rgba(94, 106, 210, 0.08);
}

.current-compare-header h3 { margin-bottom: 8px; }
.current-compare-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.current-compare-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: 12px;
}

.compare-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
}

.compare-card-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}

.compare-card-header strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.compare-card-header em {
  color: var(--success);
  font-style: normal;
  font-weight: 700;
}

.compare-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  background: var(--hairline);
}

.compare-pair figure {
  min-width: 0;
  margin: 0;
  background: var(--surface-2);
}

.compare-pair figcaption {
  padding: 8px 10px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.compare-image-button {
  display: block;
  width: 100%;
  padding: 8px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: zoom-in;
}

.compare-image-button:hover { background: rgba(94, 106, 210, 0.07); }
.compare-image-button img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}
.compare-result img { background: #fff; }

.compare-empty,
.compare-pending {
  min-height: 120px;
  margin: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  border: 1px dashed var(--hairline-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
}

.compare-pending {
  color: var(--primary-hover);
  background: rgba(94, 106, 210, 0.09);
}
.compare-failed {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.08);
}

.compare-open-button {
  width: calc(100% - 20px);
  margin: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(94, 106, 210, 0.16);
  color: var(--primary-hover);
  box-shadow: none;
  font-size: 12px;
}
.compare-open-button:hover { background: rgba(94, 106, 210, 0.24); }

.single-retry-button {
  width: calc(100% - 20px);
  margin: 0 10px 10px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface-1);
  color: var(--text);
  box-shadow: none;
  font-size: 12px;
  font-weight: 700;
}
.single-retry-button:hover:not(:disabled) {
  border-color: rgba(94, 106, 210, 0.4);
  background: rgba(94, 106, 210, 0.08);
  color: var(--primary-hover);
}
.single-retry-button:disabled {
  cursor: wait;
  color: var(--muted);
  background: var(--surface-2);
}

.history-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.history-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.history-header small { color: var(--muted); }
.history-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
.history-filter span {
  margin-bottom: 7px;
  font-size: 12px;
}
.history-filter select {
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 13px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, auto);
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.history-item:hover {
  border-color: rgba(130, 143, 255, 0.5);
  background: rgba(94, 106, 210, 0.1);
  transform: translateY(-1px);
}

.history-item-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.history-item-main, .history-item-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-item-main strong { font-size: 14px; }
.history-item-main em, .history-item-meta {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.history-preview-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  max-width: 100%;
  overflow: hidden;
}

.history-preview-thumb,
.history-preview-more {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--surface-2);
}

.history-preview-thumb {
  display: block;
  object-fit: cover;
}

.history-preview-more,
.history-preview-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.history-preview-more {
  background: rgba(94, 106, 210, 0.12);
  color: var(--primary-hover);
  font-weight: 700;
}

.history-preview-empty {
  min-height: 42px;
  padding: 0 10px;
  border: 1px dashed var(--hairline);
  border-radius: 6px;
}

.status-pill {
  color: var(--text);
  font-weight: 700;
}

.history-progress-text {
  max-width: 260px;
  color: var(--muted);
  line-height: 1.45;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 4px;
}

.history-action-button {
  padding: 7px 10px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary-hover);
  box-shadow: none;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}
.history-action-button:hover {
  border-color: rgba(94, 106, 210, 0.42);
  background: rgba(94, 106, 210, 0.1);
  text-decoration: none;
}
.history-action-button:disabled {
  cursor: wait;
  opacity: 0.62;
}
.history-detail-button {
  border-color: rgba(94, 106, 210, 0.22);
  background: rgba(94, 106, 210, 0.12);
  color: var(--primary-hover);
}
.history-download-button {
  color: var(--muted-strong);
}
.history-copy-path-button,
.history-copy-path-button:hover,
.history-download-button:hover {
  color: var(--primary-hover);
}
.history-delete-button {
  color: #b42318;
}
.history-delete-button:hover {
  border-color: rgba(180, 35, 24, 0.32);
  background: rgba(180, 35, 24, 0.08);
  color: #b42318;
}

.history-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.history-batch-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 12px 2px 0;
  color: var(--muted);
  font-size: 13px;
}

.history-page-controls {
  display: inline-flex;
  gap: 8px;
}

.history-page-button {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(94, 106, 210, 0.14);
  color: var(--primary-hover);
  box-shadow: none;
  font-size: 12px;
}
.history-page-button:hover { background: rgba(94, 106, 210, 0.22); }
.history-page-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.prompt-debug {
  overflow: auto;
  max-height: 420px;
}
.meta-card ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

.prompt-details, .result-debug {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--surface-2);
}

.prompt-details summary, .result-debug summary {
  cursor: pointer;
  color: var(--primary-hover);
  font-weight: 600;
}
.prompt-section { margin-top: 12px; }
.prompt-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}
.prompt-section pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.6;
}
.correction-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}
.muted { color: var(--muted); }

.results {
  width: min(100%, 1920px);
  margin: 0 auto;
  padding: 0 var(--page-gutter) var(--page-gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: clamp(12px, 1.4vw, 18px);
}
.results:empty { display: none; }
.results-header {
  flex: 1 0 100%;
  margin-bottom: 6px;
}
.results-header p {
  max-width: 960px;
  color: var(--muted);
  line-height: 1.6;
}

.result-card {
  flex: 0 1 var(--thumb-size);
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
}

.result-meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 8px;
  align-items: center;
  padding: 11px 12px;
  color: var(--muted);
  font-size: 12px;
}

.result-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-meta em {
  grid-column: 2;
  font-style: normal;
}

.modal-result-meta .modal-result-filename {
  grid-column: 1 / -1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-image-button {
  display: block;
  width: 100%;
  padding: 0;
  border-radius: 0;
  background: var(--surface-2);
  color: inherit;
  box-shadow: none;
  cursor: zoom-in;
}
.result-image-button:hover { background: var(--surface-2); }
.result-image-button:hover img {
  transform: scale(1.015);
  filter: brightness(1.04);
}
.result-image-button img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--surface-2);
  transition: transform 0.18s ease, filter 0.18s ease;
}
.modal-result-image-button img { aspect-ratio: 1 / 1; }
.result-error {
  min-height: 140px;
  display: flex;
  align-items: center;
  padding: 18px;
}
.result-notes {
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.result-card .result-debug, .modal-result-card .result-debug {
  margin: 10px;
  padding: 10px 12px;
}
.error { color: var(--danger); }

@keyframes button-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .workspace {
    padding: 12px;
    gap: 12px;
  }
  .panel {
    padding: 16px;
    border-radius: 14px;
  }
  .field-grid { grid-template-columns: 1fr; }
  .panel-header {
    flex-wrap: wrap;
    margin-bottom: 14px;
  }
  .top-action-group {
    width: 100%;
    justify-content: stretch;
    margin-top: 0;
  }
  .top-action-button {
    flex: 1 1 160px;
  }
  .composer-tools {
    flex-direction: column;
    align-items: stretch;
  }
  .auto-prompt-panel { grid-template-columns: 1fr; }
  .auto-prompt-panel button { width: 100%; }
  .team-excel-modal-actions { flex-direction: column; }
  .file-list { grid-template-columns: repeat(auto-fill, minmax(min(130px, 48%), 1fr)); }
  .image-preview-modal { padding: 18px; }
  .image-preview-large {
    max-width: 100%;
    max-height: calc(100vh - 36px);
  }
  .image-compare-large {
    grid-template-columns: 1fr;
    overflow: auto;
    max-height: calc(100vh - 36px);
  }
  .image-compare-large img { max-height: none; }
  .batch-modal { padding: 14px; }
  .batch-modal-dialog {
    max-height: calc(100vh - 28px);
    padding: 18px;
  }
  .batch-modal-dialog.is-single,
  .batch-modal-dialog.is-multi,
  .batch-modal-dialog.is-loading {
    width: 100%;
    max-width: 100%;
  }
  .history-result-grid { gap: 12px; }
  .batch-modal-dialog.is-multi .history-result-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .result-card { flex-basis: calc(50% - 6px); }
  .modal-result-card { flex-basis: 100%; }
  .history-compare-pair { grid-template-columns: 1fr; }
  .history-item {
    align-items: flex-start;
    grid-template-columns: minmax(0, 1fr) minmax(260px, auto);
  }
  .history-item-meta { text-align: right; }
  .history-pagination,
  .history-batch-pagination {
    flex-direction: column;
    align-items: stretch;
  }
  .history-page-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .compare-pair { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .result-card, .modal-result-card { flex-basis: 100%; }
  .history-item { grid-template-columns: 1fr; }
  .history-item-meta { text-align: left; }
  .history-actions { grid-template-columns: repeat(2, max-content); }
}
