:root {
  --bg: #eef7f8;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --panel-soft: #edf5f7;
  --text: #152235;
  --muted: #6d7b8f;
  --border: rgba(177, 214, 218, 0.72);
  --border-strong: #9dd5d0;
  --accent: #13a292;
  --accent-2: #48c8ba;
  --accent-dark: #087a70;
  --danger: #ef5350;
  --danger-soft: #fff6f6;
  --shadow: 0 22px 60px rgba(42, 83, 100, 0.14);
  --shadow-soft: 0 12px 34px rgba(20, 94, 108, 0.1);
  --radius: 14px;
  --control-height: 48px;
  font-family:
    Inter, "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 5% 10%, rgba(255, 255, 255, 0.96) 0, rgba(255, 255, 255, 0) 34%),
    radial-gradient(circle at 96% 16%, rgba(201, 241, 236, 0.9) 0, rgba(201, 241, 236, 0) 30%),
    radial-gradient(circle at 88% 92%, rgba(218, 235, 255, 0.74) 0, rgba(218, 235, 255, 0) 36%),
    linear-gradient(135deg, #f8fbfd 0%, #eef8f7 48%, #f5fbfd 100%);
}

body.is-busy {
  cursor: progress;
}

button,
input {
  font: inherit;
}

button svg,
.section-heading svg,
.segmented-control svg,
.brand-icon svg,
.upload-icon svg,
.color-control svg,
.remove-button svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.order-buttons svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  width: min(1620px, 100%);
  margin: 0 auto;
  padding: 38px 44px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
  gap: 28px;
  min-width: 0;
  min-height: calc(100vh - 76px);
}

.control-panel,
.thumb-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid rgba(202, 225, 229, 0.82);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  animation: panelIn 520ms ease both;
}

.control-panel {
  align-self: start;
  display: grid;
  gap: 22px;
  min-width: 0;
  padding: 30px;
  position: sticky;
  top: 28px;
}

.thumb-panel {
  animation-delay: 80ms;
}

.preview-panel {
  animation-delay: 150ms;
}

@keyframes panelIn {
  from {
    transform: translateY(10px);
  }
  to {
    transform: translateY(0);
  }
}

.title-block {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  color: #ffffff;
  background: linear-gradient(145deg, var(--accent-2), var(--accent));
  box-shadow: 0 14px 26px rgba(19, 162, 146, 0.24);
}

.brand-icon svg {
  width: 25px;
  height: 25px;
  stroke-width: 1.8;
}

.title-block h1 {
  margin: 0 0 10px;
  color: #142033;
  font-size: 26px;
  line-height: 1.18;
  letter-spacing: 0;
}

.title-block p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
}

.upload-zone {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 210px;
  padding: 26px 18px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(246, 253, 252, 0.74)),
    rgba(248, 253, 253, 0.76);
  text-align: center;
  cursor: pointer;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease,
    background 180ms ease;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(239, 251, 249, 0.98);
  box-shadow: inset 0 0 0 1px rgba(19, 162, 146, 0.12), 0 18px 36px rgba(19, 162, 146, 0.1);
  transform: translateY(-2px);
}

.upload-zone:hover .upload-icon,
.upload-zone.drag-over .upload-icon {
  transform: translateY(-4px) scale(1.04);
}

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

.upload-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  color: var(--accent);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.2)),
    #d9f4f0;
  border-radius: 999px;
  box-shadow: 0 12px 26px rgba(19, 162, 146, 0.13);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.upload-icon svg {
  width: 30px;
  height: 30px;
}

.upload-title {
  margin-top: 6px;
  color: #1c2c43;
  font-size: 16px;
  font-weight: 800;
}

.upload-subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.settings-grid {
  display: grid;
  gap: 16px;
}

.field-block {
  margin: 0;
  padding: 0;
  border: 0;
}

