/* source: styles/00-tokens.css */
:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --line: #e2e8e5;
  --text: #1f352f;
  --text-secondary: #4a635b;
  --muted: #889d95;
  --primary: #457b66;
  --primary-foreground: #ffffff;
  --primary-strong: #335d4d;
  --primary-light: #e6f0ec;
  --accent: #9b7f4f;
  --danger: #a6463d;
  --status-blue: #2f6fe4;
  --code: #142f2d;
  --code-text: #bfe0cf;
  --success-soft: #eef6f2;
  --danger-soft: #fff4f2;
  --panel-border: color-mix(in srgb, var(--line) 78%, transparent);
  --section-heading: var(--text);
  --task-title: var(--text);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --touch-target: 44px;
  --motion-fast: 140ms ease;
  --motion-base: 180ms ease;
  --motion-height: 220ms ease;
  --font: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --shadow-sm: 0 2px 8px rgba(29, 52, 46, 0.04);
  --shadow-popover: 0 14px 34px rgba(29, 52, 46, 0.16);
  --shadow-modal: 0 24px 80px rgba(24, 45, 39, 0.24);
  --overlay: rgba(12, 28, 23, 0.46);
  --overlay-subtle: rgba(12, 28, 23, 0.28);
  --workspace-texture:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--primary) 10%, transparent) 1px, transparent 1.6px),
    linear-gradient(135deg, color-mix(in srgb, var(--primary-light) 34%, transparent), transparent 48%);
  --sidebar-width: 347px;
  --sidebar-min-width: 280px;
  --sidebar-max-width: 520px;
  --workspace-side-action-width: 164px;
  --header-height: 60px;
  --scrollbar-track: rgba(230, 240, 236, 0.55);
  --scrollbar-thumb: rgba(69, 123, 102, 0.36);
  --scrollbar-thumb-hover: rgba(51, 93, 77, 0.58);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101815;
  --surface: #17221e;
  --surface-soft: #1e2b26;
  --line: #31433b;
  --text: #e7f0ec;
  --text-secondary: #b9cac2;
  --muted: #82978e;
  --primary: #72b79b;
  --primary-foreground: #10201b;
  --primary-strong: #a6d8c5;
  --primary-light: #243d34;
  --accent: #d3b776;
  --danger: #e18479;
  --status-blue: #83a9ff;
  --code: #0b1110;
  --code-text: #c9e8d9;
  --success-soft: #1b342b;
  --danger-soft: #3a201d;
  --panel-border: color-mix(in srgb, var(--line) 58%, transparent);
  --section-heading: color-mix(in srgb, var(--text) 58%, var(--text-secondary));
  --task-title: color-mix(in srgb, var(--text) 36%, var(--text-secondary));
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-popover: 0 18px 42px rgba(0, 0, 0, 0.38);
  --shadow-modal: 0 28px 84px rgba(0, 0, 0, 0.48);
  --overlay: rgba(5, 12, 10, 0.62);
  --overlay-subtle: rgba(5, 12, 10, 0.44);
  --workspace-texture:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--primary-strong) 7%, transparent) 1px, transparent 1.6px),
    linear-gradient(135deg, color-mix(in srgb, var(--primary-light) 32%, transparent), transparent 52%);
  --scrollbar-track: rgba(49, 67, 59, 0.55);
  --scrollbar-thumb: rgba(114, 183, 155, 0.42);
  --scrollbar-thumb-hover: rgba(166, 216, 197, 0.64);
}

* {
  box-sizing: border-box;
}

:root.theme-transition-lock *,
:root.theme-transition-lock *::before,
:root.theme-transition-lock *::after {
  transition: none !important;
}

/* source: styles/01-base.css */
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
}

.sidebar-content,
.task-active-list,
.dashboard,
.prompt-editor,
.modal-panel {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.sidebar-content::-webkit-scrollbar,
.task-active-list::-webkit-scrollbar,
.dashboard::-webkit-scrollbar,
.prompt-editor::-webkit-scrollbar,
.modal-panel::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.sidebar-content::-webkit-scrollbar-track,
.task-active-list::-webkit-scrollbar-track,
.dashboard::-webkit-scrollbar-track,
.prompt-editor::-webkit-scrollbar-track,
.modal-panel::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}

.sidebar-content::-webkit-scrollbar-thumb,
.task-active-list::-webkit-scrollbar-thumb,
.dashboard::-webkit-scrollbar-thumb,
.prompt-editor::-webkit-scrollbar-thumb,
.modal-panel::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--scrollbar-thumb);
  background-clip: content-box;
}

.sidebar-content::-webkit-scrollbar-thumb:hover,
.task-active-list::-webkit-scrollbar-thumb:hover,
.dashboard::-webkit-scrollbar-thumb:hover,
.prompt-editor::-webkit-scrollbar-thumb:hover,
.modal-panel::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: content-box;
}

.dashboard {
  scrollbar-width: none;
}

.dashboard::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.layout-container {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* source: styles/10-sidebar.css */
/* Sidebar */
.sidebar {
  position: relative;
  width: clamp(var(--sidebar-min-width), var(--sidebar-width), var(--sidebar-max-width));
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 25;
}

.sidebar-resize-handle::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 3px;
  width: 2px;
  border-radius: 999px;
  background: transparent;
  transition: background var(--motion-base);
}

.sidebar-resize-handle:hover::before,
.sidebar-resize-handle:focus-visible::before,
.sidebar.resizing .sidebar-resize-handle::before {
  background: color-mix(in srgb, var(--primary) 34%, transparent);
}

.sidebar-resize-shield {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: transparent;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
}

.sidebar-header {
  padding: 16px 16px 10px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  margin-bottom: 14px;
  padding: 0 3px;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  background:
    radial-gradient(circle at 58% 48%, rgba(247, 213, 157, 0.42) 0 10%, transparent 11%),
    linear-gradient(145deg, #2f604f 0%, #4d8b72 66%, #b89155 100%);
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 9px 19px rgba(51, 93, 77, 0.18);
}

.brand-rabbit-logo {
  color: #ffffff;
  fill: currentColor;
  filter: drop-shadow(0 1px 0 rgba(16, 32, 27, 0.18));
}

.brand-rabbit-cutout {
  fill: #457b66;
}

.brand-rabbit-spark {
  color: var(--dark-accent, #d3b776);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
}

.brand-title {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.brand-name {
  font-size: 17px;
  line-height: 1.08;
  font-weight: 760;
  color: var(--text);
  letter-spacing: 0;
  white-space: nowrap;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-actions {
  flex: 0 0 auto;
}

.sidebar-search {
  margin-top: 0;
  position: relative;
  z-index: 32;
}

.sidebar-search input {
  width: 100%;
  height: 36px;
  padding: 0 82px 0 32px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft) url('data:image/svg+xml;utf8,<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%23889d95" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>') no-repeat 12px center;
  outline: none;
  font-size: 13px;
  transition: border-color var(--motion-base), background-color var(--motion-base);
}

.sidebar-search input::-webkit-search-cancel-button {
  appearance: none;
  -webkit-appearance: none;
}

.sidebar-search input:focus {
  border-color: var(--primary);
  background-color: var(--surface);
}

.task-search-clear-button {
  position: absolute;
  top: 18px;
  right: 39px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  transform: translateY(-50%);
  cursor: pointer;
  transition:
    background var(--motion-fast),
    color var(--motion-fast);
}

.task-search-clear-button:hover,
.task-search-clear-button:focus-visible {
  background: var(--primary-light);
  color: var(--primary-strong);
  outline: none;
}

.task-search-clear-button[hidden] {
  display: none;
}

.task-filter-button {
  position: absolute;
  top: 18px;
  right: 5px;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  display: inline-grid;
  place-items: center;
  transform: translateY(-50%);
  cursor: pointer;
  transition:
    background var(--motion-fast),
    border-color var(--motion-fast),
    color var(--motion-fast),
    box-shadow var(--motion-fast);
}

.task-filter-button:hover,
.task-filter-button:focus-visible,
.task-filter-button.is-open,
.task-filter-button.has-active-filters {
  border-color: color-mix(in srgb, var(--primary) 46%, var(--line));
  background: var(--primary-light);
  color: var(--primary-strong);
  outline: none;
}

.task-filter-button:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

.task-filter-icon {
  display: block;
  pointer-events: none;
}

.task-filter-active-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border: 2px solid var(--surface-soft);
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 9.5px;
  font-weight: 760;
  line-height: 1;
}

.task-filter-active-count[hidden] {
  display: none;
}

.task-filter-panel {
  position: static;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.task-filter-panel[hidden] {
  display: none;
}

.task-filter-popover-header {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}

.task-filter-clear-button {
  height: 26px;
  padding: 0 9px;
}

.task-filter-clear-button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.sidebar-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.task-filter-select {
  min-width: 0;
  width: 100%;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11.5px;
  outline: none;
}

.task-filter-select:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.task-history-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 12px;
  gap: 6px;
}

.task-history-tools {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding-right: var(--task-history-scrollbar-offset, 0px);
}

.task-history-batch-button {
  min-height: 30px;
  padding: 0 10px;
  white-space: nowrap;
}

.sidebar-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.task-history-anchor-rail {
  flex: 0 0 auto;
  display: grid;
  gap: 6px;
  padding-right: var(--task-history-scrollbar-offset, 0px);
}

.task-history-anchor-rail-top {
  padding-top: 0;
}

.task-history-anchor-rail-bottom {
  padding-bottom: 6px;
}

.task-history-library-slot {
  flex: 0 0 auto;
  margin-bottom: 12px;
  padding-right: var(--task-history-scrollbar-offset, 0px);
}

.task-history-library-slot.hidden {
  display: none;
}

/* source: styles/20-tasks.css */
/* Tasks */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 4px;
}

.task-active-list {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(52dvh, 520px);
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.task-active-list.hidden {
  display: none;
}

.task-history-anchor-row,
.task-group-header-split {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 32px;
  width: 100%;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  appearance: none;
  transition:
    background var(--motion-base),
    border-color var(--motion-base),
    box-shadow var(--motion-base);
}

.task-history-anchor-label,
.task-group-label-button {
  display: flex;
  align-items: center;
  min-width: 0;
  justify-content: flex-start;
  padding: 0 10px 0 12px;
  border-radius: 8px;
}

.task-history-anchor-arrow,
.task-group-arrow-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
}

.task-history-anchor-row:hover,
.task-history-anchor-row:focus-visible,
.task-group-header-split:hover,
.task-group-header-split:focus-visible {
  background: var(--surface-soft);
}

.task-group {
  display: grid;
  gap: 4px;
}

.task-group + .task-group {
  margin-top: 2px;
}

.task-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  min-height: 32px;
  padding: 3px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition:
    background var(--motion-base),
    border-color var(--motion-base),
    box-shadow var(--motion-base);
}

.task-group-header.task-group-header-split {
  display: grid;
}

.task-list > .task-group-expanded > .task-group-header-split {
  position: sticky;
  top: 0;
  z-index: 6;
}

.task-group-title {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-group-count {
  color: var(--primary-strong);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.task-group-count-separator {
  color: var(--muted);
  font-weight: 600;
}

.task-group-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  color: var(--muted);
  transform-origin: 50% 50%;
  transition: transform var(--motion-base), color var(--motion-base);
}

.task-group-toggle-icon {
  width: 12px;
  height: 12px;
  display: block;
  overflow: visible;
}

.task-history-anchor-row[aria-expanded="true"] .task-group-toggle,
.task-group-header-split[aria-expanded="true"] .task-group-toggle {
  transform: rotate(90deg);
  color: var(--primary);
}

.task-group-toggle-placeholder {
  opacity: 0;
}

.task-history-anchor-label,
.task-group-label-button,
.task-history-anchor-arrow,
.task-group-arrow-button {
  color: var(--text-secondary);
  transition:
    color var(--motion-base),
    transform var(--motion-base),
    opacity var(--motion-base);
}

.task-group-items {
  display: grid;
  gap: 4px;
  max-height: 2400px;
  overflow: clip;
  transition:
    max-height var(--motion-height),
    opacity var(--motion-base);
}

.task-active-collapsed .task-group-items {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.task-group-items-expanded {
  opacity: 1;
}

.task-group-active .task-group-items-expanded {
  gap: 4px;
}

.task-history-library-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 3px;
  margin-top: 0;
  min-height: 54px;
  padding: 9px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 82%, var(--primary-light));
  color: var(--text);
  text-decoration: none;
  transition: background var(--motion-base), border-color var(--motion-base), box-shadow var(--motion-base);
}

.task-history-library-card:hover,
.task-history-library-card:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 46%, transparent);
  background: var(--surface-soft);
  box-shadow: var(--shadow-sm);
  outline: none;
}

.task-history-library-card span {
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-history-library-card small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-active-group-header {
  cursor: pointer;
}

.task-active-group-header:hover,
.task-active-group-header:focus-visible {
  background: var(--surface-soft);
}

.task-active-section {
  display: grid;
  gap: 4px;
}

.task-active-section + .task-active-section,
.task-active-section + .task-active-empty,
.task-active-empty + .task-active-section {
  margin-top: 2px;
}

.task-active-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 22px;
  padding: 0 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.task-active-section-count {
  color: var(--primary-strong);
  font-variant-numeric: tabular-nums;
}

.task-active-section-items {
  display: grid;
  gap: 4px;
}

.task-active-empty {
  padding: 10px 12px;
  border: 1px dashed var(--panel-border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .task-history-anchor-row,
  .task-group-header-split,
  .task-group-items,
  .task-card,
  .task-card-actions,
  .task-queue-actions,
  .task-queue-action,
  .task-queue-drag-handle,
  .task-history-library-card,
  .task-archive-button,
  .task-delete-button,
  .task-thumb-stack img,
  .task-group-toggle,
  .task-history-anchor-label,
  .task-group-label-button,
  .task-history-anchor-arrow,
  .task-group-arrow-button {
    transition: none;
  }
}

.task-list.batch-marquee-enabled .task-card.batch-mode {
  cursor: crosshair;
  user-select: none;
}

.task-list.batch-marquee-active .task-card.batch-mode {
  transition: none;
}

.batch-selection-marquee {
  position: fixed;
  z-index: 9000;
  pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--primary) 72%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--surface) 72%, transparent) inset;
}

.task-card {
  display: flex;
  align-items: center;
  gap: 9px;
  position: relative;
  height: 66px;
  padding: 6px 7px;
  padding-right: 30px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--line) 34%, transparent);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  transition:
    background var(--motion-base),
    border-color var(--motion-base),
    box-shadow var(--motion-base),
    color var(--motion-base);
  overflow: hidden; /* For text truncation */
}

.task-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.task-card.active:focus-visible,
.task-card.batch-selected:focus-visible {
  outline: none;
}

.task-card.batch-mode {
  padding-left: 42px;
  padding-right: 8px;
}

.task-card.queue-waiting {
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
}

.task-card.queue-running {
  border-color: color-mix(in srgb, var(--status-blue) 22%, transparent);
}

.task-card.queue-dragging {
  opacity: 0.58;
}

.task-queue-transparent-drag-image {
  position: fixed;
  left: -1000px;
  top: -1000px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.task-card.batch-selected {
  background: var(--primary-light);
  border-color: color-mix(in srgb, var(--primary) 36%, transparent);
}

.task-card > .task-info {
  min-width: 0;
  flex: 1;
}

.task-card:hover {
  background: color-mix(in srgb, var(--surface-soft) 88%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 32%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary-light) 72%, transparent);
}

.task-card.unread {
  border-color: color-mix(in srgb, var(--status-blue) 40%, var(--line));
  background: color-mix(in srgb, var(--status-blue) 6%, var(--surface-soft));
}

.task-card.running {
  height: 78px;
  background: var(--surface);
  border-color: color-mix(in srgb, var(--status-blue) 26%, var(--line));
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--status-blue) 34%, transparent);
}

.task-card.submitting,
.task-card.queued {
  height: 78px;
}

.task-card.failed,
.task-card.partial_failed {
  background: color-mix(in srgb, var(--danger-soft) 64%, var(--surface));
  border-color: transparent;
  box-shadow: none;
}

.task-card.active {
  background: color-mix(in srgb, var(--primary) 16%, var(--surface-soft));
  border-color: var(--primary);
  box-shadow:
    inset 4px 0 0 var(--primary),
    0 0 0 2px color-mix(in srgb, var(--primary-light) 86%, transparent),
    0 8px 18px rgba(29, 52, 46, 0.08);
}

.task-card.active.running {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface-soft));
  border-color: color-mix(in srgb, var(--primary) 72%, var(--status-blue));
  box-shadow:
    inset 4px 0 0 var(--primary),
    inset 0 1px 0 color-mix(in srgb, var(--status-blue) 24%, transparent),
    0 0 0 2px color-mix(in srgb, var(--primary-light) 86%, transparent),
    0 8px 18px rgba(29, 52, 46, 0.08);
}

.task-card.active.failed,
.task-card.active.partial_failed {
  background: color-mix(in srgb, var(--danger-soft) 68%, var(--surface));
  border-color: var(--primary);
  box-shadow:
    inset 4px 0 0 var(--primary),
    0 0 0 2px color-mix(in srgb, var(--primary-light) 86%, transparent),
    0 8px 18px rgba(29, 52, 46, 0.08);
}

.task-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: var(--line);
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.task-thumb,
.task-thumb img {
  user-select: none;
  -webkit-user-drag: none;
}

.task-thumb-stack {
  --task-thumb-layer-size: 40px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: transparent;
}

.task-thumb-stack img {
  position: absolute;
  width: var(--task-thumb-layer-size);
  height: var(--task-thumb-layer-size);
  object-fit: contain;
  border-radius: 5px;
  background: transparent;
  transition:
    opacity var(--motion-base),
    transform var(--motion-base);
}

.task-thumb-reference {
  right: 0;
  bottom: 0;
  z-index: 1;
  opacity: 0.78;
}

.task-thumb-output {
  left: 0;
  top: 0;
  z-index: 2;
  box-shadow: 4px 4px 10px rgba(16, 35, 28, 0.34);
}

.task-thumb-stack-spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 78%, var(--primary));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--primary) 16%, transparent),
    0 5px 14px rgba(16, 35, 28, 0.32);
  isolation: isolate;
  pointer-events: none;
}

.task-thumb-stack-spinner::before,
.task-thumb-stack-spinner::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.task-thumb-stack-spinner::before {
  inset: 2px;
  background: conic-gradient(
    from 205deg,
    transparent 0deg 202deg,
    color-mix(in srgb, var(--primary) 28%, transparent) 225deg,
    var(--primary) 284deg,
    var(--primary-strong) 316deg,
    transparent 340deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #111 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #111 calc(100% - 2px));
  animation: generation-relay-spin 1.3s linear infinite;
  opacity: 0.96;
}

.task-thumb-stack-spinner::after {
  inset: 7px;
  background: conic-gradient(
    from 28deg,
    transparent 0deg 126deg,
    color-mix(in srgb, var(--primary) 34%, transparent) 150deg,
    var(--primary-strong) 236deg,
    transparent 268deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #111 calc(100% - 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #111 calc(100% - 1px));
  animation: generation-relay-spin-reverse 0.95s linear infinite;
  animation-delay: -0.28s;
  opacity: 0.9;
}

.task-thumb-single {
  position: relative;
  overflow: hidden;
}

.task-thumb-single-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: inherit;
}

.task-thumb-mode-badge {
  position: absolute;
  left: 4px;
  top: 4px;
  z-index: 3;
  min-width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface) 84%, var(--primary));
  color: color-mix(in srgb, var(--primary) 88%, var(--text));
  font-size: 10px;
  line-height: 1;
  font-weight: 760;
}

.task-card:hover .task-thumb-reference,
.task-card:focus-visible .task-thumb-reference,
.archive-card:hover .task-thumb-reference {
  transform: translate(-2px, -2px);
}

.task-card:hover .task-thumb-output,
.task-card:focus-visible .task-thumb-output,
.archive-card:hover .task-thumb-output {
  opacity: 0.24;
  transform: translate(-3px, -3px) scale(0.9);
}

.archive-thumb.task-thumb-stack {
  --task-thumb-layer-size: 48px;
}

.task-thumb.running-thumb {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
}

.running-thumb span,
.waiting-spinner {
  position: relative;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 17%, transparent);
  isolation: isolate;
}

.running-thumb span {
  width: 30px;
  height: 30px;
}

.waiting-spinner {
  width: 38px;
  height: 38px;
}

.running-thumb span::before,
.running-thumb span::after,
.waiting-spinner::before,
.waiting-spinner::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.running-thumb span::before {
  inset: 0;
  background: conic-gradient(
    from 205deg,
    transparent 0deg 202deg,
    color-mix(in srgb, var(--primary) 28%, transparent) 225deg,
    var(--primary) 284deg,
    var(--primary-strong) 316deg,
    transparent 340deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #111 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #111 calc(100% - 3px));
  animation: generation-relay-spin 1.3s linear infinite;
  opacity: 0.96;
}

.running-thumb span::after {
  inset: 7px;
  background: conic-gradient(
    from 28deg,
    transparent 0deg 126deg,
    color-mix(in srgb, var(--primary) 34%, transparent) 150deg,
    var(--primary-strong) 236deg,
    transparent 268deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #111 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #111 calc(100% - 2px));
  animation: generation-relay-spin-reverse 0.95s linear infinite;
  animation-delay: -0.28s;
  opacity: 0.9;
}

.waiting-spinner::before {
  inset: 0;
  background: conic-gradient(
    from 205deg,
    transparent 0deg 205deg,
    color-mix(in srgb, var(--primary) 24%, transparent) 226deg,
    var(--primary) 288deg,
    var(--primary-strong) 316deg,
    transparent 338deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #111 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #111 calc(100% - 4px));
  animation: generation-relay-spin 1.6s linear infinite;
  opacity: 0.92;
}

.waiting-spinner::after {
  inset: 8px;
  background: conic-gradient(
    from 28deg,
    transparent 0deg 132deg,
    color-mix(in srgb, var(--primary) 30%, transparent) 155deg,
    var(--primary-strong) 236deg,
    transparent 265deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #111 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #111 calc(100% - 3px));
  animation: generation-relay-spin-reverse 1.15s linear infinite;
  animation-delay: -0.35s;
  opacity: 0.84;
}

@keyframes generation-relay-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes generation-relay-spin-reverse {
  to {
    transform: rotate(-360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .waiting-spinner::before,
  .waiting-spinner::after,
  .running-thumb span::before,
  .running-thumb span::after,
  .task-thumb-stack-spinner::before,
  .task-thumb-stack-spinner::after {
    animation: none;
  }

  .waiting-spinner::before,
  .running-thumb span::before,
  .task-thumb-stack-spinner::before {
    transform: rotate(34deg);
  }

  .waiting-spinner::after,
  .running-thumb span::after,
  .task-thumb-stack-spinner::after {
    transform: rotate(-28deg);
  }
}

.failed-thumb {
  display: grid;
  place-items: center;
  background: var(--danger-soft);
}

.failed-thumb span {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--danger) 28%, transparent);
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  animation: none;
}

.task-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.task-card-actions {
  position: absolute;
  right: 8px;
  top: 50%;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity var(--motion-base);
}

.task-archive-button,
.task-delete-button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--motion-base), border-color var(--motion-base), color var(--motion-base);
}

.task-archive-button {
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  background: var(--surface-soft);
  color: var(--primary-strong);
}

.task-delete-button {
  border: 1px solid color-mix(in srgb, var(--line) 82%, var(--text-secondary));
  background: var(--surface-soft);
  color: var(--text-secondary);
}

.task-select-button {
  position: absolute;
  left: 10px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid color-mix(in srgb, var(--text-secondary) 30%, var(--line));
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  z-index: 2;
}

.task-select-button span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
}

.task-select-button[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
}

.task-select-button[aria-pressed="true"] span {
  background: var(--surface);
}

.task-action-icon {
  display: block;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.task-card:hover .task-card-actions,
.task-card:focus-within .task-card-actions,
.task-card-actions:focus-within {
  opacity: 1;
  pointer-events: auto;
}

.task-queue-actions {
  position: absolute;
  right: 12px;
  bottom: 6px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-sizing: border-box;
  max-width: calc(100% - 24px);
  padding: 3px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, var(--surface));
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition:
    opacity var(--motion-base),
    transform var(--motion-base),
    border-color var(--motion-base);
}

.task-card:hover .task-queue-actions,
.task-card.queue-waiting:focus-within .task-queue-actions,
.task-card.queue-waiting.active .task-queue-actions,
.task-queue-actions:focus-within {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.task-queue-action,
.task-queue-drag-handle {
  display: inline-grid;
  place-items: center;
  width: 24px;
  min-width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--text-secondary) 22%, var(--line));
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    background var(--motion-base),
    border-color var(--motion-base),
    color var(--motion-base);
}

.task-queue-drag-handle {
  cursor: grab;
}

.task-queue-drag-handle:active {
  cursor: grabbing;
}

.task-queue-drag-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.task-queue-action-icon {
  width: 14px;
  height: 14px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.task-queue-cancel-button .task-queue-action-icon path {
  fill: currentColor;
  stroke: none;
}

.task-queue-action:hover,
.task-queue-action:focus-visible,
.task-queue-drag-handle:hover,
.task-queue-drag-handle:focus-visible {
  background: var(--primary-light);
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  color: var(--primary-strong);
}

.task-queue-action:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.task-queue-cancel-button,
.task-queue-delete-button {
  color: var(--text-secondary);
}

.task-queue-cancel-button:hover,
.task-queue-cancel-button:focus-visible,
.task-queue-delete-button:hover,
.task-queue-delete-button:focus-visible {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 46%, var(--line));
  color: var(--danger);
}

.task-card.batch-mode .task-card-actions {
  display: none;
}

.task-card.batch-mode .task-queue-actions {
  display: none;
}

.task-context-menu {
  position: fixed;
  z-index: 9300;
  min-width: 178px;
  max-width: min(240px, calc(100vw - 16px));
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-popover);
}

.task-context-menu.hidden {
  display: none;
}

.task-context-menu-section {
  display: grid;
  gap: 2px;
  padding: 3px 0;
}

.task-context-menu-section + .task-context-menu-section {
  border-top: 1px solid var(--line);
}

.task-context-menu-button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 30px;
  padding: 5px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.task-context-menu-button:hover,
.task-context-menu-button:focus-visible {
  background: var(--primary-light);
  color: var(--primary-strong);
  outline: 0;
}

.task-context-menu-button.danger {
  color: var(--danger);
}

.task-context-menu-button.danger:hover,
.task-context-menu-button.danger:focus-visible {
  background: var(--danger-soft);
  color: var(--danger);
}

.task-context-menu-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.task-delete-button:hover,
.task-delete-button:focus-visible {
  background: color-mix(in srgb, var(--danger) 16%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}

.task-archive-button:hover {
  background: var(--primary-light);
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
}

.task-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 500;
  font-size: 13px;
  color: var(--task-title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0;
  line-height: 1.25;
}

.task-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.task-unread-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--status-blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-blue) 14%, transparent);
}

.task-meta,
.task-meta-row,
.task-runtime,
.task-card-time,
.task-retry-state {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.task-meta-row {
  color: var(--muted);
}

.task-detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(72px, 40%);
  align-items: center;
  min-width: 0;
  color: var(--text-secondary);
  gap: 6px;
}

.task-detail-row-meta-only {
  grid-template-columns: minmax(0, 1fr);
}

.task-runtime {
  justify-self: end;
  min-width: 0;
  max-width: 82px;
  color: var(--text-secondary);
  font-size: 10.5px;
  white-space: nowrap;
  text-align: right;
}

.task-retry-state {
  justify-self: end;
  max-width: 100%;
  color: var(--primary-strong);
  text-align: right;
}

.task-card-time {
  justify-self: end;
  max-width: 82px;
  color: var(--text-secondary);
  text-align: right;
}

