:root {
  color-scheme: dark;
  --bg: #06090d;
  --bg-deep: #030507;
  --panel: rgba(10, 14, 18, 0.9);
  --panel-strong: rgba(13, 18, 24, 0.96);
  --panel-line: rgba(113, 140, 162, 0.18);
  --panel-line-strong: rgba(108, 227, 255, 0.32);
  --ink: #f6fbff;
  --muted: #8d9aa7;
  --soft: #0f151b;
  --soft-2: #0b1016;
  --accent: #38e5ff;
  --accent-strong: #00c8ff;
  --accent-glow: rgba(56, 229, 255, 0.22);
  --accent-ink: #031117;
  --range-track: #3b8fbd;
  --warning: #f6c35b;
  --success: #3bf1b7;
  --danger: #ff6c87;
  --button: #111820;
  --button-ink: #eef8ff;
  --focus: rgba(56, 229, 255, 0.24);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top, rgba(30, 82, 99, 0.18), transparent 30%),
    radial-gradient(circle at 80% 10%, rgba(0, 200, 255, 0.12), transparent 22%),
    linear-gradient(180deg, #0b0f13 0%, #06090d 38%, #030507 100%);
  color: var(--ink);
  font-family:
    "Space Grotesk", "Avenir Next", "SF Pro Display", "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0.01em;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body::before {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 72px 72px;
  opacity: 0.22;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.88), transparent);
}

body::after {
  background:
    radial-gradient(circle at 50% 44%, rgba(56, 229, 255, 0.12), transparent 26%),
    radial-gradient(circle at 50% 74%, rgba(49, 99, 135, 0.18), transparent 30%);
}

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

button {
  appearance: none;
}

.app-topbar,
.app-shell,
.modal {
  position: relative;
  z-index: 1;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(11, 15, 19, 0.96), rgba(7, 10, 13, 0.9));
  backdrop-filter: blur(20px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid rgba(56, 229, 255, 0.45);
  background:
    linear-gradient(180deg, rgba(15, 29, 36, 0.96), rgba(7, 14, 19, 0.96)),
    linear-gradient(135deg, rgba(56, 229, 255, 0.36), transparent 58%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 24px rgba(56, 229, 255, 0.16);
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
}

.brand-copy h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0.04em;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(56, 229, 255, 0.08), 0 0 18px rgba(56, 229, 255, 0.45);
}

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

.app-shell {
  flex: 1;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  gap: 0;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 16px;
  background: linear-gradient(180deg, rgba(10, 14, 18, 0.96), rgba(8, 12, 16, 0.92));
  overflow-y: auto;
}

