@font-face {
  font-family: "Rubik";
  src: url("../fonts/rubik-400.ttf") format("truetype");
  font-weight: 400;
}

@font-face {
  font-family: "Rubik";
  src: url("../fonts/rubik-500.ttf") format("truetype");
  font-weight: 500;
}

@font-face {
  font-family: "Rubik";
  src: url("../fonts/rubik-600.ttf") format("truetype");
  font-weight: 600;
}

@font-face {
  font-family: "Rubik";
  src: url("../fonts/rubik-700.ttf") format("truetype");
  font-weight: 700;
}

@font-face {
  font-family: "Rubik";
  src: url("../fonts/rubik-800.ttf") format("truetype");
  font-weight: 800;
}

:root {
  --bg: #050712;
  --bg-soft: rgba(98, 84, 243, 0.1);
  --panel: rgba(10, 14, 30, 0.78);
  --panel-strong: rgba(15, 20, 40, 0.94);
  --panel-muted: rgba(20, 26, 48, 0.82);
  --panel-border: rgba(126, 145, 255, 0.2);
  --line: rgba(126, 145, 255, 0.18);
  --text: #eef2ff;
  --text-dim: #a8b2d6;
  --text-soft: #68749d;
  --primary: #8b5cf6;
  --primary-2: #22d3ee;
  --primary-3: #4f46e5;
  --primary-soft: rgba(139, 92, 246, 0.16);
  --ink: #030712;
  --green: #2dd4bf;
  --amber: #f59e0b;
  --red: #f04438;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  --shadow-tight: 0 18px 46px rgba(0, 0, 0, 0.42);
  --glow: 0 0 34px rgba(34, 211, 238, 0.2), 0 0 46px rgba(139, 92, 246, 0.2);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 0%, rgba(79, 70, 229, 0.34), transparent 28rem),
    radial-gradient(circle at 86% 12%, rgba(34, 211, 238, 0.2), transparent 30rem),
    radial-gradient(circle at 50% 100%, rgba(139, 92, 246, 0.2), transparent 34rem),
    linear-gradient(135deg, #030712 0%, #070b1a 42%, #111827 100%);
  color: var(--text);
  font-family: "Rubik", ui-sans-serif, system-ui, sans-serif;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(126, 145, 255, 0.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(126, 145, 255, 0.075) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 82%);
}

body::after {
  content: "";
  position: fixed;
  width: 42rem;
  height: 42rem;
  right: -18rem;
  top: 14rem;
  pointer-events: none;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.14), transparent 60%);
  filter: blur(14px);
}

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

button {
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

.app-shell {
  width: min(1880px, calc(100vw - 24px));
  margin: 0 auto;
  height: 100vh;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.app-footer {
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
}

.topbar,
.panel,
.preview-dialog,
.settings-dialog {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.1);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, auto) 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 22px;
  margin-bottom: 12px;
  position: sticky;
  top: 8px;
  z-index: 10;
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(15, 23, 42, 0.72)),
    linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(34, 211, 238, 0.08));
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent),
    linear-gradient(135deg, #4f46e5, #8b5cf6 52%, #22d3ee);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.04em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 0 32px rgba(34, 211, 238, 0.24),
    0 0 32px rgba(34, 211, 238, 0.26);
}

.brand-copy h1,
.panel-head h3 {
  margin: 0;
}

.brand-copy h1 {
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(90deg, #ffffff, #c4b5fd 48%, #67e8f9);
  -webkit-background-clip: text;
  color: transparent;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-status,
.top-actions,
.actions-row,
.preview-actions,
.panel-tools,
.history-actions,
.secondary-actions,
.field-label-row,
.results-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-status {
  justify-content: center;
  gap: 12px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  align-content: flex-start;
}

.status-chip,
.status-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.84), rgba(10, 14, 30, 0.92));
  color: var(--text-dim);
  white-space: nowrap;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 12px 28px rgba(0, 0, 0, 0.18);
  font-size: 0.84rem;
}

.status-chip strong,
.status-inline strong {
  color: #fff;
  font-weight: 700;
}

.status-chip.is-warn {
  border-color: rgba(240, 68, 56, 0.34);
  background: rgba(127, 29, 29, 0.2);
  color: #fecaca;
}

.status-chip.is-warn strong {
  color: #fff1f2;
}

.status-chip.is-actionable {
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.status-chip.is-actionable:hover {
  transform: translateY(-1px);
  border-color: rgba(34, 211, 238, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 26px rgba(8, 145, 178, 0.14);
}

.status-chip.is-actionable:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.72);
  outline-offset: 2px;
}

