:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --card: #141416;
  --card-2: #19191c;
  --line: #29292e;
  --text: #f1eee7;
  --muted: #96918a;
  --faint: #655f58;
  --gold: #e6c27c;
  --gold-deep: #b78f47;
  --green: #71d29b;
  --red: #e47c78;
  --radius: 22px;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif,
    system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0.01em;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

.ambient {
  position: fixed;
  inset: -25% -10% auto;
  height: 70vh;
  background:
    radial-gradient(circle at 20% 30%, rgba(230, 194, 124, 0.16), transparent 34%),
    radial-gradient(circle at 78% 10%, rgba(120, 85, 200, 0.12), transparent 32%),
    radial-gradient(circle at 55% 70%, rgba(50, 100, 120, 0.1), transparent 34%);
  filter: blur(30px);
  pointer-events: none;
  z-index: 0;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 28px 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  border-radius: 9px;
  box-shadow: 0 8px 24px rgba(192, 38, 211, 0.25);
}

.brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.24em;
}

.brand-name span {
  color: var(--muted);
  margin-left: 6px;
  font-weight: 500;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 20, 22, 0.7);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.05em;
  backdrop-filter: blur(12px);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 4px rgba(101, 95, 88, 0.12);
}

.pill--ok {
  color: var(--green);
  border-color: rgba(113, 210, 155, 0.24);
}

.pill--ok .dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(113, 210, 155, 0.12);
}

.pill--warn {
  color: var(--gold);
  border-color: rgba(230, 194, 124, 0.24);
}

.pill--warn .dot {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(230, 194, 124, 0.12);
}

.pill--bad {
  color: var(--red);
  border-color: rgba(228, 124, 120, 0.24);
}

.pill--bad .dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(228, 124, 120, 0.12);
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.85fr);
  gap: 22px;
  max-width: 1180px;
  margin: 22px auto 0;
  padding: 0 28px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 30%),
    var(--card);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.stage {
  padding: 26px;
}

.stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.28em;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", "Noto Serif SC", serif;
  font-weight: 500;
  letter-spacing: 0.02em;
}

h1 {
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.05;
}

h2 {
  font-size: 20px;
}

.tag {
  flex: none;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid #303036;
  border-radius: 14px;
  background: #030304;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.02),
    0 20px 50px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: border-color 160ms ease;
}

.canvas-wrap.is-drag {
  border-color: var(--gold);
}

#preview {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

.canvas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--faint);
  text-align: center;
  pointer-events: none;
}

.canvas-empty p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.canvas-empty span {
  font-size: 11px;
  letter-spacing: 0.08em;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.032) 0,
    rgba(255, 255, 255, 0.032) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: soft-light;
  opacity: 0.35;
  pointer-events: none;
}

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    opacity 140ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #3a3a42;
  background: #1d1d21;
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.btn--primary {
  border-color: rgba(230, 194, 124, 0.42);
  color: #1b160d;
  background: var(--gold);
}

.btn--primary:hover:not(:disabled) {
  border-color: var(--gold);
  background: #f0cf8e;
}

.btn--accent {
  margin-left: auto;
  border-color: rgba(230, 194, 124, 0.4);
  color: var(--gold);
  background: rgba(230, 194, 124, 0.08);
}

.btn--accent:hover:not(:disabled) {
  background: rgba(230, 194, 124, 0.14);
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn--danger {
  width: 100%;
  margin-top: 18px;
  border-color: rgba(228, 124, 120, 0.22);
  color: var(--red);
  background: rgba(228, 124, 120, 0.06);
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.side {
  display: grid;
  align-content: start;
  gap: 22px;
}

.panel {
  padding: 24px;
}

.facts {
  margin: 20px 0 0;
}

.facts div {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #232327;
}

.facts div:last-child {
  border-bottom: 0;
}

dt {
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.steps {
  display: grid;
  gap: 14px;
  margin: 20px 0;
  padding: 0;
  list-style: none;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.steps span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.06em;
}

.fine {
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid #232327;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.6;
}

.footer {
  display: flex;
  justify-content: space-between;
  max-width: 1180px;
  margin: 34px auto 0;
  padding: 0 28px 30px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.2em;
}

.token-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
}

.token-dialog::backdrop {
  background: rgba(3, 3, 4, 0.72);
  backdrop-filter: blur(8px);
}

.token-dialog form {
  padding: 30px;
}

.token-dialog h2 {
  font-size: 30px;
}

.dialog-copy {
  margin: 10px 0 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #0e0e10;
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.field input:focus {
  border-color: rgba(230, 194, 124, 0.55);
}

.token-dialog .btn {
  width: 100%;
  margin-top: 18px;
}

.error {
  margin: 12px 0 0;
  color: var(--red);
  font-size: 11px;
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 0 16px;
  }

  .topbar {
    padding: 20px 16px 8px;
  }

  .stage {
    padding: 18px;
  }

  .upload-row {
    align-items: stretch;
    flex-direction: column;
  }

  .btn--accent {
    margin-left: 0;
  }

  .footer {
    padding: 0 16px 24px;
  }
}
