/* 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;
  --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;
}

/* 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: 100vh;
  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);
}

body.sidebar-resizing {
  cursor: col-resize;
  user-select: none;
}

.sidebar-header {
  padding: 20px 16px 12px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  margin-bottom: 18px;
  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-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;
}

.sidebar-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 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:focus {
  border-color: var(--primary);
  background-color: var(--surface);
}

.sidebar-filter-panel {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

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

.task-filter-select {
  min-width: 0;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 12px;
  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;
}

.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: 6px;
  padding-bottom: 6px;
}

.task-active-list {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  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: 34px;
  width: 100%;
  padding: 4px;
  border-radius: 12px;
  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 12px 0 14px;
  border-radius: 10px;
}

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

.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: 6px;
}

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

.task-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  min-height: 34px;
  padding: 4px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  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: 6px;
  overflow: clip;
  transition:
    max-height var(--motion-height),
    opacity var(--motion-base);
}

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

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

.task-history-library-card {
  display: grid;
  gap: 4px;
  margin-top: 0;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--surface);
  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;
}

.task-history-library-card small {
  color: var(--muted);
}

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

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

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

.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: 6px;
}

.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: 12px;
  position: relative;
  height: 82px;
  padding: 8px;
  padding-right: 34px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid 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.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: var(--surface-soft);
}

.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 {
  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.failed,
.task-card.partial_failed {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.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 .task-title-row {
  padding-right: 94px;
}

.task-card.active::after {
  content: attr(data-active-label);
  position: absolute;
  right: 40px;
  top: 7px;
  z-index: 1;
  max-width: 54px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 11px;
  font-weight: 760;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}

.task-card.active.queue-waiting .task-title-row,
.task-card.active.queue-running .task-title-row,
.task-card.active.batch-mode .task-title-row {
  padding-right: 58px;
}

.task-card.active.queue-waiting::after,
.task-card.active.queue-running::after,
.task-card.active.batch-mode::after {
  right: 8px;
}

.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: var(--danger-soft);
  border-color: var(--primary);
  box-shadow:
    inset 4px 0 0 var(--primary),
    inset 0 0 0 1px color-mix(in srgb, var(--danger) 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-thumb {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  background: var(--line);
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.task-thumb-stack {
  --task-thumb-layer-size: 44px;
  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: cover;
  border-radius: 5px;
  transition:
    opacity var(--motion-base),
    transform var(--motion-base);
}

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

.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: 0 5px 14px rgba(16, 35, 28, 0.32);
  pointer-events: none;
  animation: spinner-breathe 2.2s ease-in-out infinite;
}

.task-thumb-stack-spinner::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  box-sizing: border-box;
  border: 3px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-right-color: var(--primary);
  border-bottom-color: color-mix(in srgb, var(--primary) 58%, transparent);
  animation: soft-spin 1.2s linear infinite;
}

.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: 52px;
  height: 52px;
  display: grid;
  place-items: center;
}

.running-thumb span,
.waiting-spinner {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 6%, transparent);
  animation: spinner-breathe 2.2s ease-in-out infinite;
}

.running-thumb span::before,
.waiting-spinner::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-sizing: border-box;
  border: 5px solid color-mix(in srgb, var(--primary) 14%, transparent);
  border-right-color: var(--primary);
  border-bottom-color: color-mix(in srgb, var(--primary) 42%, transparent);
  animation: soft-spin 1.2s linear infinite;
}

.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 {
  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-runtime,
.task-retry-state {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-runtime {
  color: var(--text-secondary);
  font-size: 11px;
  white-space: nowrap;
}

.task-retry-state {
  color: var(--primary-strong);
}

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

.task-status-light {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: var(--muted);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 12%, transparent);
}

.task-status-light.failed {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 12%, transparent);
}

.task-status-light.completed {
  background: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

.task-status-light.running {
  background: var(--status-blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-blue) 13%, transparent);
}

.task-status-light.queued {
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.task-status-label {
  flex: 0 0 auto;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.task-status-meta {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.task-image-progress {
  --task-block-count: 1;
  display: grid;
  grid-template-columns: repeat(var(--task-block-count), minmax(0, 1fr));
  gap: 2px;
  width: 66px;
  height: 7px;
  flex: 0 0 66px;
}

.task-image-progress.compressed {
  width: 72px;
  flex-basis: 72px;
}

.task-image-block {
  min-width: 0;
  border-radius: 2px;
  border: 1px solid color-mix(in srgb, var(--muted) 26%, transparent);
  background: color-mix(in srgb, var(--line) 72%, var(--surface-soft));
}

.task-image-block.completed {
  border-color: color-mix(in srgb, var(--primary) 24%, transparent);
  background: var(--primary);
}

.task-image-block.failed {
  border-color: color-mix(in srgb, var(--danger) 24%, transparent);
  background: var(--danger);
}

.task-image-block.running {
  border-color: color-mix(in srgb, var(--status-blue) 24%, transparent);
  background: var(--status-blue);
}

.task-image-block.queued {
  border-color: color-mix(in srgb, var(--accent) 24%, transparent);
  background: var(--accent);
}

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

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

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.footer-actions .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;
}

.api-status-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 6px 12px;
  background: var(--surface-soft);
  border-radius: 999px;
  color: var(--text-secondary);
}

.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: 100%;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 2px 6px;
  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;
  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);
}

.language-switcher {
  order: 3;
  flex: 0 0 auto;
  position: relative;
  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;
}

.language-option {
  position: relative;
  z-index: 1;
  height: var(--top-nav-segment-height);
  min-height: var(--top-nav-segment-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--top-nav-control-radius);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--top-nav-control-font-size);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--motion-base), color var(--motion-base);
}

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

.language-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,
  .language-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: calc(100dvh - var(--header-height));
  margin-inline: auto;
  padding: 24px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: minmax(520px, 760px) minmax(520px, 1fr);
  gap: 24px;
  align-content: safe center;
  align-items: stretch;
}

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

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

.preview-col {
  position: relative;
  height: var(--controls-col-height, auto);
  min-height: 0;
  overflow: hidden;
}

.preview-panel {
  height: var(--controls-col-height, 100%);
  max-height: var(--controls-col-height, 100%);
  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: 32px;
  min-height: 32px;
  padding: 0 12px;
  gap: 6px;
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
}

.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;
}

.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;
}

.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;
}

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

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

.image-uploader-grid.has-images .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-images .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-images .upload-tile {
  gap: 6px;
  padding: 8px;
}

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

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

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

.image-uploader-grid.compact-grid .image-strip {
  grid-template-columns: none;
  grid-template-rows: var(--image-input-compact-thumb-size);
  grid-auto-flow: column;
  grid-auto-columns: var(--image-input-compact-thumb-size);
  align-content: center;
  align-items: stretch;
  justify-content: start;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

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

.image-uploader-grid.compact-grid .image-strip::-webkit-scrollbar {
  height: 8px;
}

.image-uploader-grid.compact-grid .image-strip::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}

.image-uploader-grid.compact-grid .image-strip::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--scrollbar-thumb);
  background-clip: content-box;
}

.image-uploader-grid.compact-grid .image-strip::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: content-box;
}

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

.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 .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 .ghost-button {
  flex: 0 0 auto;
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
  white-space: nowrap;
}

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

.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);
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
  white-space: nowrap;
}

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

.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-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 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.prompt-template-card {
  min-height: 132px;
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.prompt-template-card-thumb {
  display: block;
  aspect-ratio: 4 / 3;
  width: 100%;
  overflow: hidden;
  border-radius: 6px;
  background: var(--line);
}

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

.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 {
  grid-column: 1 / -1;
  padding: 20px 10px;
  color: var(--muted);
  text-align: center;
}

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

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

.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-settings-preview.css */
/* 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);
}

.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;
}

.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) {
  .settings-grid,
  .mode-transition {
    transition: none;
  }
}

/* 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); }

/* 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;
  width: 100%;
  max-height: 100%;
  min-height: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  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);
}

.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%;
}

.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: flex;
  flex-wrap: wrap;
  align-items: center;
  width: auto;
  max-width: min(360px, calc(100% - 24px));
  justify-content: center;
  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;
}

.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(860px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: min(72vh, 640px);
  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: 10px;
  margin-bottom: 7px;
}

.prompt-popover-label {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.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(42vh, 390px);
  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-popover-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.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-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-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  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;
}

.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(430px, 94vw);
}

.system-settings-modal-panel {
  width: min(760px, 94vw);
  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;
  gap: 10px;
}

.version-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
}

.version-detail-row strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.version-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.version-modal-actions .run-button,
.version-modal-actions .ghost-button {
  width: auto;
  min-width: 112px;
  height: 34px;
}

.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(3, 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: #fff;
  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: #fff;
  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: auto;
  padding-right: 0;
  display: flex;
  flex-direction: column;
}

.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(160px, 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;
}

.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, 1.15fr) minmax(220px, 0.85fr);
  gap: 10px 12px;
  align-items: end;
}

.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-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

.api-provider-list {
  display: contents;
  min-width: 0;
}

.api-provider-list.is-sorting {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.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: #fff;
  box-shadow: var(--shadow-soft);
}

.api-provider-choice.active span {
  color: rgba(255, 255, 255, 0.82);
}

.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 {
  justify-content: flex-end;
  padding-top: 2px;
}

.api-provider-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.9fr) minmax(0, 0.75fr) minmax(64px, 0.45fr);
  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: 10px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.api-provider-editor.hidden,
.api-provider-detail-panel.hidden {
  display: none;
}

.api-provider-name-field {
  grid-column: 2 / 3;
}

.api-provider-editor .api-provider-name-field {
  grid-column: 1 / 2;
}

@media (max-width: 720px) {
  .api-provider-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .api-provider-choice-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.api-mode-field {
  grid-column: 1 / -1;
}

.api-base-url-field,
.api-image-model-field {
  grid-column: 1 / 2;
}

.api-key-field,
.api-concurrency-field {
  grid-column: 2 / 3;
}

.compact-api-settings-grid .field {
  gap: 5px;
}

.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);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.codex-channel-note {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
}

.codex-channel-note + .codex-channel-note {
  border-left: 1px solid var(--line);
}

.codex-channel-note strong {
  color: var(--text);
  font-size: 13px;
}

.codex-channel-note span {
  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-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;
  }
}

.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;
  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-height: 58px;
  padding: 10px;
}

.gallery-card-heading {
  display: block;
}

.gallery-card-heading strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card-body span {
  color: var(--muted);
  font-size: 12px;
}

.gallery-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 0 10px 10px;
}

.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-canvas-wrap {
  position: relative;
  line-height: 0;
  touch-action: none;
  user-select: none;
}

.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-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-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 spinner-breathe {
  0%,
  100% {
    transform: scale(0.96);
    opacity: 0.82;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes waiting-bar {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(260%);
  }
}

/* source: styles/80-utilities-responsive.css */
/* 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: 1080px) and (min-width: 1024px) {
  .sidebar-footer {
    padding: 8px 12px;
    gap: 6px;
  }

  .footer-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }

  .footer-actions .ghost-button {
    width: 100%;
    height: 28px;
    padding: 0 6px;
    font-size: 12px;
    white-space: nowrap;
  }

  .status-text:not(.error) {
    display: none;
  }

  .status-text.error {
    -webkit-line-clamp: 1;
    max-height: 1.45em;
    font-size: 11px;
  }

  .api-status-bar {
    min-height: 24px;
    padding: 4px 10px;
    font-size: 11px;
  }

  .version-info {
    display: none;
  }

  .version-info.has-update {
    display: inline-flex;
    width: auto;
    min-height: 22px;
    padding: 2px 8px;
    margin: 0 auto;
  }

  .version-info.has-update .version-label {
    display: none;
  }

  .dashboard {
    padding: 14px;
    gap: 14px;
    align-content: start;
  }

  .preview-col {
    height: calc(100dvh - var(--header-height) - 28px);
  }

  .preview-panel {
    height: 100%;
    max-height: none;
  }

  .dashboard-col {
    gap: 12px;
  }

  .controls-col {
    min-height: calc(100dvh - var(--header-height) - 28px);
    height: calc(100dvh - var(--header-height) - 28px);
    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 194px;
    min-height: 194px;
  }

  .controls-col .prompt-panel {
    flex: 2 1 148px;
    min-height: 148px;
    overflow: hidden;
  }

  .controls-col .output-panel {
    flex: 0 0 auto;
  }

  .panel {
    padding: 14px;
    border-radius: 10px;
  }

  .controls-col .image-panel .panel-heading,
  .controls-col .output-panel > h2 {
    height: 0;
    margin: 0;
    overflow: hidden;
  }

  .controls-col .panel-heading h2,
  .controls-col .output-panel > h2 {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
  }

  .controls-col .prompt-heading {
    margin-bottom: 4px;
  }

  .controls-col .prompt-heading-main {
    justify-content: flex-end;
  }

  .image-input-workspace {
    --image-input-main-height: 124px;
    --image-input-action-height: 34px;
    --image-input-gap: 6px;
    --image-upload-source-compact-width: 106px;
    --image-input-thumb-size: 104px;
    --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: 8px;
  }

  .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 .ghost-button {
    height: var(--image-input-action-height);
  }

  .quick-gallery-category {
    flex-basis: 24px;
    height: 24px;
  }

  .quick-gallery-list {
    --quick-gallery-item-height: 24px;
  }

  .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: 34px;
    --prompt-secondary-chip-height: 30px;
  }

  .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 {
    gap: 6px;
  }

  .field {
    gap: 4px;
  }

  .settings-grid .field > span {
    font-size: 12px;
  }

  .settings-grid .control {
    height: 30px;
    padding: 0 10px;
  }

  .settings-grid .radio-group {
    --segmented-control-height: 24px;
    --segmented-control-padding: 2px;
  }

  .settings-grid .radio-btn {
    padding: 0 6px;
    white-space: nowrap;
  }

  .custom-size-control {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    align-items: flex-start;
    gap: 4px;
  }

  .custom-size-control .field-label {
    display: block;
    font-size: 12px;
  }

  .size-mode-group {
    width: 100%;
    min-width: 0;
  }

  .orientation-field {
    grid-column: 1 / 2;
    grid-row: 3 / 4;
  }

  .resolution-field {
    grid-column: 2 / 3;
    grid-row: 3 / 4;
  }

  .ratio-field {
    grid-column: 1 / 2;
    grid-row: 4 / 6;
  }

  .quantity-quality-row {
    display: contents;
  }

  .quantity-quality-row .field {
    gap: 4px;
  }

  .quantity-field {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
  }

  .quality-field {
    grid-column: 2 / 3;
    grid-row: 4 / 5;
  }

  .ratio-group {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: repeat(2, 24px);
  }

  .mode-settings-slot {
    --mode-settings-stable-height: 52px;
  }

  .mode-specific-settings {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: end;
    gap: 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;
  }

  .web-search-toggle {
    width: 100%;
    min-width: 0;
    height: 30px;
    grid-template-columns: 32px minmax(0, max-content);
    gap: 6px;
    padding: 0 8px;
  }

  .web-search-toggle-track {
    width: 32px;
    height: 18px;
  }

  .web-search-toggle-track::before {
    width: 12px;
    height: 12px;
  }

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

  .web-search-toggle-text {
    font-size: 11px;
  }

  .api-direct-settings-notice {
    min-height: 46px;
  }

  .api-direct-settings-control {
    height: 30px;
    gap: 8px;
    padding: 0 4px 0 8px;
  }

  .api-direct-settings-header {
    display: flex;
    grid-template-columns: none;
    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 {
    grid-column: 2 / 3;
    grid-row: 5 / 6;
    min-height: 20px;
    padding: 3px 8px !important;
    font-size: 11px !important;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #outputFormatField {
    grid-column: 1 / 2;
    grid-row: 6 / 7;
  }

  .moderation-field {
    grid-column: 2 / 3;
    grid-row: 6 / 7;
  }

  .settings-grid.custom-size-mode {
    --custom-size-mode-card-height: 142px;
  }

  .settings-grid.custom-size-mode .custom-size {
    grid-column: 1 / 2;
    grid-row: 3 / 4;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    min-height: var(--custom-size-mode-card-height);
    max-height: var(--custom-size-mode-card-height);
    padding: 10px 12px;
  }

  .settings-grid.custom-size-mode .quality-field {
    grid-row: 3 / 4;
  }

  .settings-grid.custom-size-mode #pixelPreview {
    grid-column: 1 / -1;
    grid-row: 4 / 5;
  }

  .settings-grid.custom-size-mode #outputFormatField,
  .settings-grid.custom-size-mode .moderation-field {
    grid-row: 5 / 6;
  }

  .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-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: 620px) {
  .image-input-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 1080px) and (min-width: 1024px) and (max-width: 1500px) {
  .dashboard {
    grid-template-columns: minmax(600px, 1.08fr) minmax(400px, 0.92fr);
    padding: 12px;
    gap: 12px;
  }

  .preview-col,
  .controls-col {
    height: calc(100dvh - var(--header-height) - 24px);
  }

  .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 .ghost-button {
    width: 100%;
    padding: 0 8px;
    font-size: 12px;
  }

  .controls-col .prompt-panel {
    --prompt-action-column-width: 132px;
  }
}

@media (max-width: 1024px) {
  .layout-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-resize-handle {
    display: none;
  }
  .sidebar-content, .sidebar-footer {
    display: none;
  }
  .sidebar-search,
  .sidebar-filter-panel,
  .task-history-anchor-rail,
  .task-history-library-slot {
    display: none;
  }
  .dashboard {
    grid-template-columns: 1fr;
    align-content: start;
  }
  .preview-col {
    height: auto;
    overflow: visible;
  }
  .preview-panel {
    height: auto;
    max-height: none;
  }
  .top-nav {
    padding: 0 14px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .top-nav::-webkit-scrollbar {
    display: none;
  }
  .nav-actions {
    width: max-content;
    min-width: 100%;
    justify-content: flex-start;
    gap: 10px;
  }
  .auth-source-switcher {
    flex: 0 0 auto;
  }
  .auth-source-detail {
    display: none;
  }
  .queue-drawer {
    width: 100vw;
    max-width: 100%;
  }
  .field-pair {
    grid-template-columns: 1fr;
  }
}

/* source: styles/90-history.css */
.history-page {
  --history-sidebar-width: 280px;
  --history-detail-width: 380px;
  --history-resizer-width: 8px;
  display: grid;
  grid-template-columns:
    clamp(220px, var(--history-sidebar-width), 420px)
    var(--history-resizer-width)
    minmax(360px, 1fr)
    var(--history-resizer-width)
    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-resizer {
  position: relative;
  z-index: 5;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  cursor: col-resize;
  touch-action: none;
  outline: none;
}

.history-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  border-radius: 999px;
  background: var(--panel-border);
  transform: translateX(-50%);
  transition:
    width var(--motion-fast),
    background var(--motion-fast),
    box-shadow var(--motion-fast);
}

