/* =========================================================================
   Atelier AI — Components
   Semantic, composable blocks. Consume tokens from tokens.css.
   ========================================================================= */

/* =========================================================================
   Base · body, links
   ========================================================================= */
body {
  margin: 0;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent-secondary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: var(--accent-secondary-hover); }
a:focus-visible {
  outline: none;
  box-shadow: var(--ring-default);
  border-radius: var(--radius-sm);
}

:focus-visible {
  outline: none;
}

/* =========================================================================
   Icon · <svg class="icon"><use .../></svg>
   ========================================================================= */
.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -2px;
}
.icon-sm { width: 14px; height: 14px; }
.icon-md { width: 16px; height: 16px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 24px; height: 24px; }

/* =========================================================================
   Button
   ========================================================================= */
.btn {
  --btn-h: 34px;
  --btn-px: 14px;
  --btn-bg: var(--bg-elevated);
  --btn-bg-hover: var(--alpha-hover);
  --btn-bg-active: var(--alpha-active);
  --btn-fg: var(--text-primary);
  --btn-border: var(--border-default);
  --btn-ring: var(--ring-default);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1-5);
  height: var(--btn-h);
  padding: 0 var(--btn-px);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-control);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    transform var(--duration-instant) var(--ease-out);
}
.btn:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--btn-bg-hover);
}
.btn:active:not(:disabled):not([aria-disabled="true"]) {
  background: var(--btn-bg-active);
  transform: scale(0.98);
}
.btn:focus-visible {
  box-shadow: var(--btn-ring);
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary — orange gradient-tinted, solid */
.btn-primary {
  --btn-bg: var(--accent-primary);
  --btn-bg-hover: var(--accent-primary-hover);
  --btn-bg-active: var(--accent-primary-active);
  --btn-fg: var(--accent-primary-fg);
  --btn-border: transparent;
  --btn-ring: var(--ring-primary);
  box-shadow: var(--shadow-xs);
}

/* Secondary — violet for AI-flavored actions */
.btn-secondary {
  --btn-bg: var(--accent-secondary);
  --btn-bg-hover: var(--accent-secondary-hover);
  --btn-bg-active: var(--accent-secondary-active);
  --btn-fg: var(--accent-secondary-fg);
  --btn-border: transparent;
  --btn-ring: var(--ring-default);
  box-shadow: var(--shadow-xs);
}

/* Ghost — transparent, subtle hover */
.btn-ghost {
  --btn-bg: transparent;
  --btn-border: transparent;
  --btn-fg: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--alpha-hover);
}

/* Danger */
.btn-danger {
  --btn-bg: var(--role-danger);
  --btn-bg-hover: var(--role-danger-hover);
  --btn-bg-active: var(--danger-700);
  --btn-fg: var(--neutral-0);
  --btn-border: transparent;
  --btn-ring: var(--ring-danger);
}

/* Gradient — signature hero CTA (use sparingly) */
.btn-gradient {
  --btn-border: transparent;
  --btn-fg: var(--neutral-0);
  background: var(--accent-gradient);
  box-shadow: var(--shadow-sm);
}
.btn-gradient:hover:not(:disabled) {
  filter: brightness(1.06);
  background: var(--accent-gradient);
}
.btn-gradient:focus-visible {
  box-shadow: var(--ring-primary);
}

/* Sizes */
.btn-sm { --btn-h: 28px; --btn-px: 10px; font-size: var(--text-sm); }
.btn-md { --btn-h: 34px; --btn-px: 14px; }
.btn-lg { --btn-h: 40px; --btn-px: 18px; font-size: var(--text-md); }

/* Icon-only — square */
.btn-icon {
  --btn-px: 0;
  width: var(--btn-h);
  padding: 0;
}

/* Loading state — disables and swaps content with spinner */
.btn[data-loading="true"] {
  pointer-events: none;
  color: transparent !important;
  position: relative;
}
.btn[data-loading="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  color: var(--btn-fg);
}

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

/* Legacy compatibility — existing markup uses bare "primary/success/danger/small" */
button.primary,
.btn.primary       { /* alias */ --btn-bg: var(--accent-primary); --btn-bg-hover: var(--accent-primary-hover); --btn-fg: var(--accent-primary-fg); --btn-border: transparent; color: var(--accent-primary-fg); background: var(--accent-primary); border-color: transparent; }
button.success,
.btn.success       { --btn-bg: var(--role-success); --btn-bg-hover: var(--success-600); --btn-fg: var(--neutral-0); --btn-border: transparent; color: var(--neutral-0); background: var(--role-success); border-color: transparent; }
button.danger,
.btn.danger        { --btn-bg: var(--role-danger); --btn-bg-hover: var(--role-danger-hover); --btn-fg: var(--neutral-0); --btn-border: transparent; color: var(--neutral-0); background: var(--role-danger); border-color: transparent; }
button.small,
.btn.small         { --btn-h: 28px; --btn-px: 10px; font-size: var(--text-sm); }

