/* SQL 精修层：以最新本地提交 9c4016e 为视觉基准，不再重做原版皮肤。
 * 保留冷灰纸面、半透明白卡、绿色四角框、蓝绿语义及原生代码高亮。
 * 方格换成章节边缘数据纹理；按信息 / 比较 / 函数 / 结果分开整理表格。
 */
@media screen {
  :root[data-doc-theme="neutral"] {
    --yd-type-muted: var(--txt-dim);
  }
  :root[data-doc-theme="neutral"]:not([data-theme="dark"]) {
    --txt-dim: #6a6e81;
    --doc-data-ink: rgba(5, 112, 80, .32);
    --doc-rule-ink: rgba(0, 129, 79, .32);
  }
  :root[data-doc-theme="neutral"][data-theme="dark"] {
    --txt-dim: #9b9eb0;
    --doc-data-ink: rgba(96, 211, 168, .25);
    --doc-rule-ink: rgba(52, 227, 166, .36);
  }

  /* 文档背景标准：净阅读面 + 章节留白内的低对比数据带，不在字后重复铺图。 */
  html[data-doc-theme="neutral"] body { background-image: none; }
  html[data-doc-theme="neutral"] main section { position: relative; }
  html[data-doc-theme="neutral"] main section::before {
    content: none;
    position: absolute;
    top: 4px;
    right: 0;
    width: min(60%, 480px);
    height: 42px;
    background: var(--doc-data-ink);
    -webkit-mask: url("../images/document-data-ribbon.svg?v=20261020-data-v1") right center / contain no-repeat;
    mask: url("../images/document-data-ribbon.svg?v=20261020-data-v1") right center / contain no-repeat;
    pointer-events: none;
    user-select: none;
  }
  @supports ((mask-image: url("")) or (-webkit-mask-image: url(""))) {
    html[data-doc-theme="neutral"] main section::before { content: ""; }
  }
  html[data-doc-theme="neutral"] main .rule {
    border-top-style: solid;
    border-image: linear-gradient(90deg, var(--doc-rule-ink), var(--line) 36%, transparent) 1;
  }

  @media (max-width: 760px) {
    html[data-doc-theme="neutral"] main section::before {
      top: 6px;
      width: min(78%, 320px);
      height: 32px;
      -webkit-mask-size: 400px 35px;
      mask-size: 400px 35px;
      opacity: .85;
    }
  }
  @media (forced-colors: active) {
    html[data-doc-theme="neutral"] main section::before { content: none; }
    html[data-doc-theme="neutral"] main .rule { border-image: none; }
  }

  /* 长启动参数在 320px 自然断行；保留完整可复制内容。 */
  html[data-doc-theme="neutral"] .sec-desc > code { overflow-wrap: anywhere; }

  /* 保留原版搜索框与边距，仅增加键盘 / 输入焦点反馈。 */
  html[data-doc-theme="neutral"] .searchbar:focus-within {
    border-color: var(--accent-2);
    outline: 2px solid var(--accent-bg);
    outline-offset: 2px;
  }
  html[data-doc-theme="neutral"] ::selection {
    color: var(--panel);
    background: var(--accent-3);
  }

  /* 速查表不是产品对比表：中性阅读面、语法 / 说明分层，仅作用于 §16。 */
  html[data-doc-theme="neutral"] #s-ref {
    --ref-code: #2b568f;
    --ref-alternate: #f8fafc;
  }
  html[data-doc-theme="neutral"][data-theme="dark"] #s-ref {
    --ref-code: #a9c6f4;
    --ref-alternate: #20232d;
  }
  #s-ref .reference-table { width: 100%; table-layout: fixed; }
  #s-ref .reference-table :is(th, td) {
    padding: var(--doc-row-inset, 10px) var(--doc-cell-inset, 16px);
    text-align: left;
    vertical-align: top;
    line-height: 1.6;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: anywhere;
  }
  #s-ref .reference-table thead th {
    color: var(--txt-dim);
    font-size: 11px;
    font-weight: 600;
    background: var(--panel-2);
    border-bottom: 1px solid var(--line-2);
  }
  #s-ref .reference-table tbody th {
    color: var(--txt-bright);
    /* 行标题是正文索引，不应落入共享 th 的 11px 表头标注档。 */
    font-size: 12.5px !important;
    font-weight: 600;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
  }
  #s-ref .reference-table tbody td {
    color: var(--txt);
    font-weight: 400;
    background: var(--panel);
  }
  #s-ref .reference-table tbody tr:nth-child(even) > :is(th, td) { background: var(--ref-alternate); }
  #s-ref .reference-table tbody tr:hover > :is(th, td) { background: var(--accent-bg2); }
  #s-ref .reference-table code { color: var(--ref-code); font-weight: 400; overflow-wrap: anywhere; }
  #s-ref .ref-signature { color: var(--txt); font-weight: 400; }
  #s-ref .ref-note { margin: 4px 0 0; color: var(--txt-dim); font-size: 12px; line-height: 1.6; }
  #s-ref .reference-sql :is(th, td):first-child { width: 144px; }
  #s-ref .reference-api :is(th, td):first-child { width: 204px; }
  #s-ref .reference-api :is(th, td):nth-child(2) { width: 160px; }
  #s-ref .reference-api tbody td:nth-child(2) { color: var(--txt-dim); }
  #s-ref .ref-group-start > :is(th, td) { border-top: 1px solid var(--line-2); }
  #s-ref .reference-scroll:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; }
  #s-ref .reference-scroll-hint { display: none; }
  @media (max-width: 760px) {
    #s-ref .reference-sql { min-width: 640px; }
    #s-ref .reference-api { min-width: 780px; }
    #s-ref .reference-sql :is(th, td):first-child { width: 112px; }
    #s-ref .reference-api :is(th, td):first-child { width: 180px; }
    #s-ref .reference-table tr > :first-child {
      position: sticky;
      left: 0;
      z-index: 1;
      box-shadow: 1px 0 0 var(--line);
    }
    #s-ref .reference-scroll-hint { display: block; margin: 8px 0; color: var(--txt-dim); font-size: 12px; }
  }

  /* 行标题与列头是不同字号档，不让共享 th 标注规则缩小正文。 */
  html[data-doc-theme="neutral"] table.dd.doc-matrix tbody th,
  html[data-doc-theme="neutral"] table.dd.doc-reading tbody th,
  html[data-doc-theme="neutral"] table.dd.doc-result-table tbody th {
    font-size: 12.5px !important;
    border-bottom: 1px solid var(--line);
  }
  /* 行标题、数据格和最后一行均保留细线；不再用 last-child 清掉表尾。 */
  html[data-doc-theme="neutral"] .doc-table-scroll:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: -2px;
  }

  /* 普通说明表：中性阅读面，保留绿色支持状态，语法不整列加粗染蓝。 */
  html[data-doc-theme="neutral"] {
    --doc-inline-code: #2b568f;
    --doc-alternate: #f8fafc;
  }
  html[data-doc-theme="neutral"][data-theme="dark"] {
    --doc-inline-code: #a9c6f4;
    --doc-alternate: #20232d;
  }
  html[data-doc-theme="neutral"] table.doc-reading {
    width: 100%;
    min-width: 680px;
    table-layout: fixed;
  }
  html[data-doc-theme="neutral"] table.doc-reading :is(th, td) {
    padding: var(--doc-row-inset, 10px) var(--doc-cell-inset, 16px);
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: anywhere;
    background: var(--panel);
  }
  html[data-doc-theme="neutral"] table.doc-reading thead th {
    background: var(--panel-2);
    color: var(--txt-dim);
    font-weight: 600;
  }
  html[data-doc-theme="neutral"] table.doc-reading tr > :first-child { width: 164px; }
  html[data-doc-theme="neutral"] table.doc-reading tbody td:not(.c-ok) { font-weight: 400; }
  html[data-doc-theme="neutral"] table.doc-reading tbody tr:nth-child(even) > :is(th, td) {
    background: var(--doc-alternate);
  }
  html[data-doc-theme="neutral"] table.doc-reading tbody tr:hover > :is(th, td) {
    background: var(--accent-bg2);
  }
  html[data-doc-theme="neutral"] table.doc-reading code { color: var(--doc-inline-code); font-weight: 400; }
  html[data-doc-theme="neutral"] table.doc-syntax tr > :nth-child(2) { width: 64px; text-align: center; }
  html[data-doc-theme="neutral"] #s8 table.doc-deployment tr > :first-child { width: 248px; min-width: 0; }
  html[data-doc-theme="neutral"] table.doc-deployment tr > :nth-child(2) { width: 148px; }
  html[data-doc-theme="neutral"] .doc-detail-line { margin: 0; }
  html[data-doc-theme="neutral"] .doc-detail-line + .doc-detail-line { margin-top: 7px; }
  html[data-doc-theme="neutral"] .vs-why:has(> .doc-detail-line)::before { content: none; }

  /* 函数手册：共用最长内容列宽、所有内容单行，余宽归说明列；窄屏整表横滑。 */
  html[data-doc-theme="neutral"] #s11 table.fn {
    width: 100%;
    min-width: calc(var(--doc-fn-name-width, 320px) + var(--doc-fn-signature-width, 440px) + var(--doc-fn-description-width, 640px));
    table-layout: fixed;
  }
  html[data-doc-theme="neutral"] #s11 table.fn :is(th, td) {
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
    text-align: left;
  }
  html[data-doc-theme="neutral"] #s11 table.fn tr > :first-child { width: var(--doc-fn-name-width, 320px); }
  html[data-doc-theme="neutral"] #s11 table.fn tr > :nth-child(2) { width: var(--doc-fn-signature-width, 440px); }
  html[data-doc-theme="neutral"] #s11 table.fn tr > :last-child { width: auto; }
  html[data-doc-theme="neutral"] #s11 table.fn tbody th.fn-name {
    color: var(--accent-2);
    font-size: 12px !important;
    font-weight: 700;
  }
  html[data-doc-theme="neutral"] #s11 table.fn tbody tr:hover th { background: var(--panel-2); }

  /* 实际输出按数据字段配列，不再让最后一列占半张表。 */
  html[data-doc-theme="neutral"] #s12 table.doc-result-table {
    width: 100%; min-width: 700px; table-layout: fixed; font-variant-numeric: tabular-nums;
  }
  html[data-doc-theme="neutral"] #s12 table.doc-result-table tr > :is(th, td) { width: 12%; padding: var(--doc-row-inset, 10px) var(--doc-cell-inset, 16px); }
  html[data-doc-theme="neutral"] #s12 table.doc-result-table tr > :nth-child(2) { width: 10%; }
  html[data-doc-theme="neutral"] #s12 table.doc-result-table tr > :nth-child(3) { width: 16%; }
  html[data-doc-theme="neutral"] #s12 table.doc-result-table tr > :nth-child(4) { width: 8%; }
  html[data-doc-theme="neutral"] #s12 table.doc-result-table tr > :nth-child(n+4),
  html[data-doc-theme="neutral"] #s12 table.doc-result-table tr > :nth-child(2) { text-align: right; }
  html[data-doc-theme="neutral"] #s12 table.doc-result-table tr > :last-child { width: 18%; }
  /* 短能力对照：前两列仅按单行内容取宽，余宽由最后一列承接，不做三等分。 */
  html[data-doc-theme="neutral"] #s12 table.doc-compatibility { width: 100%; min-width: 660px; table-layout: auto !important; }
  html[data-doc-theme="neutral"] #s12 table.doc-compatibility tr > :is(th, td) {
    text-align: left; white-space: normal !important; word-break: normal !important; overflow-wrap: anywhere;
  }
  html[data-doc-theme="neutral"] #s12 table.doc-compatibility tr > :nth-child(-n+2) {
    width: 1% !important; white-space: nowrap !important;
  }
  html[data-doc-theme="neutral"] #s12 table.doc-compatibility tr > :last-child { width: auto; }

  /* 真实代码继续原生横滑，解释性的预格式化文字则随阅读宽度换行。 */
  html[data-doc-theme="neutral"] pre.code.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
  @media (max-width: 1100px) {
    /* 中等宽度也不把十列矩阵硬挤进纸面，列内换行 + 容器内横滑。 */
    html[data-doc-theme="neutral"] table.doc-matrix { width: 100%; min-width: 760px; table-layout: fixed !important; }
    html[data-doc-theme="neutral"] table.doc-matrix :is(th, td) {
      white-space: normal !important; word-break: normal !important; overflow-wrap: anywhere;
    }
    html[data-doc-theme="neutral"] table.doc-matrix tr > :first-child { width: 180px !important; }
    html[data-doc-theme="neutral"] #s2 table.doc-matrix { min-width: 1010px; }
    html[data-doc-theme="neutral"] #s2 table.doc-matrix tr > :first-child { width: 200px !important; }
  }
  @media (max-width: 960px) {
    html[data-doc-theme="neutral"] .vs-col.bad,
    html[data-doc-theme="neutral"] .vs-col.good { padding-left: 16px; padding-right: 16px; }
  }
  @media (max-width: 760px) {
    html[data-doc-theme="neutral"] #s8 table.doc-deployment tr > :first-child { width: 180px; }
    html[data-doc-theme="neutral"] #s12 table.doc-compatibility tr > :first-child {
      width: 180px !important; white-space: normal !important;
    }
    /* 共享导航尚未接管（含禁用脚本）时，旧顶栏也不能撑宽手机纸面。 */
    html[data-doc-theme="neutral"] body:not(.yd-site-shell-ready) > .topbar { padding: 0 16px; gap: 12px; }
    html[data-doc-theme="neutral"] body:not(.yd-site-shell-ready) > .topbar :is(.brand small, .pulse, .live) { display: none; }
    html[data-doc-theme="neutral"] body:not(.yd-site-shell-ready) > .topbar .iconbtn { flex-shrink: 0; }
    html[data-doc-theme="neutral"] table.doc-matrix tbody th,
    html[data-doc-theme="neutral"] table.doc-reading tbody th,
    html[data-doc-theme="neutral"] table.doc-functions tbody th,
    html[data-doc-theme="neutral"] table.doc-result-table tbody th {
      position: sticky; left: 0; z-index: 1; background: var(--panel); box-shadow: 1px 0 0 var(--line);
    }
    html[data-doc-theme="neutral"] table.doc-matrix thead th:first-child,
    html[data-doc-theme="neutral"] table.doc-reading thead th:first-child,
    html[data-doc-theme="neutral"] table.doc-functions thead th:first-child,
    html[data-doc-theme="neutral"] table.doc-result-table thead th:first-child {
      position: sticky; left: 0; z-index: 2; background: var(--panel-2); box-shadow: 1px 0 0 var(--line);
    }
  }

  /* 四列卡片旁的三列摘要：前两列受控，说明列左对齐并承接全部余宽。 */
  html[data-doc-theme="neutral"] table.doc-grid-summary {
    width: 100%; table-layout: fixed !important;
  }
  html[data-doc-theme="neutral"] table.doc-grid-summary tr > :is(th, td) {
    text-align: left;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: anywhere;
  }
  html[data-doc-theme="neutral"] table.doc-grid-summary tr > :first-child { width: 180px !important; }
  html[data-doc-theme="neutral"] table.doc-grid-summary tr > :nth-child(2) { width: 160px; }
  html[data-doc-theme="neutral"] table.doc-grid-summary tr > :last-child { width: auto; }
  @media (min-width: 1081px) {
    html[data-doc-theme="neutral"] table.doc-grid-summary { min-width: 0; }
    html[data-doc-theme="neutral"] table.doc-grid-summary tr > :first-child { width: 25% !important; }
    @supports (container-type: inline-size) and (width: 1cqw) {
      html[data-doc-theme="neutral"] .doc-grid-summary-scroll { container-type: inline-size; }
      /* cqw 先解析为长度，避免表格列算法把“百分比减像素”忽略成 auto。 */
      html[data-doc-theme="neutral"] table.doc-grid-summary tr > :first-child {
        width: calc(25cqw - var(--doc-grid-gap, 14px) / 4) !important;
      }
    }
  }
  @media (max-width: 760px) {
    /* 最长函数名可能比整块手机纸面还宽，不能固定首列把签名与说明挡住。 */
    html[data-doc-theme="neutral"] #s11 table.fn tr > :first-child {
      position: static; box-shadow: none;
    }
  }
}

