:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --panel: #fffdfa;
  --panel-strong: #f0ece2;
  --line: #ddd6c8;
  --line-strong: #c7bca7;
  --text: #24211d;
  --muted: #746d61;
  --soft: #9b907e;
  --accent: #a27a2b;
  --accent-dark: #7c5b1c;
  --success: #28715a;
  --warning: #9a6526;
  --danger: #9b3d32;
  --shadow: 0 18px 42px rgba(44, 37, 25, 0.1);
  --radius: 8px;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    linear-gradient(90deg, rgba(36, 33, 29, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(36, 33, 29, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 250, 0.86);
  backdrop-filter: blur(18px);
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--panel);
  background: #2a261f;
  font-size: 12px;
  letter-spacing: 0;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.08em;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.25;
}

h2 {
  font-size: 24px;
  line-height: 1.16;
}

h3 {
  font-size: 17px;
  line-height: 1.25;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.runtime-pill,
.module-stats,
.task-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 250, 0.78);
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(40, 113, 90, 0.12);
}

.icon-button {
  width: 38px;
  height: 38px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  display: grid;
  place-items: center;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: #ffffff;
}

.topbar-action-button {
  min-height: 38px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 850;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.topbar-action-button:hover {
  border-color: var(--line-strong);
  background: #ffffff;
}

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

.topbar-action-button.danger:hover {
  border-color: rgba(155, 61, 50, 0.32);
  background: #fff7f4;
}

.topbar-action-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fffdfa;
  background: var(--accent);
  font-size: 11px;
  line-height: 1;
}

.topbar-count.alert {
  background: var(--danger);
}

.icon-button:active,
.topbar-action-button:active,
.primary-button:active,
.secondary-button:active,
.stepper button:active {
  transform: translateY(1px) scale(0.99);
}

.icon-button svg,
.upload-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.plain {
  background: transparent;
}

.task-count {
  position: absolute;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  top: -7px;
  right: -7px;
  color: #fffdfa;
  background: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

.module-rail {
  padding: 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 250, 0.54);
  min-height: 0;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.rail-heading {
  margin-bottom: 16px;
}

.module-list {
  display: grid;
  gap: 8px;
}

.module-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 8px;
  color: var(--text);
  background: rgba(255, 253, 250, 0.76);
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.module-item strong {
  display: block;
  font-size: 14px;
}

.module-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.module-item small {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  color: var(--soft);
  font-size: 11px;
}

.module-item.active {
  border-color: rgba(162, 122, 43, 0.5);
  background: #fff9ec;
}

.module-item:not(.disabled):hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.module-item.disabled {
  opacity: 0.62;
}

.main-panel {
  padding: 22px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.module-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.module-stats {
  flex-wrap: wrap;
  border-radius: var(--radius);
}

.module-stats span + span {
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 340px);
  grid-template-areas:
    "operation settings"
    "upload create";
  gap: 16px;
  align-items: stretch;
}

.work-column {
  display: contents;
}

.settings-panel {
  display: contents;
}

.tool-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 250, 0.82);
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tool-section.compact {
  padding: 16px;
}

.operation-section {
  grid-area: operation;
}

.upload-section {
  grid-area: upload;
}

.task-settings-section {
  grid-area: settings;
}

.task-create-section {
  grid-area: create;
}

.section-title {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.section-title p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  margin-top: 4px;
}