/* Apply base reset to legacy bare buttons so they inherit new look */
button:not(.btn):not(.icon-btn):not([class]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1-5);
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    transform var(--duration-instant) var(--ease-out);
}
button:not(.btn):not(.icon-btn):not([class]):hover {
  background: var(--alpha-hover);
}
button:not(.btn):not(.icon-btn):not([class]):active {
  transform: scale(0.98);
}
button:not(.btn):not(.icon-btn):not([class]):focus-visible {
  outline: none;
  box-shadow: var(--ring-default);
}
button:not(.btn):not(.icon-btn):not([class]):disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Icon-only button (header / toolbar) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    transform var(--duration-normal) var(--ease-spring);
}
.icon-btn:hover { background: var(--alpha-hover); color: var(--text-primary); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring-default); }

/* =========================================================================
   Inputs (text, number, password, email, url, search) + select + textarea
   ========================================================================= */
.input,
.select,
.textarea,
input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="search"],
select,
textarea {
  display: block;
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

input[type="text"]:hover,
input[type="number"]:hover,
input[type="password"]:hover,
select:hover,
textarea:hover,
.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus,
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent-secondary);
  box-shadow: var(--ring-default);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--bg-subtle);
  color: var(--text-disabled);
  cursor: not-allowed;
  border-color: var(--border-subtle);
}

textarea {
  min-height: 72px;
  resize: vertical;
  line-height: var(--leading-relaxed);
}

/* Error state */
.input-error,
.input.is-error,
input.is-error,
select.is-error,
textarea.is-error {
  border-color: var(--role-danger);
}
.input-error:focus,
.input.is-error:focus,
input.is-error:focus,
select.is-error:focus,
textarea.is-error:focus {
  box-shadow: var(--ring-danger);
}

/* Select chevron tweak (cross-browser basic) */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* Range slider — use accent color */
input[type="range"] {
  accent-color: var(--accent-primary);
}

/* Checkbox/radio — brand accent */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent-secondary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Color swatch input */
input[type="color"] {
  width: 36px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  cursor: pointer;
}

/* Label / field structure */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.field-label,
label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}
.field-label[data-required="true"]::after,
label[data-required="true"]::after {
  content: "*";
  color: var(--role-danger);
  margin-left: 2px;
}
.field-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
.field-error {
  font-size: var(--text-xs);
  color: var(--role-danger);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* =========================================================================
   Card
   ========================================================================= */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
  transition:
    box-shadow var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
}
.card-outlined {
  box-shadow: none;
  border-color: var(--border-default);
}
.card-subtle {
  background: var(--bg-subtle);
  border-color: transparent;
  box-shadow: none;
}
.card-interactive {
  cursor: pointer;
}
.card-interactive:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-default);
}

.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.card-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin: 0;
}
.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0;
}

/* =========================================================================
   Badge
   ========================================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  white-space: nowrap;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}
.badge-brand    { background: var(--accent-primary-subtle); color: var(--accent-primary); }
.badge-accent   { background: var(--accent-secondary-subtle); color: var(--accent-secondary); }
.badge-success  { background: var(--role-success-bg); color: var(--role-success-fg); }
.badge-warning  { background: var(--role-warning-bg); color: var(--role-warning-fg); }
.badge-danger   { background: var(--role-danger-bg); color: var(--role-danger-fg); }
.badge-info     { background: var(--role-info-bg); color: var(--role-info-fg); }

.badge-solid-success { background: var(--role-success); color: var(--neutral-0); }
.badge-solid-warning { background: var(--role-warning); color: var(--neutral-900); }
.badge-solid-danger  { background: var(--role-danger); color: var(--neutral-0); }

.badge-dot::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* =========================================================================
   Chip — filter / toggle
   ========================================================================= */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.chip[aria-pressed="true"],
.chip.is-selected {
  background: var(--accent-secondary-subtle);
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
}

/* =========================================================================
   Tabs (top nav mode switcher)
   ========================================================================= */
