  :root {
    --bg: #05070f;
    --panel: rgba(13, 19, 34, 0.74);
    --panel-solid: #0b1120;
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #e9eefb;
    --muted: #90a0be;
    --muted-2: #6d7c9b;
    --accent: #ffd166;
    --glucose: #4ea1ff;
    --fructose: #b083ff;
    --galactose: #35d7c8;
    --sodium: #ffd166;
    --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --cn: "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  * { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; }
  body {
    background:
      radial-gradient(1100px 620px at 8% -12%, rgba(78, 161, 255, 0.14), transparent 62%),
      radial-gradient(900px 560px at 92% -6%, rgba(255, 107, 107, 0.10), transparent 58%),
      radial-gradient(1100px 760px at 52% 118%, rgba(126, 231, 135, 0.07), transparent 60%),
      var(--bg);
    color: var(--text);
    font-family: var(--cn);
    font-size: 14px;
    line-height: 1.55;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
  }
  h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
  button { font-family: inherit; color: inherit; cursor: pointer; }
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 8px; }
  ::-webkit-scrollbar-track { background: transparent; }

  .app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px 12px;
    /* iPad 横屏 Home 条/圆角不压住 dock（env 不支持时回退上一行） */
    padding: 14px calc(16px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom))
             calc(16px + env(safe-area-inset-left));
  }

  /* ---------- top bar ---------- */
  .topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    padding: 0 4px;
    flex: 0 0 auto;
  }
  .brand .kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    letter-spacing: 0.14em;
    color: var(--muted);
    text-transform: uppercase;
  }
  .brand .kicker::before {
    content: "";
    width: 22px; height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent));
  }
  .brand h1 {
    font-size: 27px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
    margin-top: 2px;
  }
  .brand h1 span {
    color: var(--muted-2);
    font-size: 15px;
    font-weight: 400;
    margin-left: 10px;
    letter-spacing: 0.06em;
  }
  .brand .subtitle {
    color: var(--muted);
    font-size: 12.5px;
    margin-top: 4px;
  }
  .legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    justify-content: flex-end;
    padding-bottom: 3px;
  }
  .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
  }
  .legend-item i {
    width: 10px; height: 10px;
    border-radius: 3px;
    display: inline-block;
    box-shadow: 0 0 10px currentColor;
  }

  /* ---------- main grid ---------- */
  .main {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr) 428px;
    gap: 13px;
  }
  .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    backdrop-filter: blur(10px);
  }

  /* ---------- left rail ---------- */
  .rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 13px 12px;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .rail h2 {
    font-size: 11px;
    letter-spacing: 0.18em;
    color: var(--muted-2);
    text-transform: uppercase;
    padding-left: 3px;
  }
  .stage-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
  .stage-item {
    display: grid;
    grid-template-columns: 26px 1fr;
    gap: 9px;
    align-items: start;
    padding: 8px 10px 8px 8px;
    border-radius: 11px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
    color: var(--muted);
    text-align: left;
    width: 100%;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
  }
  .stage-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
  .stage-item .num {
    width: 24px; height: 24px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted-2);
    border: 1px solid var(--line);
  }
  .stage-item .name { font-size: 13.5px; color: var(--text); font-weight: 600; display: block; }
  .stage-item .sub { font-size: 11.5px; color: var(--muted); display: block; margin-top: 1px; }
  .stage-item .win {
    font-size: 10.5px;
    color: var(--muted-2);
    font-family: var(--mono);
    display: block;
    margin-top: 2px;
  }
  .stage-item.is-active {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02));
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03), 0 6px 18px -12px var(--accent);
  }
  .stage-item.is-active .num {
    background: var(--accent);
    color: #0a0f1c;
    border-color: transparent;
    font-weight: 700;
  }
  .stage-item.is-done .num { color: var(--accent); border-color: var(--accent); }

  .rail-block {
    border-top: 1px solid var(--line);
    padding-top: 10px;
  }
  .rail-block h3 {
    font-size: 11px;
    letter-spacing: 0.16em;
    color: var(--muted-2);
    text-transform: uppercase;
    margin-bottom: 7px;
  }
  .bullets { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
  .bullets li {
    position: relative;
    padding-left: 16px;
    font-size: 12.5px;
    color: var(--text);
    opacity: 0.92;
  }
  .bullets li::before {
    content: "";
    position: absolute;
    left: 2px; top: 8px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
  }
  details.rail-details {
    border-top: 1px solid var(--line);
    padding-top: 10px;
    font-size: 12.5px;
  }
  details.rail-details > summary {
    cursor: pointer;
    list-style: none;
    font-size: 11px;
    letter-spacing: 0.16em;
    color: var(--muted-2);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  details.rail-details > summary::-webkit-details-marker { display: none; }
  details.rail-details > summary::after { content: "＋"; font-size: 13px; color: var(--muted); }
  details.rail-details[open] > summary::after { content: "－"; }
details.rail-details .detail-body { margin-top: 9px; display: flex; flex-direction: column; gap: 8px; }

  .term { color: var(--text); font-weight: 600; font-size: 12px; }
  .term-desc { color: var(--muted); font-size: 12px; }
  .fact { color: var(--muted); font-size: 12px; padding-left: 14px; position: relative; }
  .fact::before {
    content: "·";
    position: absolute; left: 3px; color: var(--accent);
  }

  /* ---------- center stage ---------- */
  .stage {
    position: relative;
    border-radius: 18px;
    border: 1px solid var(--line);
    overflow: hidden;
    background:
      radial-gradient(720px 520px at 50% 8%, rgba(78, 161, 255, 0.13), transparent 70%),
      radial-gradient(620px 460px at 50% 108%, rgba(255, 107, 107, 0.09), transparent 68%),
      linear-gradient(180deg, #070c17 0%, #05080f 100%);
  }
  .stage::after {
    /* hologram grid */
    content: "";
    position: absolute; inset: 0;
    background-image:
      linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 46px 46px, 46px 46px;
    mask-image: radial-gradient(70% 60% at 50% 45%, #000 20%, transparent 100%);
    pointer-events: none;
    z-index: 0;
  }
  #gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 1; touch-action: none; }
  #gl.is-hover { cursor: pointer; }
  #gl.is-grabbing { cursor: grabbing; }

  .stage-hud {
    position: absolute;
    top: 14px; left: 16px; right: 16px;
    display: flex;
    flex-wrap: wrap;
    row-gap: 8px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    z-index: 3;
    pointer-events: none;
  }
  .stage-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: min(46%, 360px);
    min-width: 0;
    padding: 7px 13px;
    border-radius: 999px;
    background: rgba(7, 11, 20, 0.72);
    border: 1px solid var(--line-strong);
    backdrop-filter: blur(8px);
    font-size: 12.5px;
  }

  .stage-badge b { white-space: nowrap; }

  .stage-badge #badgeSub {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  .stage-badge .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
  }
  .stage-badge b { font-weight: 600; }
  .stage-badge .win { color: var(--muted); font-family: var(--mono); font-size: 11px; }
  .stage-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 6px;
    gap: 10px;
    margin-left: auto;
    pointer-events: auto;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(7, 11, 20, 0.72);
    border: 1px solid var(--line);
    backdrop-filter: blur(8px);
    font-size: 11.5px;
    color: var(--muted);
  }
  .stage-tools .tool {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
  }
  .stage-tools input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 78px; height: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.18);
    outline: none;
  }
  .stage-tools input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
    cursor: pointer;
  }
  .tool-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 3px 9px;
    font-size: 11.5px;
    color: var(--muted);
  }
  .tool-btn:hover { color: var(--text); border-color: var(--line-strong); }
  .tool-btn.is-on { color: #0a0f1c; background: var(--accent); border-color: transparent; font-weight: 600; }

  .caption {
    position: absolute;
    left: 16px; right: 16px; bottom: 14px;
    z-index: 3;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 16px;
    padding: 13px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    background: linear-gradient(180deg, rgba(9, 14, 26, 0.9), rgba(9, 14, 26, 0.78));
    backdrop-filter: blur(10px);
    box-shadow: 0 22px 40px -30px #000;
  }
  .caption-head { display: flex; align-items: center; gap: 10px; }
  .caption-head .idx {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    color: #0a0f1c;
    background: var(--accent);
    border-radius: 6px;
    padding: 1px 7px;
    font-weight: 700;
  }
  .caption-head .cn { font-size: 15px; font-weight: 700; }
  .caption-head .cn em { font-style: normal; color: var(--muted); font-weight: 400; font-size: 12.5px; margin-left: 8px; }
  .caption h2 { font-size: 15px; margin-top: 8px; color: var(--text); font-weight: 600; }
  .caption p { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.62; }
  .caption .aside { border-left: 1px solid var(--line); padding-left: 16px; display: flex; flex-direction: column; gap: 8px; }
  .kv { display: grid; grid-template-columns: 42px 1fr; gap: 8px; font-size: 12px; align-items: baseline; }
  .kv dt { color: var(--muted-2); }
  .kv dd { margin: 0; color: var(--text); }
  .kv dd.eq { font-family: var(--mono); font-size: 11.5px; color: var(--accent); line-height: 1.5; }
  .kv dd.note { color: var(--muted); font-size: 11.5px; line-height: 1.55; }

  .tooltip {
    position: absolute;
    z-index: 5;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(7, 11, 20, 0.92);
    border: 1px solid var(--line-strong);
    font-size: 12px;
    color: var(--text);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -140%);
    transition: opacity 0.14s ease;
    white-space: nowrap;
  }
  .tooltip.is-on { opacity: 1; }

  .stage-loading {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: grid;
    place-items: center;
    gap: 10px;
    background: rgba(5, 8, 15, 0.86);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    transition: opacity 0.4s ease;
  }
  .stage-loading.is-hidden { opacity: 0; pointer-events: none; }
  .stage-loading .ring {
    width: 30px; height: 30px;
    margin: 0 auto 10px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-top-color: var(--accent);
    animation: spin 1s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ---------- right molecules ---------- */
  .mol {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    overflow-y: auto;
  }
  .mol-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .mol-head h2 { font-size: 13.5px; font-weight: 600; }
  .mol-head h2 span { font-size: 11px; color: var(--muted-2); letter-spacing: 0.14em; margin-left: 8px; text-transform: uppercase; }
  .mol-head .live {
    font-size: 10.5px;
    color: var(--muted-2);
    font-family: var(--mono);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px 8px;
  }
  .mol-wrap {
    position: relative;
    width: 100%;
    /* 用 flex 填满右侧剩余高度：固定 aspect-ratio 会被 flex 压缩（实测只有 400×264） */
    flex: 1 1 auto;
    min-height: 250px;
    max-height: min(46vh, 430px);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #0a1020 0%, #070c17 100%);
  }
  #mol { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
  .mol-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
  }
  .tag i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
  /* 单行横向滚动：给上方的分子画布让出高度（原来的多行换行会吃掉 ~45px） */
  .tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 5px; padding-bottom: 2px; }
  .tab {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding: 5px 9px;
    flex: 0 0 auto;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.25;
    transition: all 0.16s ease;
  }
  .tab small { font-size: 10px; color: var(--muted-2); }
  .tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }
  .tab.is-active {
    color: #0a0f1c;
    background: var(--accent);
    border-color: transparent;
    font-weight: 600;
  }
  .tab.is-active small { color: rgba(10, 15, 28, 0.65); }
  .mol-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    background: rgba(255, 255, 255, 0.028);
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .mol-card .title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
  .mol-card .title i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
  .mol-card .row { display: grid; grid-template-columns: 40px 1fr; gap: 8px; font-size: 11.8px; align-items: baseline; }
  .mol-card .row span { color: var(--muted-2); }
  .mol-card .row b { font-weight: 500; color: var(--text); }
  .mol-card .eq {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent);
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 9px;
    line-height: 1.5;
    word-break: break-word;
  }
  .mol-card .note { font-size: 11.5px; color: var(--muted); line-height: 1.58; }
  .mol-extra { display: flex; flex-direction: column; gap: 6px; }
  .mol-extra .hint { font-size: 11px; color: var(--muted-2); }
  .mol-extra button {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 11.5px;
    color: var(--muted);
  }
  .mol-extra button:hover { color: var(--text); border-color: var(--line-strong); }

  /* ---------- bottom dock ---------- */
  .dock {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 9px 14px;
  }
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.05);
    padding: 7px 13px;
    font-size: 12.5px;
    white-space: nowrap;
    transition: all 0.15s ease;
  }
  .btn:hover { background: rgba(255, 255, 255, 0.1); }
  .btn.primary {
    background: var(--accent);
    color: #0a0f1c;
    border-color: transparent;
    font-weight: 600;
    min-width: 84px;
    justify-content: center;
  }
  .btn.primary:hover { filter: brightness(1.08); }
  .btn .icon { font-size: 12px; }

  .track {
    flex: 1 1 auto;
    min-width: 200px;
    display: flex;
    gap: 5px;
  }
  .seg {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 9px 7px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.028);
    text-align: left;
    overflow: hidden;
    transition: border-color 0.16s ease, background 0.16s ease;
  }
  .seg:hover { background: rgba(255, 255, 255, 0.07); }
  .seg .bar {
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
  }
  .seg .fill {
    position: absolute;
    left: 0; top: 0;
    height: 2px;
    width: 0%;
    background: var(--seg-accent, var(--accent));
    box-shadow: 0 0 10px var(--seg-accent, var(--accent));
  }
  .seg .label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .seg .sub {
    display: block;
    font-size: 10px;
    color: var(--muted-2);
    font-family: var(--mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .seg.is-active { border-color: var(--seg-accent, var(--accent)); background: rgba(255, 255, 255, 0.07); }
  .seg.is-active .label { color: var(--text); }

  .time {
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  .dock-divider { width: 1px; height: 22px; background: var(--line); flex: 0 0 auto; }
  .field {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11.5px;
    color: var(--muted);
    white-space: nowrap;
  }
  .field select {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 5px 6px;
    font-family: inherit;
    font-size: 11.5px;
    outline: none;
  }
  .check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
  .check input { accent-color: var(--accent); }
  .keyhint { font-size: 10.5px; color: var(--muted-2); white-space: nowrap; }
  .credit {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    font-size: 10.5px;
    line-height: 1.65;
    color: var(--muted-2);
  }
  .keyhint kbd {
    font-family: var(--mono);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0 4px;
    margin: 0 1px;
    color: var(--muted);
  }

  .notice {
    grid-column: 1 / -1;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 176, 32, 0.4);
    background: rgba(255, 176, 32, 0.08);
    color: #ffd79a;
    font-size: 12.5px;
  }
  .notice.is-on { display: flex; }

  @media (max-width: 1500px) {
    .main { grid-template-columns: 262px minmax(0, 1fr) 390px; }
    .brand h1 { font-size: 24px; }
  }
  @media (max-width: 1240px) {
    /* 窄三栏：不再砍掉左栏，压缩为 200px（左栏自身可滚动） */
    .main { grid-template-columns: 200px minmax(0, 1fr) 330px; }
    .caption { grid-template-columns: 1fr; }
    .caption .aside { display: none; }
    .keyhint { display: none; }
  }
  @media (max-width: 1040px) {
    .main { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
    /* 底部坞放行换行：768 档起控件总宽超出单行，禁止溢出 */
    .dock { flex-wrap: wrap; row-gap: 8px; }
  }
  @media (max-width: 767.98px) {
    /* ≤768 归手机版方案（另行实施）；平板档（768–1040）左栏走下方抽屉 */
    .rail { display: none; }
  }

  /* 投影/笔记本常见 1280×720 或矮屏：压缩底部讲解卡，别挡住人体 */
  @media (max-width: 1400px), (max-height: 880px) {
    .caption {
      right: auto;
      width: min(56%, 470px);
      grid-template-columns: minmax(0, 1fr);
      gap: 0;
      padding: 10px 13px;
      bottom: 10px;
    }
    .caption .aside { display: none; }
    .caption-head .cn { font-size: 14px; }
    .caption-head .cn em { font-size: 11.5px; }
    .caption h2 { font-size: 14px; margin-top: 6px; }
    .caption p { font-size: 12px; margin-top: 5px; max-height: 3.3em; overflow: hidden; }
    .stage-tools { font-size: 11px; }
  }

  @media (max-height: 720px) {
    .caption { width: min(48%, 400px); }
    .caption p { max-height: 2.4em; }
  }

  /* ---------- 平板适配 V2（768–1040 抽屉 / 竖屏高度 / 触屏语义化） ---------- */
  .rail-toggle { display: none; }
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(2, 4, 10, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
  }
  @media (min-width: 768px) and (max-width: 1040px) {
    .rail-toggle {
      display: inline-flex;
      align-items: center;
      flex: 0 0 auto;
      gap: 6px;
      background: rgba(255, 255, 255, 0.06);
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 7px 12px;
      font-size: 13px;
      color: var(--muted);
    }
    .rail-toggle:hover { color: var(--text); border-color: var(--line-strong); }
    .rail {
      position: fixed;
      top: 0;
      bottom: 0;
      left: 0;
      z-index: 40;
      width: min(320px, 84vw);
      border-radius: 0 16px 16px 0;
      background: var(--panel-solid);
      box-shadow: 24px 0 60px -30px #000;
      transform: translateX(-102%);
      transition: transform 0.25s ease;
    }
    body.rail-open .rail { transform: none; }
    body.rail-open .drawer-backdrop { opacity: 1; visibility: visible; }
  }
  @media (orientation: portrait) and (max-width: 1040px) {
    /* 竖屏高度充裕：放宽分子画布上限、讲解卡加宽到可读 */
    .mol-wrap { max-height: min(60vh, 560px); }
    .caption { width: min(88%, 560px); }
    .caption p { max-height: 4.5em; }
  }
  @media (pointer: coarse) {
    /* 纯触屏设备无键盘，快捷键提示是噪音（外接键盘时 pointer 为 fine，仍显示） */
    .keyhint { display: none; }
  }

  /* 整页全屏时根元素兜底底色，避免边缘白/黑闪 */
  html:fullscreen { background: var(--bg); }
  html:-webkit-full-screen { background: var(--bg); }

  /* 全屏按钮：固定右上角悬浮（全屏状态下也始终可见可点） */
  .btn-fullscreen {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    right: calc(14px + env(safe-area-inset-right));
    z-index: 45;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    border-radius: 999px;
    background: rgba(7, 11, 20, 0.72);
    border: 1px solid var(--line-strong);
    backdrop-filter: blur(8px);
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
  }
  .btn-fullscreen:hover { color: var(--text); border-color: var(--accent); }
  .btn-fullscreen.is-on { color: var(--accent); border-color: var(--accent); }
  @media (max-width: 1040px) {
    /* 窄屏下图例可能换行到右上角，给悬浮按钮让出角落 */
    .legend { padding-right: 78px; }
  }