.field-block legend,
.input-row span {
  display: block;
  margin-bottom: 9px;
  color: #41566d;
  font-size: 13px;
  font-weight: 800;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  padding: 4px;
  border: 1px solid rgba(214, 226, 232, 0.9);
  border-radius: 8px;
  background: linear-gradient(180deg, #f7fafc, #edf3f6);
  box-shadow: inset 0 1px 3px rgba(30, 65, 80, 0.05);
}

.segmented-control label {
  min-width: 0;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 43px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #587087;
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.segmented-control span svg {
  width: 17px;
  height: 17px;
}

.segmented-control input:checked + span {
  border-color: rgba(19, 162, 146, 0.38);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(232, 250, 247, 0.95));
  color: var(--accent-dark);
  box-shadow: 0 10px 22px rgba(33, 105, 118, 0.12);
}

.input-row input {
  width: 100%;
  height: var(--control-height);
  padding: 0 14px;
  border: 1px solid #d5e0e7;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.input-row input:focus {
  border-color: var(--border-strong);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(19, 162, 146, 0.1);
}

.unit-control,
.color-control {
  position: relative;
  display: grid;
  align-items: center;
}

.unit-control em {
  position: absolute;
  right: 14px;
  color: #8b98a8;
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
  pointer-events: none;
}

.unit-control input {
  padding-right: 44px;
}

.color-control {
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
}

.color-control input {
  min-width: 0;
}

.color-control input[type="color"] {
  padding: 7px;
  cursor: pointer;
}

.color-control input[type="text"] {
  padding-right: 42px;
  text-transform: uppercase;
}

.color-control svg {
  position: absolute;
  right: 13px;
  width: 18px;
  height: 18px;
  color: #51667c;
  pointer-events: none;
}

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

.actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 50px;
  padding: 0 16px;
  border: 1px solid #d8e4e9;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.actions button svg {
  width: 18px;
  height: 18px;
}

.actions button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.actions button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.actions .primary-button {
  border-color: rgba(19, 162, 146, 0.52);
  background: linear-gradient(135deg, #20b7a7, #0d9385);
  color: #ffffff;
  box-shadow: 0 14px 30px rgba(19, 162, 146, 0.25);
}

.actions .primary-button:hover:not(:disabled) {
  box-shadow: 0 18px 36px rgba(19, 162, 146, 0.32);
}

.actions .ghost-button {
  border-color: rgba(239, 83, 80, 0.22);
  background: rgba(255, 255, 255, 0.68);
  color: var(--danger);
}

.actions .ghost-button:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: rgba(239, 83, 80, 0.38);
  box-shadow: 0 12px 26px rgba(239, 83, 80, 0.08);
}

.content-panel {
  display: grid;
  grid-template-rows: auto minmax(450px, 1fr);
  gap: 24px;
  min-width: 0;
}

.thumb-panel,
.preview-panel {
  min-width: 0;
  padding: 26px 30px 30px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.section-heading h2 {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  margin: 0;
  color: #162235;
  font-size: 19px;
  line-height: 1.3;
}

.section-heading h2 svg {
  width: 19px;
  height: 19px;
  color: var(--accent);
}

.section-heading span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 7px;
  background: rgba(240, 245, 248, 0.78);
  color: #536579;
  font-size: 14px;
  font-weight: 850;
}

.thumb-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 14px;
  min-height: 150px;
}

.thumb-list.empty {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  min-height: 205px;
  border: 1px solid rgba(157, 213, 208, 0.65);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.64), rgba(247, 253, 252, 0.74)),
    rgba(255, 255, 255, 0.5);
}

.order-empty,
.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 22px;
  text-align: center;
}

.order-empty img {
  width: 108px;
  height: 88px;
  object-fit: contain;
  object-position: center;
  mix-blend-mode: multiply;
  filter: drop-shadow(0 12px 18px rgba(43, 128, 138, 0.1));
}

.order-empty strong,
.empty-state strong {
  color: #172235;
  font-size: 16px;
  font-weight: 900;
}

.order-empty p,
.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.thumb-card {
  position: relative;
  display: grid;
  grid-template-rows: 96px auto;
  overflow: hidden;
  min-width: 0;
  border: 1px solid rgba(207, 224, 229, 0.86);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  cursor: grab;
  box-shadow: 0 10px 24px rgba(35, 73, 92, 0.06);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease,
    opacity 160ms ease;
}