.studio-layout {
  display: grid;
  grid-template-columns: 326px minmax(0, 1fr) 340px;
  gap: 12px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.panel {
  border-radius: var(--radius);
  padding: 14px;
  background:
    linear-gradient(145deg, rgba(15, 23, 42, 0.92), rgba(10, 14, 30, 0.76)),
    linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(34, 211, 238, 0.04));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.settings-panel,
.results-panel,
.history-panel {
  height: 100%;
  overflow: auto;
  min-height: 0;
}

.history-panel {
  min-width: 340px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-subtitle {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.info-callout {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 14px;
  background: rgba(245, 158, 11, 0.08);
  color: #fde68a;
  font-size: 0.78rem;
  line-height: 1.5;
}

.result-retention-note {
  display: block;
}

.panel-head.compact {
  margin-bottom: 10px;
}

.panel-head h3 {
  font-size: 0.98rem;
  letter-spacing: -0.02em;
  color: #f8fafc;
}

.panel-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(34, 211, 238, 0.12));
  color: #c4b5fd;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.field-stack {
  display: grid;
  gap: 9px;
}

.service-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.service-mode-switch .tab-btn {
  width: 100%;
}

.mode-note {
  padding: 12px 14px;
  border: 1px solid rgba(126, 145, 255, 0.16);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.58);
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.55;
}

.field-block {
  display: grid;
  gap: 8px;
}

.field-label {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.field-label-row {
  justify-content: space-between;
}

.model-list {
  display: grid;
  gap: 10px;
}

.model-choice { position: relative; min-width: 0; }
.model-choice .model-card { grid-template-columns: minmax(0, 1fr); min-height: 70px; padding-right: 48px; border-radius: 8px; }
.model-choice .model-card strong { font-size: 14px; overflow-wrap: anywhere; }
.model-choice .model-card.is-active::after { display: none; }
.model-info { position: absolute; right: 12px; top: 20px; width: 28px; height: 28px; border: 1px solid currentColor; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer; font: italic bold 16px Georgia, serif; }
.model-info:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.model-tooltip { display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 100; padding: 12px; border: 1px solid #687080; border-radius: 6px; background: #202327; color: #fff; font-size: 13px; line-height: 1.6; box-shadow: 0 4px 16px #0005; overflow-wrap: anywhere; }
.model-info:hover + .model-tooltip, .model-info:focus-visible + .model-tooltip, .info-open .model-tooltip { display: block; }

.model-card {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(126, 145, 255, 0.18);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.94), rgba(15, 23, 42, 0.76));
  text-align: left;
  color: var(--text);
  position: relative;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

.model-card:hover,
.model-card.is-active {
  border-color: var(--primary);
  box-shadow: var(--glow), 0 16px 34px rgba(0, 0, 0, 0.32);
  transform: translateY(-1px);
}

.model-card.is-active {
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(34, 211, 238, 0.1)),
    rgba(15, 23, 42, 0.92);
}

.model-card.is-active::after {
  content: "";
  position: absolute;
  top: 11px;
  right: 11px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.16), 0 0 22px rgba(45, 212, 191, 0.56);
}

.model-icon {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(103, 232, 249, 0.24);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.16), rgba(139, 92, 246, 0.18));
  color: #cffafe;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.model-copy {
  min-width: 0;
}

.model-card strong,
.model-card small,
.model-badge,
.model-meta span,
.model-meta i {
  display: block;
}

.model-card strong {
  margin: 3px 0;
  font-size: 0.9rem;
}

.model-card small,
.model-card em {
  color: var(--text-dim);
  font-size: 0.78rem;
}

.model-card em {
  margin-top: 4px;
  font-style: normal;
}

.model-meta {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  padding-right: 12px;
  color: var(--text-dim);
  font-size: 0.72rem;
  white-space: nowrap;
}

.model-meta span {
  color: #c4b5fd;
  font-weight: 900;
}

.model-meta i {
  font-style: normal;
  color: #67e8f9;
}

.model-badge {
  color: #67e8f9;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field-hint-inline {
  color: var(--text-dim);
  font-size: 0.74rem;
  font-weight: 600;
}

.api-key-select-block {
  padding: 10px;
  border: 1px solid rgba(126, 145, 255, 0.14);
  border-radius: 14px;
  background: rgba(3, 7, 18, 0.28);
}

.api-key-select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 8px;
}

.api-key-select-row select {
  min-width: 0;
}

.field-block.is-disabled {
  opacity: 0.58;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid rgba(126, 145, 255, 0.2);
  border-radius: 13px;
  background: rgba(3, 7, 18, 0.62);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea {
  resize: vertical;
  min-height: 112px;
  line-height: 1.55;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.16), 0 0 30px rgba(34, 211, 238, 0.13);
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.prompt-chips button {
  min-height: 28px;
  border: 1px solid rgba(126, 145, 255, 0.18);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.68);
  color: var(--text-dim);
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.prompt-chips button:hover {
  border-color: rgba(34, 211, 238, 0.42);
  color: #67e8f9;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(34, 211, 238, 0.1));
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toggle-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px 14px;
  border: 1px solid rgba(126, 145, 255, 0.18);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.68);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, background 140ms ease;
}