.left-panel {
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.right-panel {
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.section {
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.section-kicker {
  margin-bottom: 10px;
  color: rgba(180, 196, 210, 0.82);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.section h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.drop-zone {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 20px 16px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(5, 8, 11, 0.72), rgba(7, 11, 14, 0.92)),
    radial-gradient(circle at top, rgba(56, 229, 255, 0.12), transparent 42%);
  box-shadow: inset 0 0 0 1px rgba(56, 229, 255, 0.04);
  cursor: pointer;
}

.drop-zone::before {
  content: "";
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(18, 26, 33, 0.94), rgba(8, 14, 19, 0.96)),
    radial-gradient(circle at 50% 30%, rgba(56, 229, 255, 0.28), transparent 55%);
  box-shadow: 0 0 24px rgba(0, 200, 255, 0.09);
}

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

.drop-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.drop-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.meta-grid div {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(6, 9, 12, 0.72);
}

.meta-grid span,
.meta-grid strong {
  display: block;
}

.meta-grid span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta-grid strong {
  font-size: 14px;
  font-weight: 700;
}

.panel-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  color: rgba(141, 154, 167, 0.86);
  font-size: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.stage-area {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: 18px;
  overflow: hidden;
}

.stage-area::before,
.stage-area::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stage-area::before {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: 0.3;
}

.stage-area::after {
  background:
    radial-gradient(circle at 50% 14%, rgba(56, 229, 255, 0.12), transparent 28%),
    radial-gradient(circle at 50% 58%, rgba(8, 37, 48, 0.52), transparent 38%);
}

.stage-surface {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
}

.canvas-wrap {
  position: relative;
  width: min(100%, calc((100vh - 180px) * 16 / 9));
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background:
    linear-gradient(180deg, rgba(6, 10, 14, 0.74), rgba(3, 5, 8, 0.96)),
    radial-gradient(circle at 50% 22%, rgba(56, 229, 255, 0.08), transparent 42%);
  box-shadow:
    inset 0 0 0 1px rgba(56, 229, 255, 0.03),
    0 0 0 1px rgba(0, 200, 255, 0.08),
    0 24px 80px rgba(0, 0, 0, 0.42),
    0 0 56px rgba(56, 229, 255, 0.06);
  overflow: hidden;
}

.canvas-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 72px 72px;
  opacity: 0.32;
  pointer-events: none;
}

canvas {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.canvas-hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.hud-corner {
  position: absolute;
  width: 66px;
  height: 66px;
  border-color: rgba(56, 229, 255, 0.46);
  filter: drop-shadow(0 0 12px rgba(56, 229, 255, 0.3));
}

.corner-tl {
  top: 34px;
  left: 34px;
  border-top: 2px solid;
  border-left: 2px solid;
}

.corner-tr {
  top: 34px;
  right: 34px;
  border-top: 2px solid;
  border-right: 2px solid;
}

.corner-br {
  right: 34px;
  bottom: 34px;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

.corner-bl {
  left: 34px;
  bottom: 34px;
  border-bottom: 2px solid;
  border-left: 2px solid;
}

.hint {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 3;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(6, 9, 12, 0.78);
  color: rgba(230, 241, 250, 0.86);
  font-size: 11px;
  line-height: 1.5;
  backdrop-filter: blur(14px);
}

.primary-button,
.secondary-button {
  min-height: 40px;
  border-radius: 10px;
  padding: 0 16px;
  border: 1px solid transparent;
  background: var(--button);
  color: var(--button-ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.template-chip:hover,
.retry-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  border-color: rgba(56, 229, 255, 0.44);
  background:
    linear-gradient(180deg, rgba(14, 33, 41, 0.95), rgba(6, 18, 24, 0.95)),
    linear-gradient(135deg, rgba(56, 229, 255, 0.26), transparent 62%);
  box-shadow: inset 0 0 0 1px rgba(56, 229, 255, 0.1), 0 0 24px rgba(56, 229, 255, 0.12);
}

.secondary-button {
  border-color: rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(16, 22, 29, 0.96), rgba(11, 16, 22, 0.96));
}

.icon-button {
  min-width: 112px;
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.template-chip:focus-visible,
.retry-button:focus-visible,
select:focus-visible,
input[type="text"]:focus-visible,
textarea:focus-visible,
input[type="color"]:focus-visible,
input[type="range"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.native-select-cache {
  display: none;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field label,
.compact-details summary,
.chip-label {
  color: rgba(228, 240, 248, 0.88);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

select,
input[type="text"],
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(8, 11, 15, 0.88);
  color: var(--ink);
}

select,
input[type="text"] {
  height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
}

input[type="text"]:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
}

input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(8, 11, 15, 0.88);
}

input[type="range"] {
  width: 100%;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--range-track);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  background: #0b1116;
  box-shadow: 0 0 0 3px rgba(56, 229, 255, 0.1);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--range-track);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  background: #0b1116;
  box-shadow: 0 0 0 3px rgba(56, 229, 255, 0.1);
}

.range-field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.template-picker-section {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.template-chip-group {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-chip {
  min-width: 58px;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(9, 13, 17, 0.92);
  color: rgba(236, 245, 251, 0.88);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.template-chip.is-active {
  border-color: rgba(56, 229, 255, 0.56);
  background:
    linear-gradient(180deg, rgba(14, 33, 41, 0.96), rgba(6, 18, 24, 0.96)),
    linear-gradient(135deg, rgba(56, 229, 255, 0.24), transparent 64%);
  color: var(--ink);
  box-shadow: 0 0 0 2px rgba(56, 229, 255, 0.1), 0 0 28px rgba(56, 229, 255, 0.1);
}

.template-chip:disabled {
  opacity: 0.36;
  cursor: not-allowed;
  transform: none;
}

.segment {
  min-width: 136px;
}

.compact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 122px;
  gap: 12px;
  align-items: end;
}

.wide-button {
  width: 100%;
}

.note,
.template-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.note {
  margin: 0;
}

.batch-note {
  margin-top: 12px;
}

.templateQuickStatus,
#templateQuickStatus {
  margin-top: 6px;
}

.compact-details {
  display: block;
}

.compact-details summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  list-style: none;
}

.compact-details summary::-webkit-details-marker {
  display: none;
}

.summary-text {
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: none;
}

.template-editor-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 12px;
}

.template-editor-actions button,
.template-editor-actions label {
  display: grid;
  place-items: center;
  text-align: center;
}

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

.template-divider {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.template-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(9, 13, 17, 0.92);
  color: var(--ink);
  cursor: pointer;
}

.template-card.is-active {
  border-color: rgba(56, 229, 255, 0.56);
  box-shadow: 0 0 0 2px rgba(56, 229, 255, 0.1);
}

.template-card span {
  font-weight: 700;
}

.upload-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  margin-top: 12px;
  overflow: auto;
}

.upload-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(8, 11, 15, 0.8);
}

.upload-item strong,
.upload-item span,
.batch-file strong,
.batch-file span {
  display: block;
}

.upload-item strong,
.batch-file strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.upload-item span,
.batch-file span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.status-pill {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(16, 22, 29, 0.96);
  color: rgba(230, 241, 250, 0.86);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.is-working {
  color: #a8e8ff;
  border-color: rgba(66, 168, 255, 0.22);
}

.status-pill.is-done {
  color: #9df5db;
  border-color: rgba(59, 241, 183, 0.22);
}

.status-pill.is-error {
  color: #ffc2cf;
  border-color: rgba(255, 108, 135, 0.24);
}

.retry-button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(12, 18, 24, 0.94);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 4, 6, 0.72);
  backdrop-filter: blur(20px);
}

.modal.is-hidden {
  display: none;
}

.modal-card {
  width: min(780px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  padding: 20px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(11, 15, 19, 0.97), rgba(7, 10, 13, 0.97));
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.batch-rows {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.batch-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 190px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(9, 13, 17, 0.92);
}

.batch-index {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 21, 27, 0.96);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.batch-file {
  min-width: 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.completion-card {
  max-width: 520px;
}

@media (max-width: 1220px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .right-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }
}

@media (max-width: 920px) {
  .app-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .left-panel,
  .right-panel {
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .stage-area {
    min-height: 60vh;
    padding: 14px;
  }

  .canvas-wrap {
    width: 100%;
  }

  .compact-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-topbar {
    padding-inline: 12px;
  }

  .brand-copy h1 {
    font-size: 20px;
  }

  .panel,
  .stage-area {
    padding: 12px;
  }

  .template-editor-actions,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .batch-row {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .batch-row select {
    grid-column: 1 / -1;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    padding: 16px;
  }
}
