/* CHAIN 工具页 H5 样式（主样式 + 移动端覆盖；PC 与原先完全一致） */
* {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        -webkit-tap-highlight-color: transparent;
    }

    :root{--font-ui:"HarmonyOS Sans SC", "MiSans", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;--font-mono:"JetBrains Mono", "Fira Code", "Source Code Pro", "Liberation Mono", ui-monospace, monospace;
        --g: #22c55e;
        --g2: #16a34a;
        --mint: #86efac;
        --line: rgba(34, 197, 94, .28);
        --text: #eaf7ef;
        --muted: #9db0a2;
        --dim: #6d8273;
    }

    body {
        background: radial-gradient(circle at 20% 30%, #0b0e16, #07090f);
        font-family: var(--font-ui);
        padding: 20px 16px 40px;
        min-height: 100vh;
        color: #dbe4f3;
    }

    .container {
        max-width: 620px;
        margin: 0 auto;
        position: relative;
    }

    /* ---------- 顶栏 ---------- */
    .aq-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 14px;
        padding: 0 4px;
    }
    .aq-back {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        color: var(--muted);
        text-decoration: none;
        font-size: .85rem;
        font-weight: 500;
        padding: 8px 14px 8px 10px;
        border-radius: 999px;
        border: 1px solid var(--line);
        background: rgba(34, 197, 94, .06);
        transition: color .2s, border-color .2s;
    }
    .aq-back:hover { color: var(--g); border-color: var(--g); }
    .aq-back svg {
        width: 15px;
        height: 15px;
        stroke: currentColor;
        fill: none;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
    .aq-name {
        font-size: .72rem;
        letter-spacing: .12em;
        color: #5e6f63;
        white-space: nowrap;
    }

    /* ---------- 主卡片 ---------- */
    .card {
        background: rgba(10, 20, 30, .92);
        border-radius: 32px;
        border: 1px solid var(--line);
        box-shadow: 0 0 24px rgba(34, 197, 94, .12), inset 0 0 6px rgba(34, 197, 94, .08);
        padding: 24px 22px 26px;
        margin-top: 6px;
        overflow-wrap: break-word;
    }

    h1 {
        font-size: 1.7rem;
        font-weight: 700;
        background: linear-gradient(135deg, #86efac, #ff9d6b);
        background-clip: text;
        -webkit-background-clip: text;
        color: transparent;
        margin-bottom: 8px;
        letter-spacing: .5px;
        line-height: 1.3;
    }

    .sub {
        color: var(--muted);
        font-size: .82rem;
        line-height: 1.75;
        border-left: 3px solid var(--g);
        padding-left: 12px;
        margin-bottom: 16px;
    }
    .sub b { color: #d7f7e4; font-weight: 600; }
    .nowrap { white-space: nowrap; }

    /* ---------- 语言 ---------- */

    /* ---------- 折叠块 ---------- */
    details {
        background: rgba(34, 197, 94, .06);
        border: 1px solid rgba(34, 197, 94, .22);
        border-radius: 16px;
        margin-bottom: 18px;
        font-size: .8rem;
        color: var(--muted);
    }
    summary {
        padding: 13px 16px;
        cursor: pointer;
        font-weight: 600;
        color: #d7f7e4;
        outline: none;
        list-style: none;
    }
    summary::-webkit-details-marker { display: none; }
    details[open] summary { border-bottom: 1px solid rgba(34, 197, 94, .18); }
    .details-content {
        padding: 14px 16px 16px;
        line-height: 1.85;
    }
    .details-content b { color: #4ade80; }

    /* ---------- 段落标题 ---------- */
    .cond-title {
        font-size: .7rem;
        color: var(--dim);
        letter-spacing: .22em;
        margin: 20px 0 12px;
        font-weight: 700;
    }

    /* ---------- 链轮输入 ---------- */
    .sprocket-grid {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        gap: 10px;
        align-items: start;
    }
    .sprocket-item { min-width: 0; }
    .sprocket-item label {
        display: block;
        font-size: .75rem;
        color: #b7c9bd;
        margin-bottom: 7px;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .big-box {
        display: flex;
        align-items: baseline;
        justify-content: center;
        gap: 5px;
        background: #0a1218;
        border: 1px solid rgba(34, 197, 94, .3);
        border-radius: 15px;
        padding: 4px 10px;
        transition: border-color .2s, box-shadow .2s;
    }
    .big-box:focus-within {
        border-color: var(--g);
        box-shadow: 0 0 0 4px rgba(34, 197, 94, .14);
    }
    .big-box input {
        flex: 1;
        min-width: 0;
        width: 100%;
        background: none;
        border: 0;
        outline: none;
        color: #fff;
        font-size: 2rem;
        font-weight: 800;
        text-align: center;
        padding: 4px 0;
        font-family: inherit;
        letter-spacing: -.02em;
    }
    .big-box span { font-size: .72rem; color: var(--dim); flex: none; }

    .ratio-preview {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 98px;
        margin-top: 23px;
        padding: 9px 12px 10px;
        background: rgba(34, 197, 94, .08);
        border: 1px solid rgba(34, 197, 94, .32);
        border-radius: 15px;
    }
    .rp-label { font-size: .62rem; color: var(--muted); letter-spacing: .12em; }
    .rp-main { display: flex; align-items: baseline; gap: 2px; line-height: 1; }
    .rp-main strong {
        font-size: 1.55rem;
        font-weight: 800;
        letter-spacing: -.03em;
        background: linear-gradient(135deg, #fff, #86efac 60%, #22c55e);
        background-clip: text;
        -webkit-background-clip: text;
        color: transparent;
    }
    .rp-main em { font-style: normal; font-size: .72rem; font-weight: 700; color: var(--mint); }
    .rp-tag {
        font-size: .62rem;
        color: #bff3d3;
        background: rgba(34, 197, 94, .16);
        border-radius: 999px;
        padding: 2px 8px;
        white-space: nowrap;
    }

    /* ---------- 表单 ---------- */
    .grid2 {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
    .field { min-width: 0; }
    .field label {
        display: block;
        font-size: .75rem;
        color: #b7c9bd;
        margin-bottom: 7px;
        font-weight: 500;
    }
    .field input,
    .field select {
        width: 100%;
        min-width: 0;
        background: #0a1218;
        border: 1px solid rgba(34, 197, 94, .26);
        color: var(--text);
        padding: 12px 14px;
        border-radius: 13px;
        font-size: 16px;
        font-family: inherit;
        outline: none;
        transition: border-color .2s, box-shadow .2s, opacity .2s;
    }
    .field input:focus,
    .field select:focus {
        border-color: var(--g);
        box-shadow: 0 0 0 3px rgba(34, 197, 94, .14);
    }
    .field select { cursor: pointer; }
    .field input:disabled {
        opacity: .45;
        cursor: not-allowed;
    }
    .field-hint {
        display: block;
        font-size: .68rem;
        color: var(--dim);
        line-height: 1.6;
        margin-top: 6px;
    }
    input[type=number]::-webkit-outer-spin-button,
    input[type=number]::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
    input[type=number] { -moz-appearance: textfield; }

    /* ---------- 型号对照表 ---------- */
    .model-ref { margin-top: 14px; font-size: .76rem; }
    .model-ref summary { font-size: .76rem; font-weight: 500; color: #b7c9bd; }
    .table-wrap { padding: 4px 12px 12px; overflow-x: auto; }
    table {
        width: 100%;
        border-collapse: collapse;
        font-size: .7rem;
        white-space: nowrap;
    }
    th, td {
        text-align: left;
        padding: 7px 6px;
        border-bottom: 1px solid rgba(34, 197, 94, .12);
        color: #b7c9bd;
    }
    th { color: var(--dim); font-weight: 600; font-size: .66rem; }
    td:first-child { color: #d7f7e4; font-weight: 700; }
    tr:last-child td { border-bottom: 0; }

    /* ---------- 高级 ---------- */
    .adv { margin: 16px 0 0; }
    .adv summary { font-size: .78rem; }
    .adv-body { padding: 14px 16px 16px; }

    /* ---------- 按钮 ---------- */
    .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        margin-top: 20px;
    }
    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 14px 18px;
        border: 0;
        border-radius: 15px;
        font-size: .9rem;
        font-weight: 700;
        font-family: inherit;
        letter-spacing: .5px;
        cursor: pointer;
        text-decoration: none;
        transition: transform .14s ease-out, background .2s, border-color .2s;
    }
    .btn:active { transform: scale(.98); }
    .btn-primary {
        flex: 1 1 100%;
        background: linear-gradient(135deg, #22c55e, #16a34a);
        color: #04170b;
        box-shadow: 0 8px 22px -12px rgba(34, 197, 94, .8);
    }
    .btn-primary:hover { filter: brightness(1.05); }
    .btn-secondary {
        flex: 1;
        background: #10141d;
        border: 1px solid rgba(34, 197, 94, .28);
        color: #d7f7e4;
        font-weight: 600;
    }
    .btn-secondary:hover { border-color: var(--g); color: var(--mint); }

    /* ---------- 结果 ---------- */
    #result { margin-top: 16px; scroll-margin-top: 16px; }
    .result-card {
        border-color: rgba(34, 197, 94, .4);
        box-shadow: 0 0 48px -20px rgba(34, 197, 94, .6), inset 0 0 6px rgba(34, 197, 94, .08);
    }
    .placeholder {
        text-align: center;
        color: var(--muted);
        font-size: .82rem;
        line-height: 1.8;
        padding: 30px 20px;
    }

    .rec-kicker {
        font-size: .66rem;
        letter-spacing: .26em;
        color: var(--g);
        font-weight: 700;
    }
    .rec-ratio {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
        margin: 6px 0 4px;
    }
    .rec-main { display: flex; align-items: baseline; gap: 3px; line-height: 1.05; }
    .rec-num {
        font-size: 2.5rem;
        font-weight: 800;
        letter-spacing: -.04em;
        background: linear-gradient(135deg, #ffffff 10%, #86efac 62%, #22c55e);
        background-clip: text;
        -webkit-background-clip: text;
        color: transparent;
    }
    .rec-unit { font-size: 1.1rem; font-weight: 700; color: var(--mint); }
    .rec-tag {
        font-size: .7rem;
        font-weight: 600;
        color: #bff3d3;
        background: rgba(34, 197, 94, .12);
        border: 1px solid rgba(34, 197, 94, .3);
        border-radius: 999px;
        padding: 4px 10px;
    }
    .rec-sub {
        font-size: .8rem;
        color: #a9bdae;
        line-height: 1.7;
        margin: 4px 0 12px;
    }
    .badges {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin: 0 0 12px;
    }
    .badge {
        font-size: .68rem;
        padding: 5px 10px;
        border-radius: 999px;
        background: rgba(34, 197, 94, .1);
        border: 1px solid rgba(34, 197, 94, .24);
        color: #bff3d3;
    }

    .formula {
        background: #0a1218;
        border: 1px solid rgba(34, 197, 94, .16);
        border-left: 3px solid var(--g);
        border-radius: 12px;
        padding: 12px 14px;
        font-size: .74rem;
        line-height: 1.9;
        color: #a9bdae;
        word-break: break-word;
    }
    .formula b { color: var(--text); font-weight: 600; }

    /* 链轮示意图 */
    .diagram {
        margin: 14px 0 2px;
        background: #08110d;
        border: 1px solid rgba(34, 197, 94, .16);
        border-radius: 16px;
        padding: 6px 6px 0;
    }
    .diagram svg { display: block; width: 100%; height: auto; }
    .diagram-cap {
        font-size: .64rem;
        color: var(--dim);
        text-align: center;
        line-height: 1.6;
        padding: 0 8px 8px;
    }
    .chain-path {
        fill: none;
        stroke: rgba(134, 239, 172, .55);
        stroke-width: 2;
        stroke-dasharray: 7 5;
        animation: chainmove 1.8s linear infinite;
    }
    @keyframes chainmove { to { stroke-dashoffset: -24; } }
    .spr-ring { fill: #0a1410; stroke: rgba(34, 197, 94, .55); stroke-width: 2; }
    .spr-tooth { stroke: rgba(74, 222, 128, .72); stroke-width: 1.4; }
    .spr-hub { fill: rgba(34, 197, 94, .14); stroke: rgba(34, 197, 94, .45); stroke-width: 1.2; }
    .spr-label {
        fill: #9db0a2;
        font-size: 11px;
        text-anchor: middle;
        font-family: inherit;
        font-weight: 600;
    }

    .metrics {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin: 14px 0 0;
    }
    .metric {
        background: rgba(255, 255, 255, .03);
        border: 1px solid rgba(255, 255, 255, .06);
        border-radius: 14px;
        padding: 10px 12px;
        min-width: 0;
    }
    .metric .m-label {
        display: block;
        font-size: .66rem;
        color: #8fa396;
        margin-bottom: 4px;
    }
    .metric .m-value {
        font-size: 1.12rem;
        font-weight: 700;
        color: #fff;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .metric .m-value em {
        font-style: normal;
        font-size: .68rem;
        font-weight: 600;
        color: var(--muted);
        margin-left: 3px;
    }
    .metric .m-note {
        display: block;
        font-size: .62rem;
        color: var(--dim);
        margin-top: 3px;
        line-height: 1.5;
    }

    /* 改装对比 */
    .cmp-box {
        margin-top: 14px;
        padding: 14px;
        background: rgba(56, 189, 248, .05);
        border: 1px solid rgba(56, 189, 248, .22);
        border-radius: 16px;
    }
    .cmp-box h4 {
        font-size: .8rem;
        font-weight: 700;
        color: #7dd3fc;
        margin-bottom: 10px;
        line-height: 1.5;
    }
    .cmp-grid { display: grid; gap: 8px; }
    .cmp-row {
        display: grid;
        grid-template-columns: 74px 1fr;
        align-items: center;
        gap: 10px;
        font-size: .76rem;
        color: #8fa396;
    }
    .cmp-vals {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
        color: #b7c9bd;
    }
    .cmp-vals b { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }
    .cmp-vals .arrow { color: #5e6f63; }
    .cmp-vals em {
        font-style: normal;
        font-weight: 700;
        font-size: .68rem;
        padding: 2px 7px;
        border-radius: 999px;
        white-space: nowrap;
    }
    .cmp-vals em.up { color: #4ade80; background: rgba(34, 197, 94, .12); }
    .cmp-vals em.down { color: #fbbf24; background: rgba(251, 191, 36, .12); }
    .cmp-vals em.flat { color: #8fa396; background: rgba(255, 255, 255, .06); }
    .cmp-note {
        margin-top: 10px;
        font-size: .7rem;
        line-height: 1.7;
        color: #8fa396;
    }

    .warn {
        background: rgba(251, 146, 60, .08);
        border: 1px solid rgba(251, 146, 60, .35);
        color: #fdba74;
        border-radius: 12px;
        padding: 10px 13px;
        font-size: .75rem;
        line-height: 1.7;
        margin-bottom: 12px;
    }

    .notes {
        margin-top: 16px;
        padding-top: 14px;
        border-top: 1px dashed rgba(34, 197, 94, .18);
    }
    .notes h4 {
        font-size: .78rem;
        color: #d7f7e4;
        margin-bottom: 9px;
        font-weight: 700;
    }
    .notes ul { list-style: none; }
    .notes li {
        position: relative;
        padding-left: 15px;
        font-size: .74rem;
        line-height: 1.75;
        color: var(--muted);
        margin-bottom: 7px;
    }
    .notes li::before {
        content: "›";
        position: absolute;
        left: 2px;
        top: 0;
        color: var(--g);
        font-weight: 700;
    }
    .notes a { color: var(--mint); text-decoration: none; border-bottom: 1px solid rgba(134, 239, 172, .35); }
    .notes a:hover { color: #fff; }

    .tool-foot {
        text-align: center;
        font-size: .68rem;
        color: #5e6f63;
        line-height: 1.8;
        margin: 22px 8px 0;
    }

    /* ---------- 手机 ---------- */
    @media (max-width: 560px) {
        .card { padding: 20px 16px 22px; border-radius: 26px; }
        h1 { font-size: 1.4rem; }
        .sprocket-grid { gap: 6px; }
        .big-box { padding: 2px 8px; }
        .big-box input { font-size: 1.6rem; }
        .ratio-preview { min-width: 82px; padding: 8px 8px 9px; margin-top: 23px; }
        .rp-main strong { font-size: 1.3rem; }
        .grid2 { gap: 10px; }
        .metrics { grid-template-columns: 1fr; }
        .btn-group { flex-direction: column; }
        .btn { width: 100%; }
        .btn-primary { flex: 1 1 auto; }
        .rec-num { font-size: 2.1rem; }
    }

    @media (max-width: 390px) {
        .sprocket-grid { grid-template-columns: 1fr; }
        .ratio-preview { margin-top: 0; flex-direction: row; justify-content: center; gap: 8px; }
    }

    @media (prefers-reduced-motion: reduce) {
        *, *::before, *::after {
            animation: none !important;
            transition: none !important;
        }
    }

@media (max-width:640px){
  html,body{max-width:100%!important;overflow-x:hidden!important;}
  body{padding-bottom:calc(104px + env(safe-area-inset-bottom))!important;}
  input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select,textarea{min-height:44px!important;font-size:16px!important;}
  .topbar{position:sticky!important;}
}

@media (max-width:640px){
  
  
  body.tool-chain .btn-group{
    position:fixed!important;inset:auto 0 0 0!important;
    width:auto!important;min-width:0!important;max-width:none!important;height:auto!important;
    margin:0!important;box-sizing:border-box!important;transform:none!important;
    display:grid!important;grid-template-columns:1fr 1fr!important;gap:8px!important;
    padding:10px 14px calc(10px + env(safe-area-inset-bottom))!important;
    background:#f7f3e8!important;border-top:1px solid #e6e0d1!important;
    box-shadow:0 -8px 24px rgba(0,0,0,.06)!important;
  }
  body.tool-chain .btn-group > *{min-height:48px!important;width:100%!important;font-size:15px!important;border-radius:12px!important;}
  body.tool-chain .btn-group > .btn-primary{grid-column:1/-1!important;}
}

/* H5 链轮齿数输入高度补足 44px */
body.tool-chain input[type="number"]{min-height:44px!important;height:44px!important}
body.tool-chain #z1,body.tool-chain #z2{height:44px!important;min-height:44px!important;line-height:44px!important}