.toggle-card:hover {
  border-color: rgba(34, 211, 238, 0.42);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.toggle-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--green);
}

.toggle-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.toggle-copy strong {
  color: var(--text);
  font-size: 0.84rem;
}

.toggle-copy small {
  color: var(--text-dim);
  font-size: 0.76rem;
  line-height: 1.45;
}

.upload-zone {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 88px;
  border: 1px dashed rgba(34, 211, 238, 0.3);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(34, 211, 238, 0.12), transparent 60%),
    linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(15, 23, 42, 0.68));
  color: var(--text-dim);
  text-align: center;
  padding: 12px;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.upload-zone.is-dragging,
.upload-zone:hover {
  border-color: var(--primary-2);
  background:
    radial-gradient(circle at 50% 0%, rgba(34, 211, 238, 0.18), transparent 64%),
    rgba(15, 23, 42, 0.82);
  transform: translateY(-1px);
}

.upload-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #8b5cf6, #22d3ee);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  font-weight: 800;
}

.thumb-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 8px;
}

.reference-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.actions-stack {
  position: sticky;
  bottom: -12px;
  z-index: 3;
  display: grid;
  gap: 8px;
  padding: 10px 0 12px;
  background: linear-gradient(180deg, rgba(10, 14, 30, 0), rgba(10, 14, 30, 0.96) 32%);
  backdrop-filter: blur(12px);
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.82);
}

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

.thumb-tools {
  position: absolute;
  top: 6px;
  right: 6px;
  left: 6px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.thumb-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(6, 182, 212, 0.92);
  color: #eff6ff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.thumb-mask-btn {
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(3, 7, 18, 0.84);
  color: #e2e8f0;
  font-size: 0.7rem;
  font-weight: 700;
}

.thumb-mask-btn:hover {
  border-color: rgba(34, 211, 238, 0.48);
  color: #67e8f9;
}

.thumb button,
.icon-btn {
  border: 0;
  border-radius: 999px;
  background: rgba(3, 7, 18, 0.78);
  color: #fff;
}

.thumb button {
  width: 22px;
  height: 22px;
}

.ghost-btn,
.primary-btn,
.tab-btn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid rgba(126, 145, 255, 0.2);
  font-size: 0.84rem;
  font-weight: 700;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

.ghost-btn {
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
}

.ghost-btn.recharge-cta {
  border-color: rgba(240, 68, 56, 0.36);
  background: rgba(127, 29, 29, 0.2);
  color: #fecaca;
}

.ghost-btn.create-key-cta {
  border-color: rgba(34, 197, 94, 0.34);
  background: rgba(20, 83, 45, 0.22);
  color: #bbf7d0;
}

.ghost-btn.auth-cta {
  border-color: rgba(56, 189, 248, 0.36);
  background: rgba(12, 74, 110, 0.24);
  color: #bae6fd;
}

.ghost-btn.create-key-cta:hover {
  border-color: rgba(74, 222, 128, 0.52);
  background: rgba(20, 83, 45, 0.34);
  box-shadow: 0 10px 26px rgba(34, 197, 94, 0.14);
}

.ghost-btn.auth-cta:hover {
  border-color: rgba(125, 211, 252, 0.56);
  background: rgba(12, 74, 110, 0.34);
  box-shadow: 0 10px 26px rgba(56, 189, 248, 0.14);
}

.ghost-btn.recharge-cta:hover {
  border-color: rgba(248, 113, 113, 0.52);
  background: rgba(127, 29, 29, 0.32);
  box-shadow: 0 10px 26px rgba(240, 68, 56, 0.14);
}

.ghost-btn:hover,
.tab-btn:hover {
  border-color: rgba(34, 211, 238, 0.38);
  background: rgba(20, 26, 48, 0.94);
  box-shadow: 0 10px 26px rgba(34, 211, 238, 0.08);
}

.ghost-btn:disabled,
.primary-btn:disabled,
.tab-btn:disabled,
.thumb-mask-btn:disabled {
  opacity: 0.46;
  cursor: not-allowed;
  box-shadow: none;
}

