.stereo-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 8px 0 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbf9;
}

.stereo-kicker {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stereo-hero h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.24;
  letter-spacing: 0;
}

.stereo-lead {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--ink-mid);
  font-size: 14px;
}

.stereo-source {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.stereo-source a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.stereo-workspace {
  display: grid;
  grid-template-columns: minmax(520px, 1.45fr) minmax(280px, 0.55fr);
  gap: 12px;
}

.language-suggest {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(64, 179, 224, 0.35);
  border-radius: 8px;
  background: rgba(240, 249, 255, 0.92);
  color: #075985;
  font-size: 13px;
  font-weight: 700;
}

.language-suggest[hidden] {
  display: none;
}

.language-suggest-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.language-suggest a {
  color: #0369a1;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.language-suggest button {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: rgba(14, 116, 144, 0.1);
  color: #075985;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.result-panel {
  grid-column: 1 / -1;
}

.stereo-panel .panel-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stereo-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.btn svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  fill: currentColor;
}

.tool-tab svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin-right: 6px;
  fill: currentColor;
}

.btn-compact {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.tool-tabs,
.stereo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-actions .btn-primary {
  width: 100%;
}

.stereo-actions .btn-secondary {
  width: 100%;
}

.tool-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--ink-mid);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.tool-tab.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

.draw-tools,
.settings-grid {
  display: grid;
  gap: 10px;
}

.draw-tools {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

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

.tool-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--ink-mid);
  font-size: 12px;
  font-weight: 800;
}

.draw-control {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.draw-control-label {
  flex: 0 0 auto;
  color: var(--ink-mid);
  font-size: 12px;
  font-weight: 800;
}

.tone-picker,
.brush-picker {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-width: 0;
}

.tone-swatch,
.brush-dot {
  flex: 0 0 auto;
  border: 2px solid transparent;
  background: #ffffff;
  cursor: pointer;
}

.tone-swatch {
  width: 30px;
  height: 30px;
  border-color: #a3a3a3;
  border-radius: 0;
}

.tone-swatch[data-depth="255"] {
  background: #ffffff;
}

.tone-swatch[data-depth="210"] {
  background: #d2d2d2;
}

.tone-swatch[data-depth="120"] {
  background: #787878;
}

.tone-swatch[data-depth="55"] {
  background: #373737;
}

.tone-swatch[data-depth="0"] {
  background: #000000;
}

.tone-swatch.active {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.24);
}

.brush-dot {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  padding: 0;
  border-radius: 999px;
}

.brush-dot::before {
  content: "";
  display: block;
  border-radius: 999px;
  background: #7dd3fc;
}

.brush-dot.small::before {
  width: 18px;
  height: 18px;
}

.brush-dot.medium::before {
  width: 32px;
  height: 32px;
}

.brush-dot.large::before {
  width: 36px;
  height: 36px;
  background: #38bdf8;
}

.brush-dot.active {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.24);
}

.depth-hint {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.pattern-upload-field {
  position: relative;
  gap: 4px;
  padding: 12px;
  border: 1px dashed #93c5fd;
  border-radius: var(--radius-sm);
  background: #f8fbff;
  cursor: pointer;
}

.pattern-upload-field.drag-over {
  border-color: #0284c7;
  background: #e0f2fe;
}

.pattern-upload-title {
  color: var(--ink-main);
}

.pattern-upload-copy {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 700;
}

.pattern-upload-preview {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 190px;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #eef6ff 25%, transparent 25%),
    linear-gradient(-45deg, #eef6ff 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef6ff 75%),
    linear-gradient(-45deg, transparent 75%, #eef6ff 75%),
    #ffffff;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  overflow: hidden;
}

.pattern-upload-preview img {
  display: block;
  width: 100%;
  max-height: 230px;
  object-fit: contain;
}

.pattern-upload-placeholder {
  padding: 10px;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.pattern-upload-name {
  min-height: 16px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  word-break: break-all;
}

.stereo-step-ad {
  display: block;
  width: 100%;
  min-height: 250px;
  overflow: hidden;
}

.stereogram-pattern-ad {
  display: block;
  width: 100%;
  min-height: 250px;
}

.mask-tools {
  min-height: 122px;
}

.mask-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 8px;
  max-height: 214px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  overflow: auto;
}

.mask-choice {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  cursor: pointer;
}

.mask-choice img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.mask-choice.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

.canvas-frame,
.result-frame {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  overflow: hidden;
}

.canvas-frame canvas,
.result-frame canvas {
  display: block;
  width: 100%;
  touch-action: none;
}

.canvas-frame canvas {
  aspect-ratio: 64 / 38;
}

.result-frame canvas {
  aspect-ratio: 64 / 42;
}

.result-frame {
  width: 100%;
  min-height: 420px;
}

.empty-result {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  background: rgba(255, 255, 255, 0.78);
}

.empty-result.hidden,
.hidden {
  display: none !important;
}

.stereo-guide {
  margin-top: 14px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: #ffffff;
}

.stereo-guide h2 {
  margin: 0 0 16px;
  color: #0f3ea8;
  font-size: 30px;
  font-weight: 900;
  text-align: center;
}

.magic-guide-image {
  display: block;
  width: 100%;
  max-width: 980px;
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  border: 1px solid #dbeafe;
}

.magic-app-card {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 22px;
  max-width: 980px;
  margin: 16px auto 0;
  padding: 22px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: linear-gradient(135deg, #f8fbff 0%, #ffffff 46%, #f7fdf9 100%);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
}

.magic-app-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.magic-app-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.magic-app-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.15);
}

.magic-app-eyebrow {
  margin: 0 0 4px;
  color: #0f766e;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
}

.magic-app-card h2 {
  margin: 0;
  color: #102033;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.28;
  letter-spacing: 0;
  text-align: left;
}

.magic-app-description {
  margin: 14px 0 0;
  color: var(--ink-mid);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.7;
}

.magic-app-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.magic-app-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #d1fae5;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.magic-app-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 42px;
  margin-top: 18px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  background: #111827;
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  transition: background 140ms ease, transform 140ms ease;
}

.magic-app-button:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.magic-app-screenshots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  min-width: 0;
}

.magic-app-screenshots img {
  display: block;
  width: 100%;
  aspect-ratio: 333 / 592;
  object-fit: cover;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.magic-app-screenshots img:nth-child(2) {
  transform: translateY(-8px);
}

@media (max-width: 900px) {
  .stereo-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .stereo-source {
    text-align: left;
  }

  .stereo-workspace {
    grid-template-columns: 1fr;
  }

  .result-panel {
    grid-column: auto;
  }

  .result-frame {
    min-height: 260px;
  }

}

@media (max-width: 640px) {
  .stereo-hero {
    padding: 16px;
  }

  .stereo-hero h1 {
    font-size: 23px;
  }

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

  .draw-tools {
    grid-template-columns: 1fr;
  }

  .stereo-guide {
    padding: 0;
  }

  .stereo-guide h2 {
    font-size: 24px;
  }

  .magic-app-card {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 16px;
  }

  .magic-app-card h2 {
    font-size: 20px;
  }

  .magic-app-button {
    width: 100%;
  }

  .magic-app-screenshots {
    display: flex;
    gap: 10px;
    margin: 0 -16px;
    padding: 2px 16px 8px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .magic-app-screenshots img {
    flex: 0 0 46%;
    max-width: 180px;
    scroll-snap-align: start;
  }

  .magic-app-screenshots img:nth-child(2) {
    transform: none;
  }

}
