:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --bg-2: #111113;
  --surface: rgba(22, 22, 25, 0.88);
  --surface-strong: rgba(30, 30, 34, 0.94);
  --surface-soft: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f2ea;
  --muted: #9b978f;
  --subtle: #6f6b65;
  --primary: #d8b16a;
  --primary-2: #6fd0bd;
  --danger: #ff8f70;
  --success: #7bd6a4;
  --stage: #f5f5f2;
  --stage-grid: #e7e6e1;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.46);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(216, 177, 106, 0.08), transparent 34rem),
    linear-gradient(90deg, rgba(111, 208, 189, 0.08), transparent 30rem),
    linear-gradient(135deg, #0b0b0d 0%, #111113 46%, #09090b 100%);
  color: var(--text);
  font-family:
    "DM Sans", Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 72%);
}

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

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 11, 13, 0.78);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(216, 177, 106, 0.42);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(216, 177, 106, 0.28), rgba(111, 208, 189, 0.08)),
    rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.brand-mark span {
  width: 18px;
  height: 18px;
  border: 2px solid var(--primary);
  border-right-color: var(--primary-2);
  border-radius: 50%;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.icon-btn,
.text-btn,
.primary-btn,
.history-toggle {
  cursor: pointer;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
}

.history-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 11px 0 13px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
}

.history-toggle span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.history-toggle strong {
  min-width: 22px;
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(216, 177, 106, 0.16);
  color: var(--primary);
  font-size: 12px;
  text-align: center;
}

.history-toggle:hover {
  border-color: rgba(216, 177, 106, 0.48);
  background: rgba(216, 177, 106, 0.1);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
}

.icon-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:hover,
.text-btn:hover {
  border-color: rgba(216, 177, 106, 0.48);
  background: rgba(216, 177, 106, 0.1);
  color: var(--text);
}

.settings-panel {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(220px, 360px) auto;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 18, 21, 0.92);
  backdrop-filter: blur(18px);
}

.settings-panel label,
.inline-controls label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.settings-panel input,
.inline-controls select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.settings-panel input::placeholder,
textarea::placeholder {
  color: var(--subtle);
}

.settings-panel input:focus,
.inline-controls select:focus,
textarea:focus {
  border-color: rgba(216, 177, 106, 0.72);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(216, 177, 106, 0.14);
}

.settings-panel button {
  align-self: end;
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  background: var(--text);
  color: #0b0b0d;
  font-weight: 800;
  cursor: pointer;
}

.history-drawer {
  position: fixed;
  z-index: 40;
  top: 92px;
  right: 18px;
  width: min(430px, calc(100vw - 28px));
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(18, 18, 21, 0.96);
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(24px);
  overflow: hidden;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(216, 177, 106, 0.12), rgba(255, 255, 255, 0.03));
}

.history-head h2 {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.2;
}

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

.history-list {
  display: grid;
  gap: 10px;
  padding: 12px;
  overflow: auto;
}

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

.history-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.history-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.history-item-title {
  min-width: 0;
}

.history-item-title strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
}

.history-item-title span {
  display: block;
  margin-top: 4px;
  color: var(--subtle);
  font-size: 11px;
}

.history-status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.065);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.history-status.success {
  background: rgba(123, 214, 164, 0.14);
  color: var(--success);
}

.history-status.failed {
  background: rgba(255, 143, 112, 0.14);
  color: var(--danger);
}

.history-status.processing,
.history-status.submitted {
  background: rgba(216, 177, 106, 0.14);
  color: var(--primary);
}

.history-prompt {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  word-break: break-word;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.history-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 7px;
  color: var(--subtle);
  font-size: 11px;
}

.history-result {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.history-result img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--stage);
}

.history-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 11px;
}

.history-item-actions button,
.history-item-actions a {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--primary);
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 392px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  height: calc(100vh - 79px);
  min-height: 0;
}

.tool-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.tool-panel {
  padding: 16px;
  overflow: auto;
  max-height: 100%;
}

.panel-kicker {
  margin-bottom: 14px;
  border: 1px solid rgba(216, 177, 106, 0.26);
  border-radius: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(216, 177, 106, 0.14), rgba(111, 208, 189, 0.06));
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.section-title {
  margin: 16px 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

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

.tool-card {
  position: relative;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 78px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.tool-card.wide {
  grid-column: 1 / -1;
}

.tool-card::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(90deg, rgba(216, 177, 106, 0.16), transparent);
  transition: opacity 180ms ease;
}

.tool-card:hover {
  transform: translateY(-1px);
  border-color: rgba(216, 177, 106, 0.36);
  background: rgba(255, 255, 255, 0.065);
}

.tool-card:hover::after,
.tool-card.active::after {
  opacity: 1;
}

.tool-card.active {
  border-color: rgba(216, 177, 106, 0.72);
  background: rgba(216, 177, 106, 0.12);
}

.tool-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--primary);
}