.step-index {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: #fffdfa;
  background: var(--text);
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

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

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

.field-block > span,
.quality-field legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

select,
input[type="number"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffefa;
  color: var(--text);
  padding: 0 12px;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

select:focus,
input[type="number"]:focus {
  border-color: rgba(162, 122, 43, 0.66);
  box-shadow: 0 0 0 4px rgba(162, 122, 43, 0.12);
}

.quality-field {
  border: 0;
  padding: 0;
  margin: 0;
  grid-column: 1 / -1;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
}

.segment-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment-option span {
  min-height: 48px;
  border-radius: 6px;
  display: grid;
  gap: 2px;
  place-items: center;
  color: var(--muted);
  line-height: 1.15;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.segment-option b {
  font-size: 13px;
  font-weight: 850;
}

.segment-option small {
  font-size: 11px;
  font-weight: 700;
}

.segment-option input:checked + span {
  background: #fffdfa;
  color: var(--accent-dark);
  box-shadow: 0 5px 16px rgba(44, 37, 25, 0.1);
}

.quality-note {
  display: grid;
  gap: 5px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(162, 122, 43, 0.22);
  border-radius: var(--radius);
  background: #fff9ec;
}

.quality-note span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.quality-note strong {
  font-size: 14px;
}

.quality-note p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.quality-limit-list {
  display: grid;
  gap: 6px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.quality-limit-list li {
  display: grid;
  grid-template-columns: minmax(64px, auto) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  min-height: 24px;
  padding: 6px 8px;
  border: 1px solid rgba(162, 122, 43, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.62);
}

.quality-limit-list li span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.quality-limit-list li strong {
  min-width: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
  gap: 14px;
  flex: 1;
}

.upload-channel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.upload-zone {
  min-height: 190px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fffefa;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  padding: 18px;
  text-align: center;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: #fff9ec;
}

.upload-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  background: rgba(162, 122, 43, 0.1);
}

.upload-title {
  font-weight: 800;
}

.upload-meta {
  color: var(--muted);
  font-size: 13px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-alert {
  margin-top: 12px;
  border: 1px solid rgba(154, 101, 38, 0.22);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--warning);
  background: rgba(154, 101, 38, 0.08);
  font-size: 13px;
  line-height: 1.5;
}

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

.upload-preview-grid.single {
  grid-template-columns: minmax(0, 164px);
}

.clear-channel-button {
  justify-self: start;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdfa;
  color: var(--muted);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease, transform 180ms ease;
}

.clear-channel-button:hover {
  border-color: rgba(154, 60, 38, 0.3);
  color: var(--text);
  background: #fff8f2;
}

.clear-channel-button:active {
  transform: translateY(1px);
}

.preview-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fffdfa;
  min-width: 0;
  position: relative;
}

.preview-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  background: var(--panel-strong);
}

.preview-card span {
  display: block;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-remove-button {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(42, 38, 32, 0.14);
  border-radius: 999px;
  background: rgba(255, 253, 250, 0.92);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(56, 47, 32, 0.12);
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.preview-remove-button:hover {
  border-color: rgba(154, 60, 38, 0.34);
  background: #fff7f2;
}

.preview-remove-button:active {
  transform: translateY(1px) scale(0.98);
}

.stepper {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 6px;
}

.stepper button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdfa;
  color: var(--text);
  font-size: 20px;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.summary-stack {
  display: grid;
  gap: 1px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.task-settings-section .summary-stack {
  margin-top: auto;
}

.summary-stack div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  background: rgba(255, 253, 250, 0.78);
}

.summary-stack span {
  color: var(--muted);
  font-size: 13px;
}

.summary-stack strong {
  font-size: 13px;
  text-align: right;
}

.action-stack {
  display: grid;
  gap: 8px;
}

.task-create-section .action-stack {
  margin-top: auto;
}

.create-checklist {
  display: grid;
  gap: 10px;
  margin-top: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 250, 0.62);
}

.create-checklist div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(218, 211, 196, 0.72);
}

.create-checklist div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.create-checklist span {
  color: var(--muted);
  font-size: 13px;
}

.create-checklist strong {
  font-size: 13px;
  text-align: right;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 800;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.primary-button {
  border: 1px solid var(--accent-dark);
  color: #fffdfa;
  background: var(--accent-dark);
}

.primary-button:hover:not(:disabled) {
  background: #644813;
}

.primary-button:disabled {
  border-color: var(--line);
  color: var(--soft);
  background: var(--panel-strong);
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: #fffdfa;
  padding: 0 14px;
  width: auto;
}

.secondary-button.full {
  width: 100%;
}

.secondary-button:hover {
  border-color: var(--line-strong);
}

.bottom-bar {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  min-height: 66px;
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 250, 0.9);
  backdrop-filter: blur(18px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 22px;
}

.bottom-bar div {
  display: grid;
  gap: 3px;
}

.bottom-bar span {
  color: var(--muted);
  font-size: 13px;
}

.bottom-bar strong {
  font-size: 14px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(36, 33, 29, 0.22);
  z-index: 50;
}

.task-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100dvh;
  z-index: 60;
  border-left: 1px solid var(--line);
  background: #fffdfa;
  box-shadow: -20px 0 48px rgba(44, 37, 25, 0.16);
  transform: translateX(104%);
  transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
}

.task-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-toolbar {
  display: grid;
  gap: 8px;
}

.task-summary {
  width: 100%;
  justify-content: space-between;
  border-radius: var(--radius);
}

.drawer-primary-button,
.drawer-secondary-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdfa;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.drawer-primary-button {
  border-color: rgba(162, 122, 43, 0.42);
  background: #fff9ec;
  color: var(--accent-dark);
}

.drawer-primary-button:hover:not(:disabled) {
  border-color: rgba(162, 122, 43, 0.62);
  background: #ffffff;
}

.drawer-secondary-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #ffffff;
}