.tabs {
  display: flex;
  gap: var(--space-0-5);
  flex-wrap: wrap;
  align-items: center;
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out);
}
.tab:hover { color: var(--text-primary); background: var(--alpha-hover); }
.tab:focus-visible { outline: none; box-shadow: var(--ring-default); }
.tab.active {
  color: var(--text-primary);
}
.tab.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
}

/* =========================================================================
   Progress bar
   ========================================================================= */
.progress {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent-gradient);
  transition: width var(--duration-slow) var(--ease-out);
}
.progress.is-indeterminate .progress-fill {
  width: 40%;
  animation: progress-indeterminate 1.4s var(--ease-in-out) infinite;
}
@keyframes progress-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* =========================================================================
   Skeleton
   ========================================================================= */
.skeleton {
  background: var(--bg-subtle);
  background-image: linear-gradient(
    90deg,
    var(--bg-subtle) 0%,
    var(--bg-muted) 50%,
    var(--bg-subtle) 100%
  );
  background-size: 600px 100%;
  background-repeat: no-repeat;
  animation: shimmer 1.6s linear infinite;
  border-radius: var(--radius-md);
}
.skeleton-text       { height: 12px; margin: 6px 0; }
.skeleton-title      { height: 16px; width: 60%; margin-bottom: 10px; }
.skeleton-thumb      { width: 80px; height: 80px; border-radius: var(--radius-md); }
.skeleton-card       { height: 120px; border-radius: var(--radius-card); }

/* =========================================================================
   Spinner
   ========================================================================= */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 20px; height: 20px; border-width: 2.5px; }

/* =========================================================================
   Toast notifications
   ========================================================================= */
.toast-viewport {
  position: fixed;
  /* 避让底部 fixed footer */
  bottom: calc(var(--space-5) + var(--footer-h));
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  pointer-events: none;
  max-width: min(380px, calc(100vw - 2 * var(--space-5)));
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: var(--text-base);
  opacity: 0;
  transform: translateX(16px);
  transition: opacity var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-spring);
}
.toast.is-enter { opacity: 1; transform: translateX(0); }
.toast.is-exit  { opacity: 0; transform: translateX(16px); }
.toast-icon {
  flex-shrink: 0;
  margin-top: 1px;
}
.toast-body   { flex: 1; min-width: 0; }
.toast-title  { font-weight: var(--weight-semibold); }
.toast-desc   { color: var(--text-secondary); font-size: var(--text-sm); margin-top: 2px; }
.toast-close {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}
.toast-close:hover { background: var(--alpha-hover); color: var(--text-primary); }

.toast-success { border-left: 3px solid var(--role-success); }
.toast-success .toast-icon { color: var(--role-success); }
.toast-warning { border-left: 3px solid var(--role-warning); }
.toast-warning .toast-icon { color: var(--role-warning); }
.toast-danger  { border-left: 3px solid var(--role-danger); }
.toast-danger  .toast-icon { color: var(--role-danger); }
.toast-info    { border-left: 3px solid var(--role-info); }
.toast-info    .toast-icon { color: var(--role-info); }

/* =========================================================================
   Modal / Dialog
   ========================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: overlay-in var(--duration-normal) var(--ease-out);
}
.modal-overlay.hidden { display: none; }

.modal-dialog {
  background: var(--bg-elevated);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  padding: var(--space-6);
  max-width: min(520px, calc(100vw - 2 * var(--space-4)));
  max-height: calc(100vh - 2 * var(--space-4));
  overflow: auto;
  animation: dialog-in var(--duration-normal) var(--ease-spring);
}
.modal-dialog[data-modal-size="sm"] { max-width: 400px; }
.modal-dialog[data-modal-size="md"] { max-width: 520px; }
.modal-dialog[data-modal-size="lg"] { max-width: 720px; }
.modal-dialog[data-modal-size="xl"] { max-width: 960px; }

.modal-title {
  margin: 0 0 var(--space-2) 0;
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
}
.modal-body  { color: var(--text-secondary); margin-bottom: var(--space-5); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-2); }

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================================================================
   Status dot (SSE connection indicator)
   ========================================================================= */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-tertiary);
}
.status-dot.is-live     { background: var(--role-success); box-shadow: 0 0 0 3px rgb(16 185 129 / 0.2); }
.status-dot.is-connecting { background: var(--role-warning); animation: pulse-soft 1.4s infinite; }
.status-dot.is-offline  { background: var(--role-danger); }