.ghost-btn.tiny {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.ghost-btn.small {
  min-height: 28px;
  padding: 0 9px;
  font-size: 0.76rem;
}

.primary-btn {
  background: linear-gradient(135deg, #4f46e5, #8b5cf6 48%, #22d3ee);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 18px 34px rgba(79, 70, 229, 0.28), 0 0 28px rgba(34, 211, 238, 0.18);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 42px rgba(79, 70, 229, 0.36), 0 0 38px rgba(34, 211, 238, 0.26);
}

.wide {
  width: 100%;
}

.secondary-actions {
  width: 100%;
}

.secondary-actions .ghost-btn {
  flex: 1;
}

.results-panel {
  display: flex;
  flex-direction: column;
}

.results-toolbar {
  justify-content: space-between;
  margin-bottom: 10px;
}

.tab-group {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-dim);
}

.tab-btn.is-active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(34, 211, 238, 0.12));
  border-color: rgba(34, 211, 238, 0.36);
  color: #67e8f9;
  font-weight: 600;
}

.progress-shell {
  height: 7px;
  border-radius: 999px;
  background: rgba(126, 145, 255, 0.12);
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4f46e5, #8b5cf6, #22d3ee);
  transition: width 180ms ease;
}

.stage-grid {
  flex: 1;
  align-content: start;
  grid-auto-rows: min-content;
  min-height: 0;
  overflow: auto;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(144px, 1fr));
  gap: 10px;
}

.result-card,
.task-card {
  border: 1px solid rgba(126, 145, 255, 0.16);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.result-card {
  position: relative;
  padding: 8px;
  overflow: hidden;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.result-card:hover {
  border-color: rgba(34, 211, 238, 0.32);
  box-shadow: var(--shadow-tight);
  transform: translateY(-2px);
}

.result-media,
.task-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 15px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.16), rgba(34, 211, 238, 0.08)),
    #080d1c;
}

.result-media {
  cursor: zoom-in;
  position: relative;
}

.task-card:has(.task-media img) .task-media {
  cursor: zoom-in;
}

.zoom-cue {
  position: absolute;
  right: 8px;
  bottom: 8px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(3, 7, 18, 0.76);
  color: #e0f2fe;
  padding: 0 9px;
  font-size: 0.72rem;
  font-weight: 800;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.result-media:hover .zoom-cue,
.task-media:hover .zoom-cue {
  opacity: 1;
  transform: translateY(0);
}

.result-media img,
.task-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.task-media img {
  object-fit: contain;
}

.task-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  isolation: isolate;
  color: var(--text);
  text-align: center;
}

.task-loading::before {
  content: "";
  position: absolute;
  inset: -25%;
  z-index: -2;
  background:
    conic-gradient(from 120deg, rgba(34, 211, 238, 0.06), rgba(139, 92, 246, 0.38), rgba(34, 211, 238, 0.08), rgba(139, 92, 246, 0.28), rgba(34, 211, 238, 0.06));
  animation: loadingSpin 2.6s linear infinite;
}

.task-loading::after {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 35%, rgba(34, 211, 238, 0.16), transparent 38%),
    rgba(5, 8, 20, 0.9);
}

