:root {
  --bg: #030712;
  --bg-2: #07111f;
  --surface: rgba(10, 20, 38, 0.78);
  --surface-strong: rgba(13, 26, 48, 0.92);
  --surface-soft: rgba(20, 184, 166, 0.08);
  --ink: #eef7ff;
  --muted: #8ea6bf;
  --line: rgba(148, 163, 184, 0.2);
  --line-bright: rgba(34, 211, 238, 0.35);
  --accent: #22d3ee;
  --accent-2: #8b5cf6;
  --accent-3: #14f1c5;
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --glow: 0 0 32px rgba(34, 211, 238, 0.24);
  color-scheme: dark;
  font-family:
    "Inter", "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
  background:
    radial-gradient(circle at 12% 12%, rgba(34, 211, 238, 0.22), transparent 30%),
    radial-gradient(circle at 82% 8%, rgba(139, 92, 246, 0.2), transparent 32%),
    radial-gradient(circle at 70% 88%, rgba(20, 241, 197, 0.13), transparent 34%),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-2) 48%, #020617 100%);
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent 88%);
}

body::after {
  position: fixed;
  inset: -30% -10% auto;
  z-index: -1;
  height: 50vh;
  pointer-events: none;
  content: "";
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(34, 211, 238, 0.08) 46%,
    rgba(139, 92, 246, 0.08) 52%,
    transparent 100%
  );
  transform: rotate(-8deg);
  filter: blur(2px);
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
dialog:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.shell {
  display: flex;
  flex-direction: column;
  width: min(1600px, 100%);
  height: 100vh;
  height: 100dvh;
  min-height: 640px;
  margin: 0 auto;
  padding: clamp(14px, 2vw, 28px);
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: clamp(14px, 1.6vw, 22px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 3.2vw, 46px);
  font-weight: 850;
  letter-spacing: -0.04em;
  line-height: 1;
  text-shadow: 0 0 28px rgba(34, 211, 238, 0.24);
}

h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.subtitle {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(340px, clamp(380px, 35vw, 540px)) minmax(0, 1fr);
  flex: 1 1 auto;
  gap: clamp(14px, 1.6vw, 22px);
  align-items: stretch;
  min-height: 0;
}

.panel {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(15, 23, 42, 0.94), rgba(8, 18, 34, 0.78)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
  container-type: inline-size;
}

.panel::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  border-radius: inherit;
  background:
    linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.2), transparent) top
      left / 100% 1px no-repeat,
    radial-gradient(circle at 20% 0%, rgba(34, 211, 238, 0.16), transparent 28%),
    radial-gradient(circle at 88% 10%, rgba(139, 92, 246, 0.16), transparent 30%);
}

.panel--composer {
  position: sticky;
  top: clamp(14px, 2vw, 24px);
  max-height: 100%;
  padding: clamp(18px, 1.7vw, 24px);
  overflow-y: auto;
  scrollbar-color: rgba(34, 211, 238, 0.45) rgba(15, 23, 42, 0.5);
}

.panel--tasks {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: clamp(16px, 1.45vw, 22px) clamp(14px, 1.2vw, 18px) clamp(14px, 1.2vw, 18px);
}

.section-title-row,
.label-row,
.action-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-title-row {
  margin-bottom: 16px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.field {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
}

label {
  font-weight: 760;
}

textarea {
  width: 100%;
  height: clamp(208px, 28.8vh, 288px);
  min-height: clamp(176px, 28.8vh, 288px);
  max-height: min(41.6vh, 368px);
  resize: vertical;
  border: 1px solid rgba(34, 211, 238, 0.24);
  border-radius: 18px;
  padding: 16px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(2, 6, 23, 0.68), rgba(15, 23, 42, 0.86)),
    rgba(2, 6, 23, 0.7);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    inset 0 0 32px rgba(34, 211, 238, 0.04);
  white-space: pre-wrap;
}

textarea::placeholder {
  color: #5f768e;
}

textarea:focus {
  border-color: rgba(34, 211, 238, 0.72);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.12), var(--glow);
}