/* =========================================================================
   Tooltip (CSS-only, title attribute augmentation)
   ========================================================================= */
[data-tooltip] {
  position: relative;
}
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--bg-inverse);
  color: var(--text-inverse);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  z-index: var(--z-tooltip);
  animation: tooltip-in var(--duration-fast) var(--ease-out);
}
@keyframes tooltip-in {
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* =========================================================================
   Empty state
   ========================================================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-tertiary);
  gap: var(--space-2);
}
.empty-state .icon {
  width: 32px;
  height: 32px;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}
.empty-state-title {
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}
.empty-state-desc {
  font-size: var(--text-sm);
}

/* =========================================================================
   Step indicator (phase 2 use — defined now for reuse)
   ========================================================================= */
.steps {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.step {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}
.step-dot {
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.step.is-current .step-dot {
  background: var(--accent-primary);
  border-color: transparent;
  color: var(--accent-primary-fg);
  box-shadow: var(--ring-primary);
}
.step.is-current { color: var(--text-primary); font-weight: var(--weight-medium); }
.step.is-done .step-dot {
  background: var(--accent-secondary);
  border-color: transparent;
  color: var(--accent-secondary-fg);
}
.step.is-done { color: var(--text-secondary); }
.step-divider {
  flex: 1;
  height: 1px;
  background: var(--border-default);
}

/* =========================================================================
   Image preview & Dropzone
   ========================================================================= */
.image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-height: 40px;
}
.image-preview:empty {
  display: block;
}

/* Explicit dropzone card rendered by image_upload.js when empty */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1-5);
  width: 100%;
  min-height: 112px;
  padding: var(--space-4) var(--space-3);
  border: 1.5px dashed var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  text-align: center;
  cursor: pointer;
  user-select: none;
  box-sizing: border-box;
  transition: border-color var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}
.dropzone:hover {
  border-color: var(--accent-secondary);
  background: var(--accent-secondary-subtle);
  color: var(--accent-secondary);
}
.dropzone:focus-visible {
  outline: none;
  box-shadow: var(--ring-default);
}
.dropzone-icon {
  width: 26px;
  height: 26px;
  opacity: 0.85;
}
.dropzone-primary {
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: inherit;
  line-height: var(--leading-tight);
}
.dropzone-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  display: inline-flex;
  gap: var(--space-1-5);
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.dropzone-hint kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

/* Active drop state — highlighted */
.image-preview.is-drop {
  outline: none;
}
.image-preview.is-drop .dropzone {
  border-style: solid;
  border-color: var(--accent-secondary);
  background: var(--accent-secondary-subtle);
  color: var(--accent-secondary);
  transform: scale(1.005);
  box-shadow: var(--ring-default);
}
.image-preview.is-drop .dropzone-icon {
  opacity: 1;
}
.image-preview .preview-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.image-preview .preview-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.image-preview img {
  display: block;
  width: 80px;
  height: 80px;
  object-fit: cover;
}
.img-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2px 4px;
  background: rgb(0 0 0 / 0.55);
  color: #fff;
  font-size: var(--text-xs);
  text-align: center;
}
.img-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
  border: 0;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  transition: background var(--duration-fast) var(--ease-out);
}
.img-del:hover { background: var(--role-danger); }

/* Drop zone state — applied to image-preview container on dragover */
.image-preview.is-drop {
  outline: 2px dashed var(--accent-secondary);
  outline-offset: 4px;
  background: var(--accent-secondary-subtle);
}

/* =========================================================================
   Task card (right panel)
   ========================================================================= */
.task-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.task-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
}
.task-card.is-completed {
  border-color: rgb(16 185 129 / 0.35);
}
.task-card.is-failed {
  border-color: rgb(239 68 68 / 0.35);
}

.task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.task-id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
.task-meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
.task-prompt {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.task-thumb {
  width: 100%;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  object-fit: contain;
  max-height: 280px;
}
.task-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-1-5);
}

/* =========================================================================
   Legacy class shims — preserve existing markup
   ========================================================================= */
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2-5);
}
.form-row > label { flex-shrink: 0; }

.hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.status-bar,
#status-bar {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.status-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-3) 0;
}

::placeholder {
  color: var(--text-tertiary);
  opacity: 1;
}

/* Table (usage mode) */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
thead th {
  background: var(--bg-subtle);
  padding: var(--space-2) var(--space-3);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-align: left;
  border-bottom: 1px solid var(--border-default);
}
tbody td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
tbody tr:hover {
  background: var(--alpha-hover);
}