.loading-orb {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 30%, #ffffff, rgba(255, 255, 255, 0.15) 18%, transparent 30%),
    linear-gradient(135deg, #8b5cf6, #22d3ee);
  box-shadow: 0 0 30px rgba(34, 211, 238, 0.42), 0 0 52px rgba(139, 92, 246, 0.28);
  animation: loadingPulse 1.35s ease-in-out infinite;
}

.loading-grid {
  position: absolute;
  inset: 0;
  opacity: 0.36;
  background-image:
    linear-gradient(rgba(103, 232, 249, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 232, 249, 0.12) 1px, transparent 1px);
  background-size: 18px 18px;
  mask-image: radial-gradient(circle at center, black, transparent 70%);
}

.task-loading strong,
.task-loading small {
  position: relative;
  z-index: 1;
}

.task-loading strong {
  font-size: 0.84rem;
}

.task-loading small {
  color: var(--text-dim);
  font-size: 0.74rem;
}

.task-loading[data-state="err"] .loading-orb {
  background: linear-gradient(135deg, #f87171, #fb923c);
  box-shadow: 0 0 30px rgba(248, 113, 113, 0.34);
  animation: none;
}

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

@keyframes loadingPulse {
  0%, 100% { transform: scale(0.9); opacity: 0.72; }
  50% { transform: scale(1.06); opacity: 1; }
}

.result-meta {
  margin-top: 8px;
  display: grid;
  gap: 3px;
}

.result-meta strong,
.task-head strong {
  font-size: 0.84rem;
}

.result-meta small,
.task-head small,
.task-body p {
  color: var(--text-dim);
}

.result-actions {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 58px;
  display: flex;
  justify-content: center;
  gap: 6px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.result-card:hover .result-actions {
  opacity: 1;
  transform: translateY(0);
}

.result-actions button {
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(3, 7, 18, 0.84);
  color: #fff;
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

.history-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.history-actions {
  margin-bottom: 10px;
}

.history-head-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(34, 211, 238, 0.12));
  color: #67e8f9;
  font-size: 0.8rem;
  font-weight: 700;
}

.history-list {
  overflow: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

.empty-state {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  min-height: 220px;
  border: 1px dashed rgba(34, 211, 238, 0.26);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 28%, rgba(34, 211, 238, 0.12), transparent 12rem),
    linear-gradient(180deg, rgba(15, 23, 42, 0.84), rgba(10, 14, 30, 0.66));
  color: var(--text-dim);
  text-align: center;
  padding: 20px;
}

.results-grid > .empty-state {
  grid-column: 1 / -1;
  min-height: calc(100vh - 244px);
}

.empty-results {
  isolation: isolate;
}

.empty-results > :not(.empty-gallery) {
  position: relative;
  z-index: 1;
}

.empty-gallery {
  position: absolute;
  inset: 24px;
  display: grid;
  grid-template-columns: repeat(6, minmax(80px, 1fr));
  grid-auto-rows: minmax(76px, 1fr);
  gap: 10px;
  opacity: 0.54;
  pointer-events: none;
}

.empty-gallery span {
  border-radius: 18px;
  border: 1px solid rgba(126, 145, 255, 0.16);
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.58), rgba(10, 14, 30, 0.34)),
    linear-gradient(135deg, rgba(139, 92, 246, 0.16), rgba(34, 211, 238, 0.08) 46%, rgba(79, 70, 229, 0.12));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.empty-gallery span:nth-child(3n) {
  aspect-ratio: 4 / 5;
}

.empty-gallery span:nth-child(4n) {
  opacity: 0.62;
}

.history-list > .empty-state {
  min-height: calc(100vh - 246px);
}

.empty-art {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(34, 211, 238, 0.1)),
    rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(126, 145, 255, 0.22);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28), 0 0 28px rgba(34, 211, 238, 0.12);
}

.empty-art span {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background:
    linear-gradient(135deg, #4f46e5, #8b5cf6, #22d3ee);
  box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.2);
}

.empty-state strong {
  color: var(--text);
  font-size: 0.98rem;
  letter-spacing: -0.02em;
}

.empty-state p {
  margin: 0;
  max-width: 320px;
  line-height: 1.6;
  font-size: 0.84rem;
}

.task-card {
  position: relative;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  width: 100%;
  min-width: 0;
  padding: 12px;
  overflow: hidden;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.task-card:hover {
  transform: translateY(-1px);
  border-color: rgba(34, 211, 238, 0.32);
  box-shadow: var(--shadow-tight);
}

.task-media {
  width: 88px;
  min-width: 88px;
  justify-self: start;
}

.task-body {
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 8px;
  min-width: 0;
  min-height: 88px;
}

.task-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  align-items: flex-start;
}

.task-head strong,
.task-head small,
.task-body p,
.task-actions {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.task-head strong,
.task-head small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-head strong {
  font-size: 0.92rem;
  line-height: 1.2;
}

.task-head small {
  font-size: 0.76rem;
  line-height: 1.2;
}

.task-body p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-actions {
  display: grid;
  grid-template-columns: repeat(var(--action-count, 1), minmax(0, 1fr));
  gap: 6px;
  align-self: end;
  margin-top: auto;
}

.task-actions .ghost-btn,
.task-actions.is-even .ghost-btn {
  width: 100%;
  min-width: 0;
}

.task-select {
  width: 18px;
  height: 18px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(34, 211, 238, 0.12));
  color: #67e8f9;
  font-size: 0.84rem;
  font-weight: 600;
}

.status-dot {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.status-text {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #b5bdd3;
}

.status-dot[data-state="run"]::before { background: #f1ad34; }
.status-dot[data-state="ok"]::before { background: var(--green); }
.status-dot[data-state="err"]::before { background: var(--red); }

.status-dot.has-detail {
  cursor: help;
}

.task-error-tooltip {
  position: fixed;
  z-index: 80;
  display: none;
  width: min(360px, calc(100vw - 24px));
  max-height: min(280px, calc(100vh - 24px));
  overflow: auto;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(126, 145, 255, 0.28);
  background: rgba(10, 14, 30, 0.96);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.34);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.task-error-tooltip.is-visible {
  display: block;
}

.task-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin-left: 8px;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(3, 7, 18, 0.68);
  backdrop-filter: blur(10px);
  z-index: 40;
  padding: 20px;
}

.preview-dialog,
.mask-editor-dialog,
.settings-dialog,
.template-dialog,
.log-dialog {
  width: min(960px, calc(100vw - 40px));
  border-radius: 18px;
  padding: 16px;
  background:
    linear-gradient(145deg, rgba(15, 23, 42, 0.96), rgba(10, 14, 30, 0.86)),
    linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(34, 211, 238, 0.06));
}

