/* Phone presentation. Desktop keeps its existing paper and pixel composition. */
.hero-mobile-summary, .phone-download-hint, .phone-download-meta, .phone-download-web, .phone-theme-shortcut { display: none; }

@media (max-width: 700px), (max-width: 950px) and (orientation: landscape) and (max-height: 520px) {
  html, html[data-phone-theme] {
    --phone-font: "PingFang SC", "Microsoft YaHei UI", system-ui, sans-serif;
    --phone-bg: #faf8f2;
    --phone-surface: #fffdf8;
    --phone-line: #e1dcd1;
    --phone-muted: #696255;
    --phone-soft: #f0ece2;
    --phone-accent-soft: #f3e5dc;
    --phone-info: #f0f2f8;
    --phone-success-bg: #edf1e7;
    --phone-success-ink: #476039;
    --manual-paper: var(--phone-bg);
    --manual-paper-2: var(--phone-surface);
    --manual-tint: var(--phone-soft);
    --manual-tint-2: var(--phone-line);
    color-scheme: light;
    --manual-serif-cn: var(--phone-font);
    --manual-serif-la: var(--phone-font);
    scroll-padding-top: calc(var(--portfolio-header-height, 54px) + 12px);
  }
  body { background: var(--phone-bg); min-width: 0; font: 16px/1.65 var(--phone-font); }
  .paper-world { background: var(--phone-bg); font: 16px/1.65 var(--phone-font); }
  .grain, .opener, .fold-out { display: none; }
  .to-top, .to-top:hover {
    display: flex; z-index: 85; right: 14px; bottom: calc(74px + env(safe-area-inset-bottom));
    width: 44px; height: 44px; border: 1px solid var(--phone-line); border-radius: 50%;
    background: var(--phone-surface); color: var(--manual-ink); box-shadow: 0 3px 14px #080d2020;
    opacity: 0; pointer-events: none; transform: translateY(8px);
  }
  .to-top.is-on { opacity: 1; pointer-events: auto; transform: none; }
  .to-top svg { width: 20px; height: 20px; }
  .paper-world.js .rise, .paper-world.js .bleed { opacity: 1; transform: none; clip-path: none; transition: none; }
  :focus-visible { outline-width: 2px; outline-offset: 2px; }

  /* A quiet, single-row header keeps the live scene controls available. */
  html[data-theme] .site-header { border-bottom: 1px solid var(--phone-line); box-shadow: none; background: var(--phone-bg); }
  .site-header .nav-shell { display: flex; flex-wrap: wrap; min-height: 54px; padding: 7px 14px; gap: 5px 8px; }
  .site-header .brand { min-width: 0; margin-right: auto; gap: 6px; }
  .site-header .brand canvas { flex: none; width: 23px; height: 23px; }
  .site-header .brand strong { font-size: 16px; letter-spacing: 0; white-space: nowrap; }
  .site-header .brand small, .site-header .home-btn { display: none; }
  .site-header .nav-tools { margin: 0; gap: 4px; }
  .site-header .phone-theme-shortcut {
    display: grid; place-items: center; flex: none; width: 32px; height: 36px; padding: 0;
    border: 1px solid var(--phone-line); border-radius: 8px;
    background: var(--phone-surface); color: var(--manual-ink); cursor: pointer;
  }
  .phone-theme-shortcut svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .site-header .clock { display: inline; min-width: 29px; font-size: 11px; }
  .site-header .time-dial { width: 36px; height: 36px; box-shadow: none; }
  .site-header .time-live { min-width: 36px; min-height: 36px; padding: 4px; border: 1px solid var(--phone-line); border-radius: 7px; box-shadow: none; font-size: 11px; }
  .site-header .nav-github { width: 32px; height: 36px; }
  .site-header .nav-github canvas { width: 24px; height: 24px; }
  .site-header .site-nav { order: 3; width: 100%; min-width: 0; justify-content: flex-start; gap: 18px; overflow-x: auto; padding: 5px 0; border-color: var(--phone-line); }
  .site-header .site-nav a { font-size: 14px; }
  html.has-phone-nav .site-header .nav-shell { flex-wrap: nowrap; }
  html.has-phone-nav .site-header .site-nav, html.has-phone-nav .marginalia { display: none; }

  /* The phone introduction has one headline, one short summary and two actions. */
  .hero:not(.detail-hero) { display: block; min-height: 0; padding: 25px 18px 28px; }
  .hero-content { width: 100%; max-width: none; }
  .hero .eyebrow { width: fit-content; max-width: 100%; flex-wrap: wrap; gap: 4px 6px; margin: 0 0 16px; padding: 5px 7px; box-shadow: none; font-size: 11px; letter-spacing: 0; }
  .hero:not(.detail-hero) h1 { font-size: clamp(26px, calc(6.8vw + 2px), 31px); line-height: 1.3; letter-spacing: -.035em; text-shadow: 1px 2px 0 #03051080; }
  .hero:not(.detail-hero) .hero-role, .hero:not(.detail-hero) .hero-lead { display: none; }
  .hero-mobile-summary { display: block; max-width: 32em; margin: 15px 0 0; color: #edf2ff; font-size: 15px; line-height: 1.7; text-shadow: 0 1px 5px #060b20; }
  .hero-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
  .hero-actions .button, .detail-hero .button { min-width: 0; min-height: 44px; padding: 9px 7px; border-width: 1px; border-radius: 8px; box-shadow: none; font-size: 14px; transform: none; }
  .hero-proof { margin-top: 15px; font-size: 11px; line-height: 1.6; }
  .hero-proof span { padding: 0 3px; }
  .hero-bottom, .hero .scroll-cue { display: none; }

  /* The body is a small-screen reading surface with one spacing scale. */
  .page { min-height: 0; padding: 0 16px; border: 0; background: var(--phone-bg); }
  .slab { width: 100%; }
  .body-col, .paper-world.detail-paper .body-col.detail-content { padding: 0; }
  .chapter { padding: 24px 0; border-bottom: 1px solid var(--phone-line); scroll-margin-top: 0; }
  .chapter + .chapter { padding-top: 24px; }
  .chapter + .chapter::before { display: none; }
  .ch-head { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; align-items: start; margin-bottom: 15px; }
  .ch-no { margin: 0; }
  .ch-no .big { display: grid; place-items: center; width: 25px; height: 25px; padding: 0; border-radius: 7px; background: var(--phone-accent-soft); color: var(--manual-red-dk); filter: none; font: 800 14px/1 var(--phone-font); letter-spacing: 0; }
  .ch-no .dot, .ch-side { display: none; }
  .ch-title h2 { margin: 0; font: 700 22px/1.4 var(--phone-font); letter-spacing: -.02em; }
  .ch-title h2 br { display: none; }
  .ch-title .lede { margin-top: 7px; font-size: 14px; line-height: 1.65; }

  /* Project previews are compact list cards. The detail page holds the full case. */
  .prints { grid-template-columns: 1fr; gap: 10px; }
  .print, .print:hover { display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 8px 11px; padding: 12px; border: 1px solid var(--phone-line); border-radius: 12px; background: var(--phone-surface); box-shadow: 0 2px 5px #29201105; transform: none; overflow: hidden; }
  .print .tab, .print .plate .cap, .print .plate::after, .print .spec, .print .footnote, .print .project-invite { display: none; }
  .print .plate { grid-column: 1; grid-row: 1; width: 60px; height: 60px; aspect-ratio: 1; margin: 0; border: 0; border-radius: 8px; }
  .print .plate img, .print:hover .plate img { filter: none; opacity: 1; object-fit: cover; }
  .print .pad { display: contents; }
  .print h3 { grid-column: 2; grid-row: 1; align-self: center; min-width: 0; font: 750 19px/1.25 var(--phone-font); letter-spacing: 0; }
  .print h3 small { margin-top: 4px; font-size: 13px; line-height: 1.4; }
  .print .sum { grid-column: 1 / -1; grid-row: 2; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; margin: 0; font-size: 14px; line-height: 1.6; }
  .print .acts { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; }
  .print .acts .go, .print:hover .acts .go { min-height: 34px; padding: 0; background: none; color: var(--manual-red-dk); box-shadow: none; transform: none; font: 700 14px/1.4 var(--phone-font); letter-spacing: 0; }
  .print .acts .go::after { content: "→"; }
  .print .acts .rp { color: var(--phone-muted); font: 500 12px/1.4 var(--phone-font); }
  .print .hit { border-radius: inherit; }

  /* Contributions read as a list, with the full record one tap away. */
  #open-source.chapter--oss { cursor: auto; }
  .log { display: flex; flex-direction: column; margin-top: 0; border: 1px solid var(--phone-line); border-radius: 12px; background: var(--phone-surface); box-shadow: none; overflow: hidden; }
  .log-bar { order: 1; padding: 11px 12px; background: transparent; color: var(--phone-muted); border-bottom: 1px solid var(--phone-line); font-size: 11px; letter-spacing: .08em; }
  .log-bar em { display: none; }
  #open-source .log-scroll { order: 2; height: 190px; max-height: 190px; overflow: hidden; mask-image: none; -webkit-mask-image: none; }
  .log-tag, .log-tag:hover { position: static; order: 3; min-height: 44px; height: auto; padding: 10px 12px; border: 0; border-top: 1px solid var(--phone-line); background: transparent; color: var(--manual-red-dk); font: 700 14px/1.4 var(--phone-font); letter-spacing: 0; animation: none; transform: none; }
  .log-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 12px; border-color: var(--phone-line); }
  .log-h, .log-t, .log-m p, .log-r b { display: none; }
  .log-m { grid-column: 1; grid-row: 1; }
  .log-m small { font-size: 11px; line-height: 1.5; letter-spacing: .02em; }
  .log-m strong { margin-top: 3px; font-size: 15px; line-height: 1.5; }
  .log-r { grid-column: 2; grid-row: 1; display: block; }
  .stamp { margin: 0; padding: 3px 5px; border: 0; border-radius: 5px; background: var(--phone-success-bg); color: var(--phone-success-ink); font: 600 11px/1.4 var(--phone-font); letter-spacing: 0; transform: none; }
  .cooperation { margin-top: 18px; padding: 14px 0 0; border: 0; border-top: 1px solid var(--phone-line); background: transparent; box-shadow: none; }
  .cooperation-head { gap: 4px; margin-bottom: 8px; }
  .cooperation-head h3 { font-size: 17px; }
  .cooperation-head p { font-size: 13px; }
  .cooperation-grid { grid-template-columns: 1fr; gap: 0; }
  .cooperation-grid article { padding-top: 10px; border-color: var(--phone-line); }
  .cooperation-grid h4 { margin-bottom: 0; font-size: 14px; }
  .cooperation-grid article p { display: none; }
  .cooperation-grid a { min-height: 34px; margin: 3px 13px 0 0; font-size: 13px; line-height: 30px; }

  /* Labels sit above long text to avoid a squeezed right column. */
  .keyvals, .skills-body .keyvals { display: grid; gap: 0; margin-top: 10px; border: 0; }
  .kv { grid-template-columns: 1fr; gap: 4px; padding: 11px 0; border-bottom: 1px solid var(--phone-line); }
  .kv b { font: 700 14px/1.5 var(--phone-font); letter-spacing: 0; }
  .kv span { font-size: 14.5px; line-height: 1.65; }
  .method-checks { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 16px; border: 0; background: transparent; }
  .method-checks__head { grid-column: 1 / -1; min-height: 0; padding: 0 0 2px; border: 0; background: none; color: var(--manual-ink); }
  .method-checks__head span { display: none; }
  .method-check { min-height: 0; padding: 9px; border: 0; border-radius: 8px; background: var(--phone-soft); }
  .method-check b { font-size: 12px; }
  .method-check span { font-size: 12px; line-height: 1.5; }
  .experience-body, .skills-body { padding: 10px 0 0; }
  .panel-t { font: 700 16px/1.5 var(--phone-font); }
  .panel-t i { width: 6px; height: 6px; border-radius: 2px; background: var(--manual-red); }
  .tl { margin-top: 12px; padding-left: 14px; border-left: 1px solid var(--phone-line); }
  .tl li { padding-bottom: 18px; }
  .tl li::before { left: -18px; top: 7px; width: 6px; height: 6px; border-radius: 2px; }
  .tl time { font-size: 11px; letter-spacing: 0; }
  .tl h5 { margin: 4px 0; font-size: 15px; line-height: 1.5; }
  .tl p, .event-copy { font-size: 14.5px; line-height: 1.65; }
  .event-title { margin-top: 20px; }
  .event-copy { margin-top: 8px; }
  .note-inline { margin-top: 12px; padding: 10px 12px; border-left-width: 2px; border-radius: 0 8px 8px 0; font-size: 14px; }

  .finale { padding: 0 0 8px; }
  .finale .lead { margin: 10px 0 0; font-size: 14.5px; line-height: 1.65; }
  .cta-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 16px; }
  .cta, .cta:hover, .cta.p { width: 100%; min-height: 44px; justify-content: center; padding: 9px 5px; border-width: 1px; border-radius: 8px; box-shadow: none; transform: none; font: 700 14px/1.4 var(--phone-font); letter-spacing: 0; }
  .cta:last-child { grid-column: 1 / -1; }
  .contact-table { margin-top: 20px; border: 1px solid var(--phone-line); border-radius: 12px; background: var(--phone-surface); box-shadow: none; overflow: hidden; }
  .contact-table .ct { padding: 10px 12px; border-bottom: 1px solid var(--phone-line); background: transparent; color: var(--phone-muted); font-size: 11px; letter-spacing: .06em; }
  .contact-table .cr { grid-template-columns: 55px minmax(0, 1fr); gap: 8px; padding: 12px; border-color: var(--phone-line); }
  .contact-table dt { font-size: 11px; letter-spacing: .02em; }
  .contact-table dd { font-size: 14px; line-height: 1.6; }
  .contact-table .cr small { font-size: 12px; line-height: 1.5; }
  .colophon { margin-top: 0; padding: 22px 0 calc(80px + env(safe-area-inset-bottom)); }
  .colophon-in { grid-template-columns: 1fr; gap: 14px; padding: 0 16px; }
  .colophon b { font: 700 18px/1.4 var(--phone-font); }
  .colophon p { font-size: 13px; }
  .colophon nav { gap: 15px; }
  .colophon nav a { min-height: 28px; font-size: 12px; line-height: 28px; letter-spacing: 0; }
  .colophon .end { margin-top: 0; padding-top: 12px; font-size: 11px; line-height: 1.6; letter-spacing: 0; }

  /* Detail pages use the same type, spacing, controls and surfaces. */
  .detail-hero { display: block; min-height: 0; padding: 19px 18px 25px; }
  .detail-hero-copy { width: 100%; max-width: none; }
  .detail-hero-art { display: none; }
  .detail-back { min-height: 30px; margin-bottom: 12px; font-size: 13px; }
  .detail-hero .section-kicker { margin-bottom: 10px; font-size: 11px; }
  .detail-hero h1 { font-size: clamp(27px, calc(7vw + 2px), 34px); line-height: 1.25; overflow-wrap: anywhere; }
  .detail-hero .hero-lead { margin-top: 13px; font-size: 15px; line-height: 1.65; }
  .detail-hero .detail-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 16px; }
  .detail-section, .paper-world.detail-paper .detail-section { padding: 24px 0; border-color: var(--phone-line); scroll-margin-top: 0; }
  .detail-section .section-kicker { margin-bottom: 8px; font-size: 11px; letter-spacing: .04em; }
  .detail-section h2 { margin-bottom: 13px; font: 700 23px/1.4 var(--phone-font); letter-spacing: -.02em; }
  .detail-section h3 { margin-bottom: 7px; font: 700 17px/1.5 var(--phone-font); }
  .detail-section p { margin-bottom: 12px; font-size: 15px; line-height: 1.7; }
  .detail-lede { font-size: 15px !important; }
  .detail-grid, .detail-grid--three, .detail-qr-grid { grid-template-columns: 1fr; gap: 10px; }
  .detail-panel { padding: 12px; border: 1px solid var(--phone-line); border-radius: 10px; box-shadow: none; background: var(--phone-surface); overflow-wrap: anywhere; }
  .detail-panel--accent { background: var(--phone-info); border-color: var(--phone-line); }
  .detail-panel p, .detail-panel ul { font-size: 14.5px; line-height: 1.65; }
  .detail-panel ul { margin-top: 7px; padding-left: 18px; }
  .detail-badge { margin-bottom: 8px; padding: 3px 6px; border-radius: 4px; font-size: 11px; }
  .detail-flow, .detail-flow--four { grid-template-columns: 1fr; gap: 0; margin-top: 16px; }
  .detail-flow div { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 3px 8px; padding: 12px 0 12px 12px; border: 0; border-left: 2px solid var(--phone-line); border-bottom: 1px solid var(--phone-line); background: transparent; box-shadow: none; }
  .detail-flow div::after { display: none; }
  .detail-flow b { margin: 0; font-size: 11px; line-height: 1.7; }
  .detail-flow strong { font-size: 15px; }
  .detail-flow p { grid-column: 2; margin: 0; font-size: 14px; line-height: 1.6; }
  .detail-stat-row { grid-template-columns: 1fr; gap: 7px; margin-top: 16px; }
  .detail-stat { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--phone-line); border-radius: 8px; background: var(--phone-soft); }
  .detail-stat strong { min-width: 0; font: 700 16px/1.4 var(--phone-font); overflow-wrap: anywhere; }
  .detail-stat span { margin: 0; font-size: 13px; line-height: 1.6; }
  .detail-note { margin-top: 16px; padding: 11px 12px; border-left-width: 3px; border-radius: 0 8px 8px 0; font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
  .detail-list { border-color: var(--phone-line); border-radius: 10px; background: var(--phone-surface); overflow: hidden; }
  .detail-list li { display: block; padding: 12px; border-color: var(--phone-line); overflow-wrap: anywhere; }
  .detail-list b { font-size: 15px; }
  .detail-list span { display: block; margin-top: 4px; text-align: left; font-size: 14px; }
  .detail-links { gap: 8px; margin-top: 16px; }
  .detail-content .detail-links .button, .detail-content .detail-links .button:hover { min-height: 44px; max-width: 100%; padding: 9px 11px; border-width: 1px; border-radius: 8px; box-shadow: none; transform: none; font: 700 13px/1.5 var(--phone-font); overflow-wrap: anywhere; }
  .detail-content .project-invite { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; margin: 10px 0; padding: 10px 0; border-color: var(--phone-line); }
  .detail-content .project-invite a, .detail-content .project-invite span { grid-column: 1 / -1; font-size: 13px; }
  .detail-content .project-invite code { min-width: 0; padding: 8px; font-size: 13px; background: var(--phone-soft); }
  .detail-content .project-invite button { min-width: 48px; min-height: 44px; border-color: var(--phone-line); border-radius: 7px; font-size: 14px; }
  .detail-qr { padding: 14px; border: 1px solid var(--phone-line); border-radius: 12px; box-shadow: none; }
  .detail-qr img { width: min(100%, 200px); }
  .detail-qr figcaption { font-size: 13px; }
  .detail-table-wrap { border: 0; overflow: visible; }
  .detail-table { display: block; width: 100%; min-width: 0; background: transparent; }
  .detail-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .detail-table tbody { display: grid; gap: 9px; }
  .detail-table tbody tr { display: grid; padding: 7px 11px; border: 1px solid var(--phone-line); border-radius: 10px; background: var(--phone-surface); box-shadow: none; }
  .detail-table td { display: grid; grid-template-columns: 55px minmax(0, 1fr); gap: 7px; min-width: 0; padding: 7px 0; border-color: var(--phone-line); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
  .detail-table td:last-child { border-bottom: 0; }
  .detail-table td::before { color: var(--phone-muted); font: 500 11px/1.8 var(--phone-font); }
  #merged .detail-table td:nth-child(1)::before { content: "上游项目"; }
  #merged .detail-table td:nth-child(2)::before { content: "解决问题"; }
  #merged .detail-table td:nth-child(3)::before { content: "合入日期"; }
  #merged .detail-table td:nth-child(4)::before { content: "证据"; }
  #releases .detail-table td:nth-child(1)::before { content: "已合入"; }
  #releases .detail-table td:nth-child(2)::before { content: "改动"; }
  #releases .detail-table td:nth-child(3)::before { content: "版本记录"; }
  .oss-pagination { margin: 12px 0 18px; gap: 8px; font-size: 13px; }
  .oss-pagination__buttons { gap: 6px; width: 100%; }
  .oss-pagination button { min-width: 40px; min-height: 40px; padding: 6px 10px; border-color: var(--phone-line); border-radius: 7px; }
  .detail-next, .detail-next:hover { gap: 12px; padding: 14px; border: 1px solid var(--phone-line); border-radius: 10px; box-shadow: none; transform: none; }
  .detail-next strong { font: 700 17px/1.5 var(--phone-font); }
  .site-footer { padding-bottom: calc(76px + env(safe-area-inset-bottom)); border-top: 1px solid var(--phone-line); }
  .site-footer .footer-inner { grid-template-columns: 1fr; gap: 14px; padding: 22px 16px 0; }
  .site-footer .footer-inner strong { font-size: 18px; }
  .site-footer .footer-inner p { font-size: 13px; }

  /* Stable, equal-sized icons and a low-profile bottom navigation. */
  .phone-dock { position: fixed; z-index: 90; inset: auto 0 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); height: calc(60px + env(safe-area-inset-bottom)); padding: 4px max(6px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); border-top: 1px solid var(--phone-line); background: var(--phone-bg); box-shadow: 0 -4px 15px #20180e06; font-family: var(--phone-font); }
  .phone-dock a, .phone-dock button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; min-height: 50px; padding: 0; border: 0; background: none; color: var(--phone-muted); font: 500 12px/1.2 var(--phone-font); text-decoration: none; cursor: pointer; }
  .phone-dock__icon { display: grid; place-items: center; width: 38px; height: 25px; border-radius: 9px; }
  .phone-dock__icon svg { display: block; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: square; stroke-linejoin: miter; }
  .phone-dock a[aria-current], .phone-dock button.is-current, .phone-dock button[aria-expanded="true"] { color: var(--manual-red-dk); font-weight: 700; }
  .phone-dock a[aria-current] .phone-dock__icon, .phone-dock button.is-current .phone-dock__icon, .phone-dock button[aria-expanded="true"] .phone-dock__icon { background: var(--phone-accent-soft); }
  .phone-directory { position: fixed; inset: auto 8px calc(68px + env(safe-area-inset-bottom)); width: min(560px, calc(100vw - 16px)); max-height: min(76svh, 640px); margin: 0 auto; padding: 0 0 12px; overflow-y: auto; border: 1px solid var(--phone-line); border-radius: 16px; background: var(--phone-bg); color: var(--manual-ink); box-shadow: 0 12px 40px #0b102940; font-family: var(--phone-font); }
  .phone-directory::backdrop { background: #0b102388; }
  .phone-directory__heading { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px; border-bottom: 1px solid var(--phone-line); background: var(--phone-bg); }
  .phone-directory__heading small { display: block; color: var(--phone-muted); font: 600 11px/1.5 var(--phone-font); letter-spacing: .04em; }
  .phone-directory__heading strong { display: block; margin-top: 2px; font-size: 20px; }
  .phone-directory__close { width: 40px; height: 40px; padding: 0; border: 0; border-radius: 9px; background: var(--phone-soft); color: var(--manual-ink); font-size: 26px; }
  .phone-directory__group { padding: 13px 14px 0; }
  .phone-directory__group h2 { margin: 0 0 8px; color: var(--phone-muted); font: 600 13px/1.5 var(--phone-font); }
  .phone-directory__links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .phone-directory__links a { display: flex; align-items: center; min-height: 46px; padding: 9px; border: 1px solid var(--phone-line); border-radius: 8px; background: var(--phone-surface); color: var(--manual-ink); font: 600 14px/1.5 var(--phone-font); text-decoration: none; overflow-wrap: anywhere; }
  .phone-directory__links a[aria-current] { border-color: var(--manual-red-dk); background: var(--phone-accent-soft); color: var(--manual-red-dk); }


  /* Keep footer contrast consistent across the home and project pages. */
  html[data-theme] .colophon, html[data-theme] .site-footer {
    background: var(--phone-surface); color: var(--manual-ink);
    border-top: 1px solid var(--phone-line);
  }
  .colophon b, .site-footer .footer-inner strong { color: var(--manual-ink); }
  .colophon p, .colophon nav a, .colophon .end,
  .site-footer .footer-inner p, .site-footer .footer-inner nav a { color: var(--phone-muted); }
  .colophon .end, .site-footer .footer-end { border-color: var(--phone-line); }
  .site-footer .footer-inner nav { flex-wrap: wrap; gap: 12px 20px; }
  .site-footer .footer-inner nav a { font-size: 12px; min-height: 32px; line-height: 32px; }
  .site-footer .fband { display: none; }
  .site-header .brand strong, .site-header .clock { color: var(--manual-ink); }
  .site-header .time-dial__icon { font-size: 18px; }
  .method-checks__head b { font-size: 13px; }
  .note-inline b { font-size: 11px; }
  .site-header .time-live { color: var(--manual-moss-dk); background: var(--phone-soft); }
  .detail-next > span { font-size: 12px; }
  .detail-next > b { font-size: 26px; }
  .detail-section code { font-size: 14.6px; }
  .phone-directory__heading small, .phone-directory__heading strong { font-family: var(--phone-font); }
  .phone-directory__heading { gap: 8px; }
  .phone-theme-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    width: calc(100% - 28px); min-height: 48px; margin: 12px 14px 0; padding: 10px 12px;
    border: 1px solid var(--phone-line); border-radius: 10px;
    background: var(--phone-surface); color: var(--manual-ink);
    font: 600 14px/1.5 var(--phone-font); text-align: left; cursor: pointer;
  }
  .phone-theme-toggle__state { color: var(--phone-muted); font-size: 12px; }
  .phone-theme-toggle[aria-pressed="true"] { border-color: var(--manual-indigo); }
  .phone-theme-toggle[aria-pressed="true"] .phone-theme-toggle__state { color: var(--manual-indigo); }
  .phone-download { animation: phone-download-pulse 2.8s ease-in-out infinite; }
  .detail-content .phone-download-hint {
    display: block; margin: 12px 0 0; padding: 9px 11px; border-radius: 8px;
    background: var(--phone-accent-soft); color: var(--manual-red-dk); font-size: 13px; line-height: 1.6;
  }
  .detail-content .phone-download-meta {
    display: block; margin: 12px 0 0; color: var(--phone-muted); font-size: 12px; line-height: 1.7;
    overflow-wrap: anywhere;
  }
  .detail-content .phone-download-web { display: block; margin: 9px 0 0; color: var(--phone-muted); font-size: 13px; line-height: 1.7; }
  .phone-download-web a { color: var(--manual-indigo); text-underline-offset: 3px; }
  .phone-download[aria-disabled="true"] { opacity: .72; cursor: wait; }
  .phone-download.is-download-requested { animation: none; }
  @keyframes phone-download-pulse {
    0%, 100% { box-shadow: 0 0 0 0 transparent; }
    50% { box-shadow: 0 0 0 3px var(--phone-accent-soft); border-color: var(--manual-red-dk); }
  }
  @media (prefers-reduced-motion: reduce) { html:not(.force-motion) .phone-download { animation: none; } }
  html[data-reduce-motion="1"] .phone-download { animation: none; }
  html[data-reduce-motion="1"] #open-source .log-scroll { overflow-y: auto; }

  /* Reading theme is independent of the pixel scene and only applies on phones. */
  html[data-phone-theme="dark"] {
    color-scheme: dark;
    --phone-bg: #151c26; --phone-surface: #1d2734; --phone-line: #3a4759;
    --phone-muted: #b7c1cf; --phone-soft: #273345; --phone-accent-soft: #402f2d;
    --phone-info: #26334d; --phone-success-bg: #273d35; --phone-success-ink: #b0dbc0;
    --manual-ink: #f2efe9; --manual-ink-2: #d2d8e1; --manual-ink-3: #b7c1cf; --manual-ink-4: #8997aa;
    --manual-red: #ff9f85; --manual-red-dk: #ffb49c;
    --manual-indigo: #abcaff; --manual-indigo-dk: #bed6ff;
    --manual-moss: #b0c9a6; --manual-moss-dk: #b0c9a6;
  }
  html[data-phone-theme="dark"] .paper-world,
  html[data-phone-theme="dark"] .page { color: var(--manual-ink); }
  html[data-phone-theme="dark"] .detail-content .button--gold,
  html[data-phone-theme="dark"] .cta.p { background: #a83d27; color: #fff; border-color: #d5806d; }
  html[data-phone-theme="dark"] .project-invite code { color: var(--manual-red-dk); }
  html[data-phone-theme="dark"] .detail-section + .detail-section { border-color: var(--phone-line); }
  html[data-phone-theme="dark"] .oss-pagination button { background: var(--phone-surface); color: var(--manual-ink); }
  html[data-phone-theme="dark"] .oss-pagination button[aria-current="page"] { background: #abcaff; color: #142139; }
  html[data-phone-theme="dark"] .phone-directory__close { color: var(--manual-ink); }

}

@media (max-width: 340px) {
  .site-header .nav-shell { padding-left: 10px; padding-right: 10px; gap: 4px; }
  .site-header .brand canvas { width: 19px; height: 19px; }
  .site-header .brand strong { font-size: 15px; }
  .site-header .nav-tools { gap: 3px; }
  .site-header .clock { font-size: 10px; min-width: 26px; }
  .site-header .nav-github { width: 27px; }
  .hero:not(.detail-hero), .detail-hero { padding-left: 16px; padding-right: 16px; }
  .page { padding-left: 12px; padding-right: 12px; }
  .print { grid-template-columns: 52px minmax(0, 1fr); padding: 10px; gap: 7px 9px; }
  .print .plate { width: 52px; height: 52px; }
  .print h3 { font-size: 18px; }
  .print h3 small { font-size: 12px; }
  .detail-flow div { grid-template-columns: 66px minmax(0, 1fr); }
}

@media (max-width: 950px) and (orientation: landscape) and (max-height: 520px) {
  .hero:not(.detail-hero) { padding-top: 22px; padding-bottom: 24px; }
  .hero-content { max-width: 620px; }
  .prints { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .phone-dock { grid-template-columns: repeat(5, minmax(0, 100px)); justify-content: center; }
  .phone-directory { max-height: calc(100svh - 82px); }
}

@media (min-width: 701px) and (min-height: 521px), (min-width: 951px), print {
  .phone-dock, .phone-directory { display: none; }
}
