:root {
  --paper: #f6f4ee;
  --card: #ffffff;
  --ink: #141414;
  --muted: #5a574f;
  --line: #d7d2c6;
  --accent: #141414;
  --nav-height: 62px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: "Iowan Old Style", "Songti SC", "Source Han Serif SC", Palatino, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

.site-wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* Top navigation */
.nav {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(246, 244, 238, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1.5px solid var(--ink);
}
.nav-inner {
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.site-brand {
  display: flex;
  flex: none;
  white-space: nowrap;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.site-brand img { width: 28px; height: 28px; border-radius: 6px; }
.site-brand small { font-weight: 500; font-size: 12px; color: var(--muted); margin-left: 4px; }
.nav-links { display: flex; align-items: center; gap: 24px; margin-left: auto; font-size: 14px; }
.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--ink); }
.nav-links svg { flex: none; width: 1.1em; height: 1.1em; }
/* 外链和页内导航分开：一条竖线 + 额外留白 */
.nav-source { margin-left: 6px; padding-left: 28px; border-left: 1px solid var(--line); }
.nav-language {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  margin-left: 4px;
}
.nav-language[hidden] { display: none; }
.nav-language > svg { flex: none; width: 20px; height: 20px; }
.nav-language-options {
  display: flex;
  align-items: center;
  padding: 3px;
  border: 1px solid #b6b1a6;
  border-radius: 999px;
  background: var(--card);
}
.nav-language button {
  min-width: 36px;
  min-height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 600 14px/1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
}
.nav-language button:hover { background: #eae6db; }
.nav-language button[aria-pressed="true"] { background: var(--ink); color: var(--card); }
.nav-language button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border: 1.5px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.solid { background: var(--ink); color: var(--card); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* Hero */
.site-hero {
  padding: 40px 0 56px;
  border-bottom: 1.5px solid var(--ink);
}
.site-hero, .site > .section { scroll-margin-top: var(--nav-height); }
.site-hero > #experience { display: block; scroll-margin-top: var(--nav-height); }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 442px;
  gap: clamp(28px, 4vw, 56px);
  align-items: center;
}
.hero-copy > h1 {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.18;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.site-subtitle {
  margin: 0 0 14px;
  font-size: clamp(16px, 1.5vw, 20px);
  line-height: 1.5;
}
.site-hero .site-lead {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 16px;
}
.scene-box {
  container-type: inline-size;
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  padding: 16px 18px;
}
.scene-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.site-heading {
  display: flex;
  align-items: center;
  gap: .4em;
}
.site-heading svg { flex: none; width: .8em; height: .8em; }
.scene-box-head h2 { margin: 0; font-size: 20px; }
.scene-box-head .site-heading svg { width: 1.1em; height: 1.1em; }
.scene-playback {
  padding: 3px 0 3px 6px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
  cursor: pointer;
}
.scene-pills { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.site-pill {
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background-color 160ms ease, color 160ms ease;
}
.site-pill[aria-pressed="true"] { background: var(--ink); color: var(--card); }
.scene-card {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 56px;
  padding: 8px;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1.35;
}
.scene-card svg { flex: none; width: 23px; height: 23px; }
.scene-card-primary {
  grid-column: span 2;
  min-height: 94px;
  gap: clamp(8px, 2.5cqi, 14px);
  padding: 12px clamp(9px, 2.6cqi, 16px);
  margin-bottom: 4px;
}
.scene-card-primary svg { width: clamp(25px, 7cqi, 40px); height: auto; }
.scene-card-copy {
  display: grid;
  gap: 4px;
  padding-inline-start: clamp(8px, 2.2cqi, 13px);
  border-inline-start: 1px solid var(--line);
}
.scene-card-copy strong { font-size: clamp(15px, 3.6cqi, 20px); font-weight: 700; }
.scene-card-copy small { font-size: 11px; font-weight: 500; }
.scene-card:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.scene-description {
  min-height: calc(4.8em + 12px);
  margin: 14px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 11px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
@container (max-width: 465px) {
  .scene-pills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scene-card-primary { grid-column: span 1; }
  .scene-description { min-height: calc(6.4em + 12px); }
}
@container (max-width: 310px) {
  .scene-card-primary { padding-inline: 8px; }
  .scene-card-primary svg { width: 22px; }
  .scene-card-copy { padding-inline-start: 6px; }
  .scene-description { min-height: calc(8em + 12px); }
}
@media (hover: hover) {
  .site-pill[aria-pressed="false"]:hover { background: #eae6db; }
}

.sim-slot { position: relative; min-width: 0; }
.sim-stage {
  position: relative;
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: start;
  scroll-margin-top: calc(var(--nav-height) + 16px);
}
.site.is-play .sim-stage:not(.is-fullscreen) .device {
  --zoom: 1;
  position: relative;
  /* 上面留给「全屏体验」，下面不占位：三颗键的说明画在机身下沿之外，落进后文的空隙。 */
  padding: 36px 104px 0 0;
}
.sim-stage .shell {
  --sim-zoom: var(--zoom);
  line-height: normal;
  transform-origin: top left;
  box-shadow:
    0 2px 8px #25211b14,
    0 10px 20px #25211b0d,
    0 0 0 1px #cfccd2,
    inset 0 3px 0 #5d5c60,
    inset -6px 0 0 #b4b2b7,
    inset 5px 0 0 #cfcdd2,
    inset 0 -2px 0 #dcdadf;
}
.sim-stage:not(.is-fullscreen) .sim-fullscreen-controls { display: none; }
.sim-stage.is-fullscreen .sim-expand { display: none; }
/* 「全屏体验」做成和按键标注同一套的灰色文字，不用方框按钮，免得和设备抢眼 */
.sim-expand {
  position: absolute;
  top: 0;
  right: 104px;
  z-index: 2;
  height: auto;
  padding: 2px 0;
  gap: 5px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.sim-expand svg { width: 15px; height: 15px; }
.sim-expand:hover { color: var(--ink); transform: none; text-decoration: underline; text-underline-offset: 3px; }
.sim-expand:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 3px; }
.sim-backdrop {
  position: fixed;
  inset: 0;
  z-index: 34;
  background: var(--paper);
  opacity: 0;
  pointer-events: none;
  transition: opacity 360ms ease;
}
.site.sim-fullscreen .sim-backdrop { opacity: 1; pointer-events: auto; }
.site.sim-fullscreen { overflow: hidden; }
.sim-stage.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 35;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  padding: 56px 120px 66px;
}
.site.is-play .sim-stage.is-fullscreen .device { padding: 0; }
.sim-stage.is-fullscreen .shell {
  --sim-zoom: var(--focus-zoom, 1);
  zoom: var(--sim-zoom);
}
.sim-stage.is-comparing { padding: 62px 16px 72px; }
.is-comparing .sim-devices {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: clamp(16px, 4vw, 56px);
  overflow: auto;
}
.site.is-play .sim-stage.is-comparing .device { flex: none; padding: 0 86px 48px 0; }
.sim-design-label {
  width: calc(300px * var(--focus-zoom, 1));
  height: 32px;
  margin: 0;
  text-align: center;
  font-size: 14px;
  line-height: 32px;
}
.sim-compare-status {
  display: grid;
  width: calc(300px * var(--focus-zoom, 1));
  height: calc(522px * var(--focus-zoom, 1));
  margin: 0;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}
.sim-compare-status[hidden] { display: none; }
.sim-key-tag {
  position: absolute;
  color: var(--muted);
  font: calc(12px / var(--sim-zoom)) / 1.2 var(--sans);
  pointer-events: none;
}
.sim-key-tag.is-unavailable { color: #827d72; }
.sim-key-tag::before { content: ""; position: absolute; }
.sim-key-side { left: calc(100% + 14px); transform: translateY(-50%); white-space: nowrap; }
html[lang="en"] .sim-key-side { width: 83px; white-space: normal; }
html[lang="en"] .sim-key-bottom { width: calc(74px / var(--sim-zoom)); white-space: normal; }
.sim-key-side::before {
  right: calc(100% + 3px);
  top: 50%;
  width: 9px;
  border-top: 1px solid #a9a194;
}
.sim-key-ai { top: 123px; }
.sim-key-up { top: 211.5px; }
.sim-key-down { top: 268.5px; }
.sim-key-power { top: 342.5px; }
.sim-key-bottom {
  top: calc(100% + 14px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25em;
  transform: translateX(-50%);
  text-align: center;
  white-space: nowrap;
}
.sim-key-bottom.is-unavailable { visibility: hidden; }
.sim-key-details { display: flex; align-items: center; gap: .35em; }
.sim-key-details:has([id$="menu-key-hold"][hidden]) { display: none; }
[id$="menu-key-hold"] { font-size: .85em; }
.sim-key-bottom::before {
  left: 50%;
  bottom: calc(100% + 3px);
  height: 11px;
  border-left: 1px solid #a9a194;
  transform: translateX(-50%);
}
.sim-key-menu { left: calc(var(--menu-key-left) + var(--menu-key-size) / 2); }
.sim-key-prev { left: calc(var(--prev-key-left) + var(--chin-key-width) / 2); }
.sim-key-next { left: calc(var(--next-key-left) + var(--chin-key-width) / 2); }
.sim-stage.is-fullscreen .sim-fullscreen-controls {
  animation: sim-controls-appear 280ms ease 120ms both;
}
@keyframes sim-controls-appear { from { opacity: 0; } to { opacity: 1; } }
.sim-fullscreen-controls {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 1;
  display: flex;
  gap: 8px;
}
.sim-fullscreen-controls .btn {
  height: 34px;
  padding-inline: 12px 14px;
  gap: 6px;
  line-height: 1;
  background: var(--paper);
  border-color: var(--line);
  font-size: 13px;
  white-space: nowrap;
}
.sim-compare[aria-pressed="true"] { background: var(--ink); color: var(--card); border-color: var(--ink); }
.sim-fullscreen-controls .btn svg { flex: none; width: 16px; height: 16px; }
@media (max-width: 600px) {
  .is-comparing .sim-devices { flex-direction: column; justify-content: flex-start; }
}
@media (max-width: 540px) {
  .sim-stage.is-fullscreen:not(.is-comparing) { padding-inline: 16px 104px; }
  .sim-key-tag { font-size: calc(11px / var(--sim-zoom)); }
}
@media (max-width: 500px), (max-height: 700px) {
  .sim-key-bottom { font-size: min(15px, calc(11px / var(--sim-zoom))); }
}
@media (prefers-reduced-motion: reduce) {
  .sim-backdrop { transition: none; }
  .sim-stage.is-fullscreen .sim-fullscreen-controls { animation: none; }
  .site-pill { transition: none; }
}

/* Sections */
.section { padding: 56px 0; border-bottom: 1.5px solid var(--ink); }
.section-head { margin-bottom: 28px; }
.section-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.section-head p { margin: 8px 0 0; color: var(--muted); font-size: 15px; max-width: 660px; }

/* Hardware grid */
#hardware { padding-block: 42px; }
#hardware .section-head { margin-bottom: 20px; }
.hw-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 14px;
}
.hw-card {
  background: var(--card);
  border: 1.5px solid var(--ink);
  padding: 16px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  align-content: start;
  gap: 6px 8px;
}
.hw-card svg { display: block; width: 20px; height: 20px; }
.hw-card b { font-size: 17px; line-height: 1.35; }
.hw-card span { grid-column: 1 / -1; font-size: 14px; color: var(--muted); line-height: 1.5; }

.site-improvements { margin-top: 88px; }
.site-improvements h3 { margin: 0 0 16px; font-size: 20px; scroll-margin-top: calc(var(--nav-height) + 16px); }
.improvement-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
}
.improvement-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.improvement-icon { display: block; flex: none; width: 56px; height: 56px; }
.site-improvements h4 { margin: 0; font-size: 17px; }
.site-improvements ul { margin: 0; padding: 0; list-style: none; }
.site-improvements li {
  display: grid;
  gap: 3px;
  border-top: 1px solid var(--line);
  padding: 9px 0;
}
.site-improvements strong { font-size: 15px; }
.site-improvements span { color: var(--muted); font-size: 14px; }

/* Flasher */
.flash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 20px;
  align-items: stretch;
}
.flash-panel, .flash-log-wrap {
  background: var(--card);
  border: 1.5px solid var(--ink);
  padding: 26px 24px 24px;
}
.flash-panel { display: flex; flex-direction: column; }
.flash-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.flash-row label { font-size: 12.5px; font-weight: 700; letter-spacing: .02em; }
.flash-row input[type="text"], .flash-row select, .flash-row input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  font: inherit;
  font-size: 13.5px;
}
/* 自绘下拉箭头：右侧留白和上下内边距对齐，不贴边 */
.flash-row select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23141414' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
  cursor: pointer;
}
.flash-checks { display: flex; flex-wrap: wrap; gap: 16px; margin: 12px 0 16px; font-size: 13px; }
.flash-checks label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* 更多选项：默认收起，和上面的版本选择、下面的按钮等距 */
#local-files-details {
  margin: 0 0 20px;
}
#local-files-details summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
#local-files-details summary::-webkit-details-marker { display: none; }
#local-files-details summary::before {
  content: "▸";
  font-size: 10px;
  line-height: 1;
  color: var(--muted);
  transition: transform 160ms ease;
}
#local-files-details[open] summary::before { content: "▾"; }
#local-files-details summary:hover { color: var(--ink); }
#local-files-details[open] summary { margin-bottom: 18px; }
#local-files-details .flash-row:last-child { margin-bottom: 0; }

.flash-btns { display: flex; flex-wrap: wrap; gap: 10px; }

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
}
.progress-row[hidden] { display: none; }
.progress-wrap {
  flex: 1;
  border: 1.5px solid var(--ink);
  height: 10px;
  background: var(--paper);
  position: relative;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--ink);
  transition: width 150ms linear;
}
.progress-percent {
  min-width: 3.4em;
  text-align: right;
  font: 12px var(--mono);
  color: var(--muted);
}
.progress-text {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
  font-family: var(--mono);
}

