/* 启动页样式。放在独立文件里而不是 index.html 内联：iOS Safari 恢复标签页时可能沿用旧的 index.html，
   单独的样式表会按 must-revalidate 重新校验，样式与脚本保持同一版本。 */
/* 底色与 OMC 正文画布（--page-canvas）一致：iPhone 手势条留出的安全区由这里绘制，颜色不同会在底部露出一条色带。 */
:root {
  color-scheme: light dark;
  --bg: #fbfbfb;
  --fg: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --accent: #2563eb;
  --bar: #f1f1f2;
  --warn-bg: #fde68a;
  --warn-fg: #78350f;
  --error: #b91c1c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --fg: #e2e8f0;
    --muted: #94a3b8;
    --line: #1e293b;
    --accent: #3b82f6;
    --bar: #1c1c1f;
    --warn-bg: #92400e;
    --warn-fg: #fef3c7;
    --error: #f87171;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body {
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}
#app { min-height: 100%; }
.page {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(24px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
}
h1 { font-size: 22px; line-height: 1.35; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 20px 0 8px; }
p { margin: 0 0 12px; }
ul { margin: 0; padding-left: 20px; }
li { margin-bottom: 6px; }
details { margin-top: 12px; border-top: 1px solid var(--line); }
summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--muted); list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "▸"; margin-right: 6px; }
details[open] summary::before { content: "▾"; }
details ul { color: var(--muted); font-size: 15px; }
.action { margin-top: auto; padding-top: 24px; text-align: center; }
button { font: inherit; }
button.primary {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}
button:disabled { opacity: 0.6; }
.label { color: var(--muted); margin-bottom: 4px; }
.code { font-size: 44px; font-weight: 700; letter-spacing: 0.2em; font-variant-numeric: tabular-nums; margin: 0 0 8px; }
.hint { font-weight: 600; }
.sub { color: var(--muted); font-size: 15px; }
.error { color: var(--error); }
.message { justify-content: center; }
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
/* OMC 页面声明能自己留安全区时（data-omc-framed）不再重复留。 */
.app[data-insets] { padding: 0; }
/* 量安全区用：OMC 页面在 iframe 里拿不到可靠的 env()，由启动页量好传进去（main.ts 的 syncInsets）。 */
.insets {
  position: fixed;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
/* 支持接口的 OMC 自己画连接状态与提示（main.ts 的 appDraws），启动页的状态栏、提示条与诊断面板都不显示。 */
.app[data-app-status] :is(.status, .notice, .diag-panel) { display: none; }
/* 以下状态栏、提示条与诊断面板只给 OMC 页面出来之前与不支持接口的旧版 OMC 用，冻结，不再加功能。 */
.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: calc(22px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  background: var(--bar);
  color: var(--muted);
  font-size: 12px;
  line-height: 22px;
}
/* 连接正常时不占一行，文字留给读屏；断线和连接中才显示整条（设计 3.2）。 */
.status[data-state="connected"] { min-height: env(safe-area-inset-top); }
/* 连接正常且没有提示条时整条收起，刘海区交给 OMC 页面画，底色随它的顶栏。 */
.status[data-state="connected"][data-bleed] { min-height: 0; padding-top: 0; }
.status[data-state="connected"] .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.status[data-state="waiting"] { background: var(--warn-bg); color: var(--warn-fg); min-height: calc(44px + env(safe-area-inset-top)); }
/* 等待重连时说明文字占满剩余宽度、可以折行，按钮不折行。 */
.status[data-state="waiting"] { justify-content: flex-start; }
.status[data-state="waiting"] .label { flex: 1; min-width: 0; }
.status .retry {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  white-space: nowrap;
  flex: none;
}
.status .retry[hidden] { display: none; }
.notice { display: flex; align-items: center; gap: 8px; padding: 4px 12px; background: var(--bar); color: var(--fg); font-size: 14px; line-height: 1.4; }
.notice span { flex: 1; }
.notice button { min-height: 44px; padding: 0 12px; border: 0; background: transparent; color: var(--accent); font-weight: 600; }
.actions { margin-top: 16px; }
.diag { text-align: left; }
.diag pre { margin: 8px 0; padding: 8px; border-radius: 8px; background: var(--bar); color: var(--fg); font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; user-select: text; -webkit-user-select: text; }
.diag .copy { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--accent); font-weight: 600; }
.diag-panel { max-height: 50vh; overflow-y: auto; padding: 4px 12px 8px; background: var(--bar); }
.diag-panel[hidden] { display: none; }
.stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }
/* OMC 页面加载完才显示（main.ts），加载中透明，露出下面的提示。 */
.stage iframe[data-loading] { opacity: 0; }