.disclaimer-dialog {
  width: min(620px, calc(100vw - 32px));
}

.disclaimer-copy p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.84rem;
  line-height: 1.7;
}

.mask-editor-dialog {
  width: min(980px, calc(100vw - 40px));
  display: grid;
  gap: 12px;
}

.mask-editor-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.mask-editor-meta strong {
  color: var(--text);
  font-size: 0.88rem;
}

.mask-editor-stage {
  min-height: 360px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 18%, rgba(34, 211, 238, 0.12), transparent 16rem),
    rgba(3, 7, 18, 0.58);
  padding: 12px;
}

.mask-editor-canvas {
  position: relative;
  width: fit-content;
  max-width: 100%;
  max-height: 72vh;
  user-select: none;
}

.mask-editor-canvas img {
  display: block;
  max-width: min(860px, calc(100vw - 120px));
  max-height: 68vh;
  border-radius: 14px;
  object-fit: contain;
}

.mask-overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

.mask-rect {
  position: absolute;
  border: 2px solid rgba(34, 211, 238, 0.96);
  background: rgba(34, 211, 238, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  border-radius: 10px;
}

.mask-rect.is-draft {
  border-style: dashed;
  background: rgba(129, 140, 248, 0.16);
}

.mask-rect-remove {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 800;
}

.mask-editor-help {
  color: var(--text-dim);
  font-size: 0.8rem;
  line-height: 1.55;
}

.template-dialog {
  width: min(1040px, calc(100vw - 40px));
  max-height: min(760px, calc(100vh - 40px));
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.template-search {
  margin-bottom: 12px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.template-card {
  display: grid;
  gap: 10px;
  align-content: start;
  border: 1px solid rgba(126, 145, 255, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(17, 24, 39, 0.9), rgba(10, 14, 30, 0.78));
  padding: 12px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.template-card:hover {
  border-color: rgba(34, 211, 238, 0.34);
  box-shadow: var(--shadow-tight);
}

.template-card-head {
  display: grid;
  gap: 5px;
}

.template-card-head strong {
  font-size: 0.92rem;
}

.template-card-head span {
  width: fit-content;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(34, 211, 238, 0.12));
  color: #67e8f9;
  padding: 0 8px;
  font-size: 0.72rem;
  font-weight: 800;
}

.template-card p {
  margin: 0;
  min-height: 64px;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.55;
}

.log-dialog {
  width: min(1040px, calc(100vw - 40px));
  max-height: min(760px, calc(100vh - 40px));
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.log-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.log-output {
  min-height: 420px;
  margin: 0;
  overflow: auto;
  border: 1px solid rgba(216, 180, 254, 0.26);
  border-radius: 14px;
  background:
    radial-gradient(circle at 0 0, rgba(34, 211, 238, 0.1), transparent 18rem),
    #030712;
  color: #dbeafe;
  padding: 14px;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.preview-stage {
  margin: 14px 0;
  min-height: 300px;
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 20%, rgba(34, 211, 238, 0.12), transparent 18rem),
    rgba(3, 7, 18, 0.58);
}

.preview-stage img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.preview-meta-bar {
  display: flex;
  justify-content: center;
  margin: -4px 0 10px;
}

.preview-count {
  min-width: 74px;
  text-align: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(126, 145, 255, 0.24);
  background: rgba(15, 23, 42, 0.78);
  color: var(--text-dim);
  font-size: 0.84rem;
  font-weight: 600;
}

.preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(126, 145, 255, 0.3);
  border-radius: 999px;
  background: rgba(3, 7, 18, 0.82);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.9rem;
  line-height: 1;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.36);
}

.preview-nav:hover {
  background: rgba(79, 70, 229, 0.9);
}

.preview-nav:disabled {
  opacity: 0.34;
  cursor: default;
}

.preview-prev {
  left: 18px;
}

.preview-next {
  right: 18px;
}

.icon-btn {
  width: 34px;
  height: 34px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.96), rgba(8, 145, 178, 0.92));
  color: #fff;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42), 0 0 28px rgba(34, 211, 238, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1320px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .studio-layout {
    grid-template-columns: 300px minmax(0, 1fr);
    flex: none;
  }

  .history-panel {
    grid-column: 1 / -1;
    min-height: auto;
    height: auto;
    overflow: visible;
  }

  .history-list {
    max-height: none;
  }

  .history-panel .task-card {
    grid-template-columns: 96px minmax(0, 1fr);
    grid-template-areas:
      "media main"
      "actions actions";
    min-height: 0;
    padding: 10px;
    column-gap: 12px;
    row-gap: 10px;
  }

  .history-panel .task-media {
    width: 96px;
    min-width: 96px;
  }

  .history-panel .loading-orb {
    width: 46px;
    height: 46px;
  }

  .history-panel .task-body {
    min-height: 0;
    gap: 7px;
  }

  .history-panel .task-head strong {
    font-size: 0.95rem;
  }

  .history-panel .task-prompt {
    padding: 8px 9px;
    font-size: 0.8rem;
    line-height: 1.46;
    -webkit-line-clamp: 3;
  }

  .history-panel .task-actions {
    display: grid;
  }
}