.history-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 54px;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--panel-border));
  border-radius: 999px;
  background-color: color-mix(in srgb, var(--primary-light) 44%, var(--surface));
  background-image:
    linear-gradient(color-mix(in srgb, var(--primary) 34%, transparent), color-mix(in srgb, var(--primary) 34%, transparent)),
    linear-gradient(color-mix(in srgb, var(--primary) 44%, transparent), color-mix(in srgb, var(--primary) 44%, transparent)),
    linear-gradient(color-mix(in srgb, var(--primary) 34%, transparent), color-mix(in srgb, var(--primary) 34%, transparent));
  background-repeat: no-repeat;
  background-position:
    calc(50% - 4px) center,
    50% center,
    calc(50% + 4px) center;
  background-size:
    1px 34px,
    1px 38px,
    1px 34px;
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--surface) 74%, transparent),
    0 3px 10px color-mix(in srgb, var(--primary) 8%, transparent);
  opacity: 0.72;
  transform: translate(-50%, -50%);
  transition:
    background-color var(--motion-fast),
    border-color var(--motion-fast),
    box-shadow var(--motion-fast),
    opacity var(--motion-fast);
}

.history-resizer:hover::before,
.history-resizer:focus-visible::before,
.history-page.history-resizing .history-resizer::before {
  width: 2px;
  background: var(--primary);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 14%, transparent);
}