.task-card-running-timer {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 3px;
  max-width: 102px;
  color: var(--status-blue);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.task-card-running-timer .elapsed-timer {
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  color: inherit;
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1;
}

.task-card-running-timer .elapsed-main {
  min-width: 4.4ch;
}

.task-card-running-timer .elapsed-ms {
  min-width: 1.6ch;
  opacity: 0.72;
}

.task-card.failed .task-retry-state,
.task-card.partial_failed .task-retry-state {
  color: color-mix(in srgb, var(--danger) 72%, var(--text-secondary));
  font-weight: 650;
}

.task-status-row {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
  line-height: 1.2;
}

.task-status-inline {
  flex: 0 0 auto;
  max-width: 58px;
}

.task-status-label {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 58px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.task-card.failed .task-status-label,
.task-card.partial_failed .task-status-label {
  color: color-mix(in srgb, var(--danger) 76%, var(--text-secondary));
}

.task-card.running .task-status-label {
  color: color-mix(in srgb, var(--status-blue) 78%, var(--text-secondary));
}

.task-status-meta {
  justify-self: start;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-image-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

.task-image-progress {
  --task-block-count: 1;
  display: grid;
  grid-template-columns: repeat(var(--task-block-count), 8px);
  gap: 3px;
  width: max-content;
  max-width: 41px;
  height: 8px;
  flex: 0 0 auto;
}

.task-image-progress.compressed {
  width: max-content;
  flex-basis: auto;
}

.task-image-block {
  width: 8px;
  height: 8px;
  min-width: 0;
  border-radius: 3px;
  border: 0;
  background: color-mix(in srgb, var(--line) 72%, var(--surface-soft));
}

.task-image-block.completed {
  background: var(--primary);
}

.task-image-block.failed {
  background: var(--danger);
}

.task-image-block.running {
  background: var(--status-blue);
}

.task-image-block.queued {
  background: var(--accent);
}

.task-image-summary {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 8px 16px 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
}

.task-history-batch-button.active {
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  background: var(--primary-light);
  color: var(--primary-strong);
}

.batch-toolbar {
  align-self: stretch;
  display: grid;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--line));
  border-radius: 8px;
  background: var(--surface-soft);
}

.batch-selected-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.batch-toolbar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.batch-toolbar-actions .ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.task-history-tools .status-text {
  text-align: left;
  font-size: 11px;
  line-height: 1.25;
  -webkit-line-clamp: 1;
  max-height: 1.25em;
}

.task-history-tools .status-text.error {
  -webkit-line-clamp: 2;
  max-height: 2.5em;
}

.sidebar-api-status-holder {
  display: none;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.status-dot.error {
  background: var(--danger);
}

.status-dot.loading {
  background: var(--accent);
}

.version-info {
  appearance: none;
  border: 0;
  background: transparent;
  width: auto;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition:
    background var(--motion-base),
    color var(--motion-base),
    box-shadow var(--motion-base);
}

.version-info:hover,
.version-info:focus-visible {
  background: var(--surface-soft);
  color: var(--text-secondary);
}

.version-info.has-update {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent);
}

.version-update-badge {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* source: styles/30-layout-top-nav-panels.css */
/* Main Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  container-type: inline-size;
  container-name: workspace;
  background-image: var(--workspace-texture);
  background-size: 22px 22px, 100% 100%;
}

/* Top Navigation */
.top-nav {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  padding: 0 24px;
  flex-shrink: 0;
}

.nav-actions {
  --top-nav-control-height: 36px;
  --top-nav-control-padding: 3px;
  --top-nav-control-radius: 999px;
  --top-nav-segment-height: 30px;
  --top-nav-control-font-size: 13px;

  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.queue-button {
  order: 3;
  flex: 0 0 auto;
  height: var(--top-nav-control-height);
  min-height: var(--top-nav-control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  border-radius: var(--top-nav-control-radius);
  background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
  color: var(--primary-strong);
  font-size: var(--top-nav-control-font-size);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--motion-base), border-color var(--motion-base), box-shadow var(--motion-base);
}

.queue-button:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  background: var(--primary-light);
  box-shadow: 0 3px 10px rgba(40, 116, 85, 0.1);
}

.queue-badge {
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border-radius: var(--top-nav-control-radius);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: var(--top-nav-control-font-size);
  line-height: 1;
}

.queue-badge.hidden {
  display: none;
}

.task-notification-button {
  position: relative;
  width: var(--top-nav-control-height);
  padding: 0;
}

.task-notification-button.has-unread {
  border-color: color-mix(in srgb, var(--primary) 52%, var(--line));
  background: color-mix(in srgb, var(--primary-light) 78%, var(--surface));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 14%, transparent);
}

.task-notification-icon {
  display: block;
  width: 17px;
  height: 17px;
}

.task-notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}

.task-notification-dot.hidden {
  display: none;
}

.task-notification-unread-summary {
  margin-left: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-strong);
  font-size: 11px;
  line-height: 1;
  font-weight: 700;
}

.task-notification-center {
  position: absolute;
  top: calc(100% + 8px);
  right: 24px;
  z-index: 8400;
  width: min(360px, calc(100vw - 24px));
  max-height: min(520px, calc(100vh - var(--header-height) - 24px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-popover);
}

.task-notification-center.hidden {
  display: none;
}

.task-notification-center-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.task-notification-center-header strong {
  font-size: 13px;
  color: var(--text);
}

.task-notification-list {
  display: grid;
  gap: 8px;
  min-height: 76px;
  max-height: 430px;
  overflow-y: auto;
  padding-right: 2px;
}

.task-notification-empty {
  min-height: 72px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.task-notification-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.task-notification-item:hover,
.task-notification-item:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 38%, var(--line));
  background: var(--primary-light);
  outline: 0;
}

.task-notification-item.unread {
  border-color: color-mix(in srgb, var(--primary) 46%, var(--line));
}

.task-notification-thumb {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface);
}

.task-notification-thumb-placeholder {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 18px;
}

.task-notification-body {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.task-notification-title {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-notification-message {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.task-notification-toast-region {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9400;
  display: grid;
  gap: 10px;
  width: min(340px, calc(100vw - 24px));
  pointer-events: none;
}

.task-notification-toast {
  pointer-events: auto;
  box-shadow: var(--shadow-popover);
}

.theme-switcher {
  order: 3;
  flex: 0 0 auto;
  height: var(--top-nav-control-height);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: var(--top-nav-control-padding);
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  border-radius: var(--top-nav-control-radius);
  background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
  font-size: var(--top-nav-control-font-size);
  line-height: 1;
}

.theme-option {
  height: var(--top-nav-segment-height);
  min-height: var(--top-nav-segment-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border: 0;
  border-radius: var(--top-nav-control-radius);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--top-nav-control-font-size);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--motion-base), color var(--motion-base);
}

.theme-option:hover,
.theme-option:focus-visible {
  color: var(--primary-strong);
  outline: none;
}

.theme-option.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

.github-link {
  width: var(--top-nav-control-height);
  padding: 0;
  color: var(--text-secondary);
  text-decoration: none;
}

.github-link:hover,
.github-link:focus-visible {
  color: var(--primary-strong);
  outline: none;
}

.github-link-icon {
  width: 17px;
  height: 17px;
  display: block;
}

.auth-source-switcher {
  order: 1;
  flex: 0 1 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-width: 0;
  position: relative;
}

.auth-source-group {
  height: var(--top-nav-control-height);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: var(--top-nav-control-padding);
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  border-radius: var(--top-nav-control-radius);
  background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
  font-size: var(--top-nav-control-font-size);
  line-height: 1;
}

.auth-source-button {
  flex: 0 0 auto;
  height: var(--top-nav-segment-height);
  min-height: var(--top-nav-segment-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--top-nav-control-radius);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--top-nav-control-font-size);
  line-height: 1;
  padding: 0 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--motion-base), color var(--motion-base), box-shadow var(--motion-base);
}

.auth-source-button.active {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 2px 8px rgba(40, 116, 85, 0.16);
}

.auth-source-api-button {
  gap: 4px;
}

.auth-source-settings-icon {
  width: 15px;
  height: 15px;
  opacity: 0.78;
}

.auth-source-settings-button {
  flex: 0 0 auto;
  width: var(--top-nav-control-height);
  height: var(--top-nav-control-height);
  min-height: var(--top-nav-control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  border-radius: var(--top-nav-control-radius);
  background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--motion-base), border-color var(--motion-base), color var(--motion-base), box-shadow var(--motion-base);
}

.auth-source-settings-button:hover,
.auth-source-settings-button:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  background: var(--primary-light);
  color: var(--primary-strong);
  box-shadow: 0 3px 10px rgba(40, 116, 85, 0.1);
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .queue-button,
  .theme-option,
  .auth-source-button,
  .auth-source-settings-button {
    transition: none;
  }
}

.api-provider-quick {
  height: var(--top-nav-control-height);
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  border-radius: var(--top-nav-control-radius);
  padding: 0 14px;
  background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
  color: var(--text);
  font-size: var(--top-nav-control-font-size);
  line-height: 1;
}

.auth-source-detail {
  flex: 0 0 auto;
  width: 150px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dashboard Workspace */
.dashboard {
  flex: 1;
  width: min(100%, 1760px);
  min-height: 0;
  margin-inline: auto;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: minmax(520px, 760px) minmax(520px, 1fr);
  gap: 24px;
  align-content: safe center;
  align-items: stretch;
}

.dashboard-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
}

.controls-col {
  width: 100%;
  max-width: 760px;
}

.preview-col {
  position: relative;
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.preview-panel {
  height: 100%;
  max-height: none;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Panels */
.panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--panel-border);
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--section-heading);
  line-height: 1.2;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin: 0;
}

.preview-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.preview-heading-actions .ghost-button {
  height: 34px;
  min-height: 34px;
  min-width: 112px;
  padding: 0 14px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 72%, var(--surface-soft));
  border-color: color-mix(in srgb, var(--line) 88%, var(--text-secondary));
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.preview-heading-actions .ghost-button:hover,
.preview-heading-actions .ghost-button:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  background: var(--surface-soft);
  color: var(--text);
}

.preview-heading-actions .danger-action {
  border-color: color-mix(in srgb, var(--danger) 34%, var(--line));
}

.preview-delete-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.preview-selection-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.preview-selection-count {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.danger-action {
  color: var(--danger);
}

.image-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* source: styles/40-controls.css */
/* Buttons */
.primary-button {
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  height: 44px;
  width: 100%;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--motion-base);
}

.primary-button:hover {
  background: var(--primary-strong);
  color: var(--primary-foreground);
}

.brand-new-button {
  min-width: 84px;
  width: auto;
  height: 34px;
  padding: 0 14px;
  border-radius: 11px;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 720;
  gap: 7px;
  box-shadow: 0 7px 16px rgba(51, 93, 77, 0.16);
}

.brand-new-icon {
  display: block;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.run-button {
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  height: 36px;
  padding: 0 16px;
  border-radius: 18px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--motion-base);
}

.run-button:hover {
  background: var(--primary-strong);
  color: var(--primary-foreground);
}

.run-button.running {
  background: var(--primary-strong);
  color: var(--primary-foreground);
}

.run-button.running::before {
  content: "";
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(
    from 90deg,
    rgba(255, 255, 255, 0) 0deg,
    rgba(255, 255, 255, 0.28) 90deg,
    rgba(255, 255, 255, 0.76) 250deg,
    #fff 330deg,
    rgba(255, 255, 255, 0) 360deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  animation: soft-spin 1s linear infinite;
}

.ghost-button {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--line);
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--motion-base),
    border-color var(--motion-base),
    color var(--motion-base),
    box-shadow var(--motion-base);
}

.ghost-button:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.icon-button {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-text-button {
  gap: 6px;
}

.resource-manage-button {
  width: 100%;
  min-width: 0;
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 500;
  white-space: nowrap;
}

.resource-manage-button:hover,
.resource-manage-button:focus-visible {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
  color: var(--primary-foreground);
}

.button-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button-icon svg,
svg.button-icon {
  stroke: currentColor;
}

.quiet-danger-button {
  color: var(--text-secondary);
  border-color: var(--line);
}

.quiet-danger-button:hover,
.quiet-danger-button:focus-visible {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
  background: color-mix(in srgb, var(--danger-soft) 62%, var(--surface));
}

.drawer-close-button {
  flex: 0 0 44px;
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 10px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.drawer-close-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.text-sm {
  font-size: 12px;
  height: 28px;
  padding: 0 10px;
}

/* Controls */
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.control {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--motion-base);
}

.control:focus {
  border-color: var(--primary);
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}

.model-combobox {
  position: relative;
}

.model-combobox-input {
  padding-right: 38px;
}

.model-combobox-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
  cursor: pointer;
}

.model-combobox-toggle:hover,
.model-combobox-toggle:focus-visible {
  background: var(--primary-light);
  color: var(--primary-strong);
}

.model-combobox-caret {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.model-combobox-options {
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-popover);
}

.model-combobox-option {
  display: flex;
  align-items: center;
  min-height: 30px;
  width: 100%;
  padding: 6px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.model-combobox-option:hover,
.model-combobox-option.active {
  background: var(--primary-light);
  color: var(--primary-strong);
}

.model-combobox-option.selected {
  font-weight: 600;
}

.model-combobox-empty {
  padding: 8px 9px;
  color: var(--muted);
  font-size: 12px;
}

/* Segmented Control */
.segmented {
  display: flex;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px;
  margin-bottom: 16px;
}

.segment {
  flex: 1;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition:
    background var(--motion-base),
    color var(--motion-base),
    box-shadow var(--motion-base);
}

.segment.active {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Radio Group */
.radio-group {
  --segmented-control-padding: 3px;
  --segmented-control-height: 30px;
  --segmented-indicator-radius: 5px;
  display: flex;
  align-items: stretch;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: var(--segmented-control-padding);
}

.ratio-group {
  --segmented-control-padding: 2px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(2, 30px);
  gap: 2px;
}

.ratio-group .radio-btn[data-val="1:1"] {
  grid-column: 1;
  grid-row: 1 / 3;
  height: 100%;
}

.ratio-group .radio-btn[data-val="4:5"] {
  grid-column: 2;
  grid-row: 1;
}

.ratio-group .radio-btn[data-val="5:4"] {
  grid-column: 2;
  grid-row: 2;
}

.ratio-group .radio-btn[data-val="3:4"] {
  grid-column: 3;
  grid-row: 1;
}

.ratio-group .radio-btn[data-val="4:3"] {
  grid-column: 3;
  grid-row: 2;
}

.ratio-group .radio-btn[data-val="2:3"] {
  grid-column: 4;
  grid-row: 1;
}

.ratio-group .radio-btn[data-val="3:2"] {
  grid-column: 4;
  grid-row: 2;
}

.ratio-group .radio-btn[data-val="9:16"] {
  grid-column: 5;
  grid-row: 1;
}

.ratio-group .radio-btn[data-val="16:9"] {
  grid-column: 5;
  grid-row: 2;
}

.ratio-group .radio-btn[data-val="9:21"] {
  grid-column: 6;
  grid-row: 1;
}

.ratio-group .radio-btn[data-val="21:9"] {
  grid-column: 6;
  grid-row: 2;
}

.radio-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: var(--segmented-control-height);
  padding: 0 12px;
  border: none;
  background-color: transparent;
  color: var(--text-secondary);
  border-radius: var(--segmented-indicator-radius);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color var(--motion-base),
    color var(--motion-base),
    box-shadow var(--motion-base),
    transform var(--motion-base);
}

.ratio-group .radio-btn {
  height: 100%;
  padding: 0 6px;
  transform: scale(0.985);
}

.radio-btn.active {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.ratio-group .radio-btn.active {
  transform: scale(1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.segmented-indicator-host {
  --segmented-indicator-x: 0px;
  --segmented-indicator-y: 0px;
  --segmented-indicator-width: 0px;
  --segmented-indicator-height: 0px;
  --segmented-indicator-opacity: 0;
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.segmented-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--segmented-indicator-width);
  height: var(--segmented-indicator-height);
  border-radius: var(--segmented-indicator-radius);
  background: var(--primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  opacity: var(--segmented-indicator-opacity);
  pointer-events: none;
  transform: translate3d(var(--segmented-indicator-x), var(--segmented-indicator-y), 0);
  transition:
    transform var(--motion-base),
    width var(--motion-base),
    height var(--motion-base),
    opacity var(--motion-fast);
  z-index: 0;
}

.auth-source-group .segmented-indicator {
  border-radius: 999px;
  box-shadow: 0 5px 14px rgba(40, 116, 85, 0.22);
}

.segmented-indicator-host .radio-btn,
.segmented-indicator-host .auth-source-button,
.segmented-indicator-host .system-settings-tab,
.segmented-indicator-host .history-view-button,
.segmented-indicator-host .history-sort-button {
  position: relative;
  z-index: 1;
}

.radio-group.segmented-indicator-host .radio-btn.active {
  background: transparent;
  color: var(--primary-foreground);
}

.auth-source-group.segmented-indicator-host .auth-source-button.active {
  background: transparent;
  color: var(--primary-foreground);
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  .primary-button,
  .run-button,
  .ghost-button,
  .control,
  .segment,
  .slider.round,
  .slider.round:before,
  .radio-btn,
  .ratio-group .radio-btn,
  .segmented-indicator {
    transition: none;
  }

  .ratio-group .radio-btn {
    transform: none;
  }
}

/* source: styles/50-image-input-gallery.css */
/* Image Upload */
.image-panel {
  container-type: inline-size;
}

.image-input-workspace {
  --image-input-main-height: 150px;
  --image-input-action-height: 40px;
  --image-input-gap: 10px;
  --image-input-total-height: calc(var(--image-input-main-height) + var(--image-input-gap) + var(--image-input-action-height));
  --image-upload-source-compact-width: 118px;
  --image-input-thumb-size: 116px;
  --image-input-compact-thumb-size: calc((var(--image-input-main-height) - 24px) / 2);
  --quick-gallery-column-width: var(--workspace-side-action-width);
  --quick-gallery-height: var(--image-input-main-height);
  --recent-asset-size: 32px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--quick-gallery-column-width);
  gap: 12px;
  align-items: stretch;
  min-width: 0;
}

.brand-material-picker {
  display: grid;
  grid-template-columns: minmax(150px, 0.22fr) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
}

.brand-material-picker.hidden {
  display: none;
}

.brand-material-heading {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.brand-material-heading strong {
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.25;
}

.brand-material-heading span {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.35;
}

.brand-material-list {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding: 2px 1px 4px;
  scrollbar-width: thin;
}

.brand-material-option {
  display: inline-grid;
  grid-template-columns: 54px max-content;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 42px;
  padding: 5px 10px 5px 6px;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--motion-fast), background var(--motion-fast), color var(--motion-fast);
}

.brand-material-option:hover {
  border-color: color-mix(in srgb, var(--primary) 50%, var(--line));
  color: var(--text-primary);
}

.brand-material-option.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-light) 76%, var(--surface));
  color: var(--primary-strong);
}

.brand-material-option:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 74%, white);
  outline-offset: 2px;
}

.brand-material-preview {
  display: grid;
  place-items: center;
  width: 54px;
  height: 30px;
  overflow: hidden;
  border-radius: 5px;
  background: #fff;
}

.brand-material-preview img {
  display: block;
  width: 48px;
  height: 22px;
  object-fit: contain;
}

.brand-material-none-mark {
  color: var(--text-secondary);
  font-size: 18px;
}

.brand-material-name {
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
}

.image-input-left {
  display: flex;
  flex-direction: column;
  gap: var(--image-input-gap);
  height: var(--image-input-total-height);
  min-width: 0;
  container-type: inline-size;
}

.image-gallery-column {
  display: grid;
  grid-template-rows: var(--quick-gallery-height) var(--image-input-action-height);
  gap: var(--image-input-gap);
  height: var(--image-input-total-height);
  min-width: 0;
}

.image-input-main {
  min-width: 0;
  height: var(--image-input-main-height);
  overflow: hidden;
  border: 1px dashed color-mix(in srgb, var(--text-secondary) 36%, var(--line));
  border-radius: 8px;
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--surface-soft) 88%, var(--primary-light)),
      color-mix(in srgb, var(--surface-soft) 72%, var(--primary-light))
    ),
    var(--surface-soft);
  transition: border-color var(--motion-base), background var(--motion-base);
}

.image-input-main:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.image-input-main:has(.image-uploader-grid.drag-over),
.image-uploader-grid.drag-over {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-light) 82%, var(--surface-soft));
}

.image-uploader-grid.drag-over .upload-tile {
  color: var(--primary-strong);
  background: color-mix(in srgb, var(--primary-light) 76%, var(--surface-soft));
}

.image-input-footer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  height: var(--image-input-action-height);
  min-width: 0;
}

.image-input-actions {
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
  gap: 8px;
  flex-wrap: nowrap;
  height: var(--image-input-action-height);
  min-height: var(--image-input-action-height);
  min-width: 0;
  position: relative;
}

.image-thumb-items,
.reference-file-selection {
  display: contents;
}

.reference-file-selection.hidden {
  display: none;
}

.reference-file-thumb.is-missing {
  color: var(--muted);
}

.reference-file-thumb {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: stretch;
  padding: 8px 8px 7px;
}

.reference-file-thumb .reference-file-icon {
  display: grid;
  place-items: center;
  min-height: 0;
}

.reference-file-thumb .reference-file-format-icon {
  display: block;
  width: 44px;
  height: 50px;
}

.reference-file-name {
  display: -webkit-box;
  min-height: 31px;
  overflow: hidden;
  padding-top: 5px;
  border-top: 1px solid color-mix(in srgb, var(--text-secondary) 12%, transparent);
  color: var(--text-primary);
  font-size: 10.5px;
  line-height: 1.25;
  text-align: center;
  word-break: break-all;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.reference-file-thumb .reference-file-remove {
  z-index: 2;
  opacity: 0;
  pointer-events: none;
}

.reference-file-thumb:hover .reference-file-remove,
.reference-file-thumb:focus-within .reference-file-remove,
.reference-file-thumb:focus-visible .reference-file-remove {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: none), (pointer: coarse) {
  .reference-file-thumb .reference-file-remove {
    opacity: 1;
    pointer-events: auto;
  }
}

.reference-file-requirement {
  position: absolute;
  z-index: 18;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow-popover);
  color: var(--text-secondary);
  font-size: 12px;
}

.reference-file-requirement > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-input-actions .ghost-button,
.gallery-manage-panel .resource-manage-button {
  height: var(--image-input-action-height);
}

.image-uploader-grid {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: 12px;
}

.image-uploader-grid.has-inputs .image-strip {
  grid-template-columns: minmax(0, 1fr) var(--image-upload-source-compact-width);
}

.reference-collector {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 20;
  display: grid;
  gap: 8px;
  max-width: calc(100% - 16px);
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow-popover);
  backdrop-filter: blur(10px);
}

.reference-collector.hidden {
  display: none;
}

.reference-collector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.reference-collector-header span {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.reference-collector-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.reference-collector-actions .ghost-button {
  min-height: 28px;
  padding: 5px 9px;
}

.reference-collector-list {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: min(360px, calc(100vw - 48px));
  overflow-x: auto;
  scrollbar-width: none;
}

.reference-collector-list::-webkit-scrollbar {
  display: none;
}

.reference-collector-item {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}

.reference-collector-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reference-collector-item button {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 0 8px 0 8px;
  background: color-mix(in srgb, var(--danger) 92%, transparent);
  color: #fff;
  cursor: pointer;
  line-height: 1;
}

.image-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.image-thumb-list {
  display: none;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.image-uploader-grid.has-inputs .image-thumb-list {
  display: flex;
}

.image-thumb-list::-webkit-scrollbar {
  display: none;
}

.recent-asset-dock {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: var(--recent-asset-size);
  padding: 0;
}

.recent-asset-dock.hidden {
  display: none;
}

.recent-asset-heading {
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
}

.recent-asset-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 0;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.recent-asset-list::-webkit-scrollbar {
  display: none;
}

.recent-asset-button {
  position: relative;
  width: var(--recent-asset-size);
  height: var(--recent-asset-size);
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  display: block;
  min-width: var(--recent-asset-size);
}

.recent-asset-button:hover {
  border-color: color-mix(in srgb, var(--primary) 54%, transparent);
  background: var(--surface-soft);
}

.recent-asset-use {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 2px;
  cursor: pointer;
}

.recent-asset-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.recent-asset-button span {
  display: none;
}

.recent-asset-delete {
  position: absolute;
  top: -5px;
  right: -4px;
  z-index: 2;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--danger) 34%, transparent);
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-fast), background var(--motion-fast), border-color var(--motion-fast);
}

.recent-asset-button:hover .recent-asset-delete,
.recent-asset-button:focus-within .recent-asset-delete {
  opacity: 1;
  pointer-events: auto;
}

.recent-asset-delete:hover,
.recent-asset-delete:focus-visible {
  border-color: color-mix(in srgb, var(--danger) 62%, transparent);
  background: color-mix(in srgb, var(--danger) 16%, var(--surface));
}

.image-upload-source {
  min-width: 0;
  height: 100%;
}

.thumb {
  position: relative;
  flex: 0 0 var(--image-input-thumb-size);
  width: var(--image-input-thumb-size);
  height: var(--image-input-thumb-size);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.editable-thumb {
  cursor: pointer;
  outline: none;
  transition: border-color var(--motion-base), box-shadow var(--motion-base), transform var(--motion-base);
  touch-action: manipulation;
}

.editable-thumb:hover {
  border-color: color-mix(in srgb, var(--primary) 68%, transparent);
  box-shadow: 0 10px 22px rgba(12, 28, 23, 0.14);
  transform: translateY(-1px);
}

.editable-thumb:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb .thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  width: 20px;
  height: 20px;
  border: 1px solid color-mix(in srgb, var(--danger) 36%, var(--surface));
  border-radius: 50%;
  background: color-mix(in srgb, var(--danger) 78%, var(--surface));
  color: var(--primary-foreground);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 6px 14px rgba(12, 28, 23, 0.16);
  transition: background var(--motion-base), border-color var(--motion-base), transform var(--motion-base);
}

.thumb .thumb-remove:hover,
.thumb .thumb-remove:focus-visible {
  border-color: color-mix(in srgb, var(--danger) 72%, var(--surface));
  background: var(--danger);
  transform: translateY(-1px);
}

.thumb-remove-icon,
.thumb-remove-icon svg {
  display: block;
  width: 12px;
  height: 12px;
}

.thumb-badge,
.add-upload-to-gallery {
  position: absolute;
  left: 5px;
  right: 5px;
  z-index: 1;
}

.thumb-badge {
  top: 5px;
  right: auto;
  width: fit-content;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--primary-foreground) 22%, transparent);
  background: color-mix(in srgb, var(--primary) 88%, transparent);
  color: var(--primary-foreground);
  font-size: 10px;
  box-shadow: 0 6px 14px rgba(12, 28, 23, 0.14);
}

.gallery-thumb {
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
}

.asset-thumb {
  border-color: color-mix(in srgb, var(--accent) 52%, transparent);
}

.missing-thumb {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.upload-tile {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: none;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  transition:
    background var(--motion-base),
    color var(--motion-base),
    border-color var(--motion-base);
  gap: 5px;
  text-align: center;
}

.upload-tile:hover {
  color: var(--primary-strong);
  background: color-mix(in srgb, var(--primary-light) 62%, var(--surface-soft));
}

.upload-tile input {
  display: none;
}

.upload-tile .icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--primary) 36%, var(--line));
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary-light) 68%, var(--surface-soft));
  color: var(--primary-strong);
  font-size: 19px;
  font-weight: 300;
  line-height: 0;
}

.upload-tile .icon svg {
  display: block;
  width: 18px;
  height: 18px;
}

.upload-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.upload-title-compact {
  display: none;
}

.upload-subtitle {
  color: var(--muted);
  font-size: 11px;
}

.image-uploader-grid.has-inputs .upload-tile {
  gap: 6px;
  padding: 8px;
}

.image-uploader-grid.has-inputs .upload-title-full {
  display: none;
}

.image-uploader-grid.has-inputs .upload-title-compact {
  display: inline;
}

.image-uploader-grid.has-inputs .upload-subtitle {
  display: none;
}

.image-uploader-grid.compact-grid .image-strip {
  grid-template-columns: minmax(0, 1fr) var(--image-input-compact-thumb-size);
  grid-template-rows: var(--image-input-compact-thumb-size);
  align-content: center;
  align-items: stretch;
  gap: 6px;
  overflow: hidden;
}

.image-uploader-grid.compact-grid {
  padding: 8px;
}

.image-uploader-grid.compact-grid .image-thumb-list {
  display: flex;
}

.image-uploader-grid.compact-grid .thumb,
.image-uploader-grid.compact-grid .image-upload-source {
  width: var(--image-input-compact-thumb-size);
  height: var(--image-input-compact-thumb-size);
  min-width: 0;
}

.image-uploader-grid.compact-grid .thumb {
  flex-basis: var(--image-input-compact-thumb-size);
}

.image-uploader-grid.compact-grid .upload-tile {
  gap: 3px;
  padding: 4px;
}

.image-uploader-grid.compact-grid .upload-tile .icon {
  width: 24px;
  height: 24px;
  font-size: 17px;
}

.image-uploader-grid.compact-grid .upload-title {
  font-size: 11px;
  line-height: 1.1;
  white-space: nowrap;
}

.image-uploader-grid.compact-grid .thumb-badge {
  display: none;
}

.image-uploader-grid.compact-grid .reference-file-name {
  display: none;
}

.image-uploader-grid.compact-grid .thumb .thumb-remove {
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
}

.image-uploader-grid.compact-grid .thumb-remove-icon,
.image-uploader-grid.compact-grid .thumb-remove-icon svg {
  width: 10px;
  height: 10px;
}

.image-uploader-grid.compact-grid .add-upload-to-gallery {
  left: 2px;
  bottom: 2px;
  width: 20px;
  min-width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 999px;
  font-size: 0;
  gap: 0;
}

.image-uploader-grid.compact-grid .add-upload-to-gallery .thumb-add-icon {
  width: 12px;
  height: 12px;
}

.quick-gallery-dock {
  position: relative;
  height: var(--quick-gallery-height);
  min-width: 0;
}

.quick-gallery-preview {
  position: absolute;
  top: 50%;
  right: calc(100% + 12px);
  z-index: 4;
  width: 96px;
  height: 128px;
  pointer-events: none;
  opacity: 0;
  transform: translate(8px, -50%) scale(0.98);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  box-shadow: 0 14px 36px rgba(29, 52, 46, 0.18);
  transition: opacity var(--motion-fast), transform var(--motion-fast);
}

.quick-gallery-preview.visible {
  opacity: 1;
  transform: translate(0, -50%) scale(1);
}

.quick-gallery-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.quick-gallery-preview span {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(31, 53, 47, 0.72);
  color: white;
  font-size: 10px;
}

.quick-gallery-preview-empty {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.quick-gallery-preview-empty span {
  position: static;
  background: transparent;
  color: inherit;
}

.quick-gallery-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 8px;
  height: 100%;
  min-width: 0;
}

.quick-gallery-list {
  --quick-gallery-item-height: 30px;
  position: relative;
  display: grid;
  align-content: start;
  gap: 6px;
  height: var(--quick-gallery-height);
  overflow-y: auto;
  scrollbar-width: none;
  padding: 0 4px 0 0;
  scroll-snap-type: y proximity;
}

.quick-gallery-list::-webkit-scrollbar {
  display: none;
}

.quick-gallery-list.bounce-top {
  animation: quickGalleryBounceTop var(--motion-fast);
}

.quick-gallery-list.bounce-bottom {
  animation: quickGalleryBounceBottom var(--motion-fast);
}

