/* Round 3 layout (design/round3/预览图.png). Red is used in four places only: the start button,
   changed numbers, the standing-distance result and the red dots in the picture. Selected = black. */
:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink2: #3a3a3c;
  --on-ink: #ffffff;
  --muted: #6e6e73;
  --line: #e7e4dd;
  --line2: #f0eee9;
  --chip: #f1efea;
  --field-line: #d9d5cc;
  --soft: #fbfaf8;
  --red: #c8242b;
  --red-soft: #fceded;
  --red-ink: #8e1b20;
  --warn: #8a5a00;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --card: #1e1e21;
    --ink: #ececee;
    --ink2: #cfcfd4;
    --on-ink: #141416;
    --muted: #9a9aa2;
    --line: #313136;
    --line2: #2a2a2f;
    --chip: #2a2a2f;
    --field-line: #3d3d43;
    --soft: #232327;
    --red: #e0464c;
    --red-soft: #3a1c1d;
    --red-ink: #ffb3b3;
    --warn: #e0b45a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font: inherit; color: inherit; }

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 40px 40px;
  padding-left: max(40px, env(safe-area-inset-left));
  padding-right: max(40px, env(safe-area-inset-right));
}

/* ---- header ---- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 26px 0 22px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark { width: 38px; height: 38px; display: block; flex: none; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.5px; font-weight: 800; line-height: 1.2; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.lang { display: flex; gap: 4px; background: var(--chip); padding: 3px; border-radius: 9px; flex: none; }
.lang button { border: 0; background: transparent; color: var(--ink2); padding: 4px 10px; border-radius: 7px; font-size: 12.5px; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }

/* ---- layout: settings | sticky side panel; one column on narrow screens ---- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 470px; gap: 0 24px; align-items: start; }
.steps { grid-column: 1; grid-row: 1; min-width: 0; }
.adv { grid-column: 1; grid-row: 2; min-width: 0; }
.side { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 20px; min-width: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.step { padding: 20px 26px 10px; margin-bottom: 16px; }
.step-h { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.num { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--on-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: none; }
.step-h h2 { margin: 0; font-size: 18px; }
.sub { color: var(--muted); font-size: 13px; }
.row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 18px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line2); }
.step-h + .row { border-top: 0; }
.lab { font-weight: 600; font-size: 14px; padding-top: 8px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 7px 0 0; }
.hint.warn { color: var(--warn); }
.inline-hint { margin: 0; }
.line { display: flex; align-items: center; gap: 12px; min-height: 38px; }
.line.wrap { flex-wrap: wrap; }

/* segmented buttons */
.seg { display: inline-flex; background: var(--chip); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; max-width: 100%; }
.seg button { border: 0; background: transparent; padding: 7px 15px; border-radius: 8px; font-size: 14px; color: var(--ink2); white-space: nowrap; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--on-ink); font-weight: 600; }
.seg.cls button { min-width: 46px; text-align: center; padding: 7px 10px; }
.seg.small button { font-size: 13px; padding: 6px 11px; white-space: normal; text-align: left; }

select { border: 1px solid var(--field-line); border-radius: 10px; padding: 8px 12px; background: var(--card); min-width: 300px; max-width: 100%; font-size: 14px; }

/* difficulty cards */
.cards3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.dcard { text-align: left; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--card); cursor: pointer; }
.dcard b { font-size: 14.5px; display: block; }
.dcard span { color: var(--muted); font-size: 12.5px; display: block; margin-top: 2px; }
.dcard[aria-checked="true"] { border: 2px solid var(--ink); background: var(--soft); padding: 9.5px 13.5px; }

