:root {
  --bg: #201d1d;
  --surface: #302c2c;
  --fg: #fdfcfc;
  --fg-2: #c8c6c4;
  --muted: #9a9898;
  --meta: #8a8a90;
  --border: #464343;
  --border-strong: #646262;
  --accent: #4d9fff;
  --accent-on: #ffffff;
  --accent-hover: #3a87d9;
  --accent-active: #2f6fb4;
  --success: #30d158;
  --warn: #ff9f0a;
  --danger: #ff453a;
  --font-cjk: "Fusion Pixel 12px Proportional Traditional Chinese", "PingFang TC", "Hiragino Sans TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  --font-display: "IBM Plex Mono", var(--font-cjk), ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --font-body: var(--font-mono);
  --font-mono: "IBM Plex Mono", var(--font-cjk), ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --font-terminal: "IBM Plex Mono", var(--font-cjk), ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-2xl: 22px;
  --text-3xl: 44px;
  --leading-body: 1.6;
  --leading-tight: 1.15;
  --tracking-display: -0.01em;
  --tracking-eyebrow: 0.12em;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --section-y-desktop: 80px;
  --section-y-tablet: 64px;
  --section-y-phone: 48px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 12px;
  --focus-ring: 0 0 0 2px var(--accent);
  --motion-fast: 120ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --container-max: 880px;
  --container-gutter-desktop: 24px;
  --container-gutter-tablet: 20px;
  --container-gutter-phone: 16px;
}

/* Simplified pages get the zh_hans pixel build so shared characters take their Simplified forms. */
html[lang="zh-CN"] {
  --font-cjk: "Fusion Pixel 12px Proportional Simplified Chinese", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* ── Scrollbar (macOS-style overlay look + stable gutter, no layout shift) ── */
html {
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(127, 127, 127, 0.45) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(127, 127, 127, 0.45);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(127, 127, 127, 0.65); background-clip: content-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: var(--leading-body);
  overflow-wrap: break-word;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; }
h1 { font-size: var(--text-3xl); font-weight: 700; line-height: var(--leading-tight); letter-spacing: var(--tracking-display); }
h2 { font-size: var(--text-2xl); font-weight: 700; line-height: 1.3; }
h3 { font-size: var(--text-lg); font-weight: 700; line-height: 1.4; }
p { margin: 0; }
a { color: var(--fg); font-weight: 500; text-decoration: underline 1px; text-underline-offset: 3px; }
a[href] { cursor: pointer; }
.skip-link {
  position: absolute;
  top: -48px;
  left: var(--container-gutter-desktop);
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--fg);
  text-decoration: none;
}
.skip-link:focus { top: var(--space-3); }
a:hover { color: var(--accent); }
a:focus-visible, .btn:focus-visible, .lang-btn:focus-visible, .lang-options a:focus-visible {
  outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm);
}
button { font: inherit; cursor: pointer; }

.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-gutter-desktop);
}
section { padding-block: var(--section-y-desktop); }
.stack > * + * { margin-top: var(--space-4); }
.stack-6 > * + * { margin-top: var(--space-6); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-eyebrow);
  color: var(--muted);
  margin-bottom: var(--space-4);
}
.lead { font-size: var(--text-base); color: var(--muted); }
.body-sm { font-size: var(--text-sm); color: var(--muted); line-height: 1.8; }

/* ── Nav ── */
.topnav {
  position: sticky; top: 0; z-index: 10;
  background: rgba(32, 29, 29, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topnav-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding-block: var(--space-3); flex-wrap: wrap; }
.topnav .logo { font-family: var(--font-mono); font-size: var(--text-base); font-weight: 700; text-decoration: none; }
.topnav nav { display: flex; align-items: center; gap: var(--space-5); }
.topnav nav a { font-size: var(--text-sm); font-weight: 500; color: var(--muted); text-decoration: none; padding-block: var(--space-2); }
.topnav nav a:hover { color: var(--accent); }
.lang-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
  background: none; border: none; color: var(--fg);
  transition: color var(--motion-fast) var(--ease-standard);
}
.lang-btn:hover { color: var(--accent); }
.material-symbols-rounded {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  vertical-align: middle;
  font-feature-settings: "liga";
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}

dialog {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  font-family: var(--font-mono);
  max-width: 340px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog h2 { margin-bottom: var(--space-3); font-size: var(--text-base); }
.lang-options { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.lang-options a {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  min-width: 300px; padding: var(--space-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  text-decoration: none;
}
.lang-options a:hover { border-color: var(--border-strong); }
.lang-option-name { text-decoration: underline 1px; text-underline-offset: 3px; }
.lang-current-tag { color: var(--muted); font-size: var(--text-sm); text-decoration: none; }
.dialog-actions { display: flex; justify-content: flex-end; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-1) 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 2;
  text-decoration: none;
  transition: background var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard);
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-on); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-on); }
.btn-primary:active { background: var(--accent-active); border-color: var(--accent-active); }
.btn-secondary:hover { border-color: var(--border-strong); }

/* ── Terminal ── */
.terminal {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-5);
  font-family: var(--font-terminal);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
}
.terminal .t-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--text-xs);
}
.terminal .t-line { display: block; }
.terminal .t-line + .t-line { margin-top: var(--space-2); }
.terminal .prompt { color: var(--accent); }
.terminal .cmd { color: var(--fg); font-weight: 500; }
.terminal .out { color: var(--muted); }
.terminal .ok { color: var(--success); }
.terminal .pend { color: var(--warn); }