.quick-gallery-item {
  width: 100%;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--text-secondary) 24%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-soft) 78%, var(--surface));
  color: var(--text-secondary);
  text-align: center;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.66;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  scroll-snap-align: start;
  transform: scale(0.96);
  transition:
    opacity var(--motion-base),
    transform var(--motion-base),
    background var(--motion-base),
    border-color var(--motion-base),
    box-shadow var(--motion-base),
    color var(--motion-base);
}

.quick-gallery-item.near {
  border-color: color-mix(in srgb, var(--primary) 36%, var(--line));
  opacity: 0.84;
  transform: scale(0.98);
}

.quick-gallery-item.center {
  border-color: color-mix(in srgb, var(--primary) 58%, var(--line));
  background: color-mix(in srgb, var(--primary-light) 86%, var(--surface-soft));
  color: var(--primary-strong);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 24%, transparent);
  opacity: 1;
  transform: scale(1);
}

.quick-gallery-item:hover,
.quick-gallery-item.active {
  background: color-mix(in srgb, var(--primary-light) 70%, var(--surface-soft));
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--primary-strong);
  opacity: 0.92;
  transform: scale(0.98);
}

.quick-gallery-item.center.active {
  border-color: color-mix(in srgb, var(--primary) 58%, var(--line));
  background: color-mix(in srgb, var(--primary-light) 86%, var(--surface-soft));
  color: var(--primary-strong);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 24%, transparent);
  opacity: 1;
  transform: scale(1);
}

@keyframes quickGalleryBounceTop {
  0% { transform: translateY(0); }
  42% { transform: translateY(5px); }
  100% { transform: translateY(0); }
}

@keyframes quickGalleryBounceBottom {
  0% { transform: translateY(0); }
  42% { transform: translateY(-5px); }
  100% { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .image-input-main,
  .recent-asset-delete,
  .editable-thumb,
  .upload-tile,
  .quick-gallery-preview,
  .quick-gallery-item,
  .quick-gallery-category,
  .quick-gallery-list.bounce-top,
  .quick-gallery-list.bounce-bottom {
    transition: none;
  }

  .quick-gallery-list.bounce-top,
  .quick-gallery-list.bounce-bottom {
    animation: none;
  }

  .editable-thumb:hover,
  .quick-gallery-item,
  .quick-gallery-item.near,
  .quick-gallery-item.center,
  .quick-gallery-item:hover,
  .quick-gallery-item.active {
    transform: none;
  }
}

.quick-gallery-empty {
  min-height: 110px;
  display: grid;
  place-items: center;
  border: 1px dashed color-mix(in srgb, var(--text-secondary) 30%, var(--line));
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.quick-gallery-rail {
  height: var(--quick-gallery-height);
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-snap-type: y proximity;
  scrollbar-width: none;
}

.quick-gallery-rail::-webkit-scrollbar {
  display: none;
}

.quick-gallery-category {
  flex: 0 0 30px;
  width: 100%;
  height: 30px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--line));
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--primary-strong);
  font-size: 12px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  scroll-snap-align: start;
  cursor: pointer;
  transition: background var(--motion-base), color var(--motion-base), border-color var(--motion-base);
}

.quick-gallery-category.active {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.gallery-manage-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  max-width: 100%;
  height: var(--image-input-action-height);
  min-height: var(--image-input-action-height);
  padding: 0;
  background: transparent;
}

.gallery-manage-panel .resource-manage-button {
  flex: 1 1 auto;
}

.gallery-fly-clone {
  position: fixed;
  z-index: 9000;
  object-fit: cover;
  border-radius: 8px;
  pointer-events: none;
  box-shadow: 0 16px 42px rgba(24, 45, 39, 0.24);
}

/* source: styles/60-prompt.css */
/* Prompt */
.prompt-panel {
  --prompt-action-column-width: var(--workspace-side-action-width);
  --prompt-action-gap: 12px;
  --prompt-secondary-action-height: 40px;
  --prompt-secondary-chip-height: 32px;
}

.prompt-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--prompt-action-column-width);
  gap: var(--prompt-action-gap);
  align-items: end;
  margin-bottom: 12px;
}

.prompt-heading-main {
  display: flex;
  align-items: flex-end;
  min-width: 0;
  justify-content: space-between;
  gap: 12px;
}

.prompt-count {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-soft) 72%, var(--surface));
}

.prompt-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--prompt-action-column-width);
  gap: var(--prompt-action-gap);
  align-items: start;
}

.prompt-run-wrap {
  min-width: 0;
}

.prompt-template-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--prompt-action-column-width);
  gap: var(--prompt-action-gap);
  align-items: center;
  min-height: var(--prompt-secondary-action-height);
  margin-top: 8px;
}

.prompt-template-entry {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.prompt-template-recent-cell {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: var(--prompt-secondary-action-height);
  min-width: 0;
}

.prompt-template-recent-cell.find-active .prompt-template-recent-dock {
  display: none;
}

.prompt-template-entry .prompt-template-button {
  width: 100%;
  height: var(--prompt-secondary-action-height);
  min-height: var(--prompt-secondary-action-height);
  white-space: nowrap;
}

.prompt-box {
  width: 100%;
  height: 140px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  resize: vertical;
  font-size: 13px;
  line-height: 1.5;
  background: var(--surface);
  outline: none;
}

.prompt-box:focus {
  border-color: var(--primary);
}

.prompt-editor-wrap {
  position: relative;
  min-width: 0;
}

.prompt-editor {
  overflow-y: auto;
  white-space: pre-wrap;
}

.prompt-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.gallery-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 180px;
  margin: 0 2px;
  padding: 2px 7px 2px 3px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--line));
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-strong);
  font-weight: 600;
  line-height: 1.6;
  vertical-align: middle;
  cursor: grab;
  user-select: all;
}

.gallery-chip img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
}

.gallery-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(51, 93, 77, 0.12);
  color: var(--primary-strong);
  cursor: pointer;
}

.gallery-chip-remove:hover {
  background: rgba(51, 93, 77, 0.24);
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 150px;
  margin: 0 2px;
  padding: 2px 7px 2px 4px;
  border: 1px solid color-mix(in srgb, var(--color-code) 46%, #ffffff);
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-code) 22%, #ffffff);
  color: var(--color-text, var(--text));
  font-weight: 600;
  line-height: 1.6;
  vertical-align: middle;
  cursor: grab;
  user-select: all;
}

.color-chip-swatch {
  appearance: none;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid rgba(31, 53, 47, 0.18);
  border-radius: 50%;
  background: var(--color-code);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.44);
  cursor: pointer;
}

.color-chip-swatch:hover {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.56),
    0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent);
}

.color-chip > span:not(.color-chip-swatch) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.color-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(31, 53, 47, 0.13);
  color: inherit;
  cursor: pointer;
}

.color-chip-remove:hover {
  background: rgba(31, 53, 47, 0.24);
}

.prompt-snippet-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 170px;
  margin: 0 2px;
  padding: 2px 7px 2px 4px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--text);
  font-weight: 600;
  line-height: 1.6;
  vertical-align: middle;
  cursor: grab;
  user-select: all;
}

.prompt-snippet-chip-mark {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 20%, var(--surface));
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
}

.prompt-snippet-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-snippet-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(31, 53, 47, 0.12);
  color: inherit;
  cursor: pointer;
}

.prompt-snippet-chip-remove:hover {
  background: rgba(31, 53, 47, 0.22);
}

.gallery-chip.prompt-chip-selected,
.color-chip.prompt-chip-selected,
.prompt-snippet-chip.prompt-chip-selected {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 36%, transparent);
}

.gallery-chip-remove,
.color-chip-swatch,
.color-chip-remove,
.prompt-snippet-chip-remove {
  user-select: none;
}

.prompt-chip-dragging {
  opacity: 0.45;
  cursor: grabbing;
}

.prompt-chip-drop-before,
.prompt-chip-drop-after {
  position: relative;
}

.prompt-chip-drop-before::before,
.prompt-chip-drop-after::after {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 2px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 16%, transparent);
}

.prompt-chip-drop-before::before {
  left: -4px;
}

.prompt-chip-drop-after::after {
  right: -4px;
}

.mention-suggest {
  position: fixed;
  z-index: 70;
  left: var(--mention-left, 10px);
  top: var(--mention-top, calc(100% - 6px));
  width: var(--mention-width, min(340px, calc(100% - 16px)));
  max-width: calc(100% - 16px);
  max-height: var(--prompt-popover-max-height, 240px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(29, 52, 46, 0.15);
}

.mention-option {
  width: 100%;
  height: 42px;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.mention-option:hover {
  background: var(--primary-light);
}

.mention-option img {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  object-fit: cover;
}

.mention-option small {
  color: var(--muted);
}

.prompt-snippet-suggest {
  position: fixed;
  z-index: 71;
  left: var(--prompt-snippet-left, 10px);
  top: var(--prompt-snippet-top, calc(100% - 6px));
  width: var(--prompt-snippet-width, min(380px, calc(100% - 16px)));
  max-width: calc(100% - 16px);
  max-height: var(--prompt-popover-max-height, 260px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(29, 52, 46, 0.15);
}

.prompt-snippet-option {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(68px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.prompt-snippet-option:hover {
  background: var(--primary-light);
}

.prompt-snippet-option-tag {
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent);
  font-weight: 700;
}

.prompt-snippet-option-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.prompt-snippet-option-main span,
.prompt-snippet-option-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-snippet-option small {
  color: var(--muted);
}

.prompt-snippet-save-button {
  position: fixed;
  z-index: 72;
  left: var(--prompt-snippet-save-left, 10px);
  top: var(--prompt-snippet-save-top, calc(100% - 6px));
  min-width: 52px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 36%, var(--line));
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(29, 52, 46, 0.16);
}

.prompt-snippet-popover {
  position: fixed;
  z-index: 73;
  left: var(--prompt-snippet-popover-left, 10px);
  top: var(--prompt-snippet-popover-top, calc(100% - 6px));
  width: var(--prompt-snippet-popover-width, min(380px, calc(100% - 16px)));
  max-width: calc(100% - 16px);
  max-height: var(--prompt-popover-max-height, 360px);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 14px 38px rgba(29, 52, 46, 0.15);
}

.prompt-snippet-popover-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.prompt-snippet-popover-meta {
  color: var(--muted);
  font-size: 12px;
}

.prompt-snippet-popover-preview {
  max-height: 120px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.prompt-snippet-form {
  display: grid;
  gap: 10px;
}

.prompt-snippet-field {
  display: grid;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 12px;
}

.prompt-snippet-input {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  outline: none;
}

.prompt-snippet-input:focus {
  border-color: var(--primary);
}

.prompt-snippet-textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

.prompt-snippet-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.prompt-template-recent-dock {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 100%;
  min-height: var(--prompt-secondary-action-height);
  overflow: hidden;
}

.prompt-template-recent-chip {
  min-height: var(--prompt-secondary-chip-height);
  max-width: 120px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-sheet {
  position: fixed;
  z-index: 75;
  top: 0;
  right: 0;
  height: 100vh;
  gap: 12px;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: none;
  transform: translateX(100%);
  transition: transform var(--motion-fast), box-shadow var(--motion-fast);
}

.resource-sheet.open {
  box-shadow: -18px 0 44px rgba(29, 52, 46, 0.16);
  transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
  .resource-sheet {
    transition: none;
  }
}

.resource-sheet-backdrop {
  position: fixed;
  z-index: 74;
  inset: 0;
  background: rgba(17, 24, 39, 0.22);
}

.resource-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.resource-sheet-header h2 {
  margin: 0;
  font-size: 17px;
}

.resource-sheet-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.resource-sheet-body {
  min-height: 0;
}

.resource-sheet-wide {
  width: min(760px, 52vw);
}

.prompt-template-drawer {
  width: min(420px, calc(100vw - 24px));
  display: grid;
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
}

.prompt-template-summary.ok {
  color: var(--primary);
}

.prompt-template-summary.error {
  color: var(--danger);
}

.prompt-template-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, 64px);
  gap: 8px;
  align-items: stretch;
}

.prompt-template-search-wrap {
  position: relative;
  min-width: 0;
}

.prompt-template-search-wrap .control {
  width: 100%;
  padding-right: 34px;
}

.prompt-template-search-clear-button {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  transform: translateY(-50%);
  cursor: pointer;
  transition:
    background var(--motion-fast),
    color var(--motion-fast);
}

.prompt-template-search-clear-button:hover,
.prompt-template-search-clear-button:focus-visible {
  background: var(--primary-light);
  color: var(--primary-strong);
  outline: none;
}

.prompt-template-search-clear-button[hidden] {
  display: none;
}

.prompt-template-toolbar .control,
.prompt-template-toolbar .ghost-button {
  height: 36px;
  min-height: 36px;
}

.prompt-template-toolbar .ghost-button {
  width: 100%;
  padding: 0 12px;
  white-space: nowrap;
}

.prompt-template-filter-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.prompt-template-category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow-x: visible;
  padding-bottom: 0;
}

.prompt-template-category-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.prompt-template-filter,
.prompt-template-category {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.prompt-template-filter.active,
.prompt-template-category.active {
  border-color: color-mix(in srgb, var(--primary) 34%, var(--line));
  background: var(--primary-light);
  color: var(--primary-strong);
  font-weight: 700;
}

.prompt-template-category-manage-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.prompt-template-category-create,
.prompt-template-category-manage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
}

.prompt-template-category-create {
  grid-template-columns: minmax(0, 1fr) auto;
}

.prompt-template-category-manage-list {
  display: grid;
  gap: 6px;
  max-height: 160px;
  overflow: auto;
}

.prompt-template-body {
  overflow: auto;
}

.prompt-template-grid {
  column-count: 2;
  column-gap: 8px;
}

.prompt-template-card {
  display: inline-grid;
  align-content: start;
  gap: 5px;
  width: 100%;
  margin: 0 0 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  break-inside: avoid;
  vertical-align: top;
}

.prompt-template-card-thumb {
  display: block;
  width: 100%;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface);
}

.prompt-template-detail-thumb,
.prompt-template-thumbnail-preview img,
.prompt-template-thumbnail-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.prompt-template-card-thumb img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.prompt-template-card:hover {
  border-color: color-mix(in srgb, var(--primary) 32%, var(--line));
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}

.prompt-template-card-title,
.prompt-template-card-subtitle,
.prompt-template-card-preview {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prompt-template-card-title {
  white-space: nowrap;
  color: var(--primary-strong);
  font-size: 14px;
  font-weight: 800;
}

.prompt-template-card-subtitle {
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.prompt-template-card-preview {
  display: -webkit-box;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.prompt-template-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.prompt-template-empty {
  column-span: all;
  padding: 20px 10px;
  color: var(--muted);
  text-align: center;
}

.prompt-template-detail,
.prompt-template-form-wrap {
  display: grid;
  gap: 12px;
}

.prompt-template-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
}

.prompt-template-detail-header .ghost-button {
  min-width: 74px;
  height: 36px;
  padding-inline: 14px;
  border-color: color-mix(in srgb, var(--primary) 22%, var(--line));
  background: var(--surface);
  color: var(--primary-strong);
  font-size: 14px;
  font-weight: 700;
}

.prompt-template-detail-header .prompt-template-detail-back:hover,
.prompt-template-detail-header .prompt-template-detail-back:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 38%, var(--line));
  background: var(--surface-soft);
  color: var(--primary-strong);
}

.prompt-template-detail-header .prompt-template-detail-edit {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.prompt-template-detail-header .prompt-template-detail-edit:hover,
.prompt-template-detail-header .prompt-template-detail-edit:focus-visible {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
  color: var(--primary-foreground);
}

.prompt-template-form-header,
.prompt-template-detail-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.prompt-template-detail-actions {
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.prompt-template-detail-secondary-actions {
  display: flex;
  gap: 8px;
}

.prompt-template-detail-actions .ghost-button {
  min-width: 52px;
  height: 32px;
  background: var(--surface);
}

.prompt-template-detail-actions .prompt-template-detail-replace {
  border-color: color-mix(in srgb, var(--primary) 34%, var(--line));
  color: var(--primary-strong);
  font-weight: 700;
}

.prompt-template-detail-actions .prompt-template-detail-replace:hover,
.prompt-template-detail-actions .prompt-template-detail-replace:focus-visible {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-strong);
}

.prompt-template-detail h3 {
  margin: 0;
  font-size: 16px;
}

.prompt-template-detail-thumb {
  aspect-ratio: 16 / 10;
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-soft);
}

.prompt-template-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.prompt-template-detail-content {
  max-height: 42vh;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.prompt-template-detail-notes {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.prompt-template-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.prompt-template-form-header,
.prompt-template-field-full,
.prompt-template-check,
.prompt-template-save {
  grid-column: 1 / -1;
}

.prompt-template-field {
  display: grid;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 12px;
}

.prompt-template-textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.5;
}

.prompt-template-notes {
  min-height: 70px;
  resize: vertical;
  line-height: 1.45;
}

.prompt-template-thumbnail-field {
  gap: 8px;
}

.prompt-template-thumbnail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.prompt-template-thumbnail-preview {
  min-height: 48px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.prompt-template-thumbnail-preview img {
  aspect-ratio: 4 / 3;
  border-radius: 6px;
}

.prompt-template-thumbnail-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.prompt-template-thumbnail-option {
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 7px;
  background: var(--line);
  cursor: pointer;
}

.prompt-template-thumbnail-option.active {
  border-color: var(--primary);
}

.prompt-template-thumbnail-empty {
  grid-column: 1 / -1;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.prompt-template-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

.color-suggest {
  position: fixed;
  z-index: 72;
  left: var(--color-left, 10px);
  top: var(--color-top, calc(100% - 6px));
  width: var(--color-width, min(360px, calc(100% - 16px)));
  max-width: calc(100% - 16px);
  max-height: var(--prompt-popover-max-height, 300px);
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(29, 52, 46, 0.15);
}

.color-suggest-main {
  display: grid;
  grid-template-columns: auto auto minmax(128px, 1fr);
  grid-template-rows: repeat(2, 28px);
  gap: 8px;
  align-items: stretch;
}

.color-value-control {
  --color-picker-width: 52px;
  --color-hex-input-width: calc(7ch + 20px);
  display: grid;
  grid-template-columns: var(--color-picker-width) var(--color-hex-input-width);
  align-items: center;
  grid-row: 1 / span 2;
  flex: 0 0 auto;
  width: calc(var(--color-picker-width) + var(--color-hex-input-width));
  min-width: 0;
  height: 64px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), background var(--motion-fast);
}

.color-value-control:focus-within,
.color-value-control.is-dirty {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 14%, transparent);
}

.color-suggest-actions {
  display: grid;
  grid-column: 3;
  grid-row: 1 / span 2;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, 28px);
  gap: 8px;
  align-items: center;
  width: 100%;
}

.color-suggest-actions > .ghost-button {
  justify-content: center;
  height: 28px;
  min-width: 0;
  padding-inline: 8px;
}

.color-picker-control {
  position: relative;
  display: inline-grid;
  place-items: center;
  align-self: stretch;
  width: var(--color-picker-width);
  min-width: var(--color-picker-width);
  border-right: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  background: color-mix(in srgb, var(--surface) 64%, transparent);
  color: var(--primary-strong);
  cursor: pointer;
}

.color-picker-control:hover .color-picker-swatch,
.color-picker-control:focus-within .color-picker-swatch {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--surface) 62%, transparent);
}

.color-picker-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.01;
  cursor: pointer;
}

.color-picker-swatch {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid color-mix(in srgb, var(--text-secondary) 28%, var(--line));
  border-radius: 10px;
  background: var(--active-color);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--surface) 60%, transparent);
  transition: transform var(--motion-fast), border-color var(--motion-fast), box-shadow var(--motion-fast);
  pointer-events: none;
}

.color-picker-icon {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 17px;
  height: 17px;
  padding: 3px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  color: var(--primary-strong);
  box-shadow: 0 2px 5px rgba(16, 24, 20, 0.16);
}

.color-picker-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.color-picker-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.color-picker-control input {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.color-picker-control input:not(.color-picker-input) {
  display: none;
}

.color-picker-control input.color-picker-input {
  width: 100%;
  height: 100%;
  border: 0;
}

.color-picker-control .color-picker-input {
  appearance: none;
}

.color-picker-control .color-picker-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker-control .color-picker-input::-webkit-color-swatch {
  border: 0;
}

.color-picker-control .color-picker-input::-moz-color-swatch {
  border: 0;
}

.color-hex-input {
  width: 100%;
  height: 62px;
  padding: 0 10px;
  border: 0;
  border-radius: 0;
  color: var(--text);
  background: transparent;
  font: 600 13px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
  outline: none;
}

.color-insert-button {
  grid-row: 1 / span 2;
  height: 64px;
  min-width: 64px;
  padding-inline: 14px;
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.color-insert-button:not(:disabled):hover,
.color-insert-button:not(:disabled):focus-visible {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
  color: var(--primary-foreground);
}

.color-insert-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.color-update-hint {
  grid-column: 1 / -1;
  margin-top: -2px;
  color: var(--primary-strong);
  font-size: 12px;
  line-height: 1.35;
}

.color-swatch-row,
.color-recent-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.color-swatch-item {
  position: relative;
  display: inline-flex;
}

.color-swatch-button {
  width: 28px;
  height: 28px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(31, 53, 47, 0.18);
  border-radius: 8px;
  background: var(--swatch-color);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
}

.color-swatch-button:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.color-swatch-row.is-managing .color-swatch-button {
  border-color: var(--primary);
}

.color-swatch-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid var(--surface);
  border-radius: 50%;
  background: var(--danger);
  color: var(--primary-foreground);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.color-swatch-remove-icon {
  width: 11px;
  height: 11px;
}

.color-swatch-remove-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.color-export-link {
  text-decoration: none;
  white-space: nowrap;
}

.color-import-label {
  white-space: nowrap;
  cursor: pointer;
}

.color-import-input {
  display: none;
}

.color-manage-button[aria-pressed="true"] {
  border-color: var(--primary);
  color: var(--primary-strong);
  background: var(--primary-light);
}

.color-swatch-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.prompt-footer {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex: 1 1 auto;
  gap: 6px;
  min-height: var(--prompt-secondary-action-height);
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
}

.prompt-footer .ghost-button {
  height: var(--prompt-secondary-action-height);
  min-height: var(--prompt-secondary-action-height);
}

.prompt-footer > .icon-text-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.prompt-footer > .icon-text-button span {
  white-space: nowrap;
}

.prompt-find-button {
  color: var(--text-secondary);
}

.prompt-find-button:hover,
.prompt-find-button:focus-visible {
  color: var(--primary-strong);
}

.prompt-find-panel {
  display: grid;
  grid-template-columns: minmax(78px, 1fr) minmax(78px, 1fr) max-content;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-height: var(--prompt-secondary-action-height);
  min-width: 0;
  max-width: 100%;
}

.prompt-find-panel.hidden {
  display: none;
}

.prompt-find-panel .control {
  height: calc(var(--prompt-secondary-action-height) - 4px);
  min-height: calc(var(--prompt-secondary-action-height) - 4px);
  min-width: 0;
  padding: 0 10px;
  font-size: 12px;
}

.prompt-find-panel .ghost-button {
  height: calc(var(--prompt-secondary-action-height) - 4px);
  min-height: calc(var(--prompt-secondary-action-height) - 4px);
  min-width: 32px;
  padding: 0 5px;
  white-space: nowrap;
}

.prompt-find-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  width: max-content;
  min-width: 0;
  white-space: nowrap;
}

.prompt-find-count {
  min-width: 34px;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.prompt-find-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.prompt-compose .run-button {
  width: 100%;
  height: 140px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  justify-content: center;
}

/* source: styles/70-output-settings.css */
/* Output Settings Lock */
.output-settings-header {
  position: relative;
  z-index: 3;
  min-height: 18px;
  margin-bottom: 16px;
}

.output-settings-header h2 {
  margin: 0;
}

.output-settings-stage {
  position: relative;
  min-width: 0;
}

.output-panel.is-locked-view .settings-grid {
  visibility: hidden;
  pointer-events: none;
}

.output-settings-lock-button {
  position: absolute;
  top: 50%;
  right: 0;
  z-index: 2;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  cursor: pointer;
  transform: translateY(-50%);
  transition:
    color var(--motion-fast),
    border-color var(--motion-fast),
    background var(--motion-fast),
    box-shadow var(--motion-fast);
}

.output-settings-lock-button svg {
  width: 17px;
  height: 17px;
}

.output-settings-lock-button:hover,
.output-settings-lock-button:focus-visible,
.output-settings-lock-button.is-locked {
  border-color: color-mix(in srgb, var(--primary) 46%, var(--line));
  background: var(--primary-light);
  color: var(--primary-strong);
}

.output-settings-lock-button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 44%, transparent);
  outline-offset: 2px;
}

.output-settings-lock-button:not(.is-locked) .output-settings-lock-shackle {
  transform: translate(3px, -1px) rotate(18deg);
  transform-origin: 8px 10px;
}

.output-settings-locked-summary {
  position: absolute;
  inset: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-soft) 72%, var(--surface));
}

.output-settings-summary-content {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.output-settings-summary-main {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(8px, 1.5vh, 18px) 0 clamp(36px, 5vh, 64px);
}

.output-settings-summary-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.output-settings-summary-context,
.output-settings-summary-model-label,
.output-settings-summary-card-label,
.output-settings-summary-detail-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.output-settings-summary-context {
  margin-bottom: 4px;
  color: var(--primary-strong);
  font-size: 12px;
}

.output-settings-summary-model-line {
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.output-settings-summary-model {
  min-width: 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-settings-summary-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.output-settings-summary-main > .output-settings-summary-cards:first-child {
  margin-top: 0;
}

.output-settings-summary-card {
  position: relative;
  min-width: 0;
  min-height: 166px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 10px;
  background: var(--surface);
}

.output-settings-ratio-visual,
.output-settings-count-visual {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.output-settings-ratio-frame {
  width: 86px;
  aspect-ratio: var(--output-settings-ratio, 1);
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--line));
  border-radius: 7px;
  background: color-mix(in srgb, var(--primary-light) 48%, var(--surface));
  box-shadow: inset 0 0 0 6px var(--surface);
}

.output-settings-ratio-frame.is-portrait {
  width: auto;
  height: 86px;
}

.output-settings-ratio-value {
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--primary-strong);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.output-settings-count-visual {
  gap: 6px;
}

.output-settings-count-visual.is-wide-four {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  grid-template-rows: repeat(2, max-content);
  align-content: center;
  justify-content: center;
  gap: 6px;
}

.output-settings-count-card {
  position: relative;
  width: min(var(--output-settings-count-card-max-width, 38px), calc((100% - 18px) / 4));
  min-width: 0;
  max-width: 38px;
  aspect-ratio: var(--output-settings-count-ratio, 1);
  flex: 0 1 38px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--line));
  border-radius: 7px;
  background: color-mix(in srgb, var(--primary-light) 62%, var(--surface));
  box-shadow: 0 4px 10px color-mix(in srgb, var(--text) 8%, transparent);
}

.output-settings-count-visual.is-wide-four .output-settings-count-card {
  width: 46px;
  max-width: 46px;
  flex: 0 0 46px;
}

.output-settings-count-card-sun {
  position: absolute;
  top: 20%;
  right: 20%;
  width: 16%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 34%, var(--surface));
}

.output-settings-count-card-land {
  position: absolute;
  right: 13%;
  bottom: 18%;
  left: 13%;
  height: 34%;
  background: color-mix(in srgb, var(--primary) 26%, var(--surface));
  clip-path: polygon(0 100%, 28% 34%, 48% 66%, 67% 28%, 100% 100%);
}

.output-settings-format-visual {
  width: 86px;
  aspect-ratio: 1;
  place-self: center;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--primary-light) 62%, var(--surface));
  color: var(--primary-strong);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.output-settings-card-meta {
  justify-self: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.output-settings-summary-details {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  margin-top: 18px;
  padding-top: 18px;
  border-top: 0;
}

.output-settings-summary-details::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--primary) 18%, var(--line)) 18%,
    color-mix(in srgb, var(--primary) 18%, var(--line)) 82%,
    transparent 100%
  );
  pointer-events: none;
}

.output-settings-summary-detail {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 0 7px;
  border-left: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  text-align: center;
}

.output-settings-summary-detail:first-child {
  border-left: 0;
}

.output-settings-summary-detail-value {
  min-width: 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-settings-summary-hint {
  margin: 0;
  padding-top: 28px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.output-settings-locked-summary.is-task-context .output-settings-summary-hint {
  padding-right: 190px;
}

.output-settings-task-action {
  position: absolute;
  right: 24px;
  bottom: 24px;
  display: flex;
  justify-content: flex-end;
  padding: 0;
}

.output-settings-task-action .ghost-button {
  min-height: 32px;
}

/* Settings Grid */
.settings-grid {
  --custom-size-mode-card-height: 175px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  transition: height var(--motion-height);
}

.settings-grid.is-size-transitioning {
  overflow: hidden;
  will-change: height;
}

.full-width {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.quantity-quality-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.field > span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

#orientationGroup .radio-btn {
  gap: 4px;
}

.orientation-option-icon {
  flex: 0 0 auto;
  display: block;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

#orientationGroup .radio-btn span {
  min-width: 0;
}

.mode-settings-slot {
  --mode-settings-stable-height: 144px;
  position: relative;
  z-index: 2;
  display: grid;
  align-items: start;
  min-height: var(--mode-settings-stable-height);
  overflow: visible;
}

.mode-settings-slot > .mode-transition {
  min-width: 0;
}

.mode-specific-settings {
  display: grid;
  gap: 16px;
}

.model-tool-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(104px, max-content);
  gap: 16px;
  align-items: end;
  min-width: 0;
  grid-column: 1 / 2;
}

.main-model-field,
#apiDirectSettingsNotice {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
  min-width: 0;
}

