/* pixelCamera · Web 原型 — 不引外部字体、不引 CSS 框架：离线也能开。 */

:root {
  --bg: #08080a;
  --panel: #141418;
  --panel-2: #1c1c22;
  --line: #2b2b33;
  --text: #ececf1;
  --muted: #93939f;
  --accent: #b6f36b;
  --accent-ink: #0b1400;
  --danger: #ff8f7a;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

#cam {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- 顶栏 ---------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  font-weight: 650;
  letter-spacing: .01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag {
  font: 10px/1 var(--mono);
  letter-spacing: .08em;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 4px;
  padding: 3px 5px;
}

.chip {
  font: 12px/1 var(--mono);
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 99px;
  padding: 6px 10px;
  white-space: nowrap;
}

.chip.live { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ---------- 画面 ---------- */
#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, #101014 0%, #08080a 70%);
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

#view.panning { cursor: grabbing; }
#view.pan-ready, #view.pan-mode { cursor: grab; }

.hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  max-width: min(92vw, 620px);
  text-align: center;
  font-size: 12.5px;
  color: #d9d9e2;
  background: rgba(12, 12, 15, .72);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 99px;
  padding: 7px 14px;
  backdrop-filter: blur(8px);
  pointer-events: none;
  transition: opacity .18s ease;
}

.hint.hidden { opacity: 0; }

/* 编辑态浮在画面上的查看工具：不占底栏，也不挡住主体 */
.viewtools {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;                 /* 窄屏时换行，别把画布顶出一截 */
  gap: 10px;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  background: rgba(18, 18, 23, .88);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 11px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  z-index: 6;
}

.viewtools[hidden] { display: none; }

.viewtools .tool {
  padding: 5px 10px;
  font-size: 12px;
  background: transparent;
  border-color: transparent;
}

.viewtools .tool:hover { background: #26262e; border-color: #3a3a45; }

.viewtools .tool.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}

.viewtools .check { font-size: 12px; white-space: nowrap; }

/* 底色色板：只改预览，不改数据，也不影响存图（ADR-0015） */
.vg-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.bgs { display: inline-flex; align-items: center; gap: 6px; }
.bgs.dim { opacity: .45; }          /* 编辑态里还开着「背景」时，色板暂时不起作用 */
.sw {
  width: 18px; height: 18px; padding: 0;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, .3);
  background: #555;
}
.sw:hover:not(:disabled) { background: #555; transform: none; }
.sw.on { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
.sw-checker {
  background-color: #1a1a1f;
  background-image:
    linear-gradient(45deg, #2e2e37 25%, transparent 25%),
    linear-gradient(-45deg, #2e2e37 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2e2e37 75%),
    linear-gradient(-45deg, transparent 75%, #2e2e37 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}
.sw-white { background: #fff; }
.sw-gray { background: #808080; }
.sw-blue { background: #2f6fd0; }
.sw-white:hover:not(:disabled) { background: #fff; }
.sw-gray:hover:not(:disabled) { background: #808080; }
.sw-blue:hover:not(:disabled) { background: #2f6fd0; }
.sw-checker:hover:not(:disabled) { background-color: #1a1a1f; }

.vsep {
  width: 1px;
  height: 18px;
  background: var(--line);
}

/* ---------- 遮罩层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 8, 10, .84);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.overlay[hidden] { display: none; }

.card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
  text-align: center;
}

.card.wide { width: min(920px, 100%); text-align: left; }

/* ---------- 隐私说明 ---------- */
.card.privacy { width: min(620px, 100%); max-height: 86vh; overflow: auto; }
.facts {
  margin: 14px 0 16px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}
.facts li::marker { color: var(--accent); }
.facts b { color: var(--text); font-weight: 650; }
/* 页内"为什么"链接：长得像链接，但不能触发按钮的方框样式 */
.linkbtn {
  background: none;
  border: 0;
  padding: 0 2px;
  font-size: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linkbtn:hover:not(:disabled) { background: none; border: 0; color: var(--accent); }
.overlay.fixed { position: fixed; z-index: 30; }

.card h2 { margin: 0 0 10px; font-size: 18px; letter-spacing: .01em; }
.card p { margin: 0 0 10px; }
.card code {
  font: 12px var(--mono);
  background: #000;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

.card-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }

.spinner {
  width: 26px; height: 26px;
  margin: 4px auto 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .14);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 底栏 ---------- */
.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.bar[hidden] { display: none; }

.knobs {
  display: flex;
  gap: 22px;
  flex: 1 1 460px;
  flex-wrap: wrap;
}

.knob {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1 1 190px;
  min-width: 170px;
}

.knob-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.knob-head b {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .03em;
}

.knob-head output { font: 12px var(--mono); color: var(--accent); }

.knob-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.knob.locked { opacity: .55; }
.knob.locked output { color: var(--muted); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  margin: 0;
  cursor: ew-resize;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: #303039;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0d0d10;
  box-shadow: 0 0 0 1px var(--accent);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: #303039;
}

input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0d0d10;
}

input[type="range"]:disabled { cursor: not-allowed; }
input[type="range"]:disabled::-webkit-slider-thumb { background: #5a5a66; box-shadow: none; }
input[type="range"]:disabled::-moz-range-thumb { background: #5a5a66; }

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

button, .as-button {
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
  user-select: none;
}

button:hover:not(:disabled), .as-button:hover { background: #26262e; border-color: #3a3a45; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }

button.ghost { background: transparent; }
button.primary, .as-button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}
button.primary:hover, .as-button.primary:hover { background: #c7ff85; border-color: #c7ff85; }

.small-btn { padding: 7px 10px; }
/* 开关类小按钮：只靠描边和字色区分，不抢快门的注意力 */
.small-btn[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(190, 255, 120, .08);
}

/* 快门：外圈 + 内点 */
.shutter {
  width: 58px; height: 58px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 2px solid #e9e9ef;
  display: grid;
  place-items: center;
}
.shutter span {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #e9e9ef;
  transition: transform .1s ease, background .12s ease;
}
.shutter:hover:not(:disabled) span { background: var(--accent); transform: scale(.94); }
.shutter:disabled { opacity: .3; }

/* 擦/画 二选一 */
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  width: fit-content;
}
.seg button {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 7px 16px;
  color: var(--muted);
}
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.seg button:hover:not(.on) { background: var(--panel-2); }

/* 平移开着时整组笔刷失效（ADR-0014）：标题保留原亮度好读提示，控件压暗表示不可点 */
.knob.brush-paused .seg,
.knob.brush-paused .knob-foot { opacity: .35; }
.knob.brush-paused .knob-head b { color: var(--muted); }

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.check input { accent-color: var(--accent); }

/* ---------- 结果 ---------- */
.shots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0 4px;
}

.shots figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shot-frame {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  display: grid;
  place-items: center;
  min-height: 120px;
}

.shot-frame img { display: block; max-width: 100%; max-height: 42vh; }

/* 透明背景用棋盘格露出来，否则"透明"看不出来 */
.checker {
  background-color: #1a1a1f;
  background-image:
    linear-gradient(45deg, #232329 25%, transparent 25%),
    linear-gradient(-45deg, #232329 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #232329 75%),
    linear-gradient(-45deg, transparent 75%, #232329 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.shots figcaption { font-size: 12px; color: var(--muted); }
/* 裁完是多少格——将来做拼豆图纸要的就是这个数，不是 PNG 的像素尺寸 */
.shot-info { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.shot-info b { font-size: 15px; font-weight: 650; letter-spacing: .01em; }
/* 主体图下也能换底色：图是透明的，靠背后的底色判断有没有漏格 */
.shot-bgs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.shots .as-button { text-align: center; }

@media (max-width: 720px) {
  .shots { grid-template-columns: 1fr; }
  .bar { align-items: stretch; }
  .actions { justify-content: flex-end; }
  .knobs { gap: 14px; }
  .knob { flex: 1 1 140px; min-width: 130px; }
}