.help,
.counter,
.notice {
  color: var(--muted);
  font-size: 13px;
}

.counter,
.notice {
  font-family: Consolas, "Cascadia Mono", monospace;
}

.field-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.danger-text {
  color: var(--danger) !important;
}

.action-row {
  align-items: flex-end;
  margin-top: 18px;
  flex-wrap: wrap;
}

.file-field {
  flex: 1 1 auto;
  min-width: 0;
}

input[type="file"] {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  padding: 12px;
  color: var(--ink);
  background: rgba(2, 6, 23, 0.56);
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  border: 1px solid rgba(34, 211, 238, 0.42);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--ink);
  background: rgba(34, 211, 238, 0.12);
  cursor: pointer;
}

.cached-file {
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(20, 241, 197, 0.32);
  border-radius: 999px;
  padding: 7px 10px;
  color: #b6fff0;
  background: rgba(20, 241, 197, 0.09);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-button,
.ghost-button,
.danger-button,
.download-button,
.delete-button {
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 780;
  white-space: nowrap;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.primary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled),
.danger-button:hover:not(:disabled),
.download-button:hover:not(:disabled),
.delete-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-button {
  min-width: 136px;
  color: #04111f;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-3) 100%);
  box-shadow: 0 0 28px rgba(34, 211, 238, 0.32);
}

.primary-button:hover:not(:disabled) {
  box-shadow: 0 0 40px rgba(20, 241, 197, 0.4);
}

.ghost-button {
  color: var(--ink);
  background: rgba(15, 23, 42, 0.68);
  border-color: rgba(148, 163, 184, 0.24);
}

.danger-button,
.delete-button {
  color: #fff;
  background: linear-gradient(135deg, #f43f5e, #be123c);
  border-color: rgba(251, 113, 133, 0.42);
}

.download-button {
  color: #cffff7;
  background: rgba(20, 241, 197, 0.12);
  border-color: rgba(20, 241, 197, 0.36);
}

.polling-indicator {
  position: relative;
  border: 1px solid rgba(34, 211, 238, 0.36);
  border-radius: 999px;
  padding: 7px 12px 7px 28px;
  color: #b9f7ff;
  background: rgba(34, 211, 238, 0.1);
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.12);
  font-size: 13px;
  font-weight: 720;
}

.polling-indicator::before {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 8px;
  height: 8px;
  content: "";
  background: var(--accent-3);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent-3);
  transform: translateY(-50%);
  animation: pulse 1.4s ease-in-out infinite;
}

.task-list {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: start;
  grid-auto-rows: minmax(124px, max-content);
  flex: 1 1 auto;
  gap: 12px;
  min-height: 0;
  padding-right: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(34, 211, 238, 0.45) rgba(15, 23, 42, 0.5);
}

.task-list::-webkit-scrollbar {
  width: 8px;
}

.task-list::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 999px;
}

.task-list::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--accent), var(--accent-2));
  border-radius: 999px;
}

.task-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, auto);
  gap: 12px;
  min-height: 124px;
  padding: 15px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.82), rgba(2, 6, 23, 0.62)),
    rgba(2, 6, 23, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.task-row + .task-row {
  margin-top: 0;
}

.task-row::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background: linear-gradient(
    120deg,
    transparent,
    rgba(34, 211, 238, 0.07),
    transparent
  );
  transform: translateX(-65%);
}

.task-row:hover {
  border-color: rgba(34, 211, 238, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--glow);
}

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

.task-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
  margin-bottom: 9px;
}