.web-search-field {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  align-self: end;
  min-width: 0;
}

.web-search-field > span {
  white-space: nowrap;
}

#promptFidelityField {
  grid-column: 1 / -1;
}

.prompt-fidelity-label {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 4px;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.prompt-fidelity-help-button {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  cursor: help;
  transition: color var(--motion-fast);
}

.prompt-fidelity-help-button svg {
  width: 16px;
  height: 16px;
  overflow: visible;
}

.prompt-fidelity-help-button svg > circle:first-child,
.prompt-fidelity-help-button svg > path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.prompt-fidelity-help-button .prompt-fidelity-help-dot {
  fill: currentColor;
  stroke: none;
}

.prompt-fidelity-help-button:hover,
.prompt-fidelity-help-button:focus-visible,
.prompt-fidelity-help-button[aria-expanded="true"] {
  color: var(--primary-strong);
  background: transparent;
  box-shadow: none;
}

.prompt-fidelity-help-button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 48%, transparent);
  outline-offset: 1px;
}

.prompt-fidelity-help-popover {
  position: fixed;
  z-index: 1400;
  max-height: min(420px, calc(100vh - 24px));
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--surface);
  box-shadow: var(--shadow-popover);
  color: var(--text);
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.prompt-fidelity-help-popover::-webkit-scrollbar {
  width: 8px;
}

.prompt-fidelity-help-popover::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.prompt-fidelity-help-popover::-webkit-scrollbar-thumb {
  border: 2px solid var(--scrollbar-track);
  border-radius: var(--radius-pill);
  background: var(--scrollbar-thumb);
}

.prompt-fidelity-help-popover::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.prompt-fidelity-help-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 9px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}

.prompt-fidelity-help-header strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.prompt-fidelity-help-header span {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.prompt-fidelity-help-list {
  display: grid;
  gap: 3px;
  margin: 7px 0 0;
}

.prompt-fidelity-help-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  margin: 0;
  padding: 7px 8px;
  border-radius: var(--radius-base);
}

.prompt-fidelity-help-row.is-active {
  background: var(--primary-light);
}

.prompt-fidelity-help-row dt,
.prompt-fidelity-help-row dd {
  margin: 0;
}

.prompt-fidelity-help-row dt {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.prompt-fidelity-help-row.is-active dt {
  color: var(--primary-strong);
}

.prompt-fidelity-help-row dd {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-secondary);
}

@media (max-width: 520px) {
  .prompt-fidelity-help-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .prompt-fidelity-help-row {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px;
    padding-inline: 6px;
  }
}

.mode-transition {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity var(--motion-fast),
    transform var(--motion-base);
}

.mode-transition.mode-collapsed {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

.field-note {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.api-direct-settings-notice {
  min-height: 60px;
  color: var(--text-secondary);
}

.api-direct-settings-control {
  height: 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  gap: 10px;
  padding: 0 6px 0 12px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-soft) 78%, transparent);
}

.api-direct-settings-header {
  min-width: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.api-direct-settings-header strong {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.api-direct-settings-header span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-direct-settings-button {
  min-height: 28px;
  padding: 0 10px;
}

.web-search-toggle {
  height: 36px;
  min-width: 104px;
  display: inline-grid;
  grid-template-columns: 36px minmax(0, max-content);
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    background var(--motion-base),
    border-color var(--motion-base),
    color var(--motion-base);
}

.web-search-toggle:hover,
.web-search-toggle:focus-within {
  border-color: color-mix(in srgb, var(--primary) 38%, var(--line));
  color: var(--text);
}

.web-search-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.web-search-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--line);
  transition: background var(--motion-base);
}

.web-search-toggle-track::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(29, 52, 46, 0.16);
  transition: transform var(--motion-base);
}

.web-search-toggle input:checked + .web-search-toggle-track {
  background: var(--primary);
}

.web-search-toggle input:checked + .web-search-toggle-track::before {
  transform: translateX(16px);
}

.web-search-toggle:has(input:checked) {
  border-color: color-mix(in srgb, var(--primary) 48%, var(--line));
  background: var(--primary-light);
  color: var(--primary-strong);
}

.web-search-toggle-text {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.web-search-field.is-disabled .web-search-toggle {
  cursor: not-allowed;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-soft) 70%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .output-settings-lock-button,
  .output-settings-lock-shackle,
  .settings-grid,
  .mode-transition {
    transition: none;
  }
}

@media (max-width: 640px) {
  .output-settings-summary-content {
    padding: 16px;
  }

  .output-settings-summary-cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .output-settings-summary-card {
    min-height: 148px;
  }

  .output-settings-summary-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 0;
  }

  .output-settings-summary-detail:nth-child(odd) {
    padding-left: 0;
    border-left: 0;
  }

  .output-settings-task-action {
    right: 16px;
    bottom: 16px;
  }
}

/* Number Stepper */
.number-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper-input {
  width: 48px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
  -moz-appearance: textfield;
}
.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper-hint {
  font-size: 12px;
  color: var(--muted);
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider.round {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: background-color var(--motion-base);
  border-radius: 22px;
}

.slider.round:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: transform var(--motion-base), background-color var(--motion-base);
  border-radius: 50%;
}

input:checked + .slider.round {
  background-color: var(--primary);
}

input:checked + .slider.round:before {
  transform: translateX(18px);
}

/* Custom Size Inputs */
.custom-size-control {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.size-mode-group {
  width: 100%;
}

.custom-ratio-field {
  display: none;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 8px;
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  transition: border-color var(--motion-fast);
}

.custom-ratio-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 26px;
}

.custom-ratio-header > span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.custom-ratio-image-button {
  align-self: center;
  justify-self: start;
  height: 28px;
  padding: 0 8px;
  gap: 4px;
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
}

.custom-ratio-image-button .button-icon {
  width: 13px;
  height: 13px;
}

.custom-ratio-image-button:disabled {
  display: none;
  opacity: 0.48;
  cursor: not-allowed;
  background: transparent;
  color: var(--muted);
}

.custom-measure-row {
  --measure-label-width: 36px;
  --measure-input-width: 96px;
  --measure-mid-width: 34px;
  display: grid;
  grid-template-columns:
    var(--measure-label-width)
    var(--measure-input-width)
    var(--measure-mid-width)
    var(--measure-label-width)
    var(--measure-input-width);
  align-items: center;
  justify-content: start;
  column-gap: 8px;
  width: auto;
  min-width: 0;
}

.custom-measure-label {
  justify-self: end;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.custom-measure-row > .custom-measure-label:first-child {
  justify-self: start;
}

.custom-ratio-field.active {
  border-left-color: color-mix(in srgb, var(--primary) 52%, var(--line));
}

.custom-ratio-field.active .custom-ratio-header > span {
  color: var(--text-secondary);
}

.custom-ratio-field.active .custom-ratio-digit {
  border-color: color-mix(in srgb, var(--primary) 54%, var(--line));
  background: var(--surface);
}

.custom-ratio-digit {
  width: var(--measure-input-width);
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.custom-ratio-separator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--measure-mid-width);
  color: var(--muted);
  font-weight: 600;
}

.custom-size {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(242px, 0.92fr);
  align-items: center;
  gap: 22px;
  min-width: 0;
  min-height: var(--custom-size-mode-card-height);
  max-height: var(--custom-size-mode-card-height);
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  transition:
    max-height var(--motion-height),
    opacity var(--motion-fast),
    transform var(--motion-base),
    padding var(--motion-base),
    border-width var(--motion-base),
    border-color var(--motion-fast),
    background var(--motion-fast);
}

.custom-size.custom-size-collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
  border-bottom-width: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

.custom-size.has-error {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  background: var(--danger-soft);
}

.custom-size-main {
  display: grid;
  align-content: center;
  gap: 10px;
  min-width: 0;
}

.custom-size-header {
  display: flex;
  align-items: center;
  min-height: 22px;
}

.custom-size-header > span {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.custom-size-input {
  width: var(--measure-input-width);
  height: 34px;
  padding: 0 10px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.custom-size-row {
  --measure-label-width: 36px;
  --measure-input-width: 96px;
  --measure-mid-width: 34px;
  max-width: 100%;
}

.custom-ratio-control {
  --measure-label-width: 22px;
  --measure-input-width: 44px;
  --measure-mid-width: 18px;
  grid-template-columns: 22px 44px 18px 22px 44px auto;
}

.custom-size-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  width: 30px;
  height: 30px;
  border: 1px solid color-mix(in srgb, var(--line) 68%, transparent);
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: border-color var(--motion-fast), color var(--motion-fast), background var(--motion-fast), transform var(--motion-fast);
}

.custom-size-icon-button:hover,
.custom-size-icon-button:focus-visible {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.custom-size-icon-button.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.custom-size-icon-button:active {
  transform: scale(0.96);
}

.custom-size-swap {
  margin-left: 0;
}

.custom-ratio-hint,
.custom-size-hint {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.custom-size.has-error .custom-size-hint {
  color: var(--danger);
}

.settings-grid.custom-size-mode .resolution-field,
.settings-grid.custom-size-mode .ratio-field,
.settings-grid.custom-size-mode .orientation-field {
  display: none;
}

.settings-grid.custom-size-mode .custom-ratio-field {
  display: grid;
}

.settings-grid.custom-size-mode .custom-size {
  grid-column: 1 / -1;
}

@media (prefers-reduced-motion: reduce) {
  .settings-grid,
  .slider.round,
  .slider.round:before,
  .custom-ratio-field,
  .custom-size-icon-button,
  .custom-size {
    transition: none;
  }

  .custom-size,
  .custom-size.custom-size-collapsed,
  .custom-size-icon-button:active {
    transform: none;
  }
}

@media (max-width: 640px) {
  .custom-size {
    grid-template-columns: minmax(0, 1fr);
    max-height: none;
    align-items: start;
  }

  .custom-ratio-field {
    padding-top: 12px;
    padding-left: 0;
    border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
    border-left: 0;
  }
}

/* Range Slider */
.range-control {
  --range-track: color-mix(in srgb, var(--line) 56%, var(--surface-soft));
  --range-track-border: color-mix(in srgb, var(--line) 78%, var(--surface-soft));
  --range-fill: var(--primary);
  --range-progress: 0%;
  gap: 10px;
}

.range-control.is-disabled {
  --range-fill: color-mix(in srgb, var(--muted) 58%, var(--line));
  --range-track: color-mix(in srgb, var(--line) 42%, var(--surface-soft));
  --range-track-border: color-mix(in srgb, var(--line) 68%, var(--surface-soft));
}

.output-format-field {
  position: relative;
}

.compression-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 50;
  width: min(330px, calc(100vw - 48px));
  padding: 10px 12px;
  border: 1px solid rgba(201, 221, 212, 0.95);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-popover);
}

.compression-popover::before {
  position: absolute;
  top: -6px;
  left: 38px;
  width: 10px;
  height: 10px;
  content: "";
  border-top: 1px solid rgba(201, 221, 212, 0.95);
  border-left: 1px solid rgba(201, 221, 212, 0.95);
  background: var(--surface);
  transform: rotate(45deg);
}

.compression-range {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  align-items: center;
  gap: 0 12px;
  min-height: 34px;
}

.compression-range .slider-header {
  display: contents;
}

.compression-range .slider-header > span:first-child {
  grid-column: 1;
}

.compression-range .slider {
  grid-column: 2;
}

.compression-range .range-value {
  grid-column: 3;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.range-control .field-label,
.range-control .slider-header > span:first-child {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.range-value {
  display: inline-flex;
  min-width: 54px;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--surface) 80%, transparent);
}

.range-value b {
  color: inherit;
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.range-unit {
  color: var(--text-secondary);
}

.range-value.muted {
  min-width: 86px;
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  box-shadow: none;
}

input[type=range].slider {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type=range].slider:disabled {
  cursor: not-allowed;
}

input[type=range].slider::-webkit-slider-runnable-track {
  height: 8px;
  border: 1px solid var(--range-track-border);
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--range-fill) 0%,
    var(--range-fill) var(--range-progress),
    var(--range-track) var(--range-progress),
    var(--range-track) 100%
  );
  box-shadow: inset 0 1px 2px rgba(31, 53, 47, 0.08);
}

input[type=range].slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border: 5px solid var(--range-fill);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(31, 53, 47, 0.18);
  transition: transform var(--motion-base), box-shadow var(--motion-base), border-color var(--motion-base);
}

input[type=range].slider:hover::-webkit-slider-thumb,
input[type=range].slider:focus-visible::-webkit-slider-thumb {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(31, 53, 47, 0.24);
}

input[type=range].slider:disabled::-webkit-slider-thumb {
  border-color: color-mix(in srgb, var(--text-secondary) 30%, var(--line));
  box-shadow: none;
  transform: none;
}

input[type=range].slider::-moz-range-track {
  height: 8px;
  border: 1px solid var(--range-track-border);
  border-radius: 999px;
  background: var(--range-track);
  box-shadow: inset 0 1px 2px rgba(31, 53, 47, 0.08);
}

input[type=range].slider::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--range-fill);
}

input[type=range].slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 5px solid var(--range-fill);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(31, 53, 47, 0.18);
  transition: transform var(--motion-base), box-shadow var(--motion-base), border-color var(--motion-base);
}

input[type=range].slider:hover::-moz-range-thumb,
input[type=range].slider:focus-visible::-moz-range-thumb {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(31, 53, 47, 0.24);
}

input[type=range].slider:disabled::-moz-range-thumb {
  border-color: color-mix(in srgb, var(--text-secondary) 30%, var(--line));
  box-shadow: none;
  transform: none;
}

/* Status Text */
.status-text {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  max-height: 4.5em;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.status-text.ok { color: var(--primary); }
.status-text.error { color: var(--danger); }
.status-text.running { color: var(--primary-strong); }

/* source: styles/71-preview-results.css */
/* Preview Grid */
.preview-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  place-items: center;
  overflow: hidden;
}

.preview-grid.multi-output {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-content: center;
  justify-content: center;
  place-items: stretch;
  grid-auto-rows: minmax(0, 1fr);
  overflow: hidden;
}

.preview-grid.multi-output.preview-orientation-landscape {
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: minmax(0, 1fr);
  place-items: stretch;
}

.preview-grid.preview-count-4.preview-orientation-portrait {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.preview-grid.preview-count-4.preview-orientation-square {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.preview-grid.preview-count-3.preview-orientation-landscape {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(3, minmax(0, 1fr));
}

.preview-grid.preview-count-2.preview-orientation-square {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.preview-grid.preview-count-2.preview-orientation-landscape {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.preview-grid.preview-count-4.preview-orientation-landscape {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(4, minmax(0, 1fr));
}

.preview-grid.preview-count-3.preview-orientation-portrait {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.preview-card {
  position: relative;
  container-type: inline-size;
  width: 100%;
  max-height: 100%;
  min-height: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--motion-fast),
    border-color var(--motion-fast);
}

.preview-card.is-loading-next {
  background: var(--surface-soft);
  border-color: transparent;
}

.preview-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 55%, transparent);
}

.preview-grid:not(.multi-output) .preview-card {
  height: 100%;
  border-color: transparent;
  background: transparent;
}

.preview-grid:not(.multi-output) .preview-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.preview-index {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--surface) 28%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary-strong) 84%, transparent);
  color: var(--primary-foreground);
  font-size: 11px;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--code) 20%, transparent);
  backdrop-filter: blur(8px);
}

.preview-select-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--primary) 36%, var(--surface));
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary-light) 78%, var(--surface) 22%);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(8px);
  opacity: 0.92;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--code) 18%, transparent);
  transition:
    background var(--motion-fast),
    border-color var(--motion-fast),
    box-shadow var(--motion-fast),
    opacity var(--motion-fast);
}

.preview-select-button[hidden],
.preview-card:not(.can-select-output) .preview-select-button,
.preview-grid:not(.multi-output) .preview-select-button {
  display: none;
}

.preview-select-button[aria-pressed="true"] {
  width: auto;
  gap: 5px;
  padding: 5px 9px;
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
  opacity: 1;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--primary) 30%, transparent);
}

.preview-select-button:hover,
.preview-select-button:focus-visible {
  width: auto;
  gap: 5px;
  padding: 5px 9px;
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  color: var(--primary-foreground);
  opacity: 1;
}

.preview-select-button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 70%, #fff);
  outline-offset: 2px;
}

.preview-select-icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.preview-select-button[aria-pressed="true"] .preview-select-icon {
  fill: currentColor;
}

.preview-select-label {
  display: none;
  white-space: nowrap;
}

.preview-select-button:hover .preview-select-label,
.preview-select-button:focus-visible .preview-select-label,
.preview-select-button[aria-pressed="true"] .preview-select-label {
  display: inline;
}

.preview-card img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity var(--motion-fast);
}

@media (prefers-reduced-motion: reduce) {
  .preview-card,
  .preview-select-button,
  .preview-card img {
    transition: none;
  }
}

.preview-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  background:
    linear-gradient(
      180deg,
      transparent 0%,
      color-mix(in srgb, var(--code) 18%, transparent) 22%,
      color-mix(in srgb, var(--code) 74%, transparent) 100%
    );
  opacity: 0;
  transition: opacity var(--motion-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.preview-card:hover .preview-overlay {
  opacity: 1;
}

.prompt-action-row {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  align-items: center;
  justify-content: center;
  justify-items: center;
  width: max-content;
  max-width: calc(100% - 16px);
  gap: 8px;
}

.add-to-input-btn,
.collect-input-btn,
.prompt-popover-button,
.preview-download-link {
  width: auto;
  min-width: 0;
  min-height: 32px;
  background: color-mix(in srgb, var(--surface) 90%, var(--primary-light) 10%);
  backdrop-filter: blur(8px);
  border: 1px solid color-mix(in srgb, var(--line) 68%, var(--primary-light));
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--code) 22%, transparent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

.add-to-input-btn {
  min-width: 92px;
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 34%, transparent);
}

.collect-input-btn,
.prompt-popover-button,
.preview-download-link {
  min-width: 64px;
}

.add-to-input-btn:hover,
.collect-input-btn:hover,
.prompt-popover-button:hover,
.preview-download-link:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  color: var(--primary-foreground);
  transform: translateY(-1px);
}

.collect-input-btn {
  color: var(--text-secondary);
  border-color: color-mix(in srgb, var(--line) 64%, var(--primary-light));
}

.preview-card:focus-within .preview-overlay {
  opacity: 1;
}

@container (max-width: 380px) {
  .prompt-action-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(300px, calc(100% - 16px));
  }

  .prompt-action-row > .add-to-input-btn,
  .prompt-action-row > .collect-input-btn,
  .prompt-action-row > .prompt-popover-button,
  .prompt-action-row > .preview-download-link {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }
}

.gallery-edit-popover {
  position: fixed;
  z-index: 9300;
  width: min(300px, calc(100vw - 20px));
  max-width: calc(100vw - 20px);
  padding: 10px;
  border: 1px solid rgba(201, 221, 212, 0.95);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 44px rgba(29, 52, 46, 0.22);
}

.gallery-edit-form {
  display: grid;
  gap: 10px;
}

.gallery-edit-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.gallery-edit-field {
  display: grid;
  gap: 5px;
}

.gallery-edit-field span {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.gallery-edit-input,
.gallery-edit-select {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 9px;
  outline: none;
}

.gallery-edit-input:focus,
.gallery-edit-select:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.gallery-edit-textarea,
#galleryPromptNoteInput {
  min-height: 72px;
  resize: vertical;
  padding-block: 8px;
  line-height: 1.4;
}

.gallery-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-popover {
  position: fixed;
  z-index: 9300;
  width: min(280px, calc(100vw - 20px));
  max-width: calc(100vw - 20px);
  padding: 10px;
  border: 1px solid rgba(240, 199, 193, 0.95);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 44px rgba(29, 52, 46, 0.22);
}

.confirm-popover-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.confirm-popover-message {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.confirm-popover-detail {
  margin-top: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.4;
  max-height: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.confirm-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.confirm-popover-confirm.danger-button {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}

.confirm-popover-confirm.danger-button:hover {
  background: color-mix(in srgb, var(--danger) 18%, var(--surface));
  color: var(--danger);
}

.prompt-popover {
  position: fixed;
  z-index: 6500;
  width: min(760px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: min(70vh, 560px);
  padding: 12px;
  border: 1px solid rgba(201, 221, 212, 0.95);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(29, 52, 46, 0.2);
  display: flex;
  flex-direction: column;
}

.prompt-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.prompt-popover-header strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.prompt-popover-summary {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.35;
}

.prompt-popover-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
}

.prompt-popover-body {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
  padding-right: 2px;
}

.prompt-popover-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-height: 220px;
}

.prompt-popover-section {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.prompt-popover-section-optimized {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  background: color-mix(in srgb, var(--primary-light) 55%, var(--surface));
}

.prompt-popover-section-empty {
  color: var(--muted);
}

.prompt-popover-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.prompt-popover-label {
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.prompt-popover-section-tools {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.prompt-popover-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.prompt-popover-text {
  min-height: 0;
  max-height: min(36vh, 320px);
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  line-height: 1.55;
}

.prompt-popover-submitted {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.prompt-popover-submitted summary {
  cursor: pointer;
  font-weight: 600;
}

.prompt-popover-submitted-text {
  max-height: 160px;
  margin: 8px 0 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  line-height: 1.55;
}

.prompt-popover-text,
.prompt-popover-submitted-text {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.prompt-popover-text::-webkit-scrollbar,
.prompt-popover-submitted-text::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.prompt-popover-text::-webkit-scrollbar-track,
.prompt-popover-submitted-text::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}

.prompt-popover-text::-webkit-scrollbar-thumb,
.prompt-popover-submitted-text::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--scrollbar-thumb);
  background-clip: content-box;
}

.prompt-popover-text::-webkit-scrollbar-thumb:hover,
.prompt-popover-submitted-text::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: content-box;
}

.prompt-copy-button {
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.prompt-copy-inline {
  min-height: 24px;
  padding: 3px 9px;
  font-size: 11px;
  line-height: 1.2;
}

.prompt-copy-button:disabled {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  cursor: not-allowed;
}

@media (max-width: 720px) {
  .prompt-popover {
    max-height: calc(100vh - 24px);
  }

  .prompt-popover-compare {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .prompt-popover-text {
    max-height: min(28vh, 230px);
  }
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 52px;
  background: rgba(10, 24, 20, 0.82);
  backdrop-filter: blur(10px);
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 96vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  cursor: grab;
  user-select: none;
}

.lightbox img:active {
  cursor: grabbing;
}

.lightbox-close {
  position: absolute;
  z-index: 2;
  top: 22px;
  left: 22px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox-nav {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 48px;
  height: 72px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  font-size: 46px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox-prev {
  left: 22px;
}

.lightbox-next {
  right: 22px;
}

.lightbox-counter {
  position: absolute;
  z-index: 2;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 64px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  font-size: 13px;
  text-align: center;
  backdrop-filter: blur(8px);
}

.empty-preview {
  grid-column: 1 / -1;
  width: min(100%, 520px);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed color-mix(in srgb, var(--text-secondary) 30%, var(--line));
  border-radius: 8px;
  font-size: 13px;
}

.error-preview {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: var(--danger);
  border: 1px solid transparent;
  background: var(--danger-soft);
  line-height: 1.55;
  text-align: left;
  white-space: pre-wrap;
  overflow: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.error-preview p {
  margin: 0;
}

.waiting-preview {
  grid-column: 1 / -1;
  width: min(100%, 620px);
  min-height: 220px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--line));
  background:
    radial-gradient(circle at 18% 15%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 28%),
    linear-gradient(135deg, var(--surface-soft), var(--primary-light));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
}

.waiting-preview strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 16px;
}

.waiting-preview p {
  margin: 4px 0;
  line-height: 1.6;
}

.elapsed-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  row-gap: 2px;
  white-space: normal;
  color: var(--text-secondary);
}

.elapsed-timer {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 1px;
  width: max-content;
  max-width: 100%;
  flex: 0 1 auto;
  white-space: nowrap;
  color: var(--primary-strong);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.elapsed-main {
  display: inline-flex;
  justify-content: flex-end;
  min-width: 5ch;
  text-align: right;
}

.elapsed-ms {
  display: inline-flex;
  justify-content: flex-start;
  min-width: 2ch;
  text-align: left;
  font-size: 0.56em;
  font-weight: 650;
  opacity: 0.62;
  transform: translateY(-0.04em);
}

.elapsed-wheel,
.elapsed-separator {
  display: inline-block;
  height: 1em;
  line-height: 1;
  text-align: center;
}

.elapsed-wheel {
  width: 1ch;
  overflow: hidden;
}

.elapsed-separator {
  width: 0.6ch;
}

.elapsed-wheel-strip {
  display: flex;
  flex-direction: column;
  transform: translateY(calc(var(--digit-offset, 0) * -1em));
  transition: transform var(--motion-fast);
  will-change: transform;
}

.elapsed-wheel-strip span {
  height: 1em;
  line-height: 1;
}

.elapsed-meta {
  color: var(--muted);
  font-size: 12px;
}

.waiting-preview .elapsed-timer {
  font-size: 40px;
}

.waiting-preview .elapsed-meta {
  font-size: 13px;
}

.running-progress-card {
  width: 100%;
  min-height: 180px;
  min-width: 0;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--line));
  background: var(--surface-soft);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px;
  text-align: center;
  overflow: hidden;
}

.running-progress-card > div {
  max-width: 100%;
  min-width: 0;
}

.running-progress-card strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 4px;
}

.running-progress-card p {
  max-width: 100%;
  margin: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.running-failure-notice {
  width: min(100%, 520px);
  max-height: 120px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 32%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--danger-soft) 88%, var(--surface));
  color: var(--text-secondary);
  text-align: left;
  overflow: auto;
}

.running-failure-notice strong {
  display: block;
  margin-bottom: 4px;
  color: var(--danger);
  font-size: 13px;
}

.running-failure-notice p {
  margin: 0;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.failure-summary-card {
  width: 100%;
  min-height: 180px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  background: var(--danger-soft);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  text-align: center;
}

.failure-summary-card strong {
  display: block;
  color: var(--danger);
  font-size: 14px;
}

.failure-summary-card p {
  margin: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.failure-summary-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  margin-top: 4px;
}

.failure-summary-actions .ghost-button {
  flex: 0 0 auto;
  min-width: max-content;
  white-space: nowrap;
}

.waiting-bar {
  width: min(320px, 100%);
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}

.waiting-bar span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: waiting-bar 1.4s ease-in-out infinite;
}