.tool-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.tool-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
  line-height: 1.25;
}

.tool-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 106px;
  border: 1px dashed rgba(245, 242, 234, 0.32);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025)),
    rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  padding: 16px;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.upload-box:hover,
.upload-box.dragging {
  transform: translateY(-1px);
  border-color: rgba(111, 208, 189, 0.76);
  background: rgba(111, 208, 189, 0.085);
}

.upload-box input {
  display: none;
}

.upload-box span {
  font-weight: 800;
}

.upload-box small {
  margin-top: 6px;
  color: var(--muted);
}

.thumb-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

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

.thumb button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.66);
  color: #fff;
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.65;
}

.inline-controls {
  margin-top: 12px;
}

.primary-btn {
  position: sticky;
  bottom: 0;
  z-index: 3;
  width: 100%;
  margin-top: 14px;
  border: 0;
  border-radius: 10px;
  padding: 13px 14px;
  background:
    linear-gradient(135deg, #f5f2ea 0%, #d8b16a 100%);
  color: #111113;
  font-weight: 900;
  box-shadow: 0 14px 34px rgba(216, 177, 106, 0.24);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 44px rgba(216, 177, 106, 0.3);
}

.primary-btn:disabled {
  cursor: not-allowed;
  transform: none;
  background: #5d5a55;
  color: #b9b5ad;
  box-shadow: none;
}

.primary-btn.processing {
  overflow: hidden;
  background: linear-gradient(135deg, #f5f2ea 0%, #d8b16a 54%, #6fd0bd 100%);
  color: #0b0b0d;
}

.primary-btn.processing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.46), transparent);
  transform: translateX(-120%);
  animation: buttonSweep 1.4s ease-in-out infinite;
}

.status-text {
  min-height: 22px;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status-text.error {
  color: var(--danger);
}

.status-text.success {
  color: var(--success);
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  min-width: 0;
  min-height: 0;
}

.preview-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.panel-heading h2 {
  margin: 2px 0 0;
  font-size: 16px;
  line-height: 1.15;
}

.panel-label {
  color: var(--primary);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.text-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--primary);
  text-decoration: none;
}

.image-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background-color: var(--stage);
  background-image:
    linear-gradient(45deg, var(--stage-grid) 25%, transparent 25%),
    linear-gradient(-45deg, var(--stage-grid) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--stage-grid) 75%),
    linear-gradient(-45deg, transparent 75%, var(--stage-grid) 75%);
  background-position:
    0 0,
    0 14px,
    14px -14px,
    -14px 0;
  background-size: 28px 28px;
}

.image-stage.empty {
  color: #77736b;
  font-weight: 700;
}

.image-stage.waiting {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, rgba(216, 177, 106, 0.16), transparent 34%),
    linear-gradient(145deg, #101014 0%, #17171b 52%, #0d0d10 100%);
  color: var(--text);
}

.image-stage.waiting::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: conic-gradient(
    from 90deg,
    transparent,
    rgba(216, 177, 106, 0.08),
    rgba(111, 208, 189, 0.08),
    transparent 42%
  );
  animation: waitingGlow 8s linear infinite;
}

.waiting-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  justify-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 12px;
  padding: 28px;
  background: rgba(14, 14, 17, 0.76);
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  text-align: center;
}

.waiting-visual {
  position: relative;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(216, 177, 106, 0.26);
  background:
    radial-gradient(circle, rgba(216, 177, 106, 0.18), transparent 52%),
    rgba(255, 255, 255, 0.035);
}

.waiting-grid,
.waiting-scan,
.waiting-mark {
  position: absolute;
  inset: 0;
}

.waiting-grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
  mask-image: radial-gradient(circle, #000 52%, transparent 72%);
  opacity: 0.5;
}

.waiting-scan {
  background: linear-gradient(180deg, transparent 0%, rgba(111, 208, 189, 0.34) 48%, transparent 100%);
  transform: translateY(-100%);
  animation: waitingScan 2.4s ease-in-out infinite;
}

.waiting-mark {
  inset: 22px;
  border: 2px solid rgba(216, 177, 106, 0.26);
  border-top-color: var(--primary);
  border-right-color: var(--primary-2);
  border-radius: 50%;
  animation: waitingSpin 1.2s linear infinite;
}

