:root {
  color-scheme: light;
  --paper: #ffffff;
  --surface: #f3f6f7;
  --ink: #202629;
  --muted: #657277;
  --line: #dce3e5;
  --accent: #146b64;
  --accent-hover: #10564f;
  --focus: #275fda;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
body.home-page, body.measure-page { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; text-decoration: none; }
button, .button { touch-action: manipulation; }
button:not(:disabled), a { cursor: pointer; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 5px; }
[hidden] { display: none !important; }
img { display: block; }
h1, h2, p { margin: 0; }

.site-header {
  min-height: 76px;
  margin: 0 40px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand, .back-link { display: inline-flex; align-items: center; gap: 12px; font-size: 15px; font-weight: 600; }
.brand img { width: 28px; height: 28px; }
.back-link { min-height: 44px; }
.back-link:hover { color: var(--accent); }
.header-label { color: var(--muted); font: 12px Consolas, monospace; }
.home-main { flex: 1; display: grid; place-items: center; padding: 64px 24px 96px; }
.entry { width: min(100%, 360px); display: flex; flex-direction: column; align-items: center; }
.entry-icon { width: 88px; height: 88px; margin-bottom: 24px; }
h1 { font-family: DengXian, "Microsoft YaHei", system-ui, sans-serif; font-size: 32px; line-height: 1.4; font-weight: 700; }
.entry h1 { margin-bottom: 36px; }
.button { min-height: 44px; padding: 11px 18px; border: 1px solid transparent; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.button-primary { background: var(--accent); color: var(--paper); }
.button-primary:hover { background: var(--accent-hover); }
.start-button { min-width: 208px; min-height: 50px; justify-content: space-between; }
.icon { flex: 0 0 auto; }
.icon-on-dark { filter: invert(1); }
.button-secondary { background: var(--paper); border-color: var(--line); color: var(--ink); }
.button-secondary:hover:not(:disabled), .icon-button:hover:not(:disabled) { background: var(--surface); }
.site-footer { margin: 0 40px; padding: 20px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.measure-main { width: min(100%, 1120px); padding: 28px 40px 36px; margin: 0 auto; flex: 1; }
.measurement-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.measurement-heading { min-width: 0; }
.measurement-heading h1 { font-size: 24px; }
.status { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 18px; line-height: 1.5; overflow-wrap: anywhere; }
.measurement-actions { display: flex; gap: 8px; flex-shrink: 0; }
.icon-button { width: 44px; height: 44px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; display: grid; place-items: center; position: relative; }
.icon-button::after { content: attr(data-tooltip); position: absolute; top: calc(100% + 8px); right: 0; white-space: nowrap; padding: 6px 9px; font-size: 12px; background: var(--ink); color: var(--paper); border-radius: 4px; pointer-events: none; opacity: 0; z-index: 2; }
.icon-button:hover:not(:disabled)::after, .icon-button:focus-visible::after { opacity: 1; }
.measurement-host { position: relative; min-height: 480px; height: max(480px, calc(100svh - 284px)); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; text-align: center; gap: 12px; }
.state-icon { margin-bottom: 12px; opacity: 0.45; }
.empty-state h2 { max-width: 100%; font-size: 18px; line-height: 1.6; overflow-wrap: anywhere; }
.empty-state p { max-width: 100%; color: var(--muted); font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.measurement-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--paper); }

@media (max-width: 600px) {
  .site-header { margin: 0 20px; min-height: 64px; }
  .site-footer { margin: 0 20px; padding: 18px 0; }
  .home-main { padding: 48px 24px 72px; }
  .measure-main { padding: 24px 16px; }
  .measurement-toolbar { flex-wrap: wrap; gap: 18px; margin-bottom: 20px; }
  .measurement-actions { width: 100%; justify-content: flex-end; }
  .measurement-host { min-height: 460px; height: max(460px, calc(100svh - 320px)); }
  .entry-icon { width: 72px; height: 72px; }
  .start-button { width: min(100%, 280px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