/* Brand overlay result actions (step 3-J) */
.brand-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid var(--border-subtle, rgba(0,0,0,0.08));
  background: var(--surface-elevated, rgba(255,255,255,0.04));
  font-size: 12px;
}
.brand-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.brand-badge-pending { background: rgba(250, 204, 21, 0.18); color: var(--warning, #b45309); }
.brand-badge-failed  { background: rgba(239, 68, 68, 0.18); color: var(--danger, #b91c1c); }
.brand-toggle {
  border: 1px solid var(--border-strong, rgba(0,0,0,0.2));
  background: transparent;
  color: inherit;
  padding: 3px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 12px;
}
.brand-toggle[aria-pressed="true"] {
  background: var(--primary, #2563eb);
  color: #fff;
  border-color: transparent;
}
.brand-download-link,
.brand-recompose {
  font-size: 12px;
  cursor: pointer;
  color: var(--primary, #2563eb);
  text-decoration: none;
  background: none;
  border: none;
  padding: 3px 6px;
}
.brand-recompose:disabled { opacity: 0.6; cursor: progress; }

/* source: styles/72-queue-modals.css */
.queue-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 7000;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border-left: 1px solid var(--panel-border);
  background: var(--surface);
  box-shadow: none;
  overflow: hidden;
  transform: translateX(110%);
  transition: transform var(--motion-height), box-shadow var(--motion-height);
}

.queue-drawer.open {
  box-shadow: -18px 0 60px rgba(24, 45, 39, 0.18);
  transform: translateX(0);
}

.queue-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 6990;
  background: var(--overlay-subtle);
  backdrop-filter: blur(4px);
}

.queue-drawer-backdrop.hidden {
  display: none;
}

.queue-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.queue-drawer-header h2 {
  margin: 0 0 5px;
  font-size: 18px;
  line-height: 1.2;
}

.queue-drawer-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.queue-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.queue-running-section {
  flex: 0 0 auto;
  max-height: 42%;
}

.queue-waiting-section {
  flex: 1 1 auto;
}

.queue-section-title {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.queue-list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-height: 48px;
  overflow-y: auto;
  padding-right: 2px;
}

.queue-running-list {
  min-height: 0;
}

.queue-waiting-list {
  min-height: 0;
}

.queue-running-list {
  flex: 0 1 auto;
}

.queue-running-item,
.queue-waiting-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  box-shadow: var(--shadow-sm);
}

.queue-drag-handle {
  width: 14px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 999px;
  cursor: grab;
  background:
    radial-gradient(circle, var(--muted) 1.4px, transparent 1.8px) 2px 3px / 6px 8px,
    radial-gradient(circle, var(--muted) 1.4px, transparent 1.8px) 8px 3px / 6px 8px;
  opacity: 0.55;
}

.queue-item-body {
  min-width: 0;
  flex: 1;
}

.queue-item-title,
.queue-item-meta {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.queue-item-prompt {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.queue-item-title {
  font-weight: 600;
}

.queue-item-meta {
  line-height: 1.35;
  color: var(--muted);
}

.queue-item-prompt {
  display: -webkit-box;
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.queue-running-item {
  border-color: color-mix(in srgb, var(--primary) 28%, var(--line));
  background: var(--success-soft);
}

.queue-waiting-item {
  cursor: grab;
}

.queue-waiting-item.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.queue-waiting-item.dragging .queue-drag-handle {
  cursor: grabbing;
}

.queue-item-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 128px;
  flex-shrink: 0;
}

.queue-item-action {
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--motion-base), color var(--motion-base), border-color var(--motion-base);
}

.queue-item-action:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  background: var(--primary-light);
  color: var(--primary-strong);
}

.queue-item-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.queue-item-action.danger {
  color: var(--danger);
}

.queue-item-action.danger:hover {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  background: var(--danger-soft);
  color: var(--danger);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: var(--overlay);
  backdrop-filter: blur(8px);
}

#systemSettingsModal {
  --system-settings-modal-top: 30px;
  align-items: flex-start;
  overflow: auto;
  padding-block: var(--system-settings-modal-top, 30px) 30px;
}

.modal-panel {
  width: min(920px, 94vw);
  max-height: 88vh;
  overflow: auto;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-modal);
  padding: 20px;
}

.add-gallery-panel {
  width: min(420px, 94vw);
}

.archive-modal-panel {
  width: min(520px, 94vw);
}

.version-modal-panel {
  width: min(520px, 94vw);
}

.version-popover-layer {
  display: block;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
}

.version-popover-panel {
  position: fixed;
  top: 12px;
  left: 12px;
  width: min(440px, calc(100vw - 24px));
  max-height: min(680px, calc(100dvh - 24px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  border-radius: 8px;
  box-shadow: 0 20px 54px rgba(19, 39, 32, 0.24);
}

.version-popover-panel > .modal-heading {
  flex: 0 0 auto;
  align-items: center;
  margin: 0;
  padding: 16px 16px 12px 18px;
  border-bottom: 1px solid var(--line);
}

.version-popover-panel > .modal-heading > div {
  min-width: 0;
}

.version-popover-panel > .modal-heading .drawer-close-button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  flex: 0 0 44px;
}

.system-settings-modal-panel {
  width: min(624px, calc(100vw - 60px));
  max-height: min(760px, calc(100vh - var(--system-settings-modal-top, 30px) - 30px));
  overflow: auto;
  padding: 22px 28px 24px;
  display: flex;
  flex-direction: column;
  transition: height var(--motion-height);
}

.system-settings-modal-panel.is-height-animating {
  overflow: hidden;
}

.system-settings-modal-panel > .modal-heading {
  position: relative;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-bottom: 16px;
  text-align: center;
}

.system-settings-modal-panel > .modal-heading > div {
  min-width: 0;
  text-align: center;
}

.system-settings-modal-panel > .modal-heading .drawer-close-button {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
}

.system-settings-modal-panel > .modal-heading h2 {
  margin: 0;
}

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

.modal-heading h2 {
  margin: 0 0 4px;
  font-size: 17px;
}

.modal-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.version-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  flex: 0 0 auto;
  margin: 0 18px;
  border-bottom: 1px solid var(--line);
}

.version-detail-row {
  display: flex;
  min-width: 0;
  min-height: 58px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 9px 12px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.version-detail-row:first-child {
  padding-left: 0;
}

.version-detail-row:last-child {
  padding-right: 0;
  border-right: 0;
}

.version-detail-row strong {
  max-width: 100%;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.version-history {
  flex: 1 1 auto;
  min-height: 150px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 18px 18px;
}

.version-history h3 {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.version-release-history {
  position: relative;
}

.version-release-item {
  position: relative;
  padding: 0 0 16px 20px;
}

.version-release-item:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: -8px;
  left: 4px;
  width: 1px;
  background: var(--line);
}

.version-release-item::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 0;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent);
}

.version-release-item:last-child {
  padding-bottom: 0;
}

.version-release-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.version-release-heading strong {
  color: var(--text);
  font-size: 14px;
}

.version-release-heading time {
  min-width: 0;
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.version-current-badge {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary-strong);
  font-size: 10px;
  font-weight: 700;
}

.version-release-item ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 16px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.version-release-item li::marker {
  color: var(--muted);
}

.version-history-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.version-onboarding {
  flex: 0 0 auto;
  margin: 0 18px 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.version-onboarding.hidden {
  display: none;
}

.version-onboarding strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.version-onboarding p {
  margin: 0;
}

.version-onboarding ul {
  display: grid;
  gap: 5px;
  margin: 8px 0 0;
  padding-left: 18px;
}

.version-onboarding li::marker {
  color: var(--primary);
}

.version-modal-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 0;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}

.version-modal-actions .run-button,
.version-modal-actions .ghost-button {
  width: auto;
  min-width: 112px;
  height: 34px;
}

.version-modal-actions .hidden {
  display: none;
}

.api-settings-feedback {
  display: inline-flex;
  max-width: 100%;
  min-height: 24px;
  align-items: center;
  border-radius: 6px;
  padding: 0 8px;
  background: transparent;
  line-height: 1.35;
  transition: background var(--motion-fast), color var(--motion-fast);
}

.api-settings-feedback:empty {
  display: none;
}

.api-settings-feedback.ok {
  color: var(--primary-strong);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.api-settings-feedback.error {
  color: var(--danger);
  background: rgba(214, 84, 84, 0.12);
}

.api-settings-feedback.running {
  color: var(--primary-strong);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.system-settings-tabs {
  --segmented-indicator-radius: 999px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.system-settings-tab {
  min-width: 0;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  transition: color var(--motion-fast), box-shadow var(--motion-fast);
}

.system-settings-tab.active {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-soft);
}

.system-settings-tabs .segmented-indicator {
  border-radius: 999px;
  box-shadow: 0 5px 14px rgba(40, 116, 85, 0.22);
}

.system-settings-tabs.segmented-indicator-host .system-settings-tab.active {
  background: transparent;
  color: var(--primary-foreground);
  box-shadow: none;
}

.system-settings-tab:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent);
  outline-offset: 2px;
}

.system-settings-section[hidden] {
  display: none;
}

.system-settings-section {
  flex: 0 1 auto;
  min-height: 0;
  max-height: calc(100vh - 190px);
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 0;
  display: flex;
  flex-direction: column;
}

/* source: styles/73-gallery-drawer.css */
.gallery-drawer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.gallery-drawer-body {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.gallery-drawer-top {
  display: grid;
  gap: 12px;
}

.gallery-drawer-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.gallery-drawer-category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gallery-drawer-category-tabs .quick-gallery-category {
  flex: 0 0 auto;
  width: auto;
  min-width: 60px;
  max-width: 100%;
  height: 34px;
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
}

.gallery-drawer-toolbar .ghost-button {
  min-height: 34px;
  padding-inline: 14px;
}

.gallery-drawer-main {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.gallery-category-manage-panel {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 12px;
  width: 100%;
  margin-bottom: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.gallery-category-manage-copy {
  display: grid;
  gap: 3px;
}

.gallery-category-manage-copy strong {
  color: var(--text);
  font-size: 13px;
}

.gallery-category-manage-copy span {
  color: var(--muted);
  font-size: 11px;
}

.gallery-category-create-row {
  display: grid;
  width: 100%;
  grid-template-columns: 34px minmax(160px, 1fr) minmax(220px, 1.5fr) auto;
  gap: 10px 12px;
  justify-content: stretch;
}

.gallery-category-create-row::before {
  content: "";
}

.gallery-category-create-row #newGalleryCategoryPromptRole {
  grid-column: auto;
}

.gallery-category-list {
  display: grid;
  gap: 8px;
  justify-items: stretch;
}

.gallery-category-row {
  display: grid;
  width: 100%;
  grid-template-columns: 34px minmax(160px, 1fr) minmax(220px, 1.5fr) auto;
  grid-template-areas: "toolbar name role actions";
  gap: 10px 12px;
  align-items: center;
  justify-content: stretch;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  transition: border-color var(--motion-fast), background var(--motion-fast), opacity var(--motion-fast), transform var(--motion-fast);
}

.gallery-category-row.is-current {
  border-color: color-mix(in srgb, var(--primary) 32%, var(--line));
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--primary) 68%, transparent);
}

.gallery-category-row-toolbar {
  grid-area: toolbar;
  display: flex;
  width: 34px;
  align-items: center;
  justify-content: start;
}

.gallery-category-row > [data-gallery-category-name] {
  grid-area: name;
}

.gallery-category-row > [data-gallery-category-prompt-role] {
  grid-area: role;
}

.gallery-category-row-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(2, minmax(52px, auto));
  justify-content: flex-end;
  gap: 8px;
}

.gallery-category-row .control,
.gallery-category-create-row .control {
  width: 100%;
  min-width: 0;
}

.gallery-category-create-row .ghost-button,
.gallery-category-row .ghost-button {
  white-space: nowrap;
}

.gallery-drag-handle {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: color-mix(in srgb, var(--line) 78%, transparent);
  color: var(--text-secondary);
  cursor: grab;
}

.gallery-drag-handle:active {
  cursor: grabbing;
}

.gallery-drag-handle svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.gallery-drag-preview {
  position: fixed;
  top: -999px;
  left: -999px;
  z-index: 999;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 190px;
  max-width: 280px;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--primary) 58%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 96%, var(--primary-light));
  color: var(--text);
  box-shadow: var(--shadow-popover);
  pointer-events: none;
}

.gallery-drag-preview-visual {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface-soft));
  color: var(--primary-strong);
}

.gallery-drag-preview-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-drag-preview-visual svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.gallery-drag-preview-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.gallery-drag-preview-copy strong,
.gallery-drag-preview-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-drag-preview-copy strong {
  font-size: 13px;
  color: var(--text);
}

.gallery-drag-preview-copy span {
  font-size: 12px;
  color: var(--muted);
}

.gallery-drag-preview-clone {
  position: fixed !important;
  top: -999px !important;
  left: -999px !important;
  z-index: 999;
  margin: 0;
  pointer-events: none;
  box-shadow: var(--shadow-popover);
}

.gallery-category-row.is-dragging,
.gallery-card.is-dragging {
  opacity: 0.42;
}

.gallery-category-row.drop-target {
  border-color: color-mix(in srgb, var(--primary) 44%, var(--line));
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}

.gallery-category-row.drop-before {
  box-shadow: inset 0 3px 0 color-mix(in srgb, var(--primary) 78%, transparent);
}

.gallery-category-row.drop-after {
  box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--primary) 78%, transparent);
}

.gallery-drawer-toolbar .ghost-button.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary-strong);
}

.gallery-grid {
  display: grid;
  align-items: start;
  overflow: hidden;
  transition: height var(--motion-height);
}

.gallery-grid.is-transitioning {
  will-change: height;
}

.gallery-grid > .gallery-grid-layer {
  grid-area: 1 / 1;
  min-width: 0;
}

.gallery-grid-layer {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 14px;
}

@media (prefers-reduced-motion: reduce) {
  .gallery-grid {
    transition: none;
  }
}

.gallery-empty {
  min-height: 160px;
  display: grid;
  place-items: center;
  border: 1px dashed color-mix(in srgb, var(--text-secondary) 30%, var(--line));
  border-radius: 12px;
  color: var(--muted);
}

.archive-list {
  display: grid;
  gap: 10px;
}

.language-settings-panel {
  display: grid;
  gap: 12px;
  max-width: 640px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.language-select-field {
  max-width: 420px;
}

.language-settings-status {
  margin: 0;
  width: fit-content;
  max-width: 100%;
}

/* source: styles/74-api-system-settings.css */
.settings-path-grid {
  display: grid;
  gap: 12px;
}

.notification-options-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.notification-options-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.notification-options-copy strong {
  color: var(--text);
  font-size: 13px;
}

.notification-options-copy span {
  color: var(--muted);
  font-size: 12px;
}

.notification-option-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.notification-option-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.api-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.api-provider-section {
  display: grid;
  gap: 8px;
}

.api-provider-section-header,
.api-provider-editor-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.api-provider-section-header {
  justify-content: space-between;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.api-provider-editor-heading {
  justify-content: flex-start;
}

.api-provider-section-title {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.api-provider-sort-toggle {
  width: auto;
  min-width: 72px;
  height: 30px;
  padding: 0 12px;
  justify-content: center;
  font-size: 12px;
}

.api-provider-sort-toggle.active {
  border-color: color-mix(in srgb, var(--primary) 44%, var(--line));
  background: var(--primary-light);
  color: var(--primary-strong);
}

.api-provider-count,
.api-provider-editor-heading span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.api-provider-search {
  position: relative;
  display: block;
}

.api-provider-search svg {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 11px;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  transform: translateY(-50%);
  pointer-events: none;
}

.api-provider-search .control {
  height: 36px;
  padding-left: 34px;
  font-size: 12px;
}

.api-provider-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

.api-provider-choice-grid.is-long-list {
  max-height: min(320px, 38vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-gutter: stable;
  scrollbar-color: color-mix(in srgb, var(--primary) 55%, transparent) transparent;
}

.api-provider-section.editing {
  display: none;
}

.api-provider-list {
  display: contents;
  min-width: 0;
}

.api-provider-list.is-sorting {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.api-provider-search-empty {
  grid-column: 1 / -1;
  min-height: 64px;
  display: grid;
  place-items: center;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.api-provider-choice,
.api-provider-add-card {
  width: 100%;
  min-height: 64px;
  display: grid;
  gap: 2px;
  align-content: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--motion-fast), background var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast);
}

.api-provider-add-card {
  place-content: center;
  border-style: dashed;
  background: color-mix(in srgb, var(--surface-soft) 82%, transparent);
  color: var(--text-secondary);
  font-weight: 700;
  text-align: center;
}

.api-provider-add-card::before {
  content: "+";
  color: var(--primary);
  font-size: 16px;
  line-height: 1;
}

.api-provider-choice strong,
.api-provider-choice span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-provider-choice strong {
  font-size: 13px;
}

.api-provider-choice span {
  color: var(--muted);
  font-size: 11px;
}

.api-provider-choice:hover,
.api-provider-choice:focus-visible,
.api-provider-add-card:hover,
.api-provider-add-card:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--line));
  outline: none;
}

.api-provider-add-card:hover,
.api-provider-add-card:focus-visible {
  background: var(--primary-light);
  color: var(--primary-strong);
}

.api-provider-choice.active {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-soft);
}

.api-provider-choice.active span {
  color: color-mix(in srgb, var(--primary-foreground) 82%, transparent);
}

.api-provider-sort-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.api-provider-sort-row.active {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  background: color-mix(in srgb, var(--primary-light) 70%, var(--surface));
}

.api-provider-sort-content {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.api-provider-sort-content strong,
.api-provider-sort-content span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-provider-sort-content strong {
  color: var(--text);
  font-size: 13px;
}

.api-provider-sort-content span {
  color: var(--muted);
  font-size: 11px;
}

.api-provider-sort-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.api-provider-sort-button {
  width: auto;
  min-width: 48px;
  height: 30px;
  padding: 0 10px;
  justify-content: center;
  font-size: 12px;
}

.api-provider-detail-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.api-provider-detail-actions,
.api-provider-editor-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.api-provider-detail-actions {
  padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
}

.api-provider-detail-actions .ghost-button,
.api-provider-detail-actions .danger-button,
.api-provider-editor-actions .ghost-button,
.api-provider-editor-actions .run-button {
  width: auto;
  min-width: 112px;
  height: 40px;
  padding: 0 16px;
  justify-content: center;
  text-align: center;
  font-size: 13px;
}

.api-provider-editor-actions {
  padding-top: 2px;
}

.api-provider-editor-actions .ghost-button,
.api-provider-editor-actions .run-button {
  border-radius: 8px;
}

.api-provider-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.api-provider-detail-grid > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.api-provider-detail-grid dt {
  color: var(--muted);
  font-size: 11px;
}

.api-provider-detail-grid dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-provider-editor {
  display: grid;
  gap: 12px;
  margin-top: 0;
}

.api-provider-editor.hidden,
.api-provider-detail-panel.hidden {
  display: none;
}

.api-provider-editor .api-provider-name-field {
  grid-column: 1 / -1;
}

.api-provider-editor-heading {
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary-light) 34%, var(--surface-soft));
}

.api-provider-editor-heading span:first-child {
  color: var(--text);
  font-weight: 700;
}

@media (max-width: 720px) {
  .language-settings-panel {
    grid-template-columns: minmax(0, 1fr);
  }

}

@media (max-width: 520px) {
  .api-provider-choice-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.api-mode-field {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(280px, 320px);
  align-items: center;
  justify-content: center;
}

.api-mode-field .radio-group {
  --segmented-control-height: 28px;
  --segmented-control-padding: 2px;
  --segmented-indicator-radius: 6px;
  width: 100%;
  justify-self: center;
  border-color: color-mix(in srgb, var(--line) 76%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-soft) 76%, transparent);
}

.api-mode-field .radio-btn {
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.api-mode-field .segmented-indicator {
  box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--primary) 36%, var(--line));
  background: color-mix(in srgb, var(--primary-light) 56%, var(--surface));
  box-shadow: none;
}

.api-mode-field .radio-group.segmented-indicator-host .radio-btn.active {
  color: var(--primary-strong);
  font-weight: 600;
}

.api-mode-field .radio-btn:not(.active):hover,
.api-mode-field .radio-btn:not(.active):focus-visible {
  color: var(--text-secondary);
  outline: none;
}

@media (max-width: 620px) {
  .api-mode-field {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }

  .api-mode-field .radio-group {
    justify-self: stretch;
  }
}

.api-provider-name-field,
.api-base-url-field,
.api-key-field {
  grid-column: 1 / -1;
}

.api-request-endpoint-preview {
  grid-column: 1 / -1;
  display: flex;
  min-width: 0;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-soft) 82%, transparent);
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
}

.api-request-endpoint-preview span {
  flex: 0 0 auto;
}

.api-request-endpoint-preview code {
  min-width: 0;
  overflow: hidden;
  color: var(--text-secondary);
  font: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-key-input-wrap {
  position: relative;
  min-width: 0;
}

.api-key-input-wrap .control {
  width: 100%;
  padding-right: 40px;
}

.api-key-reveal-button {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transform: translateY(-50%);
  transition: background var(--motion-fast), color var(--motion-fast), opacity var(--motion-fast);
}

.api-key-reveal-button:hover,
.api-key-reveal-button:focus-visible,
.api-key-reveal-button[aria-pressed="true"] {
  background: var(--primary-light);
  color: var(--primary-strong);
  outline: none;
}

.api-key-reveal-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.api-key-reveal-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#apiImagesConcurrency {
  appearance: textfield;
  -moz-appearance: textfield;
}

#apiImagesConcurrency::-webkit-outer-spin-button,
#apiImagesConcurrency::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.compact-api-settings-grid .field {
  gap: 5px;
}

.compact-api-settings-grid > .api-provider-name-field,
.compact-api-settings-grid > .api-base-url-field,
.compact-api-settings-grid > .api-key-field {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  row-gap: 0;
}

.compact-api-settings-grid > .api-provider-name-field > span,
.compact-api-settings-grid > .api-base-url-field > span,
.compact-api-settings-grid > .api-key-field > span {
  white-space: nowrap;
}

.compact-api-settings-grid > .api-provider-name-field .control,
.compact-api-settings-grid > .api-base-url-field .control,
.compact-api-settings-grid > .api-key-field .api-key-input-wrap {
  min-width: 0;
}

.api-advanced-settings {
  grid-column: 1 / -1;
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
}

.api-advanced-settings > summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
}

.api-advanced-settings > summary::-webkit-details-marker {
  display: none;
}

.api-advanced-settings > summary:focus-visible {
  border-radius: 7px;
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.api-advanced-settings > summary strong {
  flex: 0 0 auto;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}

.api-advanced-settings-summary {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

#apiAdvancedImageModelSummary {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.api-advanced-settings-chevron {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform var(--motion-fast);
}

.api-advanced-settings[open] .api-advanced-settings-chevron {
  transform: rotate(225deg) translate(-1px, -1px);
}

.api-advanced-settings-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 10px 11px 11px;
  border-top: 1px solid color-mix(in srgb, var(--line) 64%, transparent);
}

.api-advanced-settings-body .field {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
}

@media (max-width: 620px) {
  .api-settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .compact-api-settings-grid > .api-provider-name-field,
  .compact-api-settings-grid > .api-base-url-field,
  .compact-api-settings-grid > .api-key-field {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    row-gap: 5px;
  }

  .api-advanced-settings-body {
    grid-template-columns: minmax(0, 1fr);
  }
}

.codex-settings-layout {
  display: grid;
  gap: 14px;
}

.codex-channel-control {
  display: grid;
  gap: 8px;
}

.codex-channel-notes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.codex-channel-note {
  appearance: none;
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background var(--motion-base),
    border-color var(--motion-base),
    box-shadow var(--motion-base),
    color var(--motion-base);
}

.codex-channel-note:hover,
.codex-channel-note:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--line));
  background: color-mix(in srgb, var(--primary-light) 34%, var(--surface));
}

.codex-channel-note:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 52%, transparent);
  outline-offset: 2px;
}

.codex-channel-note.active {
  border-color: color-mix(in srgb, var(--primary) 66%, var(--line));
  background: var(--primary-light);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent);
}

.codex-channel-note-header {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.codex-channel-note strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.codex-channel-current {
  display: none;
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}

.codex-channel-note.active .codex-channel-current {
  display: inline-flex;
}

.codex-channel-note > span:not(.codex-channel-note-header) {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.settings-modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
}

.settings-modal-actions.settings-status-only {
  justify-content: flex-start;
  margin-top: 12px;
  padding-top: 0;
}

.settings-action-status {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-action-status:empty {
  display: none;
}

.settings-modal-actions .run-button {
  flex: 0 0 auto;
  margin-left: auto;
  width: auto;
  min-width: 120px;
  height: 40px;
  padding: 0 18px;
  justify-content: center;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .system-settings-modal-panel {
    transition: none;
  }
}

/* source: styles/75-gallery-card-image-editor.css */
.archive-empty {
  min-height: 130px;
  display: grid;
  place-items: center;
  border: 1px dashed color-mix(in srgb, var(--text-secondary) 30%, var(--line));
  border-radius: 12px;
  color: var(--muted);
}

.archive-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  cursor: pointer;
}

.archive-card:hover {
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
  background: var(--surface-soft);
}

.archive-thumb {
  width: 56px;
  height: 56px;
  border-radius: 7px;
  background: var(--line);
  object-fit: contain;
}

.archive-info {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.archive-info strong,
.archive-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-info strong {
  color: var(--text);
  font-size: 13px;
}

.archive-info span {
  color: var(--muted);
  font-size: 12px;
}

.archive-card-actions {
  display: flex;
  gap: 6px;
}

.gallery-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto auto;
  container-type: inline-size;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), opacity var(--motion-fast), transform var(--motion-fast);
}

.gallery-card-media {
  position: relative;
}

.gallery-card-drag-strip {
  width: 100%;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  background: color-mix(in srgb, var(--surface) 68%, transparent);
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: grab;
  transition: background var(--motion-fast), color var(--motion-fast);
}

.gallery-card-drag-strip:hover,
.gallery-card-drag-strip:focus-visible {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  color: var(--primary-strong);
}

.gallery-card-drag-strip:active {
  cursor: grabbing;
}

.gallery-card-drag-strip-icon,
.gallery-card-drag-strip svg {
  width: 14px;
  height: 14px;
  display: inline-block;
  fill: currentColor;
}

.gallery-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface-soft));
}

.gallery-card.drop-target {
  border-color: color-mix(in srgb, var(--primary) 44%, var(--line));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent);
}

.gallery-card.drop-before::before,
.gallery-card.drop-after::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  height: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 82%, transparent);
}

.gallery-card.drop-before::before {
  top: 8px;
}

.gallery-card.drop-after::after {
  bottom: 8px;
}

.gallery-card-body {
  display: grid;
  gap: 6px;
  min-width: 0;
  min-height: 58px;
  padding: 10px;
}

.gallery-card-heading {
  display: block;
  min-width: 0;
}

.gallery-card-heading strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card-body span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
  padding: 0 10px 10px;
}