.waiting-copy {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.waiting-label {
  color: var(--primary);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.waiting-copy strong {
  font-size: 19px;
  line-height: 1.25;
}

.waiting-copy p {
  max-width: 30em;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.waiting-copy small {
  color: var(--subtle);
  font-size: 12px;
}

.waiting-meter {
  width: min(280px, 100%);
  height: 4px;
  margin: 7px 0 2px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.waiting-meter span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--primary), var(--primary-2), transparent);
  animation: waitingMeter 1.8s ease-in-out infinite;
}

.processing-overlay {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 60;
  width: min(520px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 13px 14px;
  background:
    linear-gradient(135deg, rgba(216, 177, 106, 0.12), rgba(111, 208, 189, 0.08)),
    rgba(15, 15, 18, 0.9);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.processing-orbit {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(216, 177, 106, 0.26);
  background: rgba(255, 255, 255, 0.045);
}

.processing-orbit::before,
.processing-orbit span {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(216, 177, 106, 0.18);
  border-top-color: var(--primary);
  border-right-color: var(--primary-2);
  border-radius: 50%;
  animation: waitingSpin 1.1s linear infinite;
}

.processing-orbit span {
  inset: 15px;
  border-width: 0;
  background: var(--primary);
  box-shadow: 0 0 20px rgba(216, 177, 106, 0.56);
  animation: waitingPulse 1.5s ease-in-out infinite;
}

.processing-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.processing-copy strong {
  font-size: 14px;
  line-height: 1.25;
}

.processing-copy span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.processing-line {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.processing-line span {
  display: block;
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--primary), var(--primary-2), transparent);
  animation: waitingMeter 1.55s ease-in-out infinite;
}

.image-stage img {
  max-width: 100%;
  max-height: 76vh;
  border-radius: 8px;
  object-fit: contain;
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(0, 0, 0, 0.08);
}

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

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

@keyframes waitingScan {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }

  25%,
  75% {
    opacity: 1;
  }

  100% {
    transform: translateY(100%);
    opacity: 0;
  }
}

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

@keyframes waitingMeter {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(260%);
  }
}

@keyframes waitingPulse {
  0%,
  100% {
    transform: scale(0.78);
    opacity: 0.62;
  }

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

@keyframes buttonSweep {
  100% {
    transform: translateX(120%);
  }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .image-stage {
    min-height: 460px;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  .brand-lockup {
    gap: 10px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 9px;
  }

  .brand-mark span {
    width: 15px;
    height: 15px;
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 9px;
    letter-spacing: 0.14em;
  }

  .topbar h1 {
    font-size: 17px;
    line-height: 1.25;
  }

  .topbar-meta {
    grid-column: 1 / -1;
    justify-content: flex-start;
    gap: 6px;
  }

  .topbar-meta span {
    padding: 6px 8px;
    font-size: 11px;
  }

  .history-toggle {
    grid-column: 1 / -1;
    justify-content: space-between;
    width: 100%;
    height: 38px;
  }

  .settings-panel {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .history-drawer {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: calc(100vh - 20px);
  }

  .workspace {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: auto;
    min-height: auto;
    padding: 12px;
  }

  .tool-panel,
  .preview-panel {
    border-radius: 10px;
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
  }

  .tool-panel {
    padding: 12px;
    overflow: visible;
    max-height: none;
  }

  .panel-kicker {
    margin-bottom: 12px;
    padding: 9px 10px;
    font-size: 10px;
  }

  .section-title {
    margin: 14px 0 8px;
  }

  .tool-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .tool-card {
    grid-template-columns: 28px 1fr;
    gap: 7px;
    min-height: 72px;
    padding: 8px 7px;
    border-radius: 9px;
  }

  .tool-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
  }

  .tool-icon svg {
    width: 14px;
    height: 14px;
  }

  .tool-card strong {
    font-size: 12px;
  }

  .tool-card span {
    font-size: 10px;
    line-height: 1.35;
  }

  .upload-box {
    min-height: 92px;
    padding: 14px;
  }

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

  textarea {
    min-height: 110px;
  }

  .primary-btn {
    position: static;
    padding: 14px;
  }

  .processing-overlay {
    bottom: 12px;
    grid-template-columns: 36px 1fr;
    padding: 11px 12px;
  }

  .processing-orbit {
    width: 36px;
    height: 36px;
  }

  .processing-copy strong {
    font-size: 13px;
  }

  .processing-copy span {
    font-size: 11px;
  }

  .preview-grid {
    gap: 12px;
  }

  .panel-heading {
    min-height: 56px;
    padding: 11px 12px;
  }

  .panel-heading h2 {
    font-size: 15px;
  }

  .text-btn {
    padding: 7px 9px;
    font-size: 13px;
  }

  .image-stage {
    min-height: 260px;
    padding: 14px;
  }

  .image-stage img {
    max-height: 56vh;
  }
}

@media (max-width: 390px) {
  .topbar h1 {
    font-size: 15px;
  }

  .tool-list {
    gap: 6px;
  }

  .tool-card {
    grid-template-columns: 26px 1fr;
    min-height: 72px;
    padding: 7px 6px;
  }

  .tool-icon {
    width: 26px;
    height: 26px;
  }

  .tool-card strong {
    font-size: 11px;
  }

  .tool-card span {
    font-size: 9px;
    line-height: 1.3;
  }

  .image-stage {
    min-height: 230px;
  }
}
