/* input: index.html 结构
   output: 页面样式；颜色、圆角、间距只在 :root 定义
   pos: 唯一样式表 */

:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --ink: #141414;
  --muted: #5f6b70;
  --line: #e1e6e9;
  --cyan: #26d8ee;
  --cyan-ink: #007e8c;
  --pink: #ff4fa3;
  --yellow: #ffe334;
  --radius: 8px;
  --gap: 16px;
  --sans: -apple-system, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.top { max-width: 1120px; margin: 0 auto; padding: 28px 16px 8px; }
.top h1 { margin: 0; font: 800 30px/1.2 var(--serif); letter-spacing: 0.02em; }
.top p { margin: 6px 0 0; color: var(--muted); }

.layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 16px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.stage {
  position: sticky;
  top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1;
  padding: 10px 0;
  border: 0;
  background: none;
  font: 600 14px var(--sans);
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--cyan); }

.screen { position: relative; aspect-ratio: 4 / 3.4; background: #eef3f5; }
.screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.fold { cursor: grab; touch-action: none; }
.fold:active { cursor: grabbing; }
.page { object-fit: contain; padding: 12px; }

.angle { display: flex; align-items: center; gap: 12px; padding: 10px 16px 14px; color: var(--muted); font-size: 13px; }
.angle input { flex: 1; }

.panel { display: grid; gap: 14px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend, .field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; padding: 0; }
.row { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: end; }

.field input:not([type]), .field input[type="text"], .field textarea, .field input[name] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
  font: 16px/1.5 var(--sans);
  color: var(--ink);
}
.field input[type="range"], .angle input { accent-color: var(--cyan-ink); padding: 0; border: 0; background: none; }
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--cyan); outline-offset: -1px; border-color: transparent; }

.ai { display: grid; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.status { margin: 0; min-height: 1.5em; font-size: 13px; color: var(--muted); }
.status.error { color: #c42525; }
#refThumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.slot { display: grid; gap: 6px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.slot .thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 4px; background: #eef3f5 center / cover no-repeat; overflow: hidden; }
.slot .thumb.busy::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,0.7) 50%, transparent 70%) 0 0 / 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.slot b { font-size: 13px; }
.slot .acts { display: flex; gap: 6px; }
.slot .acts .btn { flex: 1; padding: 5px 0; font-size: 13px; }

.seg { display: inline-flex; max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; padding: 8px 14px; white-space: nowrap; font-weight: 600; font-size: 14px; cursor: pointer; }
.seg label + label span { border-left: 1px solid var(--line); }
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--cyan); }

.photo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.photo small { color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  padding: 8px 14px;
  font: 600 14px var(--sans);
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
}
.btn.primary { width: 100%; padding: 14px; font-size: 16px; background: var(--ink); color: #fff; }
.btn.primary:disabled { opacity: 0.6; cursor: progress; }

.actions { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: grid; gap: 8px; }
@media (min-width: 861px) {
  .actions { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); column-gap: 24px; }
  .actions > * { grid-column: 2; }
}
.open { color: var(--cyan-ink); font-weight: 600; text-align: center; }
.hint { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }

.foot {
  max-width: 1120px;
  margin: 24px auto 0;
  padding: 16px 16px 40px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}
.sign { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 600; }
.sign svg { width: 24px; height: 10px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; fill: none; }

@media (max-width: 860px) {
  .top { padding-top: 20px; }
  .top h1 { font-size: 26px; }
  .layout { grid-template-columns: 1fr; gap: 16px; }
  .stage { position: static; }
  .actions {
    position: sticky;
    bottom: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
  }
}