@media (max-width: 920px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body {
    -webkit-overflow-scrolling: touch;
  }

  .app-shell {
    width: 100%;
    min-height: 100dvh;
    height: auto;
    padding: 10px 10px 16px;
    gap: 10px;
    overflow: visible;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
    margin-bottom: 0;
    position: static;
  }

  .top-status {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .top-actions {
    justify-content: flex-start;
    gap: 8px;
  }

  .top-actions .ghost-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  .status-chip {
    min-height: 38px;
    padding: 0 12px;
    font-size: 0.8rem;
  }

  .studio-layout {
    grid-template-columns: 1fr;
    flex: none;
    min-height: auto;
  }

  .settings-panel,
  .results-panel,
  .history-panel {
    height: auto;
    min-height: auto;
    max-height: none;
    overflow: visible;
  }

  .history-panel {
    min-width: 0;
  }

  .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-card {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .task-media {
    width: 76px;
    min-width: 76px;
  }

  .field-row,
  .secondary-actions {
    grid-template-columns: 1fr;
  }

  .secondary-actions {
    display: grid;
  }

  .results-toolbar,
  .panel-head,
  .history-actions {
    flex-wrap: wrap;
  }

  .history-list {
    max-height: none;
  }

  .actions-stack {
    position: static;
    padding: 4px 0 0;
    background: transparent;
    backdrop-filter: none;
  }

  .panel {
    padding: 12px;
  }

  textarea {
    min-height: 100px;
  }

  .preview-prev {
    left: 10px;
  }

  .preview-next {
    right: 10px;
  }
}

@media (max-width: 640px) {
  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    font-size: 0.92rem;
  }

  .brand-copy h1 {
    font-size: 1.08rem;
  }

  .eyebrow {
    font-size: 0.68rem;
  }

  .top-actions .ghost-btn,
  .status-chip {
    flex: 1 1 100%;
  }

  .results-grid,
  .thumb-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-card {
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .task-media {
    width: 68px;
    min-width: 68px;
  }

  .preview-dialog,
  .settings-dialog {
    width: min(100vw - 20px, 100%);
    max-height: min(88vh, 100%);
    padding: 14px;
  }

  .preview-nav {
    width: 40px;
    height: 40px;
    font-size: 1.6rem;
  }

  .toast {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }
}

/* Refreshed history cards */
.task-card {
  position: relative;
  grid-template-columns: 96px minmax(0, 1fr);
  grid-template-areas:
    "media main"
    "actions actions";
  column-gap: 12px;
  row-gap: 10px;
  align-items: start;
  padding: 10px;
  min-height: 0;
  border-radius: 14px;
  border-color: rgba(148, 163, 184, 0.18);
  background:
    linear-gradient(145deg, rgba(17, 24, 39, 0.92), rgba(15, 23, 42, 0.78)),
    radial-gradient(circle at 0 0, rgba(34, 211, 238, 0.13), transparent 12rem);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 12px 30px rgba(2, 6, 23, 0.2);
}

.task-card::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px 0;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #22d3ee, #8b5cf6);
  opacity: 0.62;
}

.task-card[data-state="ok"]::before {
  background: linear-gradient(180deg, #34d399, #22d3ee);
}

.task-card[data-state="run"]::before {
  background: linear-gradient(180deg, #fbbf24, #22d3ee);
}

.task-card[data-state="err"]::before {
  background: linear-gradient(180deg, #fb7185, #f97316);
}

.task-card:hover {
  transform: translateY(-2px);
  border-color: rgba(125, 211, 252, 0.36);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 18px 42px rgba(2, 6, 23, 0.3);
}

.task-media {
  grid-area: media;
  width: 96px;
  min-width: 96px;
  align-self: start;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.task-card:has(.task-media img) .task-media img {
  transition: transform 220ms ease, filter 220ms ease;
}

.task-card:hover .task-media img {
  transform: scale(1.035);
  filter: saturate(1.06) contrast(1.03);
}

.task-body {
  grid-area: main;
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  gap: 7px;
  min-width: 0;
  align-content: start;
}

.task-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.task-title {
  min-width: 0;
}

.task-kicker {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-height: 18px;
  margin-bottom: 3px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.1);
  color: #a5f3fc;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.task-head strong {
  color: #f8fafc;
  font-size: 0.95rem;
}

.task-status-pill.status-dot {
  min-height: 24px;
  max-width: 86px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.11);
  color: #dbeafe;
  font-size: 0.72rem;
  font-weight: 800;
}

.task-status-pill.status-dot[data-state="ok"] {
  background: rgba(16, 185, 129, 0.13);
  color: #bbf7d0;
}

.task-status-pill.status-dot[data-state="run"] {
  background: rgba(245, 158, 11, 0.14);
  color: #fde68a;
}

.task-status-pill.status-dot[data-state="err"] {
  background: rgba(244, 63, 94, 0.15);
  color: #fecdd3;
}

.task-status-pill.status-dot::before {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
}

.task-prompt {
  margin: 0;
  padding: 8px 9px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(2, 6, 23, 0.28);
  color: #d8e2f1;
  font-size: 0.8rem;
  line-height: 1.46;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.task-meta-row span {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.1);
  color: #b6c3d6;
  font-size: 0.7rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-status-line.status-dot {
  max-width: 100%;
  font-size: 0.74rem;
  color: #aebbd0;
}

.task-status-line .status-text {
  max-width: 100%;
}

.task-check.task-select-control {
  position: absolute;
  z-index: 3;
  top: 17px;
  left: 17px;
  width: 24px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
}

.task-select-control input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.task-select-control span {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  border: 1px solid rgba(226, 232, 240, 0.74);
  background: rgba(15, 23, 42, 0.62);
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.task-select-control input:checked + span {
  border-color: #67e8f9;
  background:
    linear-gradient(135deg, #22d3ee, #8b5cf6);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.16);
}

.task-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 6px;
  align-self: stretch;
  min-width: 0;
  width: 100%;
  margin-top: 2px;
}

.task-actions .ghost-btn {
  width: 100%;
  min-width: 0;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.62);
  border-color: rgba(148, 163, 184, 0.17);
  color: #dbeafe;
  font-size: 0.72rem;
  font-weight: 800;
}

.task-actions .ghost-btn:hover {
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(103, 232, 249, 0.28);
}

.task-actions .ghost-btn:last-child:nth-child(odd) {
  grid-column: auto;
}

.history-panel .task-card {
  grid-template-columns: 96px minmax(0, 1fr);
  grid-template-areas: "media main";
  min-height: 126px;
  padding: 8px 10px;
  column-gap: 10px;
  row-gap: 0;
}

.history-panel .task-media {
  width: 96px;
  min-width: 96px;
}

.history-panel .task-check.task-select-control {
  top: 13px;
  bottom: auto;
  left: 13px;
  width: 22px;
  height: 22px;
}

.history-panel .loading-orb {
  width: 36px;
  height: 36px;
}

.history-panel .task-body {
  min-height: 72px;
  gap: 5px;
}

.history-panel .task-head {
  gap: 6px;
}

.history-panel .task-head strong {
  font-size: 0.86rem;
}

.history-panel .task-kicker {
  min-height: 17px;
  padding: 0 6px;
  font-size: 0.64rem;
}

.history-panel .task-status-pill.status-dot {
  min-height: 22px;
  max-width: 68px;
  padding: 0 7px;
  font-size: 0.68rem;
}

.history-panel .task-prompt {
  padding: 6px 7px;
  font-size: 0.72rem;
  line-height: 1.32;
  -webkit-line-clamp: 1;
}

.history-panel .task-meta-row {
  flex-wrap: nowrap;
  overflow: hidden;
}

.history-panel .task-actions {
  display: none;
}

@media (max-width: 900px) {
  .task-card {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .task-media {
    width: 88px;
    min-width: 88px;
  }
}

@media (max-width: 640px) {
  .task-card {
    grid-template-columns: 84px minmax(0, 1fr);
    padding: 8px;
  }

  .task-media {
    width: 84px;
    min-width: 84px;
  }

  .task-check.task-select-control {
    top: 13px;
    left: 13px;
  }

  .task-prompt {
    -webkit-line-clamp: 2;
  }

  .task-status-line.status-dot {
    display: none;
  }
}

.image-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: 10px;
  color: #cbd5e1;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.82), rgba(2, 6, 23, 0.78)),
    #080d1c;
}

.image-placeholder img {
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 12px;
  object-fit: cover;
  opacity: 0.86;
  background: transparent;
}

.image-placeholder strong {
  font-size: 0.76rem;
  line-height: 1.15;
}

.image-placeholder small {
  max-width: 8.5em;
  color: #94a3b8;
  font-size: 0.64rem;
  line-height: 1.25;
}

.task-media.is-unavailable,
.result-media.is-unavailable {
  cursor: default;
}
