:root {
  --ink: #252129;
  --muted: #756f79;
  --soft: #f3edf0;
  --paper: rgba(255, 253, 250, 0.9);
  --line: rgba(45, 38, 49, 0.11);
  --orange: #ff7b55;
  --orange-deep: #f25d43;
  --mint: #61d4c5;
  --mint-deep: #1a9f91;
  --blue: #5c6df3;
  --danger: #e75561;
  --shadow: 0 24px 70px rgba(61, 48, 67, 0.14);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }

html { min-width: 320px; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 139, 171, 0.25), transparent 25%),
    radial-gradient(circle at 92% 6%, rgba(85, 213, 205, 0.24), transparent 28%),
    radial-gradient(circle at 72% 94%, rgba(255, 199, 112, 0.22), transparent 28%),
    linear-gradient(145deg, #fff7f4 0%, #f3fbfa 54%, #fff9ef 100%);
}

button,
a { -webkit-tap-highlight-color: transparent; }

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(92, 109, 243, 0.38);
  outline-offset: 3px;
}

a { color: inherit; text-decoration: none; }

.skip-link {
  position: fixed;
  z-index: 200;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  color: #fff;
  background: var(--ink);
  transform: translateY(-160%);
}

.skip-link:focus { transform: none; }

.app-header {
  position: sticky;
  z-index: 100;
  top: 0;
  min-height: 70px;
  padding: 12px clamp(18px, 4vw, 58px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 250, 247, 0.76);
  backdrop-filter: blur(18px);
}

.brand-lockup { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--orange-deep));
  box-shadow: 0 9px 20px rgba(242, 93, 67, 0.24);
  font-weight: 950;
}

.brand-copy strong { display: block; font-size: 13px; letter-spacing: 0.08em; }
.brand-copy span { display: block; margin-top: 1px; color: var(--muted); font-size: 11px; }

.mode-tabs { display: flex; align-items: center; gap: 8px; }

.mode-tab {
  min-height: 42px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  color: #68616d;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(45, 38, 49, 0.08);
  font-size: 13px;
  font-weight: 850;
  transition: color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.mode-tab.active,
.mode-tab:hover {
  color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--orange-deep));
  box-shadow: 0 8px 18px rgba(242, 93, 67, 0.22);
}