.history-resizer:hover::after,
.history-resizer:focus-visible::after,
.history-page.history-resizing .history-resizer::after {
  border-color: color-mix(in srgb, var(--primary) 28%, var(--panel-border));
  background-color: color-mix(in srgb, var(--primary-light) 82%, var(--surface));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--surface) 88%, transparent),
    0 6px 16px color-mix(in srgb, var(--primary) 14%, transparent);
  opacity: 1;
}

.history-page.history-resizing,
.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) var(--scrollbar-track);
}

.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: var(--scrollbar-track);
  border-radius: 999px;
}

.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-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-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  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 {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.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 {
  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 6px calc(18px + env(safe-area-inset-bottom, 0px)) 18px;
  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 {
  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 var(--panel-border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.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: calc(var(--radius) - 2px);
  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-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;
  overflow: auto;
  padding-right: 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 4px 6px 6px;
}

.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: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) var(--radius) 0 0;
  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-active-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border: 1px solid color-mix(in srgb, var(--primary-strong) 48%, transparent);
  border-radius: 999px;
  color: var(--primary-foreground);
  background: color-mix(in srgb, var(--primary-strong) 92%, transparent);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--primary-strong) 20%, transparent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity var(--motion-base), transform var(--motion-base);
}

.history-task-card.active .history-task-active-badge {
  opacity: 1;
  transform: translateY(0);
}