@media print {
  #s-ref .reference-scroll-hint { display: none; }
  #s-ref .ref-note { margin: 4px 0 0; }
  #s-ref .reference-table thead { display: table-header-group; }
  #s-ref .reference-table tr { break-inside: avoid; }
  main table thead { display: table-header-group; }
  main table tr { break-inside: avoid; }
  main table.fn :is(th, td) { white-space: normal; overflow-wrap: anywhere; }
  main table.fn tbody th { color: var(--accent-2); font-size: 12px !important; }
  main table.dd tbody th { font-size: 12.5px !important; border-bottom: 1px solid var(--line); }
  #s12 table.doc-result-table { table-layout: fixed; }
  #s12 table.doc-result-table tr > :is(th, td) { width: auto; white-space: normal; }
  .doc-detail-line { margin: 0; }
  .doc-detail-line + .doc-detail-line { margin-top: 4px; }
  table.doc-grid-summary { width: 100%; table-layout: fixed; }
  table.doc-grid-summary tr > :is(th, td) { text-align: left; white-space: normal !important; overflow-wrap: anywhere; }
  table.doc-grid-summary tr > :first-child { width: 25%; }
  table.doc-grid-summary tr > :nth-child(2) { width: 18%; }
  table.doc-grid-summary tr > :last-child { width: auto; }
}