.flash-note {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

/* 不支持 WebSerial 的浏览器（手机、Safari、Firefox）：不显示用不了的面板，只给去处 */
.flash-unsupported {
  padding: 18px 20px;
  border: 1.5px solid var(--ink);
  background: var(--card);
  font-size: 14px;
}
.flash-unsupported p { margin: 0; }
.flash-unsupported p + p { margin-top: 6px; color: var(--muted); font-size: 13px; }
#flasher.no-webserial .flash-grid { display: none; }

.flash-log-wrap { display: flex; flex-direction: column; }
.flash-log-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.flash-log {
  flex: 1;
  min-height: 240px;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  background: #141414;
  color: #ece9df;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.warn-box {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px dashed var(--ink);
  background: var(--paper);
  font-size: 12.5px;
  color: var(--muted);
}

.site > footer {
  padding-block: 28px 40px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

@media (min-width: 981px) {
  /* 机身下沿和左边卡片下沿对齐。上面的空隙留给「全屏体验」。 */
  .hero-grid { align-items: end; }
}
@media (max-width: 1120px) {
  .hw-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .hero-grid, .flash-grid { grid-template-columns: 1fr; }
  .nav-links { gap: 16px; }
  .nav-source { margin-left: 0; padding-left: 16px; }
}
@media (max-width: 880px) {
  .site-brand small { display: none; }
}
@media (max-width: 760px) {
  /* 语言切换和四个导航挤在一行时，右侧会贴边。换成品牌一行、链接一行。 */
  :root { --nav-height: 80px; }
  .nav-inner { display: grid; grid-template: 44px 1fr / 1fr auto; gap: 0; }
  .nav-links { grid-area: 2 / 1 / 3 / 3; margin-left: 0; }
  .nav-language { grid-area: 1 / 2; margin-left: 12px; }
}
@media (max-width: 700px) {
  .site-wrap { padding-inline: 18px; }
  .improvement-grid { grid-template-columns: 1fr; gap: 20px; }
}
@media (max-width: 460px) {
  .site-brand { gap: 6px; font-size: 15px; }
  .site-brand img { width: 24px; height: 24px; }
  .nav-links { gap: 10px; font-size: 12px; }
  .nav-links a { gap: 4px; }
  .nav-source { padding-left: 10px; }
  .site.is-play .sim-stage:not(.is-fullscreen) .device { --zoom: .94; }
}
@media (max-width: 425px) {
  .site.is-play .sim-stage:not(.is-fullscreen) .device { --zoom: .8; }
}

@media (max-width: 380px) {
  .site.is-play .sim-stage:not(.is-fullscreen) .device { --zoom: .68; }
}
@media (max-width: 345px) {
  .site.is-play .sim-stage:not(.is-fullscreen) .device { --zoom: .6; }
  html[lang="en"] .nav-links { gap: 7px; }
  html[lang="en"] .nav-source { padding-left: 7px; }
}
@media (max-width: 560px) {
  .hw-grid { grid-template-columns: 1fr; grid-auto-rows: auto; }
}
