/* AI 创作页。顶栏、按钮、面板骨架与 usb-installer/styles.css 同源，刻意保持一致：
   用户在「创作」和「安装」之间来回切换时不该有割裂感。
   下面第 2 行必须与 usb-installer/styles.css 第 2 行逐字相同（test-builder-web.py 会校验）。 */
:root { color-scheme: dark; --bg: #101311; --panel: #181d19; --line: #303830; --text: #edf1e9; --muted: #a0aaa0; --accent: #c2f17c; --warning: #ebc27d; --error: #ffaaa1; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif; font-size: 14px; line-height: 1.7; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .38; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.page { max-width: 1120px; margin: 0 auto; padding: 0 40px; }
.mono, .eyebrow, .brand, .step-number, footer, code, .watch-topline, .watch-bottomline, .lint-list li { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; }
.topbar { height: 94px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 700; letter-spacing: 1px; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; background: var(--accent); color: var(--bg); border-radius: 7px; font-size: 22px; letter-spacing: -2px; padding-right: 3px; }
.brand-suffix { color: var(--muted); margin-left: -6px; }
.intro { padding: 56px 0 42px; position: relative; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--accent); font-size: 11px; letter-spacing: 1.7px; margin: 0 0 21px; }
.small-square { width: 6px; height: 6px; background: var(--accent); }
.preview-label { border: 1px solid var(--line); border-radius: 4px; padding: 1px 8px; color: var(--muted); font-family: 'PingFang SC', sans-serif; letter-spacing: 0; margin-left: 4px; }
h1 { font-size: clamp(37px, 5.2vw, 60px); line-height: 1.25; letter-spacing: -2px; margin: 0; font-weight: 600; }
h1 span { color: var(--accent); }
.intro-copy { position: absolute; left: 56%; bottom: 72px; font-size: 16px; line-height: 1.9; color: var(--muted); margin: 0; }
.assurances { display: flex; flex-wrap: wrap; gap: 12px 22px; margin-top: 26px; color: var(--muted); font-size: 12px; }
.assurances span::before { content: '✓'; color: var(--accent); margin-right: 6px; }
.workspace { display: grid; grid-template-columns: 1.4fr 1fr; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.installer { background: var(--panel); padding: 23px 30px 30px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.panel-heading h2 { font-size: 14px; font-weight: 500; margin: 0; }
.panel-heading .mono { color: var(--muted); font-size: 10px; letter-spacing: 1px; }
.step { display: flex; gap: 20px; padding: 25px 0; border-bottom: 1px solid var(--line); }
.step-number { color: #748172; font-size: 12px; padding-top: 3px; }
.step-body { min-width: 0; flex: 1; }
.step h3 { margin: 0; font-size: 16px; font-weight: 500; }
.step p { margin: 6px 0 14px; color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 18px; align-items: center; }
.button { border: 1px solid var(--line); border-radius: 7px; padding: 10px 18px; color: var(--text); background: transparent; font-weight: 500; transition: border-color .15s, background .15s; }
.button .go { margin-left: 24px; }
.secondary:hover:enabled { border-color: var(--muted); background: #222a22; }
.primary { width: 100%; display: flex; justify-content: space-between; align-items: center; background: var(--accent); color: #192016; border-color: var(--accent); padding: 13px 18px; }
.primary:hover:enabled { background: #d3ff92; }
.text-button { padding: 7px 0; background: none; border: none; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
[data-tone='success'] { color: var(--accent) !important; }
[data-tone='warning'] { color: var(--warning) !important; }
[data-tone='error'] { color: var(--error) !important; }
.last-step { border-bottom: none; padding-bottom: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- 表单 ---- */
.field { margin: 0 0 14px; }
.field > label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; background: #12160f; border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; font-size: 13px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); outline: none; }
.field input[readonly] { color: var(--muted); background: #0f130e; }
.field textarea { resize: vertical; min-height: 98px; line-height: 1.75; }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.step .field-hint { font-size: 10px; color: #7f8c7e; margin: 6px 0 0; }
.step .field-hint a { text-decoration: underline; text-underline-offset: 3px; }

/* 权限标签：选中态用强调色的低饱和底，和安装页的 current 状态同一套观感。 */
.perm-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 20px; padding: 5px 11px; font-size: 11px; color: var(--muted); cursor: pointer; }
.chip input { accent-color: var(--accent); margin: 0; width: 12px; height: 12px; }
.chip:has(input:checked) { border-color: #3c4c31; background: #242e1f; color: var(--accent); }

/* ---- 运行日志 ---- */
.run-log { list-style: none; margin: 14px 0 0; padding: 0; font-size: 11px; color: var(--muted); }
.run-log li { padding: 3px 0; overflow-wrap: anywhere; }

/* ---- 检查结果 ---- */
.lint-summary { display: flex; flex-wrap: wrap; gap: 7px; margin: 16px 0 4px; font-size: 11px; }
.lint-badge { border: 1px solid var(--line); border-radius: 4px; padding: 1px 9px; color: var(--muted); }
.lint-list { list-style: none; margin: 0 0 14px; padding: 0; }
.lint-list li { font-size: 11px; line-height: 1.85; padding: 7px 0 7px 20px; border-top: 1px solid var(--line); position: relative; overflow-wrap: anywhere; }
.lint-list li:last-child { border-bottom: 1px solid var(--line); }
.lint-list li::before { position: absolute; left: 0; top: 7px; }
.lint-list li[data-level='error']::before { content: '×'; color: var(--error); }
.lint-list li[data-level='warning']::before { content: '!'; color: var(--warning); }
.lint-list li[data-level='fix']::before { content: '✓'; color: var(--accent); }

/* ---- 代码编辑器 ---- */
/* 选择器要压过 .field textarea 的 min-height（0,1,1），否则只剩 98px 高。 */
.field .code-editor { width: 100%; min-height: 340px; background: #0d100c; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: 11px; line-height: 1.8; color: #d7e2d0; resize: vertical; tab-size: 2; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.field .code-editor:focus { border-color: var(--accent); outline: none; }

/* ---- 预览数据（模拟网络返回） ------------------------------------------ */
.mock-box { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.mock-box summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.mock-box summary::marker { color: var(--accent); }
.mock-editor { width: 100%; margin-top: 8px; min-height: 96px; background: #0d100c; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: 11px; line-height: 1.7; color: #d7e2d0; resize: vertical; tab-size: 2; }
.mock-editor:focus { border-color: var(--accent); outline: none; }

/* ---- 继续改 + 版本历史 ---- */
.refine { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }
/* 代码块现在紧跟"继续改"：它是要签名的产物，给一点分隔，别和版本列表粘在一起。 */
.refine + .field-hint { margin-top: 16px; }
.refine-row { display: flex; gap: 10px; align-items: stretch; }
.refine-row input { flex: 1; min-width: 0; background: #12160f; border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; font-size: 13px; }
.refine-row input:focus { border-color: var(--accent); outline: none; }
.refine-row input:disabled { opacity: .5; }
.refine-row .button { flex-shrink: 0; padding: 9px 16px; }
.version-list { list-style: none; margin: 12px 0 0; padding: 0; }
.version-list li { border-top: 1px solid var(--line); }
.version-list li:last-child { border-bottom: 1px solid var(--line); }
.version-item { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 0; font-size: 11px; color: var(--muted); font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; overflow-wrap: anywhere; }
.version-item::before { content: '○ '; }
.version-item:hover { color: var(--text); }
.version-item[data-current='true'] { color: var(--accent); }
.version-item[data-current='true']::before { content: '● '; }

/* ---- 预览面板 ---- */
.preview-panel { padding: 23px 26px 28px; background: #141814; border-left: 1px solid var(--line); }
.watch-stage { height: 360px; position: relative; display: flex; justify-content: center; align-items: center; overflow: hidden; }
.watch-strap { position: absolute; z-index: 0; width: 105px; height: 125px; background: repeating-linear-gradient(90deg, #232d22 0 5px, #1d261c 5px 7px); border: 1px solid #354333; }
.top-strap { top: -24px; border-radius: 20px 20px 0 0; }
.bottom-strap { bottom: -24px; border-radius: 0 0 20px 20px; }
.watch-body { position: relative; z-index: 1; width: min(248px, 100%); border: 3px solid #616a5b; border-radius: 54px; padding: 9px; background: #333b30; box-shadow: 0 20px 32px #0008, inset 0 0 0 2px #252c23; }
.watch-crown { position: absolute; right: -9px; top: 50%; transform: translateY(-50%); width: 5px; height: 30px; border-radius: 0 3px 3px 0; background: #727c69; }
/* 屏幕比例就是设备屏幕比例（410:502）。**高度由 aspect-ratio 推出来**，
   不再写死像素——写死的话改表盘宽度就得同时改高度，两处必然对不上。
   画布绝对定位铺满它，JS 只按 dpr 放大后备存储。 */
/* 面板是方的，但玻璃把四个角切掉了：半径约 38 像素（38/410、38/502），
   用百分比写，缩放时圆角与真实手表保持同一比例。 */
.watch-screen { position: relative; aspect-ratio: 410 / 502; border-radius: 9.27% / 7.57%; background: #090d09; overflow: hidden; }
.watch-placeholder { position: absolute; inset: 0; padding: 18px 15px; }
.watch-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.watch-topline { display: flex; justify-content: space-between; font-size: 6px; letter-spacing: .7px; color: #a5b59b; }
.app-glyph { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; height: 38px; width: 38px; margin: 28px 0 12px; }
.app-glyph span { background: var(--accent); border-radius: 3px; }
.app-glyph span:nth-child(2) { opacity: .65; }
.app-glyph span:nth-child(3) { opacity: .35; }
.app-glyph span:nth-child(4) { border-radius: 3px 3px 12px 3px; }
.watch-screen h3 { font-size: 18px; line-height: 1.5; margin: 0; font-weight: 500; max-height: 54px; overflow: hidden; overflow-wrap: anywhere; }
.watch-screen p { font-size: 8px; color: var(--muted); margin: 6px 0 0; max-height: 34px; overflow: hidden; }
.watch-bottomline { position: absolute; bottom: 23px; left: 25px; font-size: 6px; color: #708468; letter-spacing: 1px; }
.watch-bottomline span { font-size: 10px; margin-right: 5px; }
.preview-controls { display: flex; align-items: center; justify-content: center; gap: 20px; margin: 15px 0 0; }
.preview-controls .button { padding: 8px 16px; font-size: 12px; }
.preview-status { text-align: center; color: #82907e; font-size: 10px; margin: 7px 0 13px; min-height: 17px; overflow-wrap: anywhere; }
.preview-caption { text-align: center; color: #82907e; font-size: 10px; margin: 13px 0 24px; }
.package-meta { margin: 0; }
.package-meta div { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid #252e25; padding: 10px 0; font-size: 11px; }
.package-meta dt { color: var(--muted); flex-shrink: 0; }
.package-meta dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.signature-note { color: #82907e; font-size: 10px; line-height: 1.8; border-top: 1px solid #252e25; margin: 0; padding-top: 15px; }

.notice { background: #192018; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; padding: 16px 20px; color: var(--muted); margin-top: 20px; overflow-wrap: anywhere; }
.boundaries { padding: 38px 0 42px; }
.boundaries h2 { font-size: 14px; font-weight: 500; margin: 0 0 24px; }
.boundary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 38px; }
.boundary-grid .mono { font-size: 9px; color: #7a8b73; letter-spacing: 1.2px; }
.boundary-grid h3 { font-size: 12px; font-weight: 500; margin: 8px 0; }
.boundary-grid p { color: var(--muted); font-size: 11px; line-height: 1.9; margin: 0; }
footer { border-top: 1px solid var(--line); padding: 22px 0 35px; display: flex; justify-content: space-between; gap: 20px; font-size: 9px; color: #85917f; letter-spacing: .5px; }
.footer-divider { margin: 0 8px; color: var(--line); }
.footer-legal { margin: -20px 0 34px; color: #7d8a76; font-size: 10px; line-height: 1.9; letter-spacing: .2px; max-width: 96ch; }
.footer-legal b { color: #a9b79c; font-weight: 600; }
@media (max-width: 760px) {
  .page { padding: 0 22px; }
  .topbar { height: 74px; }
  .intro { padding: 38px 0 30px; }
  .intro-copy { position: static; margin-top: 20px; font-size: 14px; }
  .desktop-break { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .installer { padding: 20px; }
  .step { gap: 13px; }
  .preview-panel { border-left: 0; border-top: 1px solid var(--line); padding: 20px; }
  .watch-stage { height: 310px; }
  .watch-strap { height: 100px; }
  .field-row { grid-template-columns: 1fr; }
  .boundary-grid { grid-template-columns: 1fr; gap: 22px; }
  footer { flex-direction: column; gap: 10px; }
}
@media (max-width: 380px) {
  .page { padding: 0 15px; }
  .brand { font-size: 10px; gap: 7px; }
  .brand-suffix { display: none; }
  .assurances { gap: 12px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
