:root {
  --bg: #eef3f8;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --text: #111827;
  --muted: #64748b;
  --muted-strong: #475569;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --ring: rgba(37, 99, 235, 0.18);
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.10), 0 1px 0 rgba(255, 255, 255, 0.75) inset;
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "SF Pro Text", "Segoe UI", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(37, 99, 235, 0.16), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(14, 165, 233, 0.14), transparent 30%),
    linear-gradient(135deg, #f8fbff 0%, #eef3f8 52%, #e8eef7 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
  font-size: 0.95em;
}

.topbar {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 382px) minmax(0, 1fr);
  gap: 18px;
  height: 100dvh;
  padding: 18px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  padding: 2px 4px 24px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(37, 99, 235, 0.28) transparent;
}

.sidebar::-webkit-scrollbar,
.stack::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-thumb,
.stack::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.24);
}

.card {
  position: relative;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.04) inset;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.card-title::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #38bdf8, var(--accent));
  box-shadow: 0 0 0 5px var(--accent-soft);
}

.field .card-title::before {
  width: 5px;
  height: 5px;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.card .hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  text-wrap: pretty;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.field.inline {
  flex-direction: row;
  align-items: center;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 700;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row.wrap {
  flex-wrap: wrap;
}

input[type="text"],
input[type="number"],
input[type="file"],
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(248, 250, 252, 0.86);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
  font-size: 14px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="file"]:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.48);
  background: #ffffff;
  box-shadow: 0 0 0 4px var(--ring), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

input[type="file"] {
  padding: 8px;
  color: var(--muted-strong);
}

input[type="file"]::file-selector-button {
  min-height: 32px;
  margin-right: 10px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
}

textarea {
  min-height: 76px;
  resize: vertical;
  line-height: 1.5;
}

input[type="color"] {
  width: 52px;
  height: 42px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.9);
  padding: 4px;
  cursor: pointer;
}

.btn {
  min-height: 42px;
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  background: #ffffff;
  color: var(--muted-strong);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08) inset, 0 8px 18px rgba(15, 23, 42, 0.06);
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms cubic-bezier(0.2, 0, 0, 1), color 140ms ease, box-shadow 140ms ease,
    background-color 140ms ease;
}

.btn:hover {
  color: var(--accent-strong);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.24) inset, 0 12px 26px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.btn:active {
  transform: scale(0.96);
}

.btn.primary {
  background: linear-gradient(135deg, #3b82f6 0%, var(--accent-strong) 100%);
  color: #ffffff;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.24), 0 1px 0 rgba(255, 255, 255, 0.32) inset;
}

.btn.primary:hover {
  color: #ffffff;
  box-shadow: 0 16px 34px rgba(37, 99, 235, 0.32), 0 1px 0 rgba(255, 255, 255, 0.32) inset;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
}

.checkbox input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.status {
  min-height: 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.stage {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 28px;
  background:
    linear-gradient(45deg, rgba(148, 163, 184, 0.13) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(148, 163, 184, 0.13) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(148, 163, 184, 0.13) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(148, 163, 184, 0.13) 75%),
    #f8fafc;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  box-shadow: var(--shadow);
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.04) inset, 0 18px 60px rgba(255, 255, 255, 0.32) inset;
}

.stage:not(.stack-stage) canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.stack-stage {
  display: flex;
  flex-direction: column;
  padding: 14px;
}

.stack {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow: auto;
  padding: 4px 6px 4px 4px;
}

.stack-canvas {
  display: block;
  width: min(100%, 520px);
  height: auto;
  margin: 0 auto;
  border: 0;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.10), 0 14px 34px rgba(15, 23, 42, 0.12);
  touch-action: none;
}

.stack-canvas.is-selected {
  outline: 3px solid rgba(37, 99, 235, 0.84);
  outline-offset: 3px;
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
  }

  .stage {
    min-height: 60vh;
  }
}

@media (max-width: 640px) {
  .layout {
    gap: 12px;
    padding: 12px;
  }

  .card {
    border-radius: 20px;
    padding: 15px;
  }

  .row {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .btn {
    flex: 1 1 auto;
  }
}