.gallery-card-actions .ghost-button {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@container (max-width: 219px) {
  .gallery-card-actions {
    grid-template-columns: 1fr;
  }
}

.danger-button {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.image-editor-panel {
  width: min(1040px, 94vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.image-editor-heading {
  margin-bottom: 0;
}

.image-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.image-editor-tool-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.image-editor-tool {
  min-width: 78px;
  min-height: 44px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  touch-action: manipulation;
}

.image-editor-tool-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.image-editor-tool-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.9;
}

.image-editor-tool.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

.image-editor-swatch {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(31, 53, 47, 0.18);
  border-radius: 999px;
  background: var(--swatch-color, #ff3b30);
  cursor: pointer;
}

.image-editor-swatch[data-image-editor-color="#ff3b30"] { --swatch-color: #ff3b30; }
.image-editor-swatch[data-image-editor-color="#2f6fe4"] { --swatch-color: #2f6fe4; }
.image-editor-swatch[data-image-editor-color="#457b66"] { --swatch-color: #457b66; }
.image-editor-swatch[data-image-editor-color="#f2b84b"] { --swatch-color: #f2b84b; }
.image-editor-swatch[data-image-editor-color="#ffffff"] { --swatch-color: #ffffff; }
.image-editor-swatch[data-image-editor-color="#111111"] { --swatch-color: #111111; }

.image-editor-swatch.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

.image-editor-color {
  width: 32px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.image-editor-stroke-field {
  display: grid;
  grid-template-columns: auto 118px 38px;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.image-editor-stroke-field output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.image-editor-stage {
  min-height: 360px;
  display: grid;
  place-items: center;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 70%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--line) 70%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--line) 70%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--line) 70%, transparent) 75%);
  background-color: var(--surface);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  padding: 14px;
}

.image-editor-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: stretch;
  gap: 12px;
  place-items: stretch;
}

.image-editor-canvas-wrap {
  position: relative;
  line-height: 0;
  touch-action: none;
  user-select: none;
  min-width: 0;
  max-width: 100%;
  max-height: min(62vh, 640px);
  display: grid;
  place-items: center;
  overflow: auto;
}

.image-editor-canvas {
  display: block;
  max-width: 100%;
  max-height: 62vh;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(29, 52, 46, 0.14);
  cursor: crosshair;
}

.image-editor-fallback-canvas {
  display: none;
}

.image-editor-konva-mount {
  width: var(--image-editor-stage-width, 100%);
  height: var(--image-editor-stage-height, auto);
  min-height: 0;
  display: block;
  overflow: hidden;
  position: relative;
}

.image-editor-konva-mount .konvajs-content {
  width: var(--image-editor-stage-raw-width, var(--image-editor-stage-width, 100%)) !important;
  height: var(--image-editor-stage-raw-height, var(--image-editor-stage-height, auto)) !important;
  max-width: none;
  max-height: none;
  transform: scale(var(--image-editor-stage-scale, 1));
  transform-origin: top left;
}

.image-editor-konva-mount canvas {
  width: var(--image-editor-stage-raw-width, var(--image-editor-stage-width, 100%)) !important;
  height: var(--image-editor-stage-raw-height, var(--image-editor-stage-height, auto)) !important;
  max-width: none;
  max-height: none;
}

.image-editor-konva-mount canvas {
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(29, 52, 46, 0.14);
  cursor: crosshair;
}

.image-editor-crop-box {
  position: absolute;
  border: 2px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  box-shadow: 0 0 0 9999px rgba(12, 28, 23, 0.28);
  pointer-events: none;
}

.image-editor-side-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.image-editor-side-section {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
}

.image-editor-side-section:first-child {
  flex: 0 0 auto;
}

.image-editor-side-section:last-child {
  flex: 1 1 auto;
}

.image-editor-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.image-editor-canvas-scope-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.image-editor-canvas-scope-control .ghost-button {
  min-height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.image-editor-canvas-scope-control .ghost-button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

.image-editor-layer-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.image-editor-layer-actions .ghost-button {
  min-height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 11px;
}

.image-editor-insert-list,
.image-editor-layer-list {
  display: grid;
  gap: 6px;
}

.image-editor-insert-list {
  max-height: 164px;
  overflow: auto;
}

.image-editor-layer-list {
  min-height: 0;
  overflow: auto;
}

.image-editor-insert-empty {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.image-editor-insert-item,
.image-editor-layer-item {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition:
    background var(--motion-base),
    border-color var(--motion-base),
    color var(--motion-base);
}

.image-editor-insert-item:hover,
.image-editor-insert-item:focus-visible,
.image-editor-layer-item:hover,
.image-editor-layer-item:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--line));
  background: var(--primary-light);
}

.image-editor-layer-item.active {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.image-editor-insert-item img,
.image-editor-layer-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-soft);
}

.image-editor-layer-thumb {
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.image-editor-layer-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.image-editor-layer-item > span:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.image-editor-layer-item.active .image-editor-layer-thumb {
  color: var(--primary-foreground);
  background: color-mix(in srgb, var(--surface) 22%, transparent);
}

.image-editor-insert-name,
.image-editor-layer-name {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-editor-layer-meta {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-editor-layer-item.active .image-editor-layer-meta {
  color: color-mix(in srgb, var(--primary-foreground) 78%, transparent);
}

.image-editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.image-editor-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
}

.image-editor-status.error {
  color: var(--danger);
}

.image-editor-actions {
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.image-editor-actions .ghost-button,
.image-editor-actions .primary-button {
  flex: 0 0 72px;
  width: 72px;
  min-width: 72px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.add-upload-to-gallery {
  position: absolute;
  height: 32px;
  min-width: 54px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid rgba(255,255,255,0.58);
  border-radius: 999px;
  background: rgba(31, 53, 47, 0.78);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.9;
  pointer-events: auto;
  box-shadow: 0 8px 18px rgba(12, 28, 23, 0.18);
  transition: opacity var(--motion-base), background var(--motion-base), transform var(--motion-base);
  touch-action: manipulation;
}

.add-upload-to-gallery {
  bottom: 6px;
  left: 6px;
  right: auto;
  z-index: 2;
  background: color-mix(in srgb, var(--primary) 90%, transparent);
}

.thumb-add-icon {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.thumb-add-icon svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.9;
}

.thumb:hover .add-upload-to-gallery,
.thumb:focus-within .add-upload-to-gallery,
.add-upload-to-gallery:focus-visible {
  opacity: 1;
}

.add-upload-to-gallery:hover,
.add-upload-to-gallery:focus-visible {
  background: color-mix(in srgb, var(--primary) 98%, transparent);
  transform: translateY(-1px);
}

.thumb-edited-badge {
  position: absolute;
  right: 5px;
  bottom: 5px;
  z-index: 1;
  width: fit-content;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 86%, transparent);
  color: #fff;
  font-size: 10px;
}

@media (prefers-reduced-motion: reduce) {
  input[type=range].slider::-webkit-slider-thumb,
  input[type=range].slider::-moz-range-thumb,
  .preview-overlay,
  .elapsed-wheel-strip,
  .queue-drawer,
  .queue-item-action,
  .api-settings-feedback,
  .system-settings-tab,
  .gallery-grid,
  .add-upload-to-gallery {
    transition: none;
  }

  .add-upload-to-gallery:hover,
  .add-upload-to-gallery:focus-visible {
    transform: none;
  }

  .waiting-bar span {
    animation: none;
  }
}

.add-gallery-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.add-gallery-preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

@keyframes soft-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes waiting-bar {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(260%);
  }
}

/* source: styles/80-utilities-responsive.css */
/* Hamburger toggle: hidden on desktop by default. sidebar-drawer.ts removes the
   `hidden` attribute on init (so non-JS mobile users don't see a dead button), so
   CSS must keep it hidden on wide viewports — the @media(max-width:1180px) block
   below overrides this to inline-flex only on narrow screens. */
.sidebar-drawer-toggle {
  display: none;
}

.mobile-section-toggle,
.mobile-output-summary,
.mobile-advanced-settings-toggle,
.mobile-material-summary,
.mobile-materials-toggle,
.mobile-task-badge {
  display: none;
}
/* JSON */
#requestJson {
  margin: 0;
  background: var(--code);
  color: var(--code-text);
  border-radius: 6px;
  padding: 16px;
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
  max-height: 300px;
}

/* Utilities */
.hidden {
  display: none !important;
}

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-0 { margin-bottom: 0; }

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive adjustments */
@media (max-width: 1400px) {
  .dashboard {
    grid-template-columns: minmax(420px, 680px) minmax(360px, 1fr);
  }
}

@media (max-height: 1390px) and (min-width: 900px) {
  .reference-file-thumb .reference-file-format-icon {
    width: 39px;
    height: 45px;
  }

  .reference-file-name {
    min-height: 29px;
    font-size: 10px;
  }

  .sidebar-footer {
    padding: 8px 12px;
    gap: 4px;
  }

  .status-text:not(.error) {
    -webkit-line-clamp: 1;
    max-height: 1.45em;
    font-size: 11px;
  }

  .status-text.error {
    -webkit-line-clamp: 1;
    max-height: 1.45em;
    font-size: 11px;
  }

  .version-info {
    display: inline-flex;
    width: auto;
    min-height: 24px;
    padding: 2px 8px;
    margin: 0 auto;
  }

  .dashboard {
    --compact-dashboard-padding: clamp(10px, calc(2.25dvh - 7.3px), 24px);
    --compact-dashboard-gap: clamp(10px, calc(2.25dvh - 7.3px), 24px);
    padding: var(--compact-dashboard-padding);
    gap: var(--compact-dashboard-gap);
    align-content: start;
  }

  .preview-col {
    height: calc(
      100dvh - var(--header-height) - var(--compact-dashboard-padding) -
        var(--compact-dashboard-padding)
    );
  }

  .preview-panel {
    height: 100%;
    max-height: none;
  }

  .dashboard-col {
    gap: clamp(8px, calc(1.93dvh - 6.8px), 20px);
  }

  .controls-col {
    --compact-image-panel-height: clamp(
      var(--compact-image-panel-min, 130px),
      calc(23.47dvh - 50.3px - var(--compact-panel-shell-adjustment, 0px)),
      276px
    );
    --compact-prompt-panel-height: clamp(
      var(--compact-prompt-panel-min, 110px),
      calc(24.12dvh - 75.2px - var(--compact-panel-shell-adjustment, 0px)),
      260px
    );
    min-height: calc(
      100dvh - var(--header-height) - var(--compact-dashboard-padding) -
        var(--compact-dashboard-padding)
    );
    height: calc(
      100dvh - var(--header-height) - var(--compact-dashboard-padding) -
        var(--compact-dashboard-padding)
    );
    justify-content: flex-start;
  }

  .controls-col .image-panel,
  .controls-col .prompt-panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .controls-col .image-panel {
    flex: 1 1 var(--compact-image-panel-height);
    min-height: var(--compact-image-panel-height);
  }

  .controls-col .prompt-panel {
    flex: 1.15 1 var(--compact-prompt-panel-height);
    min-height: var(--compact-prompt-panel-height);
    overflow: hidden;
  }

  .controls-col .output-panel {
    flex: 0 0 auto;
    min-height: 0;
  }

  .panel {
    padding: clamp(10px, calc(1.61dvh - 2.4px), 20px);
    border-radius: 10px;
  }

  .controls-col .image-panel .panel-heading {
    margin-bottom: clamp(4px, calc(1.93dvh - 10.8px), 16px);
  }

  .controls-col .output-settings-header {
    display: flex;
    align-items: center;
    min-height: 18px;
    justify-content: space-between;
    margin-bottom: clamp(2px, calc(2.25dvh - 15.3px), 16px);
  }

  .controls-col .output-settings-lock-button {
    width: clamp(24px, calc(1.29dvh + 14.1px), 32px);
    height: clamp(24px, calc(1.29dvh + 14.1px), 32px);
  }

  .controls-col .output-settings-summary-content {
    padding: clamp(8px, calc(2.57dvh - 11.7px), 24px);
  }

  .controls-col .output-settings-summary-main {
    padding: 0 0 clamp(6px, calc(4.82dvh - 31px), 36px);
  }

  .controls-col .output-settings-summary-cards {
    gap: clamp(8px, calc(0.64dvh + 3.1px), 12px);
    margin-top: clamp(6px, calc(2.89dvh - 16.2px), 24px);
  }

  .controls-col .output-settings-summary-card {
    min-height: clamp(82px, calc(13.5dvh - 21.7px), 166px);
    gap: clamp(3px, calc(1.13dvh - 5.7px), 10px);
    padding: clamp(8px, calc(1.29dvh - 1.9px), 16px);
  }

  .controls-col .output-settings-ratio-visual,
  .controls-col .output-settings-count-visual {
    min-height: clamp(40px, calc(8.36dvh - 24.2px), 92px);
  }

  .controls-col .output-settings-ratio-frame {
    width: clamp(46px, calc(6.43dvh - 3.4px), 86px);
  }

  .controls-col .output-settings-ratio-frame.is-portrait {
    height: clamp(46px, calc(6.43dvh - 3.4px), 86px);
  }

  .controls-col .output-settings-format-visual {
    width: clamp(46px, calc(6.43dvh - 3.4px), 86px);
    font-size: clamp(12px, calc(0.64dvh + 7.1px), 16px);
  }

  .controls-col .output-settings-summary-details {
    margin-top: clamp(6px, calc(1.93dvh - 8.8px), 18px);
    padding-top: clamp(6px, calc(1.93dvh - 8.8px), 18px);
  }

  .controls-col .output-settings-summary-hint {
    padding-top: clamp(6px, calc(3.54dvh - 21.2px), 28px);
    font-size: 11px;
  }

  .controls-col .prompt-heading {
    margin-bottom: clamp(4px, calc(1.29dvh - 5.9px), 12px);
  }

  .controls-col .prompt-heading-main {
    justify-content: space-between;
  }

  .image-input-workspace {
    --image-input-main-height: clamp(
      60px,
      calc(14.47dvh - 51.1px - var(--compact-image-shell-adjustment, 0px)),
      150px
    );
    --image-input-action-height: clamp(
      28px,
      calc(1.93dvh + 13.2px - var(--compact-action-shell-adjustment, 0px)),
      40px
    );
    --image-input-gap: clamp(4px, calc(0.96dvh - 3.4px), 10px);
    --image-upload-source-compact-width: clamp(106px, calc(1.93dvh + 91.2px), 118px);
    --image-input-thumb-size: clamp(104px, calc(1.93dvh + 89.2px), 116px);
    --recent-asset-size: 32px;
    gap: 8px;
  }

  .controls-col .image-input-workspace {
    flex: 1 1 auto;
    min-height: 0;
  }

  .controls-col .image-input-left,
  .controls-col .image-gallery-column {
    height: auto;
    min-height: 0;
  }

  .controls-col .image-input-left {
    flex: 1 1 auto;
  }

  .controls-col .image-input-main {
    flex: 1 1 auto;
    min-height: var(--image-input-main-height);
    height: auto;
  }

  .controls-col .image-gallery-column {
    grid-template-rows: minmax(0, 1fr) var(--image-input-action-height);
  }

  .controls-col .quick-gallery-dock,
  .controls-col .quick-gallery-list {
    height: auto;
    min-height: 0;
  }

  .image-uploader-grid {
    padding: clamp(8px, calc(0.64dvh + 3.1px), 12px);
  }

  .controls-col .upload-tile {
    gap: clamp(2px, 0.444dvh, 5px);
  }

  .controls-col .upload-tile .icon {
    width: clamp(22px, 3.333dvh, 30px);
    height: clamp(22px, 3.333dvh, 30px);
  }

  .controls-col .upload-tile .icon svg {
    width: clamp(14px, 2dvh, 18px);
    height: clamp(14px, 2dvh, 18px);
  }

  .controls-col .upload-title {
    font-size: clamp(11px, 1.444dvh, 13px);
    line-height: 1.1;
  }

  .controls-col .upload-subtitle {
    font-size: clamp(10px, 1.222dvh, 11px);
    line-height: 1.1;
  }

  .controls-col .add-upload-to-gallery {
    left: 5px;
    bottom: 5px;
    width: 28px;
    min-width: 28px;
    height: 28px;
    padding: 0;
    font-size: 0;
    gap: 0;
  }

  .controls-col .add-upload-to-gallery .thumb-add-icon {
    width: 14px;
    height: 14px;
  }

  .image-input-actions .ghost-button,
  .gallery-manage-panel .resource-manage-button {
    height: var(--image-input-action-height);
  }

  .quick-gallery-category {
    flex-basis: clamp(24px, calc(0.96dvh + 16.6px), 30px);
    height: clamp(24px, calc(0.96dvh + 16.6px), 30px);
  }

  .quick-gallery-list {
    --quick-gallery-item-height: clamp(24px, calc(0.96dvh + 16.6px), 30px);
  }

  .prompt-heading {
    margin-bottom: 8px;
  }

  .controls-col .prompt-compose {
    flex: 1 1 0;
    min-height: 0;
    align-items: stretch;
  }

  .controls-col .prompt-editor-wrap,
  .controls-col .prompt-run-wrap {
    display: flex;
    min-height: 0;
  }

  .controls-col .prompt-editor-wrap {
    height: 100%;
    overflow: hidden;
  }

  .controls-col .prompt-box {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    resize: none;
  }

  .controls-col .prompt-compose .run-button {
    min-height: 0;
    height: 100%;
    max-height: 100%;
  }

  .prompt-template-row {
    margin-top: 6px;
  }

  .prompt-panel {
    --prompt-secondary-action-height: clamp(
      28px,
      calc(1.93dvh + 13.2px - var(--compact-action-shell-adjustment, 0px)),
      40px
    );
    --prompt-secondary-chip-height: clamp(
      26px,
      calc(0.96dvh + 18.6px - var(--compact-action-shell-adjustment, 0px)),
      32px
    );
  }

  .prompt-footer .ghost-button,
  .prompt-template-entry .prompt-template-button {
    height: var(--prompt-secondary-action-height);
    min-height: var(--prompt-secondary-action-height);
  }

  .prompt-find-panel {
    grid-template-columns: minmax(68px, 1fr) minmax(68px, 1fr) max-content;
    gap: 4px;
  }

  .prompt-find-panel .control,
  .prompt-find-panel .ghost-button {
    height: calc(var(--prompt-secondary-action-height) - 4px);
    min-height: calc(var(--prompt-secondary-action-height) - 4px);
    padding: 0 5px;
  }

  .prompt-find-actions {
    gap: 2px;
  }

  .prompt-find-count {
    min-width: 34px;
  }

  .settings-grid {
    --compact-settings-control-height: clamp(
      22px,
      calc(2.25dvh + 4.7px - var(--compact-settings-shell-adjustment, 0px)),
      36px
    );
    --compact-settings-segment-height: clamp(
      18px,
      calc(1.93dvh + 3.2px - var(--compact-settings-shell-adjustment, 0px)),
      30px
    );
    --compact-settings-gap: clamp(3px, calc(2.09dvh - 13.1px), 16px);
    --compact-field-gap: clamp(2px, calc(0.96dvh - 5.4px), 8px);
    gap: var(--compact-settings-gap);
  }

  .field {
    gap: var(--compact-field-gap);
  }

  .settings-grid .field > span {
    font-size: clamp(11px, calc(0.32dvh + 8.5px), 13px);
  }

  .settings-grid .control {
    height: var(--compact-settings-control-height);
    padding: 0 10px;
  }

  .settings-grid .radio-group {
    --segmented-control-height: var(--compact-settings-segment-height);
    --segmented-control-padding: clamp(2px, calc(0.16dvh + 0.8px), 3px);
  }

  .settings-grid .radio-btn {
    padding: 0 6px;
    white-space: nowrap;
  }

  .custom-size-control {
    gap: var(--compact-field-gap);
  }

  .custom-size-control .field-label {
    display: block;
    font-size: 12px;
  }

  .size-mode-group {
    width: 100%;
    min-width: 0;
  }

  .quantity-quality-row {
    gap: var(--compact-settings-gap);
  }

  .quantity-quality-row .field {
    gap: var(--compact-field-gap);
  }

  .ratio-group {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: repeat(2, var(--compact-settings-segment-height));
  }

  .mode-settings-slot {
    --mode-settings-stable-height: clamp(
      77px,
      calc(10.77dvh - 5.7px - var(--compact-mode-shell-adjustment, 0px)),
      144px
    );
  }

  .mode-specific-settings {
    gap: var(--compact-settings-gap);
  }

  .model-tool-row {
    grid-template-columns: minmax(0, 1fr) minmax(92px, 0.32fr);
    gap: clamp(6px, calc(1.61dvh - 6.4px), 16px);
  }

  .web-search-toggle {
    --compact-web-search-track-width: clamp(32px, calc(0.64dvh + 27.1px), 36px);
    --compact-web-search-track-height: clamp(18px, calc(0.32dvh + 15.5px), 20px);
    --compact-web-search-knob-size: clamp(12px, calc(0.32dvh + 9.5px), 14px);
    --compact-web-search-shift: clamp(14px, calc(0.32dvh + 11.5px), 16px);
    width: 100%;
    min-width: 0;
    height: var(--compact-settings-control-height);
    grid-template-columns: var(--compact-web-search-track-width) minmax(0, max-content);
    gap: clamp(6px, calc(0.32dvh + 3.5px), 8px);
    padding: 0 clamp(8px, calc(0.32dvh + 5.5px), 10px);
  }

  .web-search-toggle-track {
    width: var(--compact-web-search-track-width);
    height: var(--compact-web-search-track-height);
  }

  .web-search-toggle-track::before {
    width: var(--compact-web-search-knob-size);
    height: var(--compact-web-search-knob-size);
  }

  .web-search-toggle input:checked + .web-search-toggle-track::before {
    transform: translateX(var(--compact-web-search-shift));
  }

  .web-search-toggle-text {
    font-size: clamp(11px, calc(0.32dvh + 8.5px), 13px);
  }

  .api-direct-settings-notice {
    min-height: 46px;
  }

  .api-direct-settings-control {
    height: var(--compact-settings-control-height);
    gap: clamp(8px, calc(0.32dvh + 5.5px), 10px);
    padding: 0 6px 0 clamp(8px, calc(0.64dvh + 3.1px), 12px);
  }

  .api-direct-settings-header {
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .api-direct-settings-header span {
    font-size: 11px;
  }

  .api-direct-settings-header strong {
    min-height: 22px;
    padding: 0 8px;
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
  }

  .api-direct-settings-button {
    height: 28px;
    min-height: 28px;
  }

  #pixelPreview {
    min-height: clamp(18px, calc(2.73dvh - 3px), 35px);
    padding: clamp(3px, calc(0.8dvh - 3.1px), 8px) 8px !important;
    font-size: clamp(11px, calc(0.32dvh + 8.5px), 13px) !important;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .settings-grid.custom-size-mode {
    --custom-size-mode-card-height: clamp(130px, calc(7.23dvh + 74.5px), 175px);
  }

  .settings-grid.custom-size-mode .custom-size {
    gap: clamp(8px, calc(2.25dvh - 9.3px), 22px);
    padding: clamp(10px, calc(1.61dvh - 2.4px), 20px);
  }

  .custom-size-main {
    gap: 6px;
  }

  .custom-size-header {
    min-height: 18px;
  }

  .custom-size-header > span {
    font-size: 13px;
  }

  .custom-size-row {
    --measure-label-width: 30px;
    --measure-input-width: 78px;
    --measure-mid-width: 28px;
    column-gap: 6px;
  }

  .custom-size-input,
  .custom-ratio-digit {
    height: 28px;
  }

  .custom-size-icon-button {
    width: 28px;
    height: 28px;
  }

  .custom-ratio-field {
    padding-top: 6px;
    padding-left: 0;
    border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
    border-left: 0;
    gap: 4px;
  }

  .custom-ratio-header {
    display: none;
  }

  .custom-ratio-control {
    --measure-label-width: 18px;
    --measure-input-width: 38px;
    --measure-mid-width: 14px;
    grid-template-columns: 18px 38px 14px 18px 38px auto;
    column-gap: 6px;
  }

  .custom-ratio-image-button {
    height: 26px;
    padding: 0 7px;
  }

  .custom-size-hint {
    font-size: 11px;
    line-height: 1.25;
  }

  .custom-ratio-hint {
    display: none;
  }

}

@media (max-height: 1100px) and (min-width: 900px) {
  @container workspace (max-width: 1180px) {
    .settings-grid.custom-size-mode {
      --custom-size-mode-card-height: clamp(105px, calc(14.76dvh - 8.4px), 154px);
    }

    .mode-settings-slot {
      --mode-settings-stable-height: clamp(48px, calc(15.96dvh - 74.6px), 102px);
    }

    .mode-specific-settings {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      align-items: end;
      gap: clamp(6px, calc(0.32dvh + 3.5px), 8px);
    }

    .model-tool-row {
      grid-column: 1 / 2;
      grid-row: 1 / 2;
      grid-template-columns: minmax(0, 1fr) minmax(92px, 0.32fr);
      gap: 6px;
    }

    #mainModelField,
    #apiDirectSettingsNotice {
      grid-column: 1 / 2;
    }

    .model-tool-row .web-search-field {
      grid-column: 2 / 3;
    }

    #promptFidelityField {
      grid-column: 2 / 3;
      grid-row: 1 / 2;
    }
  }
}

@media (max-width: 640px) {
  .resource-sheet-wide {
    width: calc(100vw - 24px);
  }

  .gallery-drawer-body {
    grid-template-columns: 1fr;
  }

  .gallery-drawer-toolbar {
    grid-template-columns: 1fr;
  }

  .gallery-category-manage-panel {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .gallery-category-create-row {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .gallery-category-create-row::before {
    content: none;
  }

  .gallery-category-row {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "toolbar toolbar"
      "name name"
      "role role"
      "actions actions";
    justify-content: stretch;
  }

  .gallery-category-row-actions {
    justify-content: flex-start;
  }
}

@container (max-width: 520px) {
  .image-input-workspace {
    grid-template-columns: 1fr;
  }
}

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

  .image-editor-side-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .image-editor-insert-list,
  .image-editor-layer-list {
    max-height: 180px;
  }
}

@media (max-height: 1390px) and (min-width: 900px) and (max-width: 1560px) {
  .dashboard {
    grid-template-columns: minmax(600px, 1.08fr) minmax(400px, 0.92fr);
  }

  .controls-col .image-input-workspace {
    --quick-gallery-column-width: 132px;
    grid-template-columns: minmax(0, 1fr) var(--quick-gallery-column-width);
    grid-template-rows: none;
  }

  .controls-col .image-input-left,
  .controls-col .image-gallery-column {
    height: var(--image-input-total-height);
  }

  .controls-col .image-gallery-column {
    grid-template-rows: var(--quick-gallery-height) var(--image-input-action-height);
  }

  .controls-col .quick-gallery-dock,
  .controls-col .quick-gallery-list,
  .controls-col .quick-gallery-rail {
    height: var(--quick-gallery-height);
  }

  .controls-col .quick-gallery-picker {
    grid-template-columns: minmax(0, 1fr) 46px;
    gap: 6px;
  }

  .controls-col .quick-gallery-category {
    padding: 0 6px;
    font-size: 11px;
  }

  .controls-col .gallery-manage-panel .resource-manage-button {
    padding: 0 8px;
    font-size: 12px;
  }

  .controls-col .prompt-panel {
    --prompt-action-column-width: 132px;
  }
}

@media (max-height: 1390px) and (min-width: 900px) and (max-width: 1180px) {
  .preview-col,
  .controls-col {
    min-height: calc(
      100dvh - var(--header-height) - 64px - var(--compact-dashboard-padding) -
        var(--compact-dashboard-padding)
    );
    height: calc(
      100dvh - var(--header-height) - 64px - var(--compact-dashboard-padding) -
        var(--compact-dashboard-padding)
    );
  }
}

@media (max-width: 1180px) {
  .layout-container {
    flex-direction: column;
  }

  .main-wrapper {
    --compact-shell-extra: 64px;
    --compact-prompt-panel-min: 124px;
    --compact-panel-shell-adjustment: clamp(0px, calc(53.462px - 3.846dvh), 15px);
    --compact-settings-shell-adjustment: clamp(0px, calc(14.256px - 1.026dvh), 4px);
    --compact-mode-shell-adjustment: clamp(0px, calc(53.462px - 3.846dvh), 15px);
    --compact-image-shell-adjustment: clamp(0px, calc(42.769px - 3.077dvh), 12px);
    --compact-action-shell-adjustment: clamp(0px, calc(7.128px - 0.513dvh), 2px);
  }

  .sidebar {
    width: 100%;
    height: 64px;
    min-height: 64px;
    flex: 0 0 64px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-header {
    min-width: 0;
    padding: 0 14px;
  }

  .brand {
    min-height: 64px;
    margin: 0;
    padding: 0;
    gap: 8px;
    /* 移动端顶部栏：logo 区可收缩，按钮区固定不挤 */
    flex-wrap: nowrap;
  }

  /* logo + 文字标题：紧凑排列，允许文字收缩 */
  .brand-lockup {
    min-width: 0;
    flex: 0 1 auto;
    gap: 8px;
  }

  /* ≤480px 极窄屏：隐藏副标题，主标题保留但可省略号 */
  @media (max-width: 480px) {
    .brand-title {
      display: block;
      min-width: 0;
    }

    .brand-lockup {
      gap: 6px;
    }
  }

  .brand-subtitle {
    display: none;
  }

  .brand-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 15px;
    font-weight: 700;
  }

  /* 按钮组：固定不收缩，紧凑排列 */
  .brand-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

  .brand-rabbit-logo {
    width: 27px;
    height: 27px;
  }

  .sidebar-resize-handle,
  .sidebar-search,
  .sidebar-content,
  .sidebar-footer,
  .task-active-list,
  .task-history-anchor-rail,
  .task-history-library-slot,
  .batch-toolbar {
    display: none;
  }

  .task-history-shell {
    min-width: 0;
    padding: 0 14px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }

  .task-history-tools {
    width: auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 0;
  }

  .task-history-tools .status-text {
    width: min(280px, 34vw);
    max-width: min(280px, 34vw);
    text-align: right;
  }

  .task-history-batch-button {
    display: none;
  }

  .top-nav {
    padding: 0 14px;
    overflow: visible;
  }

  .nav-actions {
    min-width: 0;
    justify-content: flex-start;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav-actions::-webkit-scrollbar {
    display: none;
  }

  .auth-source-switcher {
    flex: 0 0 auto;
  }

  .auth-source-detail {
    display: none;
  }

  .queue-drawer {
    width: 100vw;
    max-width: 100%;
  }

  /* 汉堡菜单按钮：仅窄屏显示（桌面态永远隐藏）。
     JS 会移除 hidden 属性（见 sidebar-drawer.ts），所以必须用 CSS 在 PC 端强制隐藏，
     否则按钮会以默认 inline-block 显示出来。 */
  .sidebar-drawer-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    margin-left: 4px;
    border: 1px solid var(--line, #d0d0d0);
    border-radius: 10px;
    background: var(--surface, #fff);
    color: var(--text, #111);
    cursor: pointer;
    flex-shrink: 0;
  }
  .sidebar-drawer-toggle:active {
    background: var(--surface-hover, #f0f0f0);
  }

  /* 抽屉遮罩（默认隐藏，JS 控制） */
  .sidebar-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 7999;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  .sidebar-drawer-backdrop:not([hidden]) {
    opacity: 1;
  }

  /* 抽屉打开态：侧边栏变固定全高面板，恢复被隐藏的内容 */
  .sidebar.sidebar-drawer-open {
    position: fixed;
    top: 0;
    left: 0;
    width: min(340px, 85vw);
    height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    flex: none;
    z-index: 8000;
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    border-right: 1px solid var(--line);
    border-bottom: none;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
  }
  .sidebar.sidebar-drawer-open.is-open {
    transform: translateX(0);
  }
  .sidebar.sidebar-drawer-open .sidebar-header {
    display: flex;
    height: auto;
    padding: 12px 14px;
  }
  .sidebar.sidebar-drawer-open .sidebar-search,
  .sidebar.sidebar-drawer-open .sidebar-content,
  .sidebar.sidebar-drawer-open .sidebar-footer,
  .sidebar.sidebar-drawer-open .task-active-list {
    display: revert;
  }
  .sidebar.sidebar-drawer-open .sidebar-content {
    flex: 1 1 auto;
    min-height: 0;
  }
}

@container workspace (max-width: 1100px) {
  .dashboard {
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
    padding: var(--compact-dashboard-padding, 12px);
    gap: var(--compact-dashboard-gap, 12px);
  }

  .controls-col {
    max-width: none;
  }

  .controls-col .image-input-workspace {
    --quick-gallery-column-width: 132px;
    grid-template-columns: minmax(0, 1fr) var(--quick-gallery-column-width);
    grid-template-rows: none;
  }

  .controls-col .image-input-left,
  .controls-col .image-gallery-column {
    height: var(--image-input-total-height);
  }

  .controls-col .image-gallery-column {
    grid-template-rows: var(--quick-gallery-height) var(--image-input-action-height);
  }

  .controls-col .quick-gallery-dock,
  .controls-col .quick-gallery-list,
  .controls-col .quick-gallery-rail {
    height: var(--quick-gallery-height);
  }

  .controls-col .prompt-panel {
    --prompt-action-column-width: 132px;
  }
}

@container workspace (max-width: 899px) {
  .dashboard {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }

  .controls-col {
    max-width: none;
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .preview-col {
    height: auto;
    min-height: 260px;
    overflow: visible;
  }

  .preview-panel {
    height: auto;
    max-height: none;
    min-height: 260px;
  }

  .field-pair {
    grid-template-columns: 1fr;
  }
}

@container workspace (max-width: 520px) {
  .image-input-workspace,
  .controls-col .image-input-workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
  }
}

/* ===== Mobile (narrow viewport) refinements: stack prompt/settings, fix drawer heights ===== */
@media (max-width: 520px) {
  :root {
    --mobile-header-height: 52px;
    --mobile-action-bar-height: 68px;
  }

  .brand-material-picker {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
  }

  .brand-material-heading {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: baseline;
    column-gap: 8px;
  }

  .brand-material-heading span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-material-list {
    margin-right: -12px;
    padding-right: 12px;
    scroll-snap-type: x proximity;
  }

  .brand-material-option {
    scroll-snap-align: start;
  }

  /* 提示词区：操作按钮移到下方，输入框占满宽度 */
  .prompt-heading,
  .prompt-compose,
  .prompt-template-row {
    grid-template-columns: minmax(0, 1fr);
  }

  /* 输出设置：内部网格单栏，field-pair 堆叠 */
  .settings-grid,
  .settings-grid.is-size-transitioning {
    grid-template-columns: minmax(0, 1fr);
  }
  .field-pair {
    grid-template-columns: minmax(0, 1fr);
  }

  /* 比例按钮组换行，避免横向溢出 */
  .ratio-group {
    flex-wrap: wrap;
  }
}

/* 抽屉高度：100vh 在移动端会被浏览器地址栏遮挡，改用 100dvh（保留 vh 兜底） */
.resource-sheet,
.queue-drawer {
  height: 100vh;
  height: 100dvh;
}

/* ===== @media 兜底：镜像 @container workspace 规则 =====
   原因：微信内置浏览器（X5 / 旧 WebKit 内核）对 CSS 容器查询支持不完善，
   @container workspace (max-width: Npx) 在真实手机上可能完全不触发，
   导致 dashboard 保持桌面双列布局，在 375px 屏幕上两列被压缩重叠 → 布局失控。
   解决：在窄视口（手机）下用 @media 镜像同样的堆叠规则。
   @media 基于视口宽度，手机视口=main-wrapper 宽度，故两者等价；
   桌面端视口>1180px 不会触发，不影响原有容器查询行为。 */

@media (max-width: 899px) {
  .dashboard {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }

  .controls-col {
    max-width: none;
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .preview-col {
    height: auto;
    min-height: 260px;
    overflow: visible;
  }

  .preview-panel {
    height: auto;
    max-height: none;
    min-height: 260px;
  }

  .field-pair {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .image-input-workspace,
  .controls-col .image-input-workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
  }

  .layout-container {
    background: var(--bg);
  }

  .sidebar {
    height: var(--mobile-header-height);
    min-height: var(--mobile-header-height);
    flex-basis: var(--mobile-header-height);
  }

  .brand {
    min-height: var(--mobile-header-height);
  }

  .task-history-shell {
    display: none;
  }

  .sidebar {
    grid-template-columns: minmax(0, 1fr);
  }

  .brand-new-button {
    display: none;
  }

  .top-nav {
    display: none;
  }

  .nav-actions.mobile-drawer-tools {
    width: auto;
    margin: 12px 14px 16px;
    padding-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow: visible;
    border-top: 1px solid var(--line);
  }

  .sidebar:not(.sidebar-drawer-open) > .mobile-drawer-tools {
    display: none;
  }

  .dashboard {
    padding: 16px 16px calc(84px + env(safe-area-inset-bottom));
    gap: 16px;
    grid-auto-rows: max-content;
  }

  .controls-col {
    display: contents;
  }

  .prompt-panel {
    order: 1;
    min-height: 0;
    padding: 16px;
  }

  .output-panel {
    order: 2;
    padding: 16px;
  }

  .image-panel {
    order: 3;
    min-height: 64px;
    padding: 14px;
  }

  .preview-col {
    order: 4;
  }

  .dashboard.mobile-has-preview .preview-col {
    order: 2;
  }

  .dashboard.mobile-has-preview .output-panel {
    order: 3;
  }

  .dashboard.mobile-has-preview .image-panel {
    order: 4;
  }

  .panel {
    border-radius: 16px;
    box-shadow: none;
  }

  .prompt-heading {
    margin-bottom: 12px;
  }

  .prompt-box,
  .controls-col .prompt-box {
    height: 92px;
    min-height: 92px;
    max-height: 156px;
    resize: none;
  }

  .prompt-template-row {
    min-height: 18px;
    margin-top: 8px;
  }

  .prompt-template-entry,
  .prompt-footer {
    display: none;
  }

  .prompt-template-recent-cell {
    min-height: 18px;
  }

  .prompt-template-recent-cell::before {
    content: "@ 参考图   # 色彩   ~ 模板";
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 18px;
  }

  .prompt-run-wrap {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 7800;
    min-height: calc(var(--mobile-action-bar-height) + env(safe-area-inset-bottom));
    display: flex;
    align-items: flex-start;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px);
  }

  .prompt-compose .run-button,
  .controls-col .prompt-compose .run-button {
    width: 100%;
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    border-radius: 14px;
    font-size: 16px;
  }

  .mobile-section-toggle {
    position: absolute;
    top: 50%;
    right: 0;
    min-width: 48px;
    min-height: 44px;
    padding: 0 8px;
    border: 0;
    background: transparent;
    color: var(--primary);
    font-weight: 650;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .output-settings-lock-button {
    display: none;
  }

  .output-settings-header {
    margin-bottom: 12px;
  }

  .mobile-output-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .mobile-output-summary::-webkit-scrollbar {
    display: none;
  }

  .mobile-summary-pill {
    flex: 0 0 auto;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 13px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary-strong);
    font-size: 13px;
    font-weight: 650;
  }

  .mobile-summary-pill.is-active {
    background: var(--primary);
    color: var(--primary-foreground);
  }

  .output-panel:not(.mobile-settings-expanded) .settings-grid,
  .output-panel:not(.mobile-settings-expanded) .mobile-advanced-settings-toggle {
    display: none;
  }

  .output-panel.mobile-settings-expanded .mobile-output-summary {
    display: none;
  }

  .output-panel.mobile-settings-expanded .settings-grid {
    display: grid;
    gap: 16px;
  }

  .output-panel.mobile-settings-expanded {
    height: max-content;
    min-height: max-content;
    align-self: start;
  }

  .output-panel.mobile-settings-expanded:not(.mobile-advanced-expanded) .mode-settings-slot,
  .output-panel.mobile-settings-expanded:not(.mobile-advanced-expanded) .custom-size-control,
  .output-panel.mobile-settings-expanded:not(.mobile-advanced-expanded) #customSize,
  .output-panel.mobile-settings-expanded:not(.mobile-advanced-expanded) #pixelPreview,
  .output-panel.mobile-settings-expanded:not(.mobile-advanced-expanded) #outputFormatField,
  .output-panel.mobile-settings-expanded:not(.mobile-advanced-expanded) .moderation-field {
    display: none !important;
  }

  .mobile-advanced-settings-toggle {
    display: block;
    width: 100%;
    min-height: 44px;
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-weight: 650;
  }

  .image-panel .panel-heading {
    position: relative;
    min-height: 36px;
    margin: 0;
    padding-left: 48px;
    display: flex;
    align-items: center;
    cursor: pointer;
  }

  .image-panel .panel-heading::before {
    content: "+";
    position: absolute;
    left: 0;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-strong);
    font-size: 22px;
  }

  .image-panel .panel-heading::after {
    content: "›";
    margin-left: auto;
    color: var(--muted);
    font-size: 24px;
    transition: transform var(--motion-base);
  }

  .image-panel .panel-heading h2::after {
    content: "支持图片与素材库";
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
  }

  .mobile-material-summary {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 400;
  }

  .image-panel:not(.mobile-materials-expanded) .mobile-materials-content {
    display: none;
  }

  .image-panel.mobile-materials-expanded .panel-heading {
    margin-bottom: 14px;
  }

  .image-panel.mobile-materials-expanded .panel-heading::after {
    transform: rotate(90deg);
  }

  .preview-col,
  .preview-panel {
    min-height: 154px;
  }

  .dashboard:not(.mobile-has-preview) .preview-col,
  .dashboard:not(.mobile-has-preview) .preview-panel {
    min-height: 80px;
    height: 80px;
  }

  .preview-panel {
    height: auto;
    padding: 16px;
  }

  .preview-heading {
    margin-bottom: 12px;
  }

  .preview-heading-actions #refreshButton {
    display: none;
  }

  .preview-grid {
    min-height: 92px;
    overflow: visible;
    border-radius: 12px;
    background: var(--surface-soft);
  }

  .preview-grid:not(.multi-output) .preview-card {
    min-height: 164px;
  }

  .empty-preview {
    color: var(--text-secondary);
  }
}

/* source: styles/85-ui-redesign.css */
/* Workspace redesign: one calm creation surface, one clear accent, intrinsic content height. */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.brand-material-drawer-open,
body.mobile-task-drawer-open {
  overflow: hidden;
}

.mobile-drawer-title,
.sidebar-close-icon {
  display: none;
}

.sidebar-header {
  padding: var(--space-3);
}

.brand {
  margin-bottom: var(--space-3);
}

.brand-new-button {
  width: 100%;
  min-width: 0;
  height: var(--touch-target);
  margin-top: var(--space-2);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.sidebar-search input {
  height: var(--touch-target);
  border-radius: var(--radius-lg);
}

.task-search-clear-button,
.task-filter-button {
  top: 22px;
}

.task-card-actions {
  flex-direction: row;
}

.task-more-button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--line) 82%, var(--text-secondary));
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
}

.task-more-button:hover,
.task-more-button:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 46%, var(--line));
  background: var(--primary-light);
  color: var(--primary-strong);
  outline: none;
}

.top-nav {
  justify-content: space-between;
}

.workspace-title {
  position: absolute;
  left: 50%;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  transform: translateX(-50%);
  pointer-events: none;
}

.workspace-title strong {
  color: var(--text);
  font-weight: 680;
}

.workspace-title-separator {
  color: color-mix(in srgb, var(--muted) 58%, transparent);
}

.nav-actions {
  width: auto;
  margin-left: auto;
  gap: var(--space-2);
}

.dashboard {
  align-content: start;
}

.controls-col {
  max-width: none;
}

.panel {
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.material-section {
  min-width: 0;
}

.material-section-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

.material-section-header strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
}

.material-section-header span {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.brand-material-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
}

.brand-material-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.brand-material-heading {
  flex: 1 1 auto;
}

.brand-material-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
  overflow: visible;
  padding: 0;
}

.brand-material-row {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: stretch;
  gap: var(--space-1);
}

.brand-material-toggle,
.brand-material-select-row {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--motion-fast), background var(--motion-fast), color var(--motion-fast);
}

.brand-material-toggle {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
}

.brand-material-toggle::before {
  content: "";
  width: 26px;
  height: 15px;
  border-radius: 999px;
  background: var(--line);
  transition: background var(--motion-fast);
}

.brand-material-switch-knob {
  position: absolute;
  width: 11px;
  height: 11px;
  margin-left: -11px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(29, 52, 46, 0.18);
  transform: translateX(0);
  transition: transform var(--motion-fast);
}

.brand-material-toggle[aria-checked="true"] {
  border-color: color-mix(in srgb, var(--primary) 48%, var(--line));
  background: var(--primary-light);
}

.brand-material-toggle[aria-checked="true"]::before {
  background: var(--primary);
}

.brand-material-toggle[aria-checked="true"] .brand-material-switch-knob {
  transform: translateX(11px);
}

.brand-material-select-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 8px;
  text-align: left;
}