.thumb-card:hover {
  border-color: rgba(19, 162, 146, 0.42);
  box-shadow: 0 18px 34px rgba(35, 95, 106, 0.14);
  transform: translateY(-3px);
}

.thumb-card.dragging {
  border-color: rgba(19, 162, 146, 0.68);
  opacity: 0.68;
  transform: scale(0.98);
  box-shadow: 0 0 0 3px rgba(19, 162, 146, 0.14), 0 18px 34px rgba(35, 95, 106, 0.14);
}

.thumb-card img {
  width: 100%;
  height: 96px;
  object-fit: cover;
  background: #edf4f6;
}

.thumb-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px 40px 10px 10px;
}

.thumb-name {
  min-width: 0;
  overflow: hidden;
  color: #35465a;
  font-size: 12px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-size {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.order-buttons {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.order-buttons button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 26px;
  border: 1px solid rgba(202, 222, 228, 0.9);
  border-radius: 7px;
  background: rgba(248, 252, 252, 0.96);
  color: #51667c;
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease,
    color 150ms ease;
}

.order-buttons button:hover:not(:disabled) {
  border-color: rgba(19, 162, 146, 0.5);
  background: rgba(232, 250, 247, 0.98);
  color: var(--accent-dark);
  transform: translateY(-1px);
}

.order-buttons button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.order-buttons svg {
  width: 15px;
  height: 15px;
}

.thumb-index {
  position: absolute;
  top: 8px;
  left: 8px;
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(21, 34, 53, 0.82);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(15, 29, 45, 0.18);
}

.remove-button {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 246, 246, 0.92);
  color: var(--danger);
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.remove-button:hover {
  background: #ffecec;
  transform: scale(1.06);
}

.remove-button svg {
  width: 16px;
  height: 16px;
}

.preview-stage {
  display: grid;
  place-items: center;
  overflow: auto;
  min-height: 520px;
  max-height: calc(100vh - 220px);
  border: 1px solid #d6e1e8;
  border-radius: 10px;
  background:
    linear-gradient(45deg, rgba(231, 236, 241, 0.52) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(231, 236, 241, 0.52) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(231, 236, 241, 0.52) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(231, 236, 241, 0.52) 75%),
    #ffffff;
  background-position:
    0 0,
    0 11px,
    11px -11px,
    -11px 0;
  background-size: 22px 22px;
}

.preview-stage canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 14px 40px rgba(23, 32, 44, 0.18);
  animation: canvasIn 240ms ease both;
}

@keyframes canvasIn {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.empty-state {
  max-width: 420px;
  color: var(--muted);
}

.empty-state img {
  width: 148px;
  height: 128px;
  object-fit: contain;
  object-position: center;
  mix-blend-mode: multiply;
  filter: drop-shadow(0 14px 20px rgba(34, 127, 139, 0.12));
}

.empty-state strong {
  margin-top: 2px;
  font-size: 20px;
}

.empty-state p {
  font-size: 15px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(238, 247, 248, 0.58);
  backdrop-filter: blur(8px);
}

.loading-card {
  display: grid;
  place-items: center;
  gap: 12px;
  width: min(320px, 100%);
  padding: 30px 26px;
  border: 1px solid rgba(180, 220, 222, 0.82);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 70px rgba(35, 92, 106, 0.18);
  text-align: center;
  animation: loadingIn 180ms ease both;
}

.loading-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(19, 162, 146, 0.16);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 820ms linear infinite;
}

.loading-card strong {
  color: #172235;
  font-size: 17px;
  font-weight: 900;
}

.loading-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

@keyframes loadingIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

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

@media (max-width: 1040px) {
  .app-shell {
    padding: 18px;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .control-panel {
    position: static;
  }

  .content-panel {
    grid-template-rows: auto auto;
  }

  .preview-stage {
    min-height: 380px;
    max-height: 70vh;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 14px;
  }

  .control-panel,
  .thumb-panel,
  .preview-panel {
    padding: 20px;
  }

  .title-block {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
  }

  .title-block h1 {
    font-size: 23px;
  }

  .upload-zone {
    min-height: 178px;
  }

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

  .thumb-list {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  }

  .preview-stage {
    min-height: 330px;
  }
}