/* ── Cards (flat, outline only) ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: border-color var(--motion-fast) var(--ease-standard);
}
.card:hover { border-color: var(--border-strong); }
a.card { display: block; text-decoration: none; }
a.card h3 { color: var(--fg); margin-top: var(--space-3); }
a.card p { margin-top: var(--space-2); }
a.card:hover h3 { color: var(--accent); }

/* ── Badges / kbd ── */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--muted);
}
.badge .badge-dot-inner { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.badge-accent { color: var(--accent); }
.badge-accent .badge-dot-inner { background: var(--accent); }
.badge-warn { color: var(--warn); }
.badge-warn .badge-dot-inner { background: var(--warn); }
.status-word { color: var(--warn); }
.status-word.status-testing { color: var(--accent); }
.status-word.status-released { color: var(--success); }
.badge-ok { color: var(--success); }
.badge-ok .badge-dot-inner { background: var(--success); }
kbd {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
}

/* ── Form fields ── */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { font-size: var(--text-sm); font-weight: 600; color: var(--fg); }
.field input, .field textarea {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.field textarea { min-height: 120px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: var(--meta); }
.field input:focus-visible, .field textarea:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.field-help { font-size: var(--text-xs); color: var(--muted); line-height: 1.8; }
.field-error { color: var(--danger); }

/* ── Definition rows ── */
.defs { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-4); margin: 0; }
.defs dt { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); letter-spacing: var(--tracking-eyebrow); padding-top: 4px; }
.defs dd { margin: 0; font-size: var(--text-base); color: var(--fg-2); }

/* ── Placeholder image scaffold (labeled, flat) ── */
.ph-img {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  aspect-ratio: 16 / 10;
  display: grid; place-items: center;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-align: center;
  padding: var(--space-4);
}
/* ── Screenshots: horizontal carousel (App Store style) ── */
.shots-wrap { position: relative; }
.shots {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: var(--space-3);
}
.shots img.shot {
  flex: 0 0 auto;
  width: 240px;
  height: auto;
  scroll-snap-align: start;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
}
.shot-btn { padding: 0; border: none; background: none; }
.shot-btn:hover .shot { border-color: var(--accent); }
.shot-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-lg); }
/* The buttons float over the carousel at its two ends, level with the shots. */
.shots-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  opacity: 0.7;
}
.shots-prev { left: var(--space-2); }
.shots-next { right: var(--space-2); }
.shots-nav:hover { border-color: var(--accent); color: var(--accent); }
.shots-nav:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* The button on the side that has nothing left to move to is not shown at all. */
.shots-nav[hidden] { display: none; }
.lightbox[open] {
  position: fixed;
  inset: 0;
  margin: auto;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  background: transparent;
  border: none;
  padding: 0;
  display: grid;
  place-items: center;
}
.lightbox-img {
  display: block;
  max-height: 80vh;
  max-width: min(92vw, calc(100vw - 128px));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
}
.lightbox-stage { display: flex; align-items: center; gap: var(--space-3); }
.lightbox-close,
.lightbox-nav {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
}
.lightbox-close { position: absolute; top: var(--space-4); right: var(--space-4); }
.lightbox-close:hover, .lightbox-nav:hover { border-color: var(--accent); color: var(--accent); }
.lightbox-close:focus-visible, .lightbox-nav:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.shots:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── Feature list: pure text, no cards ── */
.feature-list { display: flex; flex-direction: column; gap: var(--space-5); }
.feature h3 { margin-bottom: var(--space-1); }
.feature p { color: var(--muted); font-size: var(--text-base); }

/* ── Footer ── */
.pagefoot {
  border-top: 1px solid var(--border);
  padding-block: var(--section-y-tablet);
  color: var(--muted);
  font-size: var(--text-sm);
}
.foot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); margin-bottom: var(--space-8); }
.foot-grid h2 { font-size: var(--text-base); font-weight: 700; color: var(--fg); margin-bottom: var(--space-3); }
.foot-grid a { color: var(--muted); font-weight: 400; text-decoration: none; display: block; }
.foot-grid a + a, .foot-grid p + p { margin-top: var(--space-2); }
.foot-grid a:hover { color: var(--accent); }
.foot-bar { display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: var(--space-4); }

.hero { padding-block: var(--section-y-desktop) var(--section-y-tablet); }
.hero h1 { margin-bottom: var(--space-4); }
.hero .lead { margin-bottom: var(--space-6); }
.hero-cta { display: inline-flex; gap: var(--space-3); flex-wrap: wrap; }

.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-4); }

/* ── App detail page ── */
.breadcrumb { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); margin-bottom: var(--space-4); }
.breadcrumb a { color: var(--muted); text-decoration: underline 1px; text-underline-offset: 3px; }
.breadcrumb a:hover { color: var(--accent); }
.prose p + p { margin-top: var(--space-4); }
.prose h2, .prose h3 { margin-top: var(--space-6); margin-bottom: var(--space-2); }
.prose ul { margin: var(--space-2) 0 0; padding-left: var(--space-6); color: var(--muted); }
.prose li + li { margin-top: var(--space-2); }
.prose code { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--fg-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px 6px; }

@media (max-width: 920px) {
  .container { padding-inline: var(--container-gutter-tablet); }
  section { padding-block: var(--section-y-tablet); }
  .foot-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .container { padding-inline: var(--container-gutter-phone); }
  section { padding-block: var(--section-y-phone); }
  h1 { font-size: 32px; }
  .terminal { padding: var(--space-4); }
  .topnav nav { gap: var(--space-3); }
  .defs { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