.brand-material-preview {
  width: 40px;
  height: 32px;
}

.brand-material-preview img {
  max-width: 38px;
}

.brand-material-row-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.brand-material-row-copy strong,
.brand-material-row-copy span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-material-row-copy strong {
  font-size: 13px;
  line-height: 1.2;
}

.brand-material-row-copy span,
.brand-material-row-state {
  color: var(--muted);
  font-size: 11px;
}

.brand-material-row-state {
  white-space: nowrap;
}

.brand-material-arrow {
  color: var(--primary-strong);
  font-size: 16px;
  line-height: 1;
}

.brand-material-toggle:hover,
.brand-material-toggle:focus-visible,
.brand-material-select-row:hover,
.brand-material-select-row:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 54%, var(--line));
  background: var(--primary-light);
  outline: none;
}

.brand-material-drawer {
  width: min(560px, calc(100vw - 24px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: var(--space-3);
  padding: var(--space-4);
  z-index: 8500;
}

.brand-material-drawer-backdrop {
  z-index: 8499;
}

.brand-material-drawer-body {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: var(--space-2);
  overflow: hidden;
}

.brand-material-search-wrap input {
  width: 100%;
  min-height: var(--touch-target);
  padding-left: 42px;
  border-radius: var(--radius-lg);
  background: var(--surface-soft) url('data:image/svg+xml;utf8,<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23889d95" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="7"></circle><path d="m20 20-4-4"></path></svg>') no-repeat 14px center;
}

.brand-material-filter-row {
  display: flex;
  gap: var(--space-1);
}

.brand-material-filter {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 13px;
  font-weight: 650;
}

.brand-material-drawer-list {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: var(--space-2);
  overflow-y: auto;
  padding: 2px 4px 2px 2px;
}

.brand-material-drawer-option {
  position: relative;
  min-width: 0;
  min-height: 132px;
  display: grid;
  grid-template-rows: 70px auto;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--motion-fast), background var(--motion-fast), transform var(--motion-fast);
}

.brand-material-drawer-option:hover,
.brand-material-drawer-option:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 54%, var(--line));
  outline: none;
  transform: translateY(-1px);
}

.brand-material-drawer-option.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-light) 60%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 34%, transparent);
}

.brand-material-drawer-visual {
  min-height: 70px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-soft);
}

.brand-material-drawer-preview {
  width: min(150px, 80%);
  height: 52px;
}

.brand-material-drawer-preview img {
  width: 100%;
  max-width: 132px;
  height: 42px;
}

.brand-material-drawer-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.brand-material-drawer-copy strong,
.brand-material-drawer-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-material-drawer-copy strong {
  font-size: 14px;
}

.brand-material-drawer-copy span {
  color: var(--muted);
  font-size: 11px;
}

.brand-material-drawer-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  opacity: 0;
}

.brand-material-drawer-option.active .brand-material-drawer-check {
  opacity: 1;
}

.brand-material-drawer-empty {
  padding: var(--space-4);
  color: var(--muted);
  text-align: center;
}

.brand-material-drawer-footer {
  display: grid;
  grid-template-columns: minmax(110px, 0.45fr) minmax(0, 1fr);
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.brand-material-drawer-footer .ghost-button,
.brand-material-drawer-footer .primary-button {
  min-height: 48px;
  border-radius: var(--radius-lg);
}

.brand-layer-summary {
  min-width: 0;
  max-width: 100%;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

@media (min-width: 900px) {
  .controls-col,
  .controls-col .image-panel,
  .controls-col .prompt-panel,
  .controls-col .output-panel {
    height: auto;
    min-height: 0;
    overflow: visible;
    flex: 0 0 auto;
  }

  .controls-col {
    justify-content: flex-start;
  }

  .controls-col .image-input-workspace,
  .controls-col .image-input-left,
  .controls-col .image-gallery-column {
    height: auto;
    min-height: 0;
  }

  .controls-col .image-input-workspace {
    align-items: stretch;
  }

  .controls-col .image-input-left,
  .controls-col .image-gallery-column {
    min-height: var(--image-input-total-height);
  }

  .controls-col .prompt-compose,
  .controls-col .prompt-editor-wrap,
  .controls-col .prompt-run-wrap {
    min-height: 112px;
  }

  .controls-col .prompt-box {
    min-height: 112px;
    max-height: 180px;
  }
}

@media (max-width: 1180px) {
  .brand-actions .version-info.compact-header-version {
    min-height: 44px;
    margin: 0;
    padding: 4px 6px;
    font-size: 10px;
    white-space: nowrap;
  }

  .workspace-title {
    display: none;
  }

  .brand-new-button {
    margin-top: 0;
  }

  .sidebar.sidebar-drawer-open {
    width: min(390px, 92vw);
    overflow: hidden;
  }

  .sidebar.sidebar-drawer-open .sidebar-header {
    position: relative;
    flex: 0 0 auto;
    order: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
    border-bottom: 1px solid var(--line);
  }

  .sidebar.sidebar-drawer-open .brand {
    min-height: var(--touch-target);
    margin: 0;
  }

  .sidebar.sidebar-drawer-open .brand-lockup {
    display: none;
  }

  .sidebar.sidebar-drawer-open .mobile-drawer-title {
    position: absolute;
    top: 16px;
    left: 16px;
    display: block;
    color: var(--text);
    font-size: 18px;
    font-weight: 740;
    line-height: var(--touch-target);
  }

  .sidebar.sidebar-drawer-open .brand-actions {
    margin-left: auto;
  }

  .sidebar.sidebar-drawer-open .sidebar-menu-icon {
    display: none;
  }

  .sidebar.sidebar-drawer-open .sidebar-close-icon {
    display: block;
  }

  .sidebar.sidebar-drawer-open .sidebar-search {
    display: block;
  }

  .sidebar.sidebar-drawer-open .brand-new-button {
    display: flex;
    min-height: 48px;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary-strong);
  }

  .sidebar.sidebar-drawer-open .task-card-actions {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar.sidebar-drawer-open .task-more-button {
    width: var(--touch-target);
    height: var(--touch-target);
    border-color: transparent;
    background: transparent;
  }

  .sidebar.sidebar-drawer-open .task-history-shell {
    order: 2;
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: var(--space-2) var(--space-3);
    overflow: hidden;
  }

  .sidebar.sidebar-drawer-open .task-history-tools {
    display: none;
  }

  .sidebar.sidebar-drawer-open .sidebar-content {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  .sidebar.sidebar-drawer-open .task-history-anchor-rail,
  .sidebar.sidebar-drawer-open .task-history-library-slot {
    display: block;
  }

  .sidebar.sidebar-drawer-open > .mobile-drawer-tools {
    order: 3;
  }

  .sidebar.sidebar-drawer-open .sidebar-footer {
    order: 4;
    display: flex;
    flex: 0 0 auto;
  }
}

@media (max-width: 520px) {
  .version-popover-layer {
    background: var(--overlay-subtle);
    backdrop-filter: blur(2px);
  }

  .version-popover-panel {
    top: auto !important;
    right: 0;
    bottom: 0;
    left: 0 !important;
    width: 100%;
    max-height: 72dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .version-popover-panel > .modal-heading {
    padding-top: 10px;
    padding-bottom: 8px;
  }

  .version-history {
    min-height: 120px;
  }

  .version-modal-actions .run-button,
  .version-modal-actions .ghost-button {
    min-height: 44px;
  }

  html {
    min-height: 100%;
    overflow-x: hidden;
  }

  body {
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .layout-container {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .sidebar:not(.sidebar-drawer-open) {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 7900;
  }

  .sidebar:not(.sidebar-drawer-open),
  .sidebar:not(.sidebar-drawer-open) .brand {
    height: var(--mobile-header-height);
    min-height: var(--mobile-header-height);
  }

  .sidebar:not(.sidebar-drawer-open) .sidebar-header {
    padding: 0 12px;
  }

  .sidebar:not(.sidebar-drawer-open) .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  .sidebar:not(.sidebar-drawer-open) .brand-rabbit-logo {
    width: 24px;
    height: 24px;
  }

  .sidebar-drawer-toggle {
    position: relative;
    width: var(--touch-target);
    height: var(--touch-target);
    min-width: var(--touch-target);
    margin-left: 0;
  }

  .mobile-task-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border: 2px solid var(--surface);
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: 9px;
    font-weight: 760;
    line-height: 1;
  }

  .sidebar.sidebar-drawer-open .mobile-task-badge {
    display: none;
  }

  .sidebar.sidebar-drawer-open .sidebar-header {
    position: relative;
    width: 100%;
    height: 112px;
    min-height: 112px;
    max-height: 112px;
    align-self: stretch;
    gap: 8px;
    padding: 10px 12px;
  }

  .sidebar.sidebar-drawer-open .brand {
    min-height: var(--touch-target);
  }

  .sidebar.sidebar-drawer-open .mobile-drawer-title {
    top: 10px;
    left: 12px;
  }

  .sidebar.sidebar-drawer-open .sidebar-search,
  .sidebar.sidebar-drawer-open .sidebar-search input {
    height: 40px;
    min-height: 40px;
  }

  .sidebar.sidebar-drawer-open .task-search-clear-button,
  .sidebar.sidebar-drawer-open .task-filter-button {
    top: 20px;
  }

  .sidebar.sidebar-drawer-open .brand-new-button {
    position: absolute;
    top: 10px;
    right: 64px;
    width: var(--touch-target);
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    margin: 0;
    padding: 0;
    border-color: var(--line);
    background: var(--surface);
  }

  .sidebar.sidebar-drawer-open .brand-new-button span {
    display: none;
  }

  .sidebar.sidebar-drawer-open .task-history-shell {
    padding: 4px 12px 8px;
  }

  .main-wrapper {
    flex: 1 0 auto;
    min-height: 100dvh;
    padding-top: var(--mobile-header-height);
    overflow: visible;
  }

  .dashboard {
    flex: 1 0 auto;
    height: auto;
    min-height: calc(100dvh - var(--mobile-header-height));
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3) calc(84px + env(safe-area-inset-bottom));
    overflow: visible;
    touch-action: pan-y;
  }

  .prompt-panel { order: 1; }
  .image-panel { order: 2; }
  .output-panel { order: 3; }
  .preview-col,
  .dashboard.mobile-has-preview .preview-col { order: 4; }

  .dashboard.mobile-has-preview .output-panel { order: 3; }
  .dashboard.mobile-has-preview .image-panel { order: 2; }

  .panel {
    border-radius: var(--radius-xl);
  }

  .image-panel {
    padding: var(--space-3);
  }

  .image-panel .panel-heading {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    padding-left: 0;
  }

  .image-panel .panel-heading::before {
    display: none;
  }

  .image-panel .panel-heading h2::after { content: none; }

  .image-panel .panel-heading h2 {
    grid-column: 1;
    grid-row: 1;
  }

  .image-panel .mobile-material-summary {
    grid-column: 1;
    grid-row: 2;
    color: var(--text-secondary);
  }

  .image-panel .panel-heading::after {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
  }

  .mobile-materials-toggle {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: block;
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    cursor: pointer;
  }

  .mobile-materials-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
  }

  .material-section-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .reference-material-section {
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--line);
  }

  .image-panel:not(.mobile-materials-expanded) .mobile-materials-content {
    display: none;
  }

  .image-panel.mobile-materials-expanded .reference-material-section .image-input-workspace {
    display: grid;
    margin-top: var(--space-2);
  }

  .brand-material-picker {
    margin-top: var(--space-2);
    padding-top: 0;
    border-top: 0;
  }

  .brand-material-toolbar {
    align-items: flex-start;
  }

  .brand-material-heading {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }

  .brand-material-heading span {
    white-space: normal;
  }

  .brand-material-open-button {
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    padding: 0 8px;
  }

  .brand-material-open-button span:first-child {
    display: none;
  }

  .brand-material-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
  }

  .brand-material-row {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .brand-material-toggle,
  .brand-material-select-row {
    min-height: 44px;
    border-radius: var(--radius-lg);
  }

  .brand-material-select-row {
    grid-template-columns: 42px minmax(0, 1fr) 16px;
  }

  .brand-material-row-state {
    display: none;
  }

  .preview-col,
  .preview-panel {
    min-height: 180px;
    height: auto;
  }

  .dashboard:not(.mobile-has-preview) .preview-col,
  .dashboard:not(.mobile-has-preview) .preview-panel {
    min-height: 80px;
    height: 80px;
  }

  .dashboard:not(.mobile-has-preview) .preview-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-2);
    padding: 12px var(--space-3);
  }

  .dashboard:not(.mobile-has-preview) .preview-heading {
    min-width: 0;
    margin: 0;
  }

  .dashboard:not(.mobile-has-preview) .preview-grid {
    width: auto;
    min-width: 0;
    min-height: 0;
    overflow: visible;
    background: transparent;
  }

  .dashboard:not(.mobile-has-preview) .empty-preview {
    width: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    white-space: nowrap;
  }

  .dashboard.mobile-has-preview .preview-grid:not(.multi-output) .preview-card {
    min-height: 320px;
  }

  .preview-grid:not(.multi-output) .preview-card img {
    object-fit: contain;
  }

  .brand-material-drawer {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    padding: var(--space-3);
    border-left: 0;
  }

  .brand-material-drawer-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .brand-material-drawer-option {
    min-height: 126px;
    padding: 10px;
  }

  .brand-material-drawer-footer {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .nav-actions.mobile-drawer-tools {
    width: auto;
    min-height: calc(48px + env(safe-area-inset-bottom));
    margin: 0;
    padding: 4px 12px calc(4px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: minmax(64px, 1fr) 40px 96px 44px;
    gap: 8px;
    border-top: 1px solid var(--line);
  }

  .nav-actions.mobile-drawer-tools .queue-status-chip {
    min-width: 0;
    height: 40px;
    width: 100%;
    justify-content: flex-start;
    order: 1;
    overflow: hidden;
  }

  .nav-actions.mobile-drawer-tools .queue-status-chip > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-actions.mobile-drawer-tools .task-notification-button {
    order: 2;
    width: 40px;
    height: 40px;
  }

  .nav-actions.mobile-drawer-tools .theme-switcher {
    order: 3;
    width: 100%;
    height: 40px;
    justify-content: stretch;
  }

  .nav-actions.mobile-drawer-tools .theme-option {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 3px;
    font-size: 11px;
  }

  .nav-actions.mobile-drawer-tools .version-info {
    order: 4;
    width: 44px;
    min-width: 44px;
    min-height: 40px;
    margin: 0;
    padding: 0 3px;
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar.sidebar-drawer-open .sidebar-footer {
    display: none;
  }

  .task-notification-center.mobile-drawer-notifications {
    position: fixed;
    top: auto;
    right: 12px;
    bottom: calc(56px + env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    max-height: 52dvh;
    z-index: 8700;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand-material-toggle,
  .brand-material-toggle::before,
  .brand-material-switch-knob,
  .brand-material-select-row,
  .brand-material-drawer-option {
    transition: none;
  }
}

/* source: styles/90-history.css */
.history-page {
  --history-sidebar-width: 280px;
  --history-detail-width: 380px;
  position: relative;
  display: grid;
  grid-template-columns:
    clamp(220px, var(--history-sidebar-width), 420px)
    minmax(360px, 1fr)
    clamp(300px, var(--history-detail-width), 620px);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background:
    var(--workspace-texture),
    var(--bg);
  color: var(--text);
}

.history-sidebar,
.history-results,
.history-detail {
  min-height: 0;
  min-width: 0;
  border-color: var(--panel-border);
}

.history-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-right: 0;
  background: var(--surface);
  overflow: auto;
}

.history-resize-hit-area {
  position: absolute;
  z-index: 5;
  top: 0;
  bottom: 0;
  width: 12px;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
  outline: none;
}

.history-resize-hit-area-left {
  left: clamp(220px, var(--history-sidebar-width), 420px);
  transform: translateX(-50%);
}

.history-resize-hit-area-right {
  right: clamp(300px, var(--history-detail-width), 620px);
  transform: translateX(50%);
}

.history-resize-hit-area:focus-visible {
  box-shadow: inset 1px 0 color-mix(in srgb, var(--primary) 52%, transparent);
}

.history-page.history-resizing {
  cursor: col-resize !important;
  user-select: none;
}

.history-sidebar,
.history-task-list,
.history-detail,
.history-detail-prompt {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.history-sidebar::-webkit-scrollbar,
.history-task-list::-webkit-scrollbar,
.history-detail::-webkit-scrollbar,
.history-detail-prompt::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.history-sidebar::-webkit-scrollbar-track,
.history-task-list::-webkit-scrollbar-track,
.history-detail::-webkit-scrollbar-track,
.history-detail-prompt::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 999px;
}

.history-sidebar::-webkit-scrollbar-corner,
.history-task-list::-webkit-scrollbar-corner,
.history-detail::-webkit-scrollbar-corner,
.history-detail-prompt::-webkit-scrollbar-corner {
  background: transparent;
}

.history-sidebar::-webkit-scrollbar-thumb,
.history-task-list::-webkit-scrollbar-thumb,
.history-detail::-webkit-scrollbar-thumb,
.history-detail-prompt::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--scrollbar-thumb);
  background-clip: padding-box;
}

.history-sidebar::-webkit-scrollbar-thumb:hover,
.history-task-list::-webkit-scrollbar-thumb:hover,
.history-detail::-webkit-scrollbar-thumb:hover,
.history-detail-prompt::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: padding-box;
}

.history-back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: max-content;
  max-width: 100%;
  min-height: 40px;
  padding: 7px 12px 7px 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--panel-border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary-light) 76%, var(--surface));
  color: var(--primary-strong);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 10%, transparent);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background var(--motion-base),
    border-color var(--motion-base),
    color var(--motion-base),
    box-shadow var(--motion-base),
    transform var(--motion-base);
}

.history-back-link::before {
  content: "";
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  background: currentColor;
  clip-path: polygon(40% 15%, 50% 25%, 31% 44%, 86% 44%, 86% 58%, 31% 58%, 50% 77%, 40% 87%, 4% 51%);
}

.history-back-link:hover,
.history-back-link:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 58%, var(--panel-border));
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 20%, transparent);
  transform: translateY(-1px);
}

.history-back-link:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 44%, transparent);
  outline-offset: 2px;
}

.history-back-link:active {
  transform: translateY(0);
}

.history-brand {
  display: grid;
  gap: 4px;
}

.history-brand strong,
.history-toolbar h1 {
  display: block;
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.history-brand span,
.history-toolbar p,
.history-detail-meta,
.history-filter-block h2,
.history-search-label,
.history-detail-kicker {
  color: var(--muted);
  font-size: 12px;
}

.history-search-label {
  font-weight: 700;
}

.history-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.history-search-row .control {
  min-height: 40px;
}

.history-page .ghost-button.text-sm {
  min-height: 40px;
}

.history-filter-block {
  display: grid;
  gap: 8px;
}

.history-filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.history-filter-summary::-webkit-details-marker {
  display: none;
}

.history-filter-summary::after {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-right: 3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--motion-fast), color var(--motion-fast);
}

.history-filter-block[open] > .history-filter-summary::after {
  transform: rotate(45deg);
}

.history-filter-summary:hover,
.history-filter-summary:focus-visible {
  color: var(--primary-strong);
}

.history-filter-summary:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 48%, transparent);
  outline-offset: 2px;
  border-radius: var(--radius-small);
}

.history-filter-block h2 {
  margin: 0;
  text-transform: uppercase;
}

.history-filter-heading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: max-content;
}

.history-filter-heading-icon,
.history-filter-icon {
  flex: 0 0 auto;
  color: var(--primary);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-filter-heading-icon {
  width: 15px;
  height: 15px;
  stroke-width: 1.8;
  opacity: 0.9;
}

.history-filter-icon {
  width: 14px;
  height: 14px;
  stroke-width: 1.9;
  opacity: 0.84;
}

.history-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-filter-block:not([open]) > .history-filter-list {
  display: none;
}

.history-filter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--motion-base), border-color var(--motion-base), color var(--motion-base);
}

.history-filter-button .history-filter-count {
  min-width: 18px;
  padding: 2px 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 62%, transparent);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  opacity: 0.82;
}

.history-filter-button[data-history-filter-key="orientation"] {
  padding-left: 10px;
}