.history-task-select {
  cursor: pointer;
  opacity: 0.24;
  transition: opacity var(--motion-base), transform var(--motion-base);
}

.history-task-card:hover .history-task-select,
.history-task-card:focus-within .history-task-select,
.history-task-card.selected .history-task-select {
  opacity: 1;
  transform: scale(1);
}

.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: 4;
  display: grid;
  place-items: center;
  width: 32px;
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.history-task-list.history-view-grid .history-task-card:not(:hover):not(:focus-within):not(.selected) .history-task-select {
  transform: scale(0.94);
}

.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;
  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-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  user-select: none;
  -webkit-user-drag: 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 {
  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: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 16px;
  line-height: 1.35;
}

.history-detail-close {
  display: none;
}

.history-detail-meta,
.history-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-detail-actions {
  justify-content: safe center;
  width: 100%;
}

.history-detail-actions > * {
  flex: 0 0 auto;
  white-space: nowrap;
}

.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-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:hover .history-detail-image-actions,
.history-detail-image: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: 12px;
  font-weight: 700;
}

.history-detail-output-prompt-text {
  max-height: 116px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
  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-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 {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 52px;
  background: rgba(10, 24, 20, 0.82);
  backdrop-filter: blur(10px);
}

.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 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-nav {
  position: absolute;
  z-index: 2;
  top: 50%;
  display: grid;
  place-items: center;
  width: 48px;
  height: 72px;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  cursor: pointer;
  font-size: 46px;
  line-height: 1;
  backdrop-filter: blur(8px);
}

.history-lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.24);
}

.history-lightbox-prev {
  left: 22px;
}

.history-lightbox-next {
  right: 22px;
}

.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);
}

.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: 13px;
}

.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);
  line-height: 1.6;
}

: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-select {
  opacity: 0.26;
}

:root[data-theme="dark"] .history-task-list.history-view-grid .history-task-select {
  background: transparent;
}

:root[data-theme="dark"] .history-task-select input {
  border-color: color-mix(in srgb, var(--muted) 80%, transparent);
  background: color-mix(in srgb, var(--surface) 86%, #000 14%);
}

: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-resizer {
    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-button,
  .history-view-button,
  .history-sort-button,
  .history-task-card,
  .history-detail {
    transition: none;
  }
}
