  :root {
    --ink: #2a241c;
    --muted: #7a6d5d;
    --line: #e4d8c4;
    --paper: #f7f1e6;
    --card: #fffdf8;
    --bubble: #ffffff;
    --bubble-me: #f3e4d6;
    --soft: #fbf6ee;
    --chip: #ffffff;
    --panel: #efe4d2;
    --disabled-bg: #e7e0d6;
    --disabled-fg: #a3988c;
    --disabled-input: #f3eee6;
    --wood: #1f7a43;
    --fire: #c23b2e;
    --earth: #b8860b;
    --metal: #8a6232;
    --water: #1d5fa8;
    --select: #8c2f2f;
  }
  /* 四档字号由根元素的 data-font-size 切换，标准档同时作为无属性时的默认值 */
  :root,
  html[data-font-size="standard"] {
    --font-msg: 15px;
    --font-heading: 16px;
    --font-code: 13px;
    --font-table: 14px;
  }
  html[data-font-size="small"] {
    --font-msg: 14px;
    --font-heading: 15px;
    --font-code: 12px;
    --font-table: 13px;
  }
  html[data-font-size="larger"] {
    --font-msg: 16px;
    --font-heading: 17px;
    --font-code: 14px;
    --font-table: 15px;
  }
  html[data-font-size="largest"] {
    --font-msg: 17px;
    --font-heading: 18px;
    --font-code: 15px;
    --font-table: 16px;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --ink: #f0e6d8;
      --muted: #a89880;
      --line: #3f362c;
      --paper: #161310;
      --card: #241f18;
      --bubble: #2a241c;
      --bubble-me: #3a2f24;
      --soft: #2a241c;
      --chip: #2a241c;
      --panel: #1c1813;
      --disabled-bg: #3a342c;
      --disabled-fg: #8a7f70;
      --disabled-input: #2a241c;
      --wood: #5bbf7a;
      --fire: #e06b5c;
      --earth: #d4a017;
      --metal: #c4a06a;
      --water: #6a9fd4;
      --select: #d47474;
    }
  }
  * { box-sizing: border-box; }
  html {
    height: 100%;
    overflow-anchor: none;
    background: var(--paper);
    /* 禁止双击放大；捏合放大仍可用 */
    touch-action: manipulation;
  }
  body {
    margin: 0;
    min-height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  }
  header.top {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--paper);
    padding: 14px 16px 8px;
    border-bottom: 1px solid var(--line);
    z-index: 2;
  }
  header.top h1 { margin: 0; font-size: 18px; font-weight: 600; }
  .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .avatar {
    position: relative;
    flex: none;
    width: 40px;
    height: 40px;
  }
  .avatar-face {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(145deg, #ff8a5c 0%, #fa5138 55%, #e63a2f 100%);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .28), 0 3px 8px rgba(224, 76, 58, .28);
    color: #fff;
    font-size: 21px;
    font-weight: 700;
    line-height: 1;
  }
  .avatar-glyph { position: relative; top: -1px; }
  .avatar-switch {
    position: absolute;
    right: -3px;
    bottom: -3px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fffdf8;
    box-shadow: 0 1px 4px rgba(60, 40, 20, .2);
    color: #6a5b48;
  }
  .avatar-switch svg { width: 12px; height: 12px; }
  .top-actions { display: flex; align-items: center; gap: 12px; }
  #asks-left { margin: 0; font-size: 14px; color: var(--muted); }
  main { padding: 12px 12px 148px; max-width: 480px; margin: 0 auto; }
  #chart { margin: 8px 0 12px; }
  #chart:empty { display: none; }
  .who, .pan, .yun, .plate-wrap {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 10px;
  }
  .who { padding: 10px 12px; font-size: 13px; line-height: 1.6; }
  table.pan { width: 100%; border-collapse: collapse; font-size: 12px; }
  table.pan th, table.pan td {
    border-bottom: 1px solid var(--line);
    text-align: center;
    vertical-align: middle;
    padding: 6px 2px;
  }
  table.pan th { background: var(--soft); font-size: 13px; }
  td.lab { width: 36px; color: var(--muted); font-size: 11px; background: var(--soft); }
  .with-side {
    display: inline-flex;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
  }
  .glyph { font-size: 26px; font-weight: 700; line-height: 1; }
  .side {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-top: 1px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.05;
  }
  .sub, .sha { font-size: 11px; line-height: 1.4; }
  .sha { color: #6d3b3b; }
  .wood { color: var(--wood); }
  .fire { color: var(--fire); }
  .earth { color: var(--earth); }
  .metal { color: var(--metal); }
  .water { color: var(--water); }
  .yun { padding: 10px; }
  .cap { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
  .strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  .cell {
    flex: none;
    min-width: 58px;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: center;
    padding: 4px 4px 6px;
    background: var(--chip);
    font-size: 11px;
    line-height: 1.35;
    color: inherit;
    font-family: inherit;
  }
  .cell.on { border-color: var(--select); background: var(--soft); }
  .cell .yr { color: var(--muted); }
  .cell .gz { font-size: 14px; font-weight: 700; }
  .plate {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
    background: var(--panel);
    padding: 3px;
  }
  .gong {
    background: var(--chip);
    min-height: 92px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    font-size: 11px;
  }
  .gong .stars { font-weight: 700; line-height: 1.3; }
  .gong .minor { color: #6a5b48; line-height: 1.3; margin-top: 2px; }
  .tag {
    display: inline-block;
    color: #fff;
    border-radius: 3px;
    font-size: 10px;
    line-height: 1;
    padding: 1px 2px;
    margin-left: 1px;
  }
  .lu { background: #1f7a43; }
  .quan { background: #8a6232; }
  .ke { background: #1d5fa8; }
  .ji { background: #c23b2e; }
  .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: flex-end; }
  .pname { font-weight: 700; }
  .pname i { font-style: normal; color: var(--select); margin-left: 2px; }
  .age { color: var(--muted); }
  .center {
    grid-column: 2 / 4;
    grid-row: 2 / 4;
    background: var(--soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    padding: 6px;
  }
  .center .big { font-size: 15px; font-weight: 700; }
  .pillars4 { display: flex; gap: 10px; font-weight: 700; }
  .msg { margin: 8px 0; font-size: var(--font-msg); line-height: 1.6; }
  .msg.me { text-align: right; }
  .msg .bubble {
    display: inline-block;
    max-width: 92%;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--bubble);
    border: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
  }
  .msg.me .bubble { background: var(--bubble-me); white-space: pre-wrap; }
  .bubble p { margin: 0 0 8px; }
  .bubble p:last-child, .bubble ul:last-child, .bubble ol:last-child, .bubble .md-table:last-child { margin-bottom: 0; }
  .bubble h1, .bubble h2, .bubble h3 { margin: 0 0 8px; font-size: var(--font-heading); line-height: 1.4; }
  .bubble hr { border: 0; border-top: 1px solid var(--line); margin: 0 0 8px; }
  .bubble ul, .bubble ol { margin: 0 0 8px; padding-left: 1.2em; }
  .bubble code { font-family: Consolas, "Courier New", monospace; font-size: var(--font-code); }
  .bubble pre {
    margin: 0 0 8px;
    padding: 8px;
    overflow-x: auto;
    background: var(--soft);
    border-radius: 8px;
    white-space: pre-wrap;
  }
  .md-table { margin: 0 0 8px; overflow-x: auto; }
  .bubble table { width: 100%; border-collapse: collapse; font-size: var(--font-table); }
  .bubble th, .bubble td {
    border: 1px solid var(--line);
    padding: 4px 6px;
    text-align: left;
    vertical-align: top;
  }
  .bubble th { background: var(--soft); font-weight: 600; }
  .bubble.wait {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
  }
  .think {
    display: inline-flex;
    align-items: flex-end;
    gap: 4px;
    height: 14px;
  }
  .think i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--select);
    opacity: 0.3;
    animation: think 1.4s ease-in-out infinite;
  }
  .think i:nth-child(2) { animation-delay: 0.18s; }
  .think i:nth-child(3) { animation-delay: 0.36s; }
  @keyframes think {
    0%, 70%, 100% { opacity: 0.28; transform: translateY(0); }
    35% { opacity: 1; transform: translateY(-3px); }
  }
  @media (prefers-reduced-motion: reduce) {
    .think i { animation: none; opacity: 0.75; }
  }
  .hint { color: var(--muted); font-size: 12px; }
  form.dock {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--card);
    border-top: 1px solid var(--line);
    padding: 8px 12px 12px;
  }
  form.dock .inner {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
    min-width: 0;
  }
  .pick-limit {
    margin: 0 0 6px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--fire);
  }
  #choices {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
  }
  #choices:empty { margin-bottom: 2px; }
  #extra {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 8px;
    width: 100%;
    min-width: 0;
  }
  #extra:empty { margin-bottom: 2px; }
  #extra .row {
    width: 100%;
    min-width: 0;
  }
  #extra input.year {
    flex: 0 0 4.5em;
    width: 4.5em;
  }
  #extra select {
    flex: 0 1 5.5em;
    max-width: 6.5em;
  }
  #extra input.label {
    flex: 1 1 0;
  }
  #extra > button {
    align-self: flex-start;
    max-width: 100%;
  }
  button, .pick {
    border: 1px solid var(--line);
    background: var(--chip);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 15px;
    color: var(--ink);
    font-family: inherit;
  }
  button.on, .pick.on { border-color: var(--select); color: var(--select); }
  button.primary { background: var(--select); color: #fff; border-color: var(--select); }
  button:disabled, button.primary:disabled {
    background: var(--disabled-bg);
    color: var(--disabled-fg);
    border-color: var(--disabled-bg);
    cursor: not-allowed;
  }
  input:disabled, select:disabled { background: var(--disabled-input); color: var(--disabled-fg); }
  .row {
    display: flex;
    gap: 6px;
    width: 100%;
    min-width: 0;
  }
  input, select, textarea {
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 16px;
    font-family: inherit;
    min-width: 0;
    background: var(--chip);
    color: var(--ink);
  }
  footer.note { font-size: 12px; color: var(--muted); margin-top: 8px; }
