:root {
  color-scheme: light;
  --paper: #fcf8f1;
  --panel: #fffcf7;
  --ink: #332923;
  --soft: #69574e;
  --rose: #913044;
  --rose-hover: #762537;
  --rose-light: #fae9e9;
  --line: #e8dcd1;
  /* Outlines of things to tap: at least 3:1 against the page, so they read as buttons. */
  --edge: #957f71;
  --ok: #265d45;
  --stage: #f2e9de;
  --focus: #2c6460;
  --tap: max(48px, 3rem);
  --gap: max(8px, .5rem);
  --serif: "Songti SC", "Noto Serif CJK SC", "SimSun", "STSong", Georgia, serif;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
*, *::before, *::after { box-sizing: border-box; }
/* A quick double tap (common when a tap seems not to have worked) must not zoom the
   page; pinching to zoom still works. Taps show the calm pressed colours below,
   not the browser's grey or blue flash. */
html { touch-action: manipulation; }
button, summary, a, label, input { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 1rem; line-height: 1.55; }
h1, h2, p { margin: 0; }
button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.symbols { position: absolute; width: 0; height: 0; }
.icon, .brand-mark svg {
  width: 1.22em; height: 1.22em; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.shell { width: min(100% - 3.5rem, 76rem); margin-inline: auto; }
.skip { position: fixed; top: .5rem; left: .5rem; z-index: 3; padding: .75rem; background: var(--panel); transform: translateY(-160%); }
.skip:focus { transform: none; }

/* Header and intro */
.top { border-bottom: 1px solid var(--line); background: var(--panel); }
.top-inner { min-height: 4.5rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; font-weight: 750; font-size: 1.35rem; letter-spacing: .055em; }
.brand-mark { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; color: var(--panel); background: var(--rose); border-radius: .7rem; }
.brand-mark svg { width: 1.55rem; height: 1.55rem; }
.help-button {
  display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .65rem; min-height: var(--tap); min-width: 48px;
  color: var(--soft); background: transparent; border: 1px solid transparent; border-radius: .5rem;
}
.help-button:hover { background: var(--rose-light); color: var(--rose); }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 1rem 2rem; padding-block: 2.75rem 2.1rem; }
h1 { font-family: var(--serif); font-size: 3.55rem; line-height: 1.18; letter-spacing: -.075em; font-weight: 750; }
h1 span { color: var(--rose); }
.intro p { font-size: 1.12rem; color: var(--soft); margin-top: .78rem; }
.privacy { display: flex; align-items: center; gap: .42rem; color: #5a5441; padding: .55rem .8rem; background: #f2eddf; border: 1px solid #e8dfcc; border-radius: 2rem; }
.privacy .icon { width: 1.05rem; height: 1.05rem; }

/* Panels */
.workspace { display: grid; grid-template-columns: 1.4fr 1fr; align-items: start; gap: 1.15rem; }
.panel { min-width: 0; padding: 1.4rem; border: 1px solid var(--line); border-radius: 1.15rem; background: var(--panel); box-shadow: 0 5px 17px #67402c09; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1rem; margin: 0 0 1.1rem; }
h2 { font-size: 1.32rem; line-height: 1.4; font-weight: 750; }
.panel h2 { display: flex; align-items: center; gap: .6rem; }
.step { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; flex: none; border-radius: 50%; background: var(--rose-light); color: var(--rose); font-size: 1rem; font-weight: 750; }
.preview-label, .frame-count { color: var(--soft); font-size: .94rem; }
.preview-label { padding: .21rem .62rem; border-radius: .4rem; background: #f5eee5; }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem; padding: .62rem 1.05rem;
  min-height: var(--tap); min-width: 48px; border: 1px solid transparent; border-radius: .63rem; text-decoration: none;
  font-size: 1.125rem; line-height: 1.35; font-weight: 700; overflow-wrap: anywhere;
  transition: background-color .15s, color .15s, border-color .15s;
}
.primary { background: var(--rose); color: var(--panel); }
.primary:hover { background: var(--rose-hover); }
.secondary { color: var(--rose); background: var(--panel); border-color: var(--edge); }
.secondary:hover { background: var(--rose-light); border-color: #c7989b; }
/* Pressed: the colour deepens at once, nothing grows, shrinks or moves. */
.primary:active, .save:active:not(:disabled) { background: var(--rose-hover); }
.secondary:active, .choice:active, .filter:active, .more:active, .frame:active { background: #f6dede; }

/* Step 1: photo */
.photo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin: 0 0 .75rem; }
.file-hint { font-size: .94rem; color: var(--soft); overflow-wrap: anywhere; }
.status { margin-top: .7rem; font-size: 1.125rem; color: var(--ok); overflow-wrap: anywhere; }
.status.error { color: #8d2839; font-weight: 700; }
.status-box > .status { margin: .75rem 0 0; }
.status-help { margin-top: .25rem; color: var(--soft); }
.status-help summary { display: inline-flex; align-items: center; min-height: var(--tap); cursor: pointer; color: var(--rose); font-weight: 700; text-decoration: underline; text-underline-offset: .2em; }
.status-help p { margin-bottom: .4rem; }
.viewer { position: relative; }
.phone-pick, .phone-only, .bar, .stage-badge, .dock-view, .sheet-title, .sheet-done, .sheet-backdrop { display: none; }
.stage {
  display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; min-width: 0;
  position: relative; aspect-ratio: 1.38; overflow: hidden; border: 1px solid #e9dece; border-radius: .8rem; padding: 1.85rem;
  background-color: var(--stage);
  background-image: radial-gradient(ellipse at 50% 24%, #f9f3e9, transparent 75%), radial-gradient(#9c80691e 0.7px, transparent 1px);
  background-size: 100% 100%, 8px 8px;
}
#preview { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; box-shadow: 0 10px 23px #51362d38, 0 2px 4px #51362d22; }
.can-pan #preview {
  cursor: grab; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  /* Fingers still scroll the page up and down; app.js handles the rest. */
  touch-action: pan-y; touch-action: pan-y pinch-zoom;
}
.panning #preview { cursor: grabbing; }
.held #preview { outline: 3px solid var(--rose); outline-offset: 3px; }
.stage-placeholder { text-align: center; color: var(--soft); }

/* Whole-page drop target */
body.dragging .stage { outline: 3px dashed var(--rose); outline-offset: -5px; background-color: var(--rose-light); }
body.dragging::after {
  content: "松开鼠标，打开这张照片"; position: fixed; inset: .75rem; z-index: 4; display: grid; place-items: center;
  border: 3px dashed var(--rose); border-radius: 1rem; background: #fffcf7e6; color: var(--rose);
  font-size: 1.5rem; font-weight: 750; pointer-events: none;
}

/* Adjustments and words: disclosures under the photo on wide screens, sheets on phones */
.dock-tools { margin-top: 1rem; border-top: 1px solid var(--line); }
.sheet + .sheet { border-top: 1px solid var(--line); }
.sheet summary {
  min-height: var(--tap); min-width: 48px; width: max-content; max-width: 100%; cursor: pointer;
  display: flex; align-items: center; gap: .5rem; list-style: none; color: var(--soft); padding: .25rem .3rem .1rem 0;
}
.sheet summary::-webkit-details-marker { display: none; }
.sheet summary:hover, .more:hover { color: var(--rose); }
.chevron { border: solid currentColor; border-width: 0 2px 2px 0; width: .43rem; height: .43rem; display: inline-block; transform: rotate(45deg); margin: -.2rem .15rem 0 .2rem; flex: none; }
details[open] .chevron, [aria-expanded="true"] .chevron { transform: rotate(225deg); margin-top: .2rem; }
.sheet-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; padding-bottom: .9rem; }
.choice-title { font-weight: 700; margin-top: .2rem; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: var(--gap); }
.choice {
  display: flex; align-items: center; justify-content: center; gap: .55rem; min-height: 3.25rem; padding: .4rem .6rem;
  color: var(--ink); background: var(--panel); border: 1px solid var(--edge); border-radius: .63rem; font-size: 1.125rem; line-height: 1.3;
}
.choice:hover { background: var(--rose-light); }
.choice[aria-pressed="true"] { color: #782538; background: var(--rose-light); border: 2px solid var(--rose); font-weight: 750; padding: calc(.4rem - 1px) calc(.6rem - 1px); }
.shape { flex: none; display: block; height: 1.5rem; aspect-ratio: var(--r, 1); max-width: 2.4rem; border: 2px solid currentColor; border-radius: 3px; }
.shape-original { --r: 1.25; border-style: dashed; }
.shape-square { --r: 1; }
.shape-portrait { --r: .75; }
.shape-landscape { --r: 1.3333; }
.shape-tall { --r: .5625; }
.shape-wide { --r: 1.7778; }
.fit-icon { flex: none; position: relative; width: 1.9rem; height: 1.5rem; border: 2px solid currentColor; border-radius: 3px; overflow: hidden; }
.fit-icon::after { content: ""; position: absolute; background: currentColor; opacity: .45; border-radius: 50% 50% 0 0; }
.fit-contain::after { left: .3rem; right: .3rem; top: .35rem; bottom: 0; }
.fit-cover::after { left: -.4rem; right: -.4rem; top: -.1rem; bottom: 0; }
.crop-note { padding: .55rem .7rem; border-radius: .55rem; background: #fdf2e3; border: 1px solid #e3c79c; color: var(--ink); }
.crop-note strong { color: #7c4a12; }
.position { display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; }
.position [aria-disabled="true"] { color: var(--soft); cursor: default; }
.adjust-actions { display: flex; flex-wrap: wrap; gap: var(--gap); margin-top: .15rem; }
.adjust-actions .button { flex: 1 1 auto; }

/* Step 2: frames */
.filters { display: flex; flex-wrap: wrap; gap: var(--gap); margin-bottom: .9rem; }
.filter {
  flex: 1 1 auto; padding: .35rem .5rem; min-height: var(--tap); min-width: 48px; font-size: 1.125rem; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--edge); color: var(--ink); border-radius: .55rem;
}
.filter:hover { background: var(--rose-light); }
.filter .count { font-size: .85em; font-weight: 400; color: var(--soft); }
.filter[aria-pressed="true"] { color: #782538; background: var(--rose-light); border: 2px solid var(--rose); font-weight: 750; padding: calc(.35rem - 1px) calc(.5rem - 1px); }
.filter[aria-pressed="true"] .count { color: inherit; }
.save-area { margin: 0 0 .8rem; padding: .65rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--panel); }
#current-frame { font-weight: 700; margin-bottom: .4rem; }
.frame-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.save { flex: 1 1 auto; background: var(--rose); color: var(--panel); }
.save:hover:not(:disabled) { background: var(--rose-hover); }
.save:disabled { background: #f3e9e2; color: #745e54; }
.save-hint { color: var(--soft); font-size: 1.125rem; margin-top: .42rem; }
.save-hint.saved, .result-lead.saved { color: var(--ok); font-weight: 700; }
.save-hint.pending { color: #8a4b00; font-weight: 700; }
.frame-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.frame {
  min-width: 0; position: relative; display: flex; flex-direction: column; align-items: stretch; gap: .32rem;
  color: var(--ink); padding: .38rem .38rem .43rem; border: 1px solid var(--edge); border-radius: .65rem; background: var(--panel);
  font-size: 1.125rem; text-align: center; line-height: 1.4; overflow-wrap: anywhere;
  transition: background-color .15s, border-color .15s;
}
.frame:hover { border-color: #ae7780; background: #f9efea; }
.frame[aria-pressed="true"] { border-color: var(--rose); box-shadow: inset 0 0 0 2px var(--rose); background: var(--rose-light); color: #782538; font-weight: 750; }
.thumbnail { display: grid; place-items: center; aspect-ratio: 184 / 116; overflow: hidden; border-radius: .3rem; background: var(--stage); }
.thumbnail canvas { display: block; width: 100%; height: auto; max-width: 100%; }
.frame .chosen { position: absolute; display: grid; place-items: center; width: 1.35rem; height: 1.35rem; top: .62rem; right: .62rem; border-radius: 50%; background: var(--rose); color: var(--panel); }
.chosen .icon { width: .9rem; height: .9rem; }
.more {
  display: flex; align-items: center; justify-content: center; gap: .42rem; min-height: var(--tap); width: 100%;
  margin-top: .42rem; padding: .2rem; border: 0; background: transparent; color: var(--soft); border-radius: .35rem; font-size: 1.125rem;
}

/* Words on frames */
.words-body .check { display: flex; align-items: center; gap: .6rem; min-height: var(--tap); cursor: pointer; font-size: 1.125rem; }
.words-body .check input { width: 1.4rem; height: 1.4rem; accent-color: var(--rose); }
.caption-fields, .caption-row { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .5rem .75rem; align-items: center; }
.caption-row { grid-column: 1 / -1; }
.words-body input[type="text"] { min-height: var(--tap); width: 100%; padding: .35rem .6rem; font-size: 1.125rem; color: var(--ink); background: var(--panel); border: 1px solid var(--edge); border-radius: .5rem; }

/* Footer */
.footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1rem; color: var(--soft); padding-block: 1.5rem; font-size: .94rem; }
.footer span:first-child { color: var(--rose); font-weight: 700; }

/* Dialogs */
dialog { width: min(100% - 1.5rem, 34rem); max-height: calc(100% - 2rem); padding: 0; border: 1px solid var(--line); border-radius: 1rem; background: var(--panel); color: var(--ink); box-shadow: 0 12px 50px #33292345; }
dialog:not([open]) { display: none; }
dialog::backdrop { background: #32231995; }
.dialog-inner { padding: 1.3rem; }
.dialog-inner h2 { margin-bottom: .55rem; }
.dialog-inner ol { padding-inline-start: 1.55rem; margin-block: .5rem 1rem; }
.dialog-inner li + li { margin-top: .35rem; }
.dialog-inner form { margin-top: 1rem; }
.dialog-inner summary { padding-block: .6rem; cursor: pointer; }
.dialog-inner details p + p { margin-top: .6rem; }
.dialog-inner .status:empty { display: none; }
#result-image { display: block; max-width: 100%; max-height: 42vh; height: auto; margin: .8rem auto; }
#frame-preview { display: block; max-width: 100%; max-height: 57vh; height: auto; margin-inline: auto; }
.zoom-view.zoomed { overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: .5rem; }
.zoom-view.zoomed #frame-preview { max-width: none; max-height: none; width: auto; }
.zoom-view.tall { max-height: 60vh; }
.zoom-view.tall #frame-preview { width: 100%; height: auto; }
.zoom-view.both { max-height: 60vh; }
#frame-preview { cursor: zoom-in; }
.zoom-view.zoomed #frame-preview { cursor: zoom-out; }
/* Shown by old.js only when the page could not start (very old phones and browsers). */
.old-browser { margin: 1rem 0; padding: 1rem 1.1rem; font-size: 1.25rem; font-weight: 700; line-height: 1.6; color: #8d2839; background: var(--panel); border: 2px solid #8d2839; border-radius: .8rem; }
.old-browser[hidden], .app-failed .workspace, .app-failed .bar { display: none; }
.zoom-actions { display: flex; flex-wrap: wrap; gap: var(--gap); margin-top: .75rem; }
.zoom-hint { margin-top: .5rem; color: var(--soft); }
#corner-preview { display: block; max-width: 100%; height: auto; margin-top: .5rem; }
.result-actions { display: flex; flex-wrap: wrap; gap: var(--gap); }
.result-actions form { margin: 0; }
.analytics-choice { display: flex; align-items: center; gap: .6rem; min-height: 3rem; width: fit-content; cursor: pointer; margin-block: .5rem; }
.analytics-choice input { width: 1.25rem; height: 1.25rem; accent-color: var(--rose); }

/* Empty live regions stay in the accessibility tree without taking space. */
#status:empty, #save-status:empty, #share-status:empty {
  position: absolute; display: block; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%);
}

@media (max-width: 63rem) {
  .workspace { gap: .85rem; }
  .panel { padding: 1rem; }
  .stage { padding: 1.2rem; }
}
/* Tablets and computers: photo on the left, frames on the right. The photo column
   stays in view while the frames scroll (app.js adds .stick when the column fits),
   and the save button stays at the top of the frames column. */
@media (min-width: 46.01rem) {
  .workspace { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
  .photo-panel.stick { position: sticky; top: .75rem; }
  .stage { max-height: max(15rem, calc(100vh - 17rem)); }
  .frame-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 8rem), 1fr)); }
}
@media (min-width: 46.01rem) and (min-height: 36rem) {
  .save-area { position: sticky; top: 0; z-index: 1; box-shadow: 0 6px 12px #67402c14; }
  .frame, .more { scroll-margin-top: 12rem; }
}
@media (min-width: 72.01rem) {
  .workspace { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  .frame-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (pointer: coarse), (max-width: 46rem) {
  .phone-pick { display: inline; }
  .desktop-pick { display: none; }
}
@media (max-width: 46rem) {
  .shell { width: min(100% - 1.5rem, 37rem); }
  .top-inner { min-height: 3.25rem; gap: .5rem; }
  .brand { font-size: 1.12rem; gap: .5rem; }
  .brand-mark { width: 2rem; height: 2rem; border-radius: .55rem; }
  .brand-mark svg { width: 1.3rem; height: 1.3rem; }
  .help-button { color: var(--rose); font-weight: 700; padding-inline: .5rem; }
  .help-button .icon { width: 1.5rem; height: 1.5rem; }
  .intro { display: grid; justify-items: start; padding-block: 1.7rem 1.23rem; gap: .7rem; }
  h1 { font-size: 2.65rem; }
  .intro p { font-size: 1rem; margin-top: .5rem; }
  .privacy { font-size: .91rem; padding: .28rem .6rem; }
  .panel { padding: .9rem; }
  .panel-head { margin-bottom: .65rem; }
  .stage { padding: 1rem; }
  .file-hint { font-size: .88rem; }
  .filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .frame-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 5.6rem), 1fr)); }
  .caption-fields, .caption-row { grid-template-columns: minmax(0, 1fr); }
  .footer { padding-block: 1.05rem; }
}
@media (max-width: 23rem) {
  h1 { font-size: 2.3rem; }
}
/* Phones: the preview stays pinned at the top while the frames scroll under it,
   and the one next step (choose a photo, then save) sits in a bar at the bottom,
   where the thumb is. Nothing on the way needs a gesture: every step is a tap.
   app.js sizes the preview so a whole row of frames always fits under it. */
@media (max-width: 46rem) {
  body { padding-bottom: calc(var(--bar-h, 7.5rem) + .5rem); font-size: 1.0625rem; }
  .intro { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); padding: 0; }
  .workspace { display: block; padding-top: .5rem; }
  .frames-panel { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .photo-panel > .panel-head, .photo-actions, .save-area, .wide-only { display: none; }
  /* The pinned preview needs the whole tool as its scroll area, not just the photo card. */
  .photo-panel { display: contents; }
  .phone-only { display: inline; }
  #frame-title .step { display: none; }

  .dock {
    position: sticky; top: 0; z-index: 2; margin-inline: -.75rem; padding: .5rem .75rem;
    background: var(--paper); border-bottom: 1px solid var(--line); box-shadow: 0 8px 14px -10px #51362d40;
  }
  /* Only problems are shown here; the bottom bar already says what to do next. */
  .status-box > .status:not(.error) {
    position: absolute; display: block; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%);
  }
  .status-box > .status { margin: 0; font-size: 1.0625rem; }
  .status-help { margin: 0; }
  /* A problem shows on top of the preview, so the frames below never move out of sight. */
  .status-box.error {
    position: absolute; top: .9rem; left: 1.15rem; right: 1.15rem; z-index: 4;
    display: flex; flex-wrap: wrap; align-items: center; column-gap: .75rem;
    padding: .2rem .75rem; background: var(--panel); border: 2px solid #8d2839; border-radius: .75rem;
    box-shadow: 0 4px 14px #33292333; max-height: calc(100% - 1.8rem); overflow-y: auto;
  }
  .status-box.error .status-help[open] { flex-basis: 100%; }
  .stage {
    aspect-ratio: auto; padding: .6rem;
    /* Close to the size app.js gives it (the sample photo's shape, room for a row of
       frames), so the box hardly changes when the page finishes loading. */
    height: 40vh; height: max(7rem, min(calc((100vw - 2.7rem - 2px) * .75 + 1.2rem), 50vh, calc(100vh - 20.3rem - 31.8vw)));
  }
  .stage-badge {
    display: block; position: absolute; top: .4rem; left: .4rem; max-width: calc(50% - .4rem);
    padding: .1rem .55rem; border-radius: .4rem; background: #fffcf7e8; color: var(--ink);
    font-size: .95rem; font-weight: 700; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .stage-badge:empty { display: none; }
  .stage-placeholder { padding: 1rem; font-size: 1.125rem; }

  /* 调整, 改字 and 看大图 sit on the corners of the preview instead of taking a row of their own. */
  .dock-tools {
    position: absolute; top: .4rem; right: .4rem; bottom: .4rem; left: .4rem; margin: 0; border: 0; pointer-events: none;
    display: grid; grid-template: "x words" auto "y y" 1fr "adjust view" auto / 1fr 1fr; align-items: end;
  }
  .dock-tools > * { pointer-events: auto; min-width: 0; }
  .sheet + .sheet { border: 0; }
  #adjust { grid-area: adjust; justify-self: start; }
  #words { grid-area: words; justify-self: end; align-self: start; }
  .dock-view { grid-area: view; justify-self: end; display: inline-flex; }
  .sheet summary, .dock-tools .dock-view {
    width: auto; min-height: 2.75rem; padding: .3rem .7rem; gap: .35rem; justify-content: center;
    color: var(--rose); font-weight: 700; font-size: 1.0625rem; line-height: 1.2; white-space: nowrap;
    background: #fffcf7f0; border: 1px solid var(--edge); border-radius: 2rem; box-shadow: 0 2px 6px #33292326;
  }
  .sheet summary .chevron { display: none; }
  .sheet[open] summary { background: var(--rose-light); border-color: var(--rose); }
  /* The sheets cover the lower part of the screen; the preview stays in sight above them. */
  .sheet[open] .sheet-body {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; max-height: min(62vh, calc(100vh - 9rem)); overflow-y: auto; overscroll-behavior: contain;
    padding: 1rem .9rem 0; background: var(--panel); text-align: left; white-space: normal; cursor: auto;
    border-top: 1px solid var(--line); border-radius: 1.1rem 1.1rem 0 0; box-shadow: 0 -10px 34px #33292340;
  }
  .sheet-backdrop { display: block; position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 5; background: #3229191f; }
  /* Sheets rise gently into place: a short fade and a small slide, no bounce. */
  .sheet[open] .sheet-body { animation: rise .2s ease-out; }
  .sheet-backdrop:not([hidden]) { animation: fade-in .2s ease-out; }
  .sheet-backdrop[hidden] { display: none; }
  /* The pinned preview is its own layer; lift it while a sheet is open so the sheet covers the bottom bar. */
  .dock.sheet-open { z-index: 7; }
  .dock.sheet-open .viewer { z-index: 6; }
  .sheet-title { display: block; font-size: 1.2rem; font-weight: 750; }
  .sheet-title span { font-size: 1rem; font-weight: 400; color: var(--soft); }
  .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #fit-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice { flex-direction: column; gap: .25rem; min-height: 4rem; padding-inline: .3rem; }
  .choice[aria-pressed="true"] { padding-inline: calc(.3rem - 1px); }
  /* 调好了 always stays at the bottom of the sheet, however long its content. */
  .sheet-done {
    display: block; position: sticky; bottom: 0; margin: .2rem -.9rem 0; padding: .6rem .9rem calc(.75rem + env(safe-area-inset-bottom));
    background: var(--panel); border-top: 1px solid var(--line);
  }
  .sheet-done .button { width: 100%; min-height: 3.25rem; font-size: 1.2rem; }

  .frames-panel { padding-top: .9rem; }
  .frames-panel .panel-head { margin-bottom: .6rem; }
  .filters { gap: .5rem; }
  .frame-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .frame { padding: .45rem .45rem .5rem; }
  .frame .chosen { width: 1.7rem; height: 1.7rem; top: .7rem; right: .7rem; }
  .chosen .icon { width: 1.1rem; height: 1.1rem; }
  /* Keyboard focus and scrolling stop clear of the pinned preview and the bottom bar. */
  .frame, .more, .filter { scroll-margin-top: calc(var(--dock-h, 40vh) + .5rem); scroll-margin-bottom: calc(var(--bar-h, 8rem) + .5rem); }
  .more { margin-top: .75rem; color: var(--rose); font-weight: 700; border: 1px solid var(--edge); background: var(--panel); border-radius: .63rem; }

  .bar {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
    padding: .5rem .75rem calc(.6rem + env(safe-area-inset-bottom));
    background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px #67402c1a;
  }
  .bar-hint { text-align: center; color: var(--soft); font-size: 1rem; line-height: 1.35; margin-bottom: .4rem; }
  .bar-hint.error { color: #8d2839; font-weight: 700; }
  .bar-hint.saved { color: var(--ok); font-weight: 700; }
  .bar-hint.pending { color: #8a4b00; font-weight: 700; }
  .bar-actions { display: flex; gap: .6rem; }
  .bar-actions .button { min-height: 3.5rem; font-size: 1.25rem; white-space: nowrap; overflow-wrap: normal; }
  #bar-pick { flex: 0 0 auto; padding-inline: 1rem; }
  #bar-main { flex: 1 1 auto; }
  .bar .button:disabled { opacity: .7; }
  .footer { padding-bottom: .5rem; }

  /* 看大图 uses the whole screen, so the photo is bigger than on the page, not smaller. */
  #frame-dialog { width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border: 0; border-radius: 0; }
  #frame-dialog .dialog-inner {
    display: flex; flex-direction: column; min-height: 100%;
    padding: calc(.6rem + env(safe-area-inset-top)) .5rem calc(.6rem + env(safe-area-inset-bottom));
  }
  #frame-dialog h2 { font-size: 1.15rem; margin-bottom: .4rem; }
  #frame-preview { max-height: calc(100vh - 13rem); }
  .zoom-view.both, .zoom-view.tall { max-height: calc(100vh - 15rem); }
  #frame-dialog form { margin-top: auto; padding-top: .75rem; }
  #frame-dialog form .button { width: 100%; min-height: 3.25rem; font-size: 1.2rem; }
  .zoom-actions .button { flex: 1 1 auto; }
}
/* Very narrow (small phones, zoomed pages): smaller bar text, no icon, so nothing wraps. */
@media (max-width: 22rem) {
  .bar-actions .button { font-size: 1.125rem; padding-inline: .6rem; }
  #bar-pick { padding-inline: .6rem; }
  #bar-icon { display: none; }
  .filter { padding-inline: .2rem; font-size: 1.0625rem; }
  .filter[aria-pressed="true"] { padding-inline: calc(.2rem - 1px); }
  .sheet summary, .dock-tools .dock-view { padding-inline: .5rem; font-size: 1rem; }
  .dock-tools .icon { display: none; }
}
/* Too short to pin the preview (a phone on its side): let it scroll with the page.
   app.js decides (class short-phone) from the window's height, ignoring the keyboard
   and the address bar, so typing a blessing does not unpin and resize the preview. */
@media (max-width: 46rem) {
  .short-phone .dock { position: relative; box-shadow: none; }
}
/* Dialogs fade in; nothing ever zooms or bounces. */
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(.75rem); } }
dialog[open] { animation: fade-in .18s ease-out; }
dialog[open]::backdrop { animation: fade-in .18s ease-out; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  dialog::backdrop { animation: none !important; }
}