.history-filter-button.active,
.history-filter-button:hover,
.history-filter-button:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 52%, transparent);
  background: var(--primary-light);
  color: var(--primary-strong);
}

.history-filter-button.active .history-filter-count,
.history-filter-button:hover .history-filter-count,
.history-filter-button:focus-visible .history-filter-count {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: color-mix(in srgb, var(--primary-strong) 62%, var(--muted));
}

.history-results {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 18px 12px 0;
  overflow: hidden;
}

.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-toolbar-actions,
.history-bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-toolbar-actions {
  --history-toolbar-control-height: 44px;
}

.history-page.history-bulk-selecting .history-toolbar-actions {
  visibility: hidden;
  pointer-events: none;
}

.history-view-toggle,
.history-sort-toggle {
  --segmented-indicator-radius: 999px;
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(58px, 1fr));
  box-sizing: border-box;
  height: var(--history-toolbar-control-height);
  min-height: 0;
  padding: 3px;
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
}

.history-sort-toggle {
  grid-template-columns: repeat(2, minmax(88px, 1fr));
}

.history-view-button,
.history-sort-button {
  min-height: calc(var(--history-toolbar-control-height) - 6px);
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  transition: background var(--motion-base), color var(--motion-base), box-shadow var(--motion-base);
}

.history-view-toggle .segmented-indicator,
.history-sort-toggle .segmented-indicator {
  border-radius: 999px;
  box-shadow: 0 5px 14px rgba(40, 116, 85, 0.22);
}

.history-view-button.active,
.history-view-button:hover,
.history-view-button:focus-visible,
.history-sort-button.active,
.history-sort-button:hover,
.history-sort-button:focus-visible {
  background: var(--surface);
  color: var(--primary-strong);
  box-shadow: var(--shadow-sm);
}

.history-view-toggle.segmented-indicator-host .history-view-button.active,
.history-sort-toggle.segmented-indicator-host .history-sort-button.active {
  background: transparent;
  color: var(--primary-foreground);
  box-shadow: none;
}

.history-toolbar-actions .control,
.history-toolbar-actions .ghost-button.text-sm {
  min-height: var(--history-toolbar-control-height);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}

.history-toolbar-actions .control {
  min-width: 148px;
  padding-left: 14px;
}

.history-toolbar-actions .ghost-button.text-sm {
  padding: 0 14px;
}

.history-bulk-toolbar {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: max-content;
  max-width: calc(100% - 36px);
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--primary-strong);
  box-shadow: var(--shadow-popover);
}

.history-bulk-toolbar > .segmented-indicator {
  display: none;
}

#historyBulkCount {
  flex: 0 0 auto;
}

.history-task-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  margin-right: -12px;
  overflow: auto;
  padding: 0 15px env(safe-area-inset-bottom, 0px) 4px;
  scrollbar-gutter: stable;
}

.history-task-list.history-view-grid {
  --history-task-thumb-row-height: clamp(154px, 17vw, 220px);
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  gap: 16px 14px;
  padding: 6px 15px calc(6px + env(safe-area-inset-bottom, 0px)) 4px;
}

.history-task-list.history-view-list {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.history-task-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: inherit;
  overflow: hidden;
  transition: background var(--motion-base), border-color var(--motion-base), box-shadow var(--motion-base);
}

.history-task-list.history-view-list .history-task-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  min-height: 82px;
  overflow: visible;
}

.history-task-list.history-view-grid .history-task-card {
  flex: 0 0 auto;
  flex-basis: var(--history-task-card-width, clamp(150px, calc(var(--history-task-card-ratio, 1) * var(--history-task-thumb-row-height)), 430px));
  width: var(--history-task-card-width, clamp(150px, calc(var(--history-task-card-ratio, 1) * var(--history-task-thumb-row-height)), 430px));
  min-height: 0;
  border-color: transparent;
  background: transparent;
}

.history-task-card[data-history-stack-depth="1"] {
  --history-task-stack-offset: 6px;
}

.history-task-card[data-history-stack-depth="2"] {
  --history-task-stack-offset: 12px;
}

.history-task-card[data-history-stack-depth="3"] {
  --history-task-stack-offset: 18px;
}

.history-task-card:hover,
.history-task-card:focus-within {
  border-color: color-mix(in srgb, var(--primary) 48%, transparent);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: var(--shadow-sm);
}

.history-task-card.active {
  border-color: color-mix(in srgb, var(--primary) 86%, transparent);
  background: var(--surface);
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--primary) 34%, transparent),
    0 0 0 3px color-mix(in srgb, var(--primary-light) 86%, transparent),
    var(--shadow-sm);
}

.history-task-card.active::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 3;
  width: 4px;
  background: var(--primary);
}

.history-task-card.selected {
  border-color: color-mix(in srgb, var(--primary) 88%, transparent);
  background: color-mix(in srgb, var(--primary-light) 72%, var(--surface));
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--primary) 46%, transparent),
    0 10px 28px color-mix(in srgb, var(--primary) 16%, transparent);
}

.history-task-card.selected::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 2px solid color-mix(in srgb, var(--primary) 76%, transparent);
  border-radius: inherit;
  pointer-events: none;
}

.history-task-card.selected .history-task-copy {
  background: color-mix(in srgb, var(--primary-light) 72%, var(--surface));
}

.history-task-list.history-view-grid .history-task-card.active,
.history-task-list.history-view-grid .history-task-card.selected {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow:
    0 0 0 2px var(--primary),
    0 0 0 6px color-mix(in srgb, var(--primary-light) 58%, transparent);
}

.history-task-list.history-view-grid .history-task-card.active::before {
  content: none;
}

.history-task-list.history-view-grid .history-task-card.selected::after {
  border-color: var(--primary);
}

.history-task-list.history-view-grid .history-task-card.active .history-task-thumb,
.history-task-list.history-view-grid .history-task-card.selected .history-task-thumb {
  border-radius: var(--radius);
  background: var(--primary);
}

.history-task-list.history-view-grid .history-task-card.active .history-task-copy,
.history-task-list.history-view-grid .history-task-card.selected .history-task-copy {
  background: var(--primary);
  color: var(--primary-foreground);
}

.history-task-list.history-view-grid .history-task-card.active .history-task-title,
.history-task-list.history-view-grid .history-task-card.selected .history-task-title,
.history-task-list.history-view-grid .history-task-card.active .history-task-meta,
.history-task-list.history-view-grid .history-task-card.selected .history-task-meta {
  color: var(--primary-foreground);
}

.history-task-list.history-view-grid .history-task-card.active .history-task-meta,
.history-task-list.history-view-grid .history-task-card.selected .history-task-meta {
  opacity: 0.78;
}

.history-task-select {
  cursor: pointer;
  opacity: 1;
  transition: opacity var(--motion-base), transform var(--motion-base);
}

.history-task-list.history-view-list .history-task-select {
  display: grid;
  place-items: center;
  min-height: 100%;
}

.history-task-list.history-view-grid .history-task-select {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 32px;
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.94);
}

.history-task-list.history-view-grid .history-task-card:has(.history-task-thumb:hover) .history-task-select,
.history-task-list.history-view-grid .history-task-card:has(.history-task-select:hover) .history-task-select,
.history-task-list.history-view-grid .history-task-card:has(.history-task-open:focus-visible) .history-task-select,
.history-task-list.history-view-grid .history-task-card:has(.history-task-select input:focus-visible) .history-task-select,
.history-task-list.history-view-grid .history-task-card.selected .history-task-select {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.history-task-select input {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 2px solid color-mix(in srgb, var(--muted) 72%, transparent);
  border-radius: 5px;
  appearance: none;
  accent-color: var(--primary);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  opacity: 0.9;
  transition: background var(--motion-base), border-color var(--motion-base), box-shadow var(--motion-base);
}

.history-task-select input::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--primary-foreground);
  clip-path: polygon(14% 48%, 38% 72%, 86% 22%, 96% 32%, 39% 90%, 4% 57%);
  transform: scale(0);
  transition: transform var(--motion-base);
}

.history-task-select input:checked {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-light) 88%, transparent);
}

.history-task-select input:checked::before {
  transform: scale(1);
}

.history-task-open {
  width: auto;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.history-task-list.history-view-list .history-task-open {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 80px;
  padding: 10px 10px 10px 0;
}

.history-task-list.history-view-grid .history-task-open {
  display: grid;
  grid-template-rows: auto auto;
  gap: 0;
  width: 100%;
  min-height: 0;
  padding: 0;
}

.history-task-open:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 62%, transparent);
  outline-offset: 2px;
}

.history-task-list.history-view-list .history-task-thumb {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-soft);
}

.history-task-list.history-view-grid .history-task-thumb {
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  width: 100%;
  height: var(--history-task-row-height, var(--history-task-thumb-row-height));
  aspect-ratio: var(--history-task-thumb-ratio, 1 / 1);
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.history-task-list.history-view-grid
  .history-task-card[data-history-stack-depth]:not([data-history-stack-depth="0"]):not(.active):not(.selected)
  .history-task-thumb {
  background: transparent;
}

.history-task-thumb-frame {
  position: relative;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-soft);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--text) 12%, transparent),
    0 4px 12px color-mix(in srgb, var(--code) 16%, transparent);
}

.history-task-list.history-view-grid .history-task-card:not([data-history-stack-depth="0"]) .history-task-thumb-frame {
  align-self: start;
  justify-self: start;
  width: calc(100% - var(--history-task-stack-offset, 0px));
  height: calc(100% - var(--history-task-stack-offset, 0px));
}

.history-task-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: inherit;
  user-select: none;
  -webkit-user-drag: none;
}

.history-task-stack-layer {
  --history-task-stack-layer-offset: 0px;
  --history-task-stack-layer-surface: #e3e8e5;
  position: absolute;
  inset: 0 auto auto 0;
  display: none;
  width: calc(100% - var(--history-task-stack-offset, 0px));
  height: calc(100% - var(--history-task-stack-offset, 0px));
  border: 0;
  border-radius: var(--radius);
  background: var(--history-task-stack-layer-surface);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 10%, transparent);
  pointer-events: none;
}

.history-task-list.history-view-grid .history-task-card[data-history-stack-depth="1"] .history-task-stack-layer[data-history-stack-layer="1"],
.history-task-list.history-view-grid .history-task-card[data-history-stack-depth="2"] .history-task-stack-layer[data-history-stack-layer="1"],
.history-task-list.history-view-grid .history-task-card[data-history-stack-depth="3"] .history-task-stack-layer[data-history-stack-layer="1"] {
  z-index: 3;
  display: block;
  --history-task-stack-layer-offset: 6px;
  --history-task-stack-layer-surface: #e3e8e5;
  transform: translate(var(--history-task-stack-layer-offset), var(--history-task-stack-layer-offset));
}

.history-task-list.history-view-grid .history-task-card[data-history-stack-depth="2"] .history-task-stack-layer[data-history-stack-layer="2"],
.history-task-list.history-view-grid .history-task-card[data-history-stack-depth="3"] .history-task-stack-layer[data-history-stack-layer="2"] {
  z-index: 2;
  display: block;
  --history-task-stack-layer-offset: 12px;
  --history-task-stack-layer-surface: #cbd3cf;
  transform: translate(var(--history-task-stack-layer-offset), var(--history-task-stack-layer-offset));
}

.history-task-list.history-view-grid .history-task-card[data-history-stack-depth="3"] .history-task-stack-layer[data-history-stack-layer="3"] {
  z-index: 1;
  display: block;
  --history-task-stack-layer-offset: 18px;
  --history-task-stack-layer-surface: #b2bdb7;
  transform: translate(var(--history-task-stack-layer-offset), var(--history-task-stack-layer-offset));
}

.history-task-list.history-view-grid .history-task-card[data-history-stack-depth="1"] .history-task-stack-layer[data-history-stack-layer="1"],
.history-task-list.history-view-grid .history-task-card[data-history-stack-depth="2"] .history-task-stack-layer[data-history-stack-layer="2"],
.history-task-list.history-view-grid .history-task-card[data-history-stack-depth="3"] .history-task-stack-layer[data-history-stack-layer="3"] {
  border: 1px solid color-mix(in srgb, var(--text) 16%, var(--line));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--text) 8%, transparent),
    0 5px 12px color-mix(in srgb, var(--code) 18%, transparent);
}

:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card .history-task-stack-layer[data-history-stack-layer="1"] {
  --history-task-stack-layer-surface: #4a5550;
}

:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card .history-task-stack-layer[data-history-stack-layer="2"] {
  --history-task-stack-layer-surface: #3a4641;
}

:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card .history-task-stack-layer[data-history-stack-layer="3"] {
  --history-task-stack-layer-surface: #2d3833;
}

.history-task-list.history-view-list .history-task-stack-layer {
  display: none;
}

.history-task-copy {
  min-width: 0;
}

.history-task-list.history-view-grid .history-task-copy {
  display: grid;
  gap: 5px;
  min-height: 74px;
  padding: 8px 7px 6px;
  border-radius: 0 0 var(--radius) var(--radius);
}

.history-task-title,
.history-detail-title {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

.history-task-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-task-list.history-view-grid .history-task-title {
  display: -webkit-box;
  min-height: 37px;
  white-space: normal;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}

.history-task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.history-task-list.history-view-grid .history-task-meta {
  gap: 6px;
  margin-top: 0;
  max-height: 18px;
  overflow: hidden;
}

.history-task-list.history-view-grid .history-task-meta span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-task-list.history-view-grid .history-task-meta span:not([data-history-meta-kind="size"]) {
  display: none;
}

.history-empty,
.history-error,
.history-detail-empty {
  padding: 18px;
  border: 1px dashed var(--panel-border);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.history-load-sentinel {
  position: absolute;
  right: 18px;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  left: 18px;
  display: grid;
  place-items: center;
  width: auto;
  min-height: 24px;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

.history-load-sentinel[hidden] {
  display: none;
}

.history-context-menu {
  position: fixed;
  z-index: 9300;
  min-width: 178px;
  max-width: min(240px, calc(100vw - 16px));
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-popover);
}

.history-context-menu.hidden {
  display: none;
}

.history-context-menu-section {
  display: grid;
  gap: 2px;
  padding: 3px 0;
}

.history-context-menu-section + .history-context-menu-section {
  border-top: 1px solid var(--line);
}

.history-context-menu-button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 30px;
  padding: 5px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.history-context-menu-button:hover,
.history-context-menu-button:focus-visible {
  background: var(--primary-light);
  color: var(--primary-strong);
  outline: 0;
}

.history-context-menu-button.danger {
  color: var(--danger);
}

.history-context-menu-button.danger:hover,
.history-context-menu-button.danger:focus-visible {
  background: var(--danger-soft);
  color: var(--danger);
}

.history-context-menu-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.history-error {
  color: var(--danger);
  background: var(--danger-soft);
}

.history-detail {
  --history-prompt-font-size: 13px;
  --history-prompt-line-height: 1.6;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding: 18px;
  border-left: 0;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  overflow: auto;
}

.history-detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.history-detail-kicker {
  margin: 0 0 4px;
  text-transform: uppercase;
}

.history-detail-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  line-height: 1.35;
}

.history-detail-close {
  display: none;
}

.history-detail-meta,
.history-detail-actions,
.history-detail-actions-primary,
.history-detail-actions-output {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-detail-actions {
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 40px;
}

.history-detail-actions-primary,
.history-detail-actions-output {
  align-items: center;
}

.history-detail-actions-output {
  justify-content: flex-end;
  margin-left: auto;
}

.history-detail-actions-primary > *,
.history-detail-actions-output > * {
  flex: 0 0 auto;
  white-space: nowrap;
}

.history-detail-actions a {
  text-decoration: none;
}

.history-detail-images {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  justify-items: center;
  width: 100%;
}

.history-detail-images-multi {
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  align-items: start;
  justify-items: stretch;
}

.history-detail-images-multi.history-detail-images-count-2 {
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
}

.history-detail-images-multi.history-detail-images-count-4 {
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}

.history-detail-images-multi.history-detail-images-stack {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
}

.history-detail-image {
  position: relative;
  display: block;
  width: min(100%, 420px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  transition:
    border-color var(--motion-fast),
    box-shadow var(--motion-fast);
}

.history-detail-images-multi .history-detail-image {
  width: 100%;
  max-width: none;
}

.history-detail-images-stack .history-detail-image {
  width: min(100%, 760px);
}

.history-detail-images-stack.history-detail-images-square .history-detail-image {
  width: min(100%, 560px);
}

.history-detail-image.selected {
  border-color: color-mix(in srgb, var(--primary) 62%, transparent);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--primary) 30%, transparent),
    0 10px 28px color-mix(in srgb, var(--primary) 10%, transparent);
}

.history-detail-image-media {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
}

.history-detail-image-preview {
  position: relative;
  display: grid;
  place-items: center;
  justify-items: center;
  width: 100%;
  min-height: 180px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-soft);
  cursor: zoom-in;
}

.history-detail-images-multi .history-detail-image-preview {
  min-height: clamp(180px, 24dvh, 260px);
}

.history-detail-image-preview img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 320px;
  margin: 0 auto;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.history-detail-images-multi .history-detail-image-preview img {
  max-height: clamp(220px, 34dvh, 360px);
}

.history-detail-images-stack .history-detail-image-preview img {
  width: 100%;
  height: auto;
  max-height: none;
}

.history-detail-output-index {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--surface) 32%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary-strong) 84%, transparent);
  color: var(--primary-foreground);
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--code) 18%, transparent);
  backdrop-filter: blur(8px);
}

.history-detail-image-actions {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: safe center;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 40px 10px 10px;
  overflow: visible;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  background:
    linear-gradient(
      180deg,
      transparent 0%,
      color-mix(in srgb, var(--code) 18%, transparent) 24%,
      color-mix(in srgb, var(--code) 78%, transparent) 100%
    );
  transition:
    opacity var(--motion-base),
    transform var(--motion-base);
}

.history-detail-image-actions > * {
  flex: 0 0 auto;
  white-space: nowrap;
}

.history-detail-image-media:hover .history-detail-image-actions,
.history-detail-image-media:focus-within .history-detail-image-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.history-detail-overlay-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 0;
  padding: 6px 12px;
  border: 1px solid color-mix(in srgb, var(--surface) 76%, var(--primary-light));
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, var(--primary-light) 12%);
  color: var(--text);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--code) 22%, transparent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  backdrop-filter: blur(8px);
  transition:
    background var(--motion-fast),
    border-color var(--motion-fast),
    color var(--motion-fast),
    transform var(--motion-fast);
}

.history-detail-overlay-button.primary,
.history-detail-overlay-button[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.history-detail-overlay-button:hover,
.history-detail-overlay-button:focus-visible {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
  color: var(--primary-foreground);
  transform: translateY(-1px);
}

.history-detail-output-prompt {
  display: grid;
  gap: 7px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--panel-border);
  background: var(--surface);
}

.history-detail-output-prompt-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--text-secondary);
  font-size: var(--history-prompt-font-size);
  font-weight: 700;
  line-height: var(--history-prompt-line-height);
}

.history-detail-output-prompt-text {
  max-height: 116px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--history-prompt-font-size);
  font-weight: 400;
  line-height: var(--history-prompt-line-height);
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.history-detail-output-prompt-text::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.history-detail-output-prompt-text::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.history-detail-output-prompt-text::-webkit-scrollbar-thumb {
  border: 2px solid var(--scrollbar-track);
  border-radius: 999px;
  background: var(--scrollbar-thumb);
}

.history-detail-output-prompt-text::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.history-detail-inputs {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 10px 0 4px;
  border-top: 1px solid color-mix(in srgb, var(--panel-border) 72%, transparent);
}

.history-detail-reference-files {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 10px 0 4px;
  border-top: 1px solid color-mix(in srgb, var(--panel-border) 72%, transparent);
}

.history-detail-reference-file-list {
  display: grid;
  gap: 6px;
}

.history-reference-file-row {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text-secondary);
}

.history-reference-file-row.is-missing {
  color: var(--muted);
}

.history-reference-file-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--primary-strong);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.history-reference-file-icon .reference-file-format-icon {
  display: block;
  width: 28px;
  height: 28px;
}

.history-reference-file-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.history-reference-file-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-reference-file-meta {
  color: var(--muted);
  font-size: 10px;
}

.history-reference-file-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-reference-file-actions .ghost-button {
  min-height: 30px;
  padding: 5px 8px;
  text-decoration: none;
}

.history-reference-file-missing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  white-space: nowrap;
}

.history-reference-file-missing > span {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-weight: 800;
}

@media (max-width: 620px) {
  .history-reference-file-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .history-reference-file-actions,
  .history-reference-file-missing {
    grid-column: 2;
    justify-self: start;
  }
}

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

.history-detail-inputs-header h3 {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.history-detail-inputs-header span {
  font-variant-numeric: tabular-nums;
}

.history-detail-inputs-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.history-detail-input-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  cursor: zoom-in;
  opacity: 0.72;
  transition:
    border-color var(--motion-fast),
    opacity var(--motion-fast),
    transform var(--motion-fast);
}

.history-detail-input-thumb:hover,
.history-detail-input-thumb:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 48%, var(--panel-border));
  opacity: 1;
  transform: translateY(-1px);
}

.history-detail-input-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (hover: none) {
  .history-detail-image-actions {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }
}

body.history-lightbox-open {
  overflow: hidden;
}

.history-lightbox {
  --history-lightbox-peek-opacity: 0.48;
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 52px 18px;
  background: rgba(10, 24, 20, 0.82);
  backdrop-filter: blur(10px);
}

.history-lightbox-track {
  position: relative;
  display: grid;
  width: min(88vw, 1600px);
  height: 92vh;
  place-items: center;
  perspective: 1400px;
}

.history-lightbox-current-frame {
  display: grid;
  min-width: 0;
  height: 100%;
  place-items: center;
  overflow: visible;
  transform-style: preserve-3d;
}

.history-lightbox[hidden] {
  display: none;
}

.history-lightbox img {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 96vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  cursor: grab;
  user-select: none;
}

.history-lightbox-current-image {
  transform-origin: center center;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.history-lightbox-transition-layer {
  position: fixed;
  z-index: 3;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.history-lightbox-transition-ghost {
  position: fixed !important;
  z-index: 1;
  display: block;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  pointer-events: none;
  transform-origin: top left;
  will-change: transform, opacity;
}

.history-lightbox.is-shared-switching .history-lightbox-current-image {
  opacity: 0;
}

.history-lightbox.is-shared-switching.is-shared-settling .history-lightbox-current-image {
  opacity: 1;
  transition: none;
}

.history-lightbox-peek {
  position: fixed;
  z-index: 1;
  top: 50%;
  width: clamp(44px, 4.5vw, 88px);
  height: min(72vh, 760px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  opacity: var(--history-lightbox-peek-opacity);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.26);
  cursor: pointer;
  transform: translateY(-50%) scale(0.96);
  transition: opacity 160ms ease, transform 180ms cubic-bezier(0.2, 0.78, 0.2, 1);
}

.history-lightbox-peek-previous {
  left: 0;
  border-left: 0;
  border-radius: 0 14px 14px 0;
  transform-origin: left center;
}

.history-lightbox-peek-next {
  right: 0;
  border-right: 0;
  border-radius: 14px 0 0 14px;
  transform-origin: right center;
}

.history-lightbox-peek:hover {
  opacity: 0.82;
}

.history-lightbox-peek-previous:hover {
  transform: translateY(-50%) scaleX(1.04) scaleY(0.98);
}

.history-lightbox-peek-next:hover {
  transform: translateY(-50%) scaleX(1.04) scaleY(0.98);
}

.history-lightbox-peek.is-unavailable {
  visibility: hidden;
  pointer-events: none;
}

.history-lightbox-peek img {
  position: absolute;
  top: 0;
  width: auto;
  min-width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border-radius: 0;
  object-fit: cover;
  box-shadow: none;
  cursor: pointer;
}

.history-lightbox-peek-previous img {
  right: 0;
  object-position: right center;
}

.history-lightbox-peek-next img {
  left: 0;
  object-position: left center;
}

.history-lightbox.is-zoomed .history-lightbox-peek {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.9);
}

.history-lightbox img:active {
  cursor: grabbing;
}

.history-lightbox-close {
  position: absolute;
  z-index: 2;
  top: 22px;
  left: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.history-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.24);
}

.history-lightbox-counter {
  position: absolute;
  z-index: 2;
  bottom: 22px;
  left: 50%;
  min-width: 64px;
  padding: 7px 12px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  font-size: 13px;
  text-align: center;
  backdrop-filter: blur(8px);
}

@media (max-width: 720px) {
  .history-lightbox {
    padding-inline: 8px;
  }

  .history-lightbox-track {
    width: calc(100vw - 40px);
  }

  .history-lightbox-peek {
    width: 44px;
    border-radius: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .history-lightbox-track,
  .history-lightbox-current-image,
  .history-lightbox-peek {
    animation-duration: 100ms !important;
    transition-duration: 100ms !important;
  }
}

.history-prompt-compare {
  display: grid;
  gap: 10px;
}

.history-prompt-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--surface);
}

.history-prompt-panel-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.history-prompt-panel h3 {
  margin: 0;
  color: var(--text);
  font-size: var(--history-prompt-font-size);
  font-weight: 700;
  line-height: var(--history-prompt-line-height);
}

.history-prompt-copy {
  min-height: 30px;
  padding: 5px 10px;
  white-space: nowrap;
}

.history-prompt-copy.copied {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  color: var(--primary-strong);
  background: var(--primary-light);
}

.history-prompt-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.history-detail-prompt {
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--history-prompt-font-size);
  font-weight: 400;
  line-height: var(--history-prompt-line-height);
}

:root[data-theme="dark"] .history-task-card {
  background: transparent;
}

:root[data-theme="dark"] .history-task-card:hover,
:root[data-theme="dark"] .history-task-card:focus-within {
  background: color-mix(in srgb, var(--surface) 72%, #000 28%);
}

:root[data-theme="dark"] .history-task-card.active {
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--primary-strong) 38%, transparent),
    0 0 0 3px color-mix(in srgb, var(--primary-light) 38%, transparent),
    var(--shadow-sm);
}

:root[data-theme="dark"] .history-task-card.selected {
  border-color: color-mix(in srgb, var(--primary-strong) 78%, transparent);
  background: color-mix(in srgb, var(--primary-light) 68%, var(--surface));
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--primary-strong) 50%, transparent),
    0 10px 28px rgba(0, 0, 0, 0.34);
}

:root[data-theme="dark"] .history-task-card.selected .history-task-copy {
  background: color-mix(in srgb, var(--primary-light) 64%, var(--surface));
}

:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card.active,
:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card.selected {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
  box-shadow:
    0 0 0 2px var(--primary-strong),
    0 0 0 6px color-mix(in srgb, var(--primary-light) 44%, transparent);
}

:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card.active .history-task-thumb,
:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card.selected .history-task-thumb {
  background: var(--primary-strong);
}

:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card.active .history-task-copy,
:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card.selected .history-task-copy {
  background: var(--primary-strong);
  color: var(--primary-foreground);
}

:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card.active .history-task-title,
:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card.selected .history-task-title,
:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card.active .history-task-meta,
:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-card.selected .history-task-meta {
  color: var(--primary-foreground);
}

:root[data-theme="dark"] .history-task-list.history-view-list .history-task-select {
  opacity: 0.72;
}

:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-select {
  background: transparent;
  box-shadow: none;
}

:root[data-theme="dark"] .history-task-select input {
  border-color: color-mix(in srgb, var(--primary-strong) 62%, var(--muted));
  background: color-mix(in srgb, var(--surface) 72%, #000 28%);
  opacity: 1;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.34);
}

:root[data-theme="dark"] .history-task-select input:checked {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-light) 58%, transparent);
}

:root[data-theme="dark"] .history-detail-image-preview {
  background: color-mix(in srgb, var(--surface-soft) 78%, #000 22%);
}

:root[data-theme="dark"] .history-lightbox {
  background: rgba(2, 8, 6, 0.78);
}

@media (max-width: 1100px) {
  .history-page {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .history-resize-hit-area {
    display: none;
  }

  .history-sidebar {
    border-right: 1px solid var(--panel-border);
  }

  .history-detail {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 20;
    width: min(440px, 92vw);
    border-left: 1px solid var(--panel-border);
    box-shadow: var(--shadow-modal);
    transform: translateX(100%);
    transition: transform var(--motion-base);
  }

  .history-page.history-detail-open .history-detail {
    transform: translateX(0);
  }

  .history-detail-close {
    display: grid;
  }
}

@media (max-width: 760px) {
  .history-page {
    grid-template-columns: minmax(0, 1fr);
  }

  .history-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--panel-border);
    max-height: 42dvh;
  }

  .history-toolbar,
  .history-toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .history-sort-toggle,
  .history-view-toggle,
  .history-toolbar-actions > * {
    width: 100%;
  }

  .history-bulk-toolbar {
    left: 18px;
    right: 18px;
    width: auto;
    max-width: none;
    flex-wrap: wrap;
  }

  .history-bulk-actions {
    flex: 1 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    width: auto;
  }

  .history-bulk-actions > * {
    width: auto;
  }

  .history-task-list.history-view-grid {
    --history-task-thumb-row-height: clamp(132px, 34vw, 176px);
    gap: 14px 12px;
  }

  .history-task-list.history-view-grid .history-task-card {
    flex-basis: var(--history-task-card-width, clamp(132px, calc(var(--history-task-card-ratio, 1) * var(--history-task-thumb-row-height)), 320px));
    width: var(--history-task-card-width, clamp(132px, calc(var(--history-task-card-ratio, 1) * var(--history-task-thumb-row-height)), 320px));
  }

  .history-detail {
    width: 100vw;
  }

  .history-detail-images {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .history-filter-summary::after,
  .history-filter-button,
  .history-view-button,
  .history-sort-button,
  .history-task-card,
  .history-detail {
    transition: none;
  }
}