.drawer-primary-button:disabled,
.drawer-secondary-button:disabled {
  color: var(--soft);
  background: var(--panel-strong);
  border-color: var(--line);
}

.error-drawer .task-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 250, 0.78);
  padding: 9px;
}

.error-drawer .task-summary {
  width: auto;
  min-height: 32px;
  border-color: var(--line);
  background: rgba(255, 253, 250, 0.82);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.error-drawer .task-summary.has-errors {
  border-color: rgba(155, 61, 50, 0.16);
  background: #fff7f4;
  color: var(--danger);
}

.error-drawer .drawer-secondary-button {
  width: auto;
  min-width: 112px;
  min-height: 34px;
  padding: 0 12px;
}

.error-log-panel {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  display: grid;
  min-width: 0;
  min-height: 0;
}

.error-log-list {
  max-height: 100%;
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 10px;
  padding-right: 4px;
}

.error-drawer .error-log-panel {
  overflow: hidden;
}

.error-log-item,
.error-log-empty {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 9px;
}

.error-log-empty {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.error-log-item {
  position: relative;
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  gap: 12px;
  border-color: rgba(155, 61, 50, 0.16);
  background: linear-gradient(180deg, #fffdfa 0%, #fff9f6 100%);
  padding: 12px 12px 12px 0;
  box-shadow: 0 8px 22px rgba(44, 37, 25, 0.05);
}

.error-log-rail {
  width: 4px;
  min-height: 100%;
  border-radius: 999px;
  background: var(--danger);
}

.error-log-content {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.error-log-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.error-log-item strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}

.error-log-item time {
  color: var(--soft);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.error-log-type {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--danger);
  background: rgba(155, 61, 50, 0.08);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.error-log-detail {
  margin: 0;
  border: 1px solid rgba(155, 61, 50, 0.08);
  border-radius: 6px;
  background: rgba(255, 253, 250, 0.76);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.error-log-task {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--soft);
  font-size: 11px;
}

.error-log-task span {
  flex: 0 0 auto;
  font-weight: 900;
}

.error-log-task code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid rgba(116, 109, 97, 0.16);
  border-radius: 999px;
  background: rgba(240, 236, 226, 0.52);
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  padding: 3px 8px;
}

.error-log-item.upload_validation {
  border-color: rgba(154, 101, 38, 0.18);
  background: linear-gradient(180deg, #fffdfa 0%, #fff8ed 100%);
}

.error-log-item.upload_validation .error-log-rail,
.error-log-item.upload_validation .error-log-type {
  background: rgba(154, 101, 38, 0.12);
  color: var(--warning);
}

.error-log-item.upload_validation .error-log-rail {
  background: var(--warning);
}

.error-log-item.task_canceled {
  border-color: rgba(162, 122, 43, 0.2);
  background: linear-gradient(180deg, #fffdfa 0%, #fff9ec 100%);
}

.error-log-item.task_canceled .error-log-rail,
.error-log-item.task_canceled .error-log-type {
  background: rgba(162, 122, 43, 0.12);
  color: var(--accent-dark);
}

.error-log-item.task_canceled .error-log-rail {
  background: var(--accent);
}

.task-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 2px;
}

.empty-state,
.task-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.task-card {
  padding: 0;
  display: grid;
  overflow: visible;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.task-card.expanded {
  border-color: rgba(162, 122, 43, 0.42);
  background: #fffdf8;
  box-shadow: 0 12px 28px rgba(44, 37, 25, 0.08);
}

.task-card.failed {
  border-color: rgba(155, 61, 50, 0.32);
  background: #fff4f2;
}

.task-card.failed.expanded {
  border-color: rgba(155, 61, 50, 0.46);
  background: #fff1ef;
  box-shadow: 0 12px 28px rgba(155, 61, 50, 0.08);
}

.task-card.failed.collapsed .task-card-summary:hover {
  background: #ffebe8;
}

.task-card.failed .progress-fill {
  background: var(--danger);
}

.task-card-summary {
  display: grid;
  gap: 11px;
  padding: 13px;
  cursor: pointer;
}

.task-card.collapsed .task-card-summary:hover {
  background: #fff9ec;
}

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

.task-badges {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 6px;
}

.task-title-block {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.task-title-line {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
}

.task-card h3 {
  font-size: 15px;
  margin: 0;
}

.task-id {
  color: var(--muted);
  font-size: 12px;
}

.task-result-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
}

.task-result-summary span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.task-result-summary i {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--soft);
}

.task-result-summary .summary-done i {
  background: var(--success);
}

.task-result-summary .summary-failed {
  color: var(--danger);
}

.task-result-summary .summary-failed i {
  background: var(--danger);
}

.status-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  background: var(--panel-strong);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.processing {
  color: var(--warning);
  background: rgba(154, 101, 38, 0.1);
}

.status-badge.waiting {
  color: var(--accent-dark);
  background: rgba(162, 122, 43, 0.1);
}

.status-badge.completed {
  color: var(--success);
  background: rgba(40, 113, 90, 0.1);
}

.status-badge.failed,
.status-badge.canceled {
  color: var(--danger);
  background: rgba(155, 61, 50, 0.1);
}

.download-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  background: var(--panel);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.download-badge.not-downloaded {
  color: var(--warning);
  background: rgba(154, 101, 38, 0.08);
  border-color: rgba(154, 101, 38, 0.22);
}

.download-badge.partial-downloaded {
  color: var(--accent-dark);
  background: #fff9ec;
  border-color: rgba(162, 122, 43, 0.28);
}

.download-badge.downloaded {
  color: var(--success);
  background: rgba(40, 113, 90, 0.08);
  border-color: rgba(40, 113, 90, 0.22);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel-strong);
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 260ms ease;
}

.task-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.task-meta span {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 10px 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.task-prompt {
  border: 1px solid rgba(162, 122, 43, 0.18);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--accent-dark);
  background: #fff9ec;
  font-size: 13px;
  font-weight: 700;
}

.task-details {
  display: grid;
  gap: 12px;
  padding: 2px 13px 15px;
}

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

.task-footer {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.preview-action-button {
  min-height: 38px;
  border: 1px solid rgba(162, 122, 43, 0.28);
  border-radius: 6px;
  background: #fff9ec;
  color: var(--accent-dark);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  flex: 0 1 128px;
}

.preview-action-button:disabled {
  border-color: var(--line);
  color: var(--soft);
  background: var(--panel-strong);
}

.task-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  flex: 1 1 260px;
}

.task-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdfa;
  color: var(--text);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.task-actions button:disabled {
  color: var(--soft);
  background: var(--panel-strong);
}

.archive-action-button {
  border-color: rgba(40, 113, 90, 0.24) !important;
  color: var(--success) !important;
  background: rgba(40, 113, 90, 0.07) !important;
}

.archive-action-button:hover:not(:disabled) {
  border-color: rgba(40, 113, 90, 0.42) !important;
  background: #ffffff !important;
}

.archive-action-button:disabled {
  color: var(--soft) !important;
  background: var(--panel-strong) !important;
  border-color: var(--line) !important;
}

.error-text {
  color: var(--danger);
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(36, 33, 29, 0.3);
  backdrop-filter: blur(2px);
}

.result-preview-modal {
  position: fixed;
  inset: 32px;
  z-index: 80;
  max-width: 1120px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdfa;
  box-shadow: 0 24px 64px rgba(44, 37, 25, 0.22);
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
}

.result-preview-modal[hidden],
.modal-backdrop[hidden],
.image-lightbox[hidden] {
  display: none;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

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

.modal-download-button {
  min-height: 40px;
  border: 1px solid rgba(162, 122, 43, 0.32);
  border-radius: 8px;
  background: #fff9ec;
  color: var(--accent-dark);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.modal-download-button:hover:not(:disabled) {
  border-color: rgba(162, 122, 43, 0.58);
  background: #ffffff;
}

.modal-download-button:disabled {
  border-color: var(--line);
  color: var(--soft);
  background: var(--panel-strong);
}

.modal-header p:last-child {
  color: var(--muted);
  font-size: 13px;
}

.result-preview-warning {
  border: 1px solid rgba(162, 122, 43, 0.24);
  border-radius: var(--radius);
  background: #fff9ec;
  color: var(--accent-dark);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}

.result-preview-body {
  min-height: 0;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
}

.result-preview-list {
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 2px;
}

.result-preview-list button {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  padding: 9px 10px;
  display: grid;
  gap: 3px;
}

.result-preview-list button.active {
  border-color: rgba(162, 122, 43, 0.52);
  background: #fff9ec;
}

.result-preview-list span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-download-state {
  width: fit-content;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 900;
  color: var(--warning);
  background: rgba(154, 101, 38, 0.08);
}

.result-download-state.downloaded {
  color: var(--success);
  background: rgba(40, 113, 90, 0.08);
}

.result-preview-image-grid {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.result-preview-panel {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(220px, 1fr) auto;
}

.result-preview-panel.simulated {
  border-color: rgba(162, 122, 43, 0.42);
}

.result-preview-panel button {
  min-height: 220px;
  border: 0;
  background: var(--panel-strong);
  padding: 0;
}

.result-preview-panel img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
}

.result-preview-panel figcaption {
  min-height: 92px;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.result-preview-panel figcaption span,
.result-preview-panel figcaption small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(24, 22, 19, 0.84);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 54px 20px 34px;
  cursor: zoom-out;
}

.image-lightbox-close {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 91;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255, 253, 250, 0.74);
  border-radius: 16px;
  background: rgba(255, 253, 250, 0.94);
  color: var(--text);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.image-lightbox-close:hover {
  background: #fffdfa;
  transform: translateY(-1px);
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.image-lightbox-close:active {
  transform: scale(0.97);
}

.image-lightbox-close svg {
  width: 26px;
  height: 26px;
  stroke: currentColor;
  stroke-width: 2.4;
}

.image-lightbox img {
  max-width: min(94vw, 1080px);
  max-height: 82vh;
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.38);
  cursor: default;
}

.image-lightbox span {
  margin-top: 12px;
  color: #fffdfa;
  font-size: 13px;
  font-weight: 700;
  cursor: default;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .module-rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: min(240px, 30dvh);
  }

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

  .content-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "operation"
      "upload"
      "settings"
      "create";
  }

  .result-preview-modal {
    inset: 16px;
  }

  .result-preview-body {
    grid-template-columns: 1fr;
  }

  .result-preview-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(160px, 1fr);
    overflow-x: auto;
  }

  .result-preview-image-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar,
  .module-header,
  .bottom-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .module-list,
  .control-grid,
  .upload-grid,
  .task-meta {
    grid-template-columns: 1fr;
  }

  .main-panel {
    padding: 16px 14px;
  }

  .module-rail {
    padding: 14px;
  }

  .bottom-bar {
    padding: 12px 14px;
  }

  .modal-header {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-actions {
    width: 100%;
    justify-content: space-between;
  }

  .modal-download-button {
    flex: 1;
  }

  .secondary-button {
    width: 100%;
  }
}