.task-id {
  min-width: 0;
  max-width: 120px;
  border: 1px solid rgba(34, 211, 238, 0.24);
  border-radius: 999px;
  padding: 4px 9px;
  color: #bff8ff;
  background: rgba(34, 211, 238, 0.08);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-time {
  color: var(--muted);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  white-space: nowrap;
}

.task-content {
  display: -webkit-box;
  color: #d8e7f5;
  font-size: 14px;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  white-space: pre-wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 0;
  border-radius: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 820;
  letter-spacing: 0.03em;
  line-height: 1.3;
  white-space: nowrap;
}

.status-badge::before {
  width: 7px;
  height: 7px;
  margin-right: 6px;
  content: "";
  border-radius: 50%;
}

.status-queued,
.status-running {
  color: #ffe7a3;
  background: transparent;
}

.status-queued::before,
.status-running::before {
  background: var(--warning);
  box-shadow: 0 0 12px var(--warning);
}

.status-completed {
  color: #b9ffe9;
  background: transparent;
}

.status-completed::before {
  background: var(--success);
  box-shadow: 0 0 12px var(--success);
}

.status-failed {
  color: #ffd2d9;
  background: transparent;
}

.status-failed::before {
  background: var(--danger);
  box-shadow: 0 0 12px var(--danger);
}

.task-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  min-width: 112px;
}

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

.task-progress {
  margin-top: 8px;
}

.task-error {
  display: -webkit-box;
  margin-top: 8px;
  color: var(--danger);
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
}

.task-actions button {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 12px;
}

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  border: 1px dashed rgba(34, 211, 238, 0.28);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  background: rgba(2, 6, 23, 0.32);
}

.delete-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 18px;
  padding: 22px;
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.delete-dialog::backdrop {
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(8px);
}

.delete-dialog p {
  margin-top: 10px;
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: translateY(-50%) scale(0.92);
  }

  50% {
    opacity: 1;
    transform: translateY(-50%) scale(1.18);
  }
}

@media (max-width: 1020px) {
  .shell {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  .workspace-layout {
    grid-template-columns: 1fr;
    flex: initial;
  }

  .panel--composer {
    position: static;
    max-height: none;
  }

  .panel--tasks {
    height: auto;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    min-height: min(520px, calc(100vh - 40px));
    min-height: min(520px, calc(100dvh - 40px));
  }

  textarea {
    height: clamp(160px, 24vh, 240px);
    min-height: clamp(160px, 24vh, 240px);
    max-height: min(36vh, 288px);
  }
}

@media (max-width: 760px) {
  .shell {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 18px 14px 28px;
  }

  .topbar,
  .section-title-row,
  .action-row,
  .label-row {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 28px;
  }

  .panel--composer,
  .panel--tasks {
    padding: 16px;
    border-radius: 20px;
  }

  .panel--tasks {
    max-height: calc(100vh - 28px);
    max-height: calc(100dvh - 28px);
    min-height: min(460px, calc(100vh - 28px));
    min-height: min(460px, calc(100dvh - 28px));
  }

  textarea {
    height: clamp(128px, 22.4vh, 176px);
    min-height: clamp(128px, 22.4vh, 176px);
    max-height: min(30.4vh, 224px);
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .task-row {
    grid-template-columns: 1fr;
    min-height: 164px;
  }

  .task-side {
    align-items: stretch;
    min-width: 0;
  }

  .task-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  }

  .task-actions button {
    width: 100%;
    min-height: 40px;
  }
}

@media (max-width: 520px) {
  .shell {
    padding: 14px 10px 22px;
  }

  .subtitle {
    letter-spacing: 0.08em;
  }

  .section-title-row,
  .label-row {
    gap: 8px;
  }

  .panel--composer,
  .panel--tasks {
    padding: 14px;
    border-radius: 18px;
  }

  .task-row {
    min-height: 154px;
    padding: 12px;
  }

  textarea {
    height: clamp(120px, 20.8vh, 160px);
    min-height: clamp(120px, 20.8vh, 160px);
  }

  .task-meta {
    gap: 7px;
  }

  .task-id,
  .task-time,
  .status-badge,
  .task-actions button {
    font-size: 11px;
  }
}

@container (max-width: 520px) {
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button {
    width: 100%;
  }

  .task-row {
    grid-template-columns: 1fr;
    min-height: 164px;
  }

  .task-side {
    align-items: stretch;
    min-width: 0;
  }

  .task-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  }

  .task-actions button {
    width: 100%;
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
