:root {
  --paper: #f2efe5;
  --surface: #fffdf7;
  --ink: #17201c;
  --muted: #68726c;
  --line: rgb(23 32 28 / 13%);
  --green: #0f9f73;
  --green-dark: #093f32;
  --green-soft: #dff4ea;
  --yellow: #ffd45a;
  --orange: #ee8841;
  --stage: #092b24;
  --anchor-x: 50%;
  --anchor-y: 52%;
  --shadow: 0 26px 72px rgb(44 53 47 / 14%);
  color-scheme: light;
  font-family: "Avenir Next", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 4%, rgb(15 159 115 / 18%), transparent 30rem),
    radial-gradient(circle at 92% 8%, rgb(238 136 65 / 18%), transparent 32rem),
    linear-gradient(135deg, #edf4ee 0%, var(--paper) 50%, #eee6d8 100%);
  overflow-x: hidden;
}

button {
  font: inherit;
  cursor: pointer;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

h1,
h2,
p,
pre {
  margin: 0;
}

.page {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 44px;
}

.page > *,
.demo-shell,
.control-bar,
.stage-section,
.bottom-grid > *,
.code-panel {
  min-width: 0;
  max-width: 100%;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.eyebrow::before {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 2px 2px 0 var(--orange);
  content: "";
}

h1 {
  font-size: clamp(34px, 4vw, 52px);
  line-height: 1.08;
}

.lead {
  margin-top: 10px;
  color: var(--muted);
  font-size: clamp(15px, 1.55vw, 18px);
  font-weight: 800;
  line-height: 1.65;
}

.support-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid rgb(15 159 115 / 24%);
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 900;
}

.support-chip.is-unsupported {
  border-color: rgb(238 136 65 / 36%);
  color: #864711;
  background: #fff0dd;
}

.demo-shell {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgb(255 253 247 / 84%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.control-bar {
  display: grid;
  grid-template-columns: minmax(220px, 0.78fr) minmax(410px, 1.35fr) minmax(210px, 0.68fr);
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.control-heading,
.control-heading > div,
.position-buttons,
.fallback-toggle,
.fallback-toggle span,
.stage-head,
.position-chip,
.code-head {
  display: flex;
  align-items: center;
}

.control-heading {
  gap: 12px;
}

.control-heading > div {
  align-items: flex-start;
  flex-direction: column;
  gap: 2px;
}

.control-number {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: white;
  background: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
}

.control-heading p,
.stage-head p,
.code-head > span,
.point-card > span {
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.control-heading h2 {
  font-size: 18px;
  letter-spacing: -0.035em;
}

.position-buttons {
  gap: 7px;
}

.position-buttons button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: white;
  font-size: 12px;
  font-weight: 900;
}

.position-buttons button[aria-pressed="true"] {
  border-color: var(--green);
  color: var(--green-dark);
  background: var(--green-soft);
}

.fallback-toggle {
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgb(15 159 115 / 25%);
  border-radius: 13px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 900;
}

.fallback-toggle span {
  gap: 7px;
}

.fallback-toggle i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgb(15 159 115 / 13%);
}

.fallback-toggle strong {
  display: grid;
  place-items: center;
  min-width: 36px;
  min-height: 26px;
  border-radius: 999px;
  color: white;
  background: var(--green-dark);
  font-size: 10px;
}

.fallback-toggle[aria-pressed="false"] {
  border-color: var(--line);
  color: var(--muted);
  background: white;
}

.fallback-toggle[aria-pressed="false"] i {
  background: #aab2ad;
  box-shadow: none;
}

.fallback-toggle[aria-pressed="false"] strong {
  color: var(--muted);
  background: #e9ece9;
}

.stage-section {
  padding: 20px;
  background:
    linear-gradient(rgb(23 32 28 / 4%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(23 32 28 / 4%) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
}

.stage-head,
.code-head {
  justify-content: space-between;
  gap: 14px;
}

.stage-head {
  margin-bottom: 14px;
}

.stage-head h2 {
  margin-top: 3px;
  font-size: 21px;
  letter-spacing: -0.035em;
}

.position-chip {
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgb(255 255 255 / 80%);
  font-size: 10px;
  letter-spacing: 0.09em;
}

.position-chip i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgb(255 212 90 / 24%);
}

.anchor-stage {
  position: relative;
  min-height: 410px;
  border: 1px solid rgb(255 255 255 / 13%);
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 46%, rgb(41 190 143 / 19%), transparent 33%),
    linear-gradient(rgb(255 255 255 / 5%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 5%) 1px, transparent 1px),
    var(--stage);
  background-size: auto, 32px 32px, 32px 32px, auto;
  box-shadow: inset 0 0 70px rgb(0 0 0 / 20%);
  overflow: hidden;
}

.safe-frame {
  position: absolute;
  inset: 24px;
  border: 1px dashed rgb(255 255 255 / 17%);
  border-radius: 14px;
  pointer-events: none;
}

.edge-label {
  position: absolute;
  z-index: 1;
  color: rgb(255 255 255 / 30%);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.16em;
  pointer-events: none;
}

.edge-label--top,
.edge-label--bottom {
  left: 50%;
  transform: translateX(-50%);
}

.edge-label--top { top: 9px; }
.edge-label--bottom { bottom: 9px; }
.edge-label--left,
.edge-label--right {
  top: 50%;
  writing-mode: vertical-rl;
  transform: translateY(-50%);
}
.edge-label--left { left: 9px; }
.edge-label--right { right: 9px; }

.anchor-point {
  position: absolute;
  left: var(--anchor-x);
  top: var(--anchor-y);
  z-index: 3;
  width: 1px;
  height: 1px;
  transition: left 360ms cubic-bezier(0.22, 1, 0.36, 1), top 360ms cubic-bezier(0.22, 1, 0.36, 1);
  anchor-name: --tooltip-trigger;
}

.anchor-point.is-dragging {
  transition: none;
}

.anchor-target {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 10px 0 18px;
  border: 0;
  border-radius: 999px;
  color: #182019;
  background: var(--yellow);
  box-shadow: 0 16px 32px rgb(0 0 0 / 28%);
  transform: translate(-50%, -50%);
  touch-action: none;
  user-select: none;
}

.anchor-target span {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.anchor-target b {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: white;
  background: var(--green-dark);
  font-size: 16px;
}

.tooltip {
  position: absolute;
  left: calc(var(--anchor-x) + 74px);
  top: var(--anchor-y);
  z-index: 2;
  display: grid;
  gap: 4px;
  width: 220px;
  padding: 14px 16px;
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 14px;
  color: white;
  background: #0f9f73;
  box-shadow: 0 18px 38px rgb(0 0 0 / 28%);
  transform: translateY(-50%);
}

.tooltip span {
  color: #baf5db;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.tooltip strong {
  font-size: 16px;
  line-height: 1.25;
}

.tooltip small {
  color: rgb(255 255 255 / 72%);
  font-size: 10px;
  font-weight: 700;
}

@supports (anchor-name: --tooltip-trigger) and (position-area: top right) {
  .tooltip {
    inset: auto;
    margin: 12px;
    position-anchor: --tooltip-trigger;
    position-area: top right;
    position-try-fallbacks:
      bottom right,
      top left,
      bottom left;
    transform: none;
  }

  .anchor-stage[data-fallback="false"] .tooltip {
    position-try-fallbacks: none;
  }
}

.drag-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 1;
  padding: 8px 12px;
  border-radius: 999px;
  color: rgb(255 255 255 / 55%);
  background: rgb(0 0 0 / 18%);
  font-size: 10px;
  font-weight: 800;
  transform: translateX(-50%);
  pointer-events: none;
}

.drag-hint span {
  color: var(--yellow);
}

.fallback-notice {
  margin-top: 12px;
  padding: 11px 13px;
  border: 1px solid rgb(238 136 65 / 34%);
  border-radius: 12px;
  color: #7b4519;
  background: #fff0dd;
  font-size: 12px;
  font-weight: 800;
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.55fr);
  gap: 14px;
  margin-top: 14px;
}

.code-panel {
  border-radius: 17px;
  color: #ecfff7;
  background: var(--green-dark);
  overflow: hidden;
}

.code-head {
  min-height: 46px;
  padding: 0 15px;
  border-bottom: 1px solid rgb(255 255 255 / 12%);
}

.code-head > span {
  color: #8fe0bf;
}

.code-head button {
  min-height: 31px;
  padding: 0 11px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 9px;
  color: white;
  background: rgb(255 255 255 / 10%);
  font-size: 10px;
  font-weight: 900;
}

.code-panel pre {
  padding: 13px 15px;
  overflow-x: auto;
}

.code-panel code {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.55;
}

.copy-status {
  padding: 0 15px;
  color: #8fe0bf;
  font-size: 11px;
  font-weight: 800;
}

.copy-status:not(:empty) {
  min-height: 28px;
  padding-bottom: 9px;
}

.point-card {
  display: grid;
  align-content: center;
  padding: 18px;
  border: 1px solid rgb(238 136 65 / 28%);
  border-radius: 17px;
  background: #fff0dd;
}

.point-card > span {
  margin-bottom: 7px;
  color: #a75a1c;
}

.point-card p {
  color: #68401e;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.65;
}

@media (max-width: 980px) {
  .control-bar {
    grid-template-columns: minmax(220px, 0.75fr) minmax(0, 1.25fr);
  }

  .fallback-toggle {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .page {
    width: min(100% - 24px, 620px);
    padding: 21px 0 28px;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 13px;
  }

  h1 {
    font-size: clamp(31px, 10.5vw, 43px);
  }

  .demo-shell {
    border-radius: 20px;
  }

  .control-bar {
    grid-template-columns: 1fr;
    padding: 17px;
  }

  .fallback-toggle {
    grid-column: auto;
  }

  .stage-section {
    padding: 14px;
  }

  .stage-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .anchor-stage {
    min-height: 430px;
  }

  .tooltip {
    width: 140px;
    padding: 12px 13px;
  }

  .tooltip strong {
    font-size: 14px;
  }

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

@media (max-width: 380px) {
  .position-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .anchor-stage {
    min-height: 400px;
  }

  .drag-hint {
    width: max-content;
    max-width: calc(100% - 32px);
  }
}

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