:root {
  color-scheme: dark;
  --bg: #111313;
  --panel: #191b1c;
  --panel-2: #202323;
  --line: rgba(255, 255, 255, 0.11);
  --text: #f5f1e8;
  --muted: #a6aaa6;
  --soft: #777c78;
  --accent: #31d1c5;
  --accent-2: #d8b867;
  --danger: #ff746d;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 50% 18%, rgba(49, 209, 197, 0.16), transparent 34%),
    #111313;
}

.auth-screen.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.auth-box {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #191b1c;
  padding: 28px;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.45);
  animation: rise 420ms ease both;
}

.auth-brand {
  margin-bottom: 26px;
}

.auth-box h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.05;
}

.auth-box p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.shell {
  min-height: 100svh;
  display: grid;
  grid-template-rows: 64px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 19, 19, 0.92);
  backdrop-filter: blur(18px);
}

.brand,
.status,
.account {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-size: 15px;
  font-weight: 680;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background:
    linear-gradient(135deg, rgba(49, 209, 197, 0.95), rgba(216, 184, 103, 0.9)),
    #222;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.status {
  color: var(--muted);
  font-size: 13px;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(49, 209, 197, 0.12);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(420px, 1fr) 292px;
}

.panel {
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 18px 20px;
  overflow: auto;
}

.history {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.panel-head,
.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-head p,
.stage-head p {
  margin: 0;
  font-size: 14px;
  font-weight: 720;
}

.stage-head span {
  display: block;
  margin-top: 4px;
  color: var(--soft);
  font-size: 12px;
}

label,
.control-group {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

label > span,
.label {
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #151717;
  color: var(--text);
  outline: none;
}

select {
  height: 40px;
  padding: 0 12px;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 146px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(49, 209, 197, 0.72);
  box-shadow: 0 0 0 3px rgba(49, 209, 197, 0.09);
}

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

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-tab {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #151717;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.mode-tab.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(49, 209, 197, 0.1);
}

.upload-zone {
  min-height: 82px;
  margin: 0;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: #151717;
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 14px;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: rgba(49, 209, 197, 0.65);
  color: var(--text);
}

.upload-zone input {
  display: none;
}

.reference-preview {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: center;
}

.reference-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.size {
  height: 62px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #151717;
  color: var(--text);
  display: grid;
  place-items: center;
  gap: 2px;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

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

.size small {
  color: var(--soft);
  font-size: 10px;
}

.size:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.24);
}

.size.active {
  border-color: var(--accent);
  background: rgba(49, 209, 197, 0.1);
}

.meta-line {
  display: flex;
  justify-content: space-between;
  margin: -8px 0 18px;
  color: var(--soft);
  font-size: 12px;
}

.ghost,
.download {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 7px 10px;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}

.ghost:hover,
.download:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.24);
}

.generate {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: var(--radius);
  color: #071514;
  background: linear-gradient(135deg, var(--accent), #81e6c9);
  font-weight: 760;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: transform 180ms ease, filter 180ms ease;
}

.generate:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.generate:disabled {
  cursor: wait;
  filter: grayscale(0.35);
}

.progress-wrap {
  margin: 2px 0 14px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.09);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 360ms ease;
}

.spark {
  font-size: 16px;
}

.stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 22px 24px 24px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #121414;
  background-size: 44px 44px;
}

.canvas-wrap {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}

.canvas {
  width: min(76vh, 100%);
  max-width: 850px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: #ede8dc;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
  animation: rise 620ms ease both;
}

.canvas img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.placeholder {
  color: #1d2020;
  text-align: center;
}

.large-mark {
  display: block;
  font-size: clamp(54px, 9vw, 112px);
  line-height: 0.9;
  font-weight: 850;
  color: rgba(29, 32, 32, 0.14);
}

.placeholder p {
  margin: 14px 0 0;
  color: rgba(29, 32, 32, 0.52);
  font-size: 14px;
}

.history-list {
  display: grid;
  gap: 12px;
}

.empty {
  margin-top: 24px;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.5;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease;
  animation: enter 300ms ease both;
}

.history-item:hover {
  transform: translateY(-1px);
  border-color: rgba(49, 209, 197, 0.55);
}

.history-item img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
}

.history-copy {
  padding: 10px;
}

.history-copy strong {
  display: block;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 10px 13px;
  border-radius: 8px;
  background: #242827;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  animation: enter 180ms ease both;
}

.toast.error {
  border-color: rgba(255, 116, 109, 0.45);
  color: #ffd5d2;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

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

  .history {
    display: none;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-rows: 58px auto;
  }

  .topbar {
    padding: 0 14px;
  }

  .workspace {
    display: block;
  }

  .panel,
  .stage {
    border: 0;
    padding: 16px;
  }

  .creator {
    border-bottom: 1px solid var(--line);
  }

  .canvas-wrap {
    padding: 12px 0;
  }

  .canvas {
    width: 100%;
  }
}