/* target type tiles with switches */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; cursor: pointer; }
.tile.on { border: 2px solid var(--ink); padding: 11.5px 13.5px; }
.tile.off { opacity: 0.45; cursor: not-allowed; }
.tile .ic { width: 40px; height: 40px; flex: none; }
.tile .tt { min-width: 0; flex: 1; }
.tile b { font-size: 14.5px; display: block; }
.tile small { color: var(--muted); font-size: 12px; line-height: 1.35; display: block; }
.tile .needs { display: none; }
.tile.off .needs { display: block; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 11px; background: #d5d2cb; transition: background 0.15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: left 0.15s; }
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::after { left: 19px; }
.switch input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.switch input:disabled { cursor: not-allowed; }

.info { display: flex; gap: 10px; align-items: flex-start; background: var(--soft); border-radius: 10px; padding: 10px 12px; margin-top: 10px; color: var(--ink2); font-size: 13px; }
.info i { font-style: normal; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid #8a8a8e; color: #8a8a8e; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex: none; margin-top: 1px; }

/* look-time panel under "full array" */
.subpanel { margin-top: 10px; border-left: 3px solid var(--ink); background: var(--soft); border-radius: 0 10px 10px 0; padding: 10px 14px; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.subpanel .t { font-weight: 600; }
.subpanel .hint { margin: 0; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--field-line); border-radius: 10px; overflow: hidden; background: var(--card); flex: none; }
.stepper button { width: 34px; height: 34px; border: 0; background: transparent; color: var(--ink2); font-size: 16px; cursor: pointer; }
.stepper input { width: 54px; height: 34px; text-align: center; font-size: 15px; font-weight: 700; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: transparent; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.unit { color: var(--muted); }

.result { display: inline-flex; align-items: baseline; gap: 6px; background: var(--red-soft); color: var(--red-ink); border-radius: 10px; padding: 7px 12px; font-size: 13.5px; }
.result b { font-size: 16px; color: var(--red); }

/* ---- advanced ---- */
.adv { padding: 18px 26px 16px; margin-bottom: 16px; }
.adv-h { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.adv-h::-webkit-details-marker { display: none; }
.adv-h h2 { margin: 0; font-size: 18px; }
.chev { width: 10px; height: 10px; border-right: 2px solid var(--ink2); border-bottom: 2px solid var(--ink2); transform: rotate(-45deg); margin: 0 4px 0 2px; transition: transform 0.15s; }
.adv[open] .chev { transform: rotate(45deg); margin-bottom: 4px; }
.ghost { margin-left: auto; border: 1px solid var(--field-line); background: var(--card); border-radius: 9px; padding: 5px 12px; font-size: 13px; color: var(--ink2); cursor: pointer; }
.adv-note { color: var(--muted); font-size: 13px; margin: 6px 0 4px 26px; }
.grp { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.grp-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.grp-h h3 { margin: 0; font-size: 15.5px; }
.grp-h .sub { font-size: 12.5px; }
.prow { display: grid; grid-template-columns: 104px minmax(0, 1fr) 150px 130px; gap: 14px; align-items: center; padding: 9px 0; border-top: 1px dashed var(--line2); }
.grp-h + .prow, .grp-h + div > .prow:first-child { border-top: 0; }
.prow.two { grid-template-columns: 104px minmax(0, 1fr); }
.prow .n { font-weight: 600; }
.prow .d { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.prow .d .warn { color: var(--warn); display: block; }
.num-in { display: inline-flex; align-items: center; border: 1px solid var(--field-line); border-radius: 9px; background: var(--card); padding: 0 10px; width: 120px; justify-content: space-between; }
.num-in input { width: 64px; border: 0; background: transparent; padding: 6px 0; font-size: 15px; font-weight: 600; -moz-appearance: textfield; }
.num-in input::-webkit-outer-spin-button, .num-in input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-in em { font-style: normal; color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.num-in.changed { border: 2px solid var(--red); background: var(--red-soft); padding: 0 9px; }
.num-in.changed input { color: var(--red); }
.def { font-size: 12px; color: var(--muted); }
.def button { border: 0; background: none; padding: 0; color: var(--red); font-weight: 600; margin-left: 6px; font-size: 12px; cursor: pointer; }
.def .warn { color: var(--warn); display: block; }

/* ---- side panel ---- */
.panel { padding: 16px 18px; margin-bottom: 14px; }
.panel-h { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-h b { font-size: 15px; }
.muted { color: var(--muted); font-size: 12.5px; }
.tv { border-radius: 10px; overflow: hidden; background: #111; padding: 6px; }
.tv canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 5px; background: #fff; }
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.flow span { background: var(--chip); border-radius: 8px; padding: 4px 9px; font-size: 12.5px; color: var(--ink2); }
.flow span.hl { background: var(--ink); color: var(--on-ink); }
.flow span.beep { background: var(--ink); color: var(--on-ink); font-weight: 700; }
.flow i { font-style: normal; color: #a3a09a; font-size: 12px; }
.stats4 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--soft); border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 19px; font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }
.stat .v.sm { font-size: 15px; line-height: 1.4; }
.stat .v small { font-size: 12.5px; font-weight: 500; color: var(--ink2); }
.error { background: var(--red-soft); color: var(--red-ink); border-radius: 10px; padding: 10px 12px; grid-column: 1 / -1; }
.btn-main { display: flex; width: 100%; align-items: center; justify-content: center; gap: 10px; background: var(--red); color: #fff; font-weight: 700; font-size: 17px; border: 0; border-radius: 12px; padding: 14px 0; margin-top: 14px; cursor: pointer; }
.btn-main:disabled { opacity: 0.5; cursor: not-allowed; }
.btns { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 8px; margin-top: 8px; }
.btn { border: 1px solid var(--field-line); border-radius: 10px; padding: 9px 6px; text-align: center; font-size: 13.5px; color: var(--ink2); background: var(--card); cursor: pointer; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.export-group { display: flex; border: 1px solid var(--field-line); border-radius: 10px; overflow: hidden; background: var(--card); }
.export-group .btn { border: 0; border-radius: 0; flex: 1; padding-right: 2px; }
.export-group select { min-width: 0; width: auto; border: 0; border-left: 1px solid var(--line); border-radius: 0; padding: 0 4px; font-size: 13px; background: transparent; }
.exportbox { margin-top: 12px; }
.export-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 10px; }
.bar div { height: 100%; width: 0; background: var(--ink); transition: width 0.2s; }
.data summary { display: flex; align-items: baseline; gap: 8px; cursor: pointer; flex-wrap: wrap; }
.data summary b { font-size: 14.5px; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12.5px; }
th { color: var(--muted); font-weight: 500; text-align: left; padding: 5px 4px; border-bottom: 1px solid var(--line); }
td { padding: 5px 4px; border-bottom: 1px solid var(--line2); vertical-align: top; }
td.r, th.r { text-align: right; white-space: nowrap; }

.safety { color: var(--muted); font-size: 12.5px; text-align: center; margin-top: 18px; }
.mobile-bar { display: none; }

/* ---- narrow screens: one column, side content after step 4, start button pinned ---- */
@media (max-width: 1099px) {
  .page { padding: 0 16px 96px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .steps, .adv, .side { grid-column: 1; grid-row: auto; position: static; }
  .side { order: 2; }
  .adv { order: 3; }
  .side #play { display: none; }
  .mobile-bar { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
  .mobile-bar .btn-main { margin: 0; }
}
@media (max-width: 720px) {
  .step, .adv { padding-left: 16px; padding-right: 16px; }
  .row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .lab { padding-top: 0; }
  .cards3, .tiles { grid-template-columns: minmax(0, 1fr); }
  .seg.cls button { min-width: 0; padding: 7px 9px; }
  select { min-width: 0; width: 100%; }
  .prow { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
  .prow .n { grid-column: 1 / -1; }
  .prow .d { grid-column: 1 / -1; }
  .prow.two { grid-template-columns: minmax(0, 1fr); }
  .btns { grid-template-columns: 1fr 1fr; }
  .btns .export-group { grid-column: 1 / -1; }
  .adv-note { margin-left: 0; }
}

/* ---- playback ---- */
.stage { position: fixed; inset: 0; background: #ffffff; z-index: 10; cursor: none; }
.stage canvas { width: 100%; height: 100%; display: block; }
.stage.show-hud { cursor: default; }
.hud {
  position: absolute;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(20, 20, 22, 0.82);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.hud .btn { background: #2c2c30; color: #fff; border-color: #44444a; }
.hud #hudState { font-size: 13px; padding: 0 6px; color: #d0d0d4; }
.stage.show-hud .hud { opacity: 1; pointer-events: auto; }