.hero {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 64px 0 34px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  color: #d95036;
  background: rgba(255, 123, 85, 0.13);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.hero h1,
.panel-title,
.landing-card h2,
.logic-title,
.flow-heading {
  font-family: "Iowan Old Style", "Songti SC", "STSong", serif;
}

.hero h1 {
  max-width: 900px;
  margin: 18px 0 14px;
  font-size: clamp(42px, 7vw, 78px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.hero p {
  max-width: 780px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 620;
  line-height: 1.75;
}

.meta-row { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 9px; }

.meta-pill {
  min-height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: #68616d;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(45, 38, 49, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.landing-grid {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 20px 0 70px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.landing-card {
  position: relative;
  min-height: 500px;
  padding: 28px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--radius-xl);
  background: var(--paper);
  box-shadow: var(--shadow);
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.landing-card:hover { transform: translateY(-4px); box-shadow: 0 32px 90px rgba(61, 48, 67, 0.19); }
.landing-card h2 { margin: 16px 0 10px; font-size: 36px; line-height: 1.05; }
.landing-card p { margin: 0; color: var(--muted); line-height: 1.7; }

.card-number {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  background: var(--ink);
  font-size: 13px;
  font-weight: 950;
}

.card-preview {
  height: 235px;
  margin-top: 26px;
  padding: 18px;
  overflow: hidden;
  border-radius: 22px;
  background:
    linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px),
    #17151b;
  background-size: 22px 22px;
}

.preview-lab { display: grid; grid-template-columns: 0.8fr 1fr 0.9fr; gap: 10px; }
.preview-panel { border-radius: 14px; background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.preview-phone { margin: 0 auto; width: 92px; border: 5px solid #302b33; border-radius: 22px; background: linear-gradient(#fff5f3, #ddf6f2); }
.preview-logic { padding: 12px; background: #fff; }
.preview-logic i { display: block; height: 7px; margin-bottom: 8px; border-radius: 99px; background: #ebe5e9; }
.preview-logic i:nth-child(2) { width: 72%; }
.preview-logic i:nth-child(3) { width: 86%; }

.preview-flow { position: relative; }
.preview-node { position: absolute; width: 72px; height: 126px; border: 3px solid #f4eee9; border-radius: 16px; background: linear-gradient(#fff, #f8e8e3); box-shadow: 0 8px 18px rgba(0,0,0,.22); }
.preview-node:nth-child(1) { left: 12px; top: 50px; }
.preview-node:nth-child(2) { left: 116px; top: 20px; }
.preview-node:nth-child(3) { left: 220px; top: 62px; }
.preview-node:nth-child(4) { right: 10px; top: 30px; }
.preview-flow::before,
.preview-flow::after { content: ""; position: absolute; height: 3px; background: var(--orange); transform-origin: left center; }
.preview-flow::before { left: 78px; top: 108px; width: 54px; transform: rotate(-19deg); }
.preview-flow::after { left: 182px; top: 84px; width: 54px; transform: rotate(18deg); }

.card-cta {
  margin-top: 20px;
  min-height: 48px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--orange-deep));
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(242, 93, 67, 0.23);
}

.lab-shell {
  width: min(1460px, calc(100% - 28px));
  margin: 0 auto;
  padding: 30px 0 52px;
}

.lab-intro {
  padding: 12px 8px 24px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
}

.lab-intro h1 { margin: 10px 0 0; font-family: "Iowan Old Style", "Songti SC", serif; font-size: clamp(34px, 4.5vw, 58px); line-height: 1; letter-spacing: -0.045em; }
.lab-intro p { max-width: 520px; margin: 0; color: var(--muted); line-height: 1.65; }

.lab-grid {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(390px, 1fr) minmax(320px, 430px);
  gap: 22px;
  align-items: start;
}

.control-panel,
.logic-panel,
.phone-stage {
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--radius-xl);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.control-panel,
.logic-panel { padding: 22px; }

.control-panel { position: sticky; top: 92px; }
.logic-panel { position: sticky; top: 92px; max-height: calc(100vh - 114px); overflow: auto; }

.panel-kicker { color: var(--orange-deep); font-size: 11px; font-weight: 950; letter-spacing: 0.12em; text-transform: uppercase; }
.panel-title { margin: 8px 0 6px; font-size: 27px; line-height: 1.05; }
.panel-copy { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.control-group { margin-top: 20px; }
.control-group-title { margin-bottom: 9px; color: #4f4854; font-size: 12px; font-weight: 900; }
.button-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.button-grid.one { grid-template-columns: 1fr; }

.control-button {
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 14px;
  color: #69616d;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 12px;
  font-weight: 850;
  transition: color 170ms ease, background 170ms ease, box-shadow 170ms ease;
}

.control-button:hover,
.control-button.active { color: #fff; background: linear-gradient(135deg, var(--orange), var(--orange-deep)); box-shadow: 0 8px 16px rgba(242, 93, 67, 0.2); }
.control-button.secondary.active { background: linear-gradient(135deg, var(--mint), var(--mint-deep)); }

.strategy-summary {
  margin-top: 18px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(97, 212, 197, 0.11);
  box-shadow: inset 0 0 0 1px rgba(26, 159, 145, 0.16);
}

.strategy-summary strong { display: block; font-size: 12px; }
.strategy-summary span { display: block; margin-top: 5px; color: #3f736d; font-size: 11px; line-height: 1.55; }

.phone-stage {
  min-height: 810px;
  padding: 24px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 152, 125, 0.2), transparent 30%),
    linear-gradient(165deg, rgba(255,255,255,.88), rgba(239,248,248,.84));
}

.phone-caption {
  width: min(390px, 100%);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.phone-device {
  --phone-scale: 0.82;
  position: relative;
  width: calc(390px * var(--phone-scale));
  height: calc(844px * var(--phone-scale));
  border-radius: 44px;
  background: #151219;
  box-shadow: 0 30px 80px rgba(36, 27, 40, 0.27);
}

.phone-device::before {
  content: "";
  position: absolute;
  z-index: 3;
  top: 10px;
  left: 50%;
  width: 96px;
  height: 25px;
  border-radius: 99px;
  background: #151219;
  transform: translateX(-50%);
  pointer-events: none;
}

.prototype-viewport {
  width: 390px;
  height: 844px;
  overflow: hidden;
  border: 0;
  border-radius: 42px;
  transform: scale(var(--phone-scale));
  transform-origin: top left;
  background: #fff;
}

.current-state {
  margin-top: 14px;
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  color: #564e59;
  background: rgba(255,255,255,.78);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 12px;
  font-weight: 850;
}

.state-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mint-deep); box-shadow: 0 0 0 5px rgba(26,159,145,.12); }

.logic-head {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.logic-step {
  display: inline-grid;
  place-items: center;
  min-width: 46px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: #fff;
  background: var(--ink);
  font-size: 11px;
  font-weight: 950;
}

.logic-stage { margin-left: 8px; color: var(--orange-deep); font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.logic-title { margin: 12px 0 8px; font-size: 30px; line-height: 1.05; }
.logic-summary { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }

.logic-section { padding: 17px 0; border-bottom: 1px solid var(--line); }
.logic-section:last-child { border-bottom: 0; }
.logic-section h3 { margin: 0 0 9px; font-size: 12px; letter-spacing: .05em; }
.logic-section p { margin: 0; color: #5f5864; font-size: 12px; line-height: 1.65; }
.logic-list { margin: 0; padding-left: 18px; color: #5f5864; font-size: 12px; line-height: 1.65; }
.logic-list li + li { margin-top: 6px; }

.rule-table { display: grid; gap: 8px; }
.rule-row { padding: 10px 11px; border-radius: 13px; background: rgba(247,243,245,.8); }
.rule-row strong { display: block; font-size: 11px; }
.rule-row span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.45; }

.ref-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ref-chip { padding: 6px 8px; border-radius: 9px; color: #775b50; background: #fff0e9; font-size: 10px; font-weight: 850; }

.flow-page { background: #111315; color: #f7f0e8; }
.flow-page .app-header { color: var(--ink); }

.flow-toolbar {
  position: sticky;
  z-index: 90;
  top: 70px;
  min-height: 60px;
  padding: 9px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(17,19,21,.9);
  backdrop-filter: blur(16px);
}

.flow-toolbar-copy strong { display: block; font-family: "Iowan Old Style", "Songti SC", serif; font-size: 19px; }
.flow-toolbar-copy span { display: block; margin-top: 2px; color: #aaa2aa; font-size: 11px; }
.flow-tools { display: flex; align-items: center; gap: 7px; }
.tool-button { min-width: 42px; min-height: 42px; padding: 0 12px; border-radius: 13px; color: #f7f0e8; background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 1px rgba(255,255,255,.09); font-weight: 900; }
.tool-button.active { color: #fff; background: var(--orange); }

.flow-viewport { position: relative; width: 100%; min-height: calc(100vh - 130px); overflow: auto; }

.flow-canvas {
  --zoom: 1;
  position: relative;
  width: 3480px;
  height: 1640px;
  transform: scale(var(--zoom));
  transform-origin: top left;
  background:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px),
    radial-gradient(circle at 46% 18%, rgba(255,123,85,.11), transparent 24%),
    #111315;
  background-size: 32px 32px, 32px 32px, auto, auto;
}

.flow-lane-title {
  position: absolute;
  z-index: 4;
  padding: 9px 13px;
  border-radius: 999px;
  color: #fff;
  background: rgba(255,255,255,.08);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.09);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
}

.flow-node {
  position: absolute;
  z-index: 5;
  width: 350px;
  min-height: 430px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 24px;
  color: var(--ink);
  background: #fffaf6;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.flow-node:hover,
.flow-node.active { transform: translateY(-5px); box-shadow: 0 32px 75px rgba(0,0,0,.42), 0 0 0 3px rgba(255,123,85,.5); }
.flow-node.branch { background: #f8fbff; }
.flow-node.call { background: #f2fbf8; }

.node-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.node-step { padding: 6px 9px; border-radius: 999px; color: #fff; background: var(--ink); font-size: 10px; font-weight: 950; }
.node-stage { color: var(--orange-deep); font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.node-body { margin-top: 13px; display: grid; grid-template-columns: 132px 1fr; gap: 13px; align-items: start; }
.node-shot { width: 132px; height: 286px; overflow: hidden; border: 5px solid #221f24; border-radius: 22px; background: #eee; box-shadow: 0 10px 24px rgba(29,24,31,.2); pointer-events: none; }
.node-shot-frame { width: 390px; height: 844px; border: 0; transform: scale(.313); transform-origin: top left; background: #fff; pointer-events: none; }
.node-copy h2 { margin: 0 0 8px; font-family: "Iowan Old Style", "Songti SC", serif; font-size: 21px; line-height: 1.05; }
.node-copy p { margin: 0; color: #69616d; font-size: 11px; line-height: 1.55; }
.node-mini { margin-top: 10px; display: grid; gap: 7px; }
.node-mini div { padding: 8px; border-radius: 10px; background: rgba(243,237,240,.75); }
.node-mini strong { display: block; font-size: 9px; letter-spacing: .08em; }
.node-mini span { display: block; margin-top: 3px; color: #6e6671; font-size: 9px; line-height: 1.4; }
.node-ref { margin-top: 10px; color: #8d6b5e; font-size: 9px; font-weight: 850; }

.flow-edges { position: absolute; inset: 0; z-index: 2; width: 3480px; height: 1640px; overflow: visible; pointer-events: none; }
.edge-main { fill: none; stroke: #ff8a62; stroke-width: 4; }
.edge-branch { fill: none; stroke: #65d6c7; stroke-width: 4; stroke-dasharray: 10 8; }
.edge-muted { fill: none; stroke: #7f8790; stroke-width: 3; stroke-dasharray: 8 8; }
.edge-label {
  fill: #f2e9e3;
  stroke: #111315;
  stroke-width: 10px;
  paint-order: stroke fill;
  text-anchor: middle;
  font-family: "Avenir Next", sans-serif;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: .01em;
}

.strategy-card {
  position: absolute;
  z-index: 5;
  width: 560px;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 22px;
  color: #f8f1e9;
  background: rgba(31,34,37,.92);
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
}

.strategy-card h2 { margin: 0 0 5px; font-family: "Iowan Old Style", "Songti SC", serif; font-size: 24px; }
.strategy-card p { margin: 0; color: #ada5aa; font-size: 11px; line-height: 1.55; }
.strategy-grid { margin-top: 13px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.strategy-item { padding: 10px; border-radius: 12px; background: rgba(255,255,255,.06); }
.strategy-item strong { display: block; font-size: 10px; }
.strategy-item span { display: block; margin-top: 4px; color: #b9b1b5; font-size: 9px; line-height: 1.4; }

.flow-detail {
  position: fixed;
  z-index: 140;
  top: 84px;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100vw - 36px));
  padding: 22px;
  overflow: auto;
  border-radius: 26px;
  color: var(--ink);
  background: rgba(255,252,248,.96);
  box-shadow: 0 30px 90px rgba(0,0,0,.4);
  transform: translateX(calc(100% + 36px));
  transition: transform 220ms ease;
}

.flow-detail.open { transform: none; }
.detail-close { float: right; width: 42px; height: 42px; border-radius: 13px; color: var(--ink); background: var(--soft); font-size: 20px; }

.flow-legend { position: absolute; z-index: 6; left: 56px; top: 70px; display: flex; gap: 18px; color: #cfc7cb; font-size: 11px; font-weight: 850; }
.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-line { width: 34px; height: 3px; background: var(--orange); }
.legend-line.branch { background: repeating-linear-gradient(90deg, var(--mint) 0 8px, transparent 8px 13px); }

@media (max-width: 1160px) {
  .lab-grid { grid-template-columns: 280px minmax(370px, 1fr); }
  .logic-panel { position: static; grid-column: 1 / -1; max-height: none; }
  .control-panel { top: 86px; }
}

@media (max-width: 840px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .mode-tabs { width: 100%; overflow-x: auto; }
  .landing-grid { grid-template-columns: 1fr; }
  .lab-intro { align-items: flex-start; flex-direction: column; }
  .lab-grid { grid-template-columns: 1fr; }
  .control-panel, .logic-panel { position: static; }
  .phone-stage { min-height: 750px; }
  .phone-device { --phone-scale: 0.78; }
  .flow-toolbar { top: 122px; align-items: flex-start; flex-direction: column; }
}

@media (max-width: 460px) {
  .app-header { padding: 12px 14px; }
  .brand-copy span { display: none; }
  .mode-tab { min-width: max-content; }
  .hero { padding-top: 42px; }
  .hero h1 { font-size: 44px; }
  .landing-card { min-height: 450px; padding: 20px; }
  .lab-shell { width: min(100% - 16px, 1460px); }
  .control-panel, .logic-panel, .phone-stage { border-radius: 22px; }
  .phone-stage { min-height: 690px; padding: 12px; }
  .phone-device { --phone-scale: 0.72; }
  .button-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
