/* 暗房 · 视觉系统
   底色是暖调近黑，像冲印房里的安全灯；琥珀色只用在真正要动手的地方。
   宋体做作品名，等宽字体承载所有读数——参数面板本来就是数字界面。 */

:root {
  --ink: #17140f;
  --ink-2: #1d1913;
  --ink-3: #262017;
  --paper: #f2ede3;
  --ash: #9a8e7b;
  --ash-2: #6a5f50;
  --line: #332b21;
  --safelight: #e8862e;

  --font-display: "Songti SC", "STSong", SimSun, "Noto Serif CJK SC", "Times New Roman", serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(232, 134, 46, 0.32); }

:focus-visible { outline: 1px solid var(--safelight); outline-offset: 2px; }

button { font: inherit; color: inherit; }

/* ---------- 布局 ---------- */

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 286px 1fr;
  grid-template-rows: 52px 1fr;
}

/* ---------- 顶栏 ---------- */

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.safelight-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--safelight);
  animation: breathe 3.4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.5; box-shadow: 0 0 6px rgba(232, 134, 46, 0.45); }
  50% { opacity: 1; box-shadow: 0 0 13px rgba(232, 134, 46, 0.9); }
}

.brand-mark {
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 0.4em;
  margin-right: -0.4em;
  color: var(--paper);
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.34em;
  color: var(--ash-2);
  padding-top: 3px;
}

.now {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left: 1px solid var(--line);
  padding-left: 22px;
}

.now-name {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.14em;
  color: var(--paper);
}

.now-hint {
  font-size: 11px;
  color: var(--ash-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.seed {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
}

.seed-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ash-2);
}

.seed input {
  width: 66px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 3px 0;
}

.seed input:hover { border-bottom-color: var(--ash-2); }
.seed input:focus { border-bottom-color: var(--safelight); outline: none; }

/* ---------- 按钮 ---------- */

.btn {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--paper);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 8px 11px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn:hover { border-color: var(--ash-2); background: rgba(242, 237, 227, 0.04); }
.btn:active { transform: translateY(0.5px); }

.btn-accent { border-color: var(--safelight); color: var(--safelight); }
.btn-accent:hover { background: rgba(232, 134, 46, 0.12); border-color: var(--safelight); }

.btn-ghost { color: var(--ash); }
.btn-ghost:hover { color: var(--paper); }

.btn-icon { padding: 8px 9px; font-size: 11px; letter-spacing: 0; }

/* ---------- 侧面板 ---------- */

.panel {
  border-right: 1px solid var(--line);
  background: var(--ink);
  overflow-y: auto;
  padding: 18px 14px 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-thumb { background: var(--line); border: 3px solid var(--ink); }
.panel::-webkit-scrollbar-track { background: transparent; }

.label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 13px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.22em;
  color: var(--ash-2);
}

.label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* 算法列表 */

.modes { display: flex; flex-direction: column; gap: 1px; }

.mode {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 9px;
  align-items: start;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  padding: 9px 10px;
  cursor: pointer;
  color: var(--ash);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mode:hover { background: rgba(242, 237, 227, 0.035); color: var(--paper); }

.mode[aria-selected="true"] {
  border-left-color: var(--safelight);
  background: rgba(232, 134, 46, 0.07);
  color: var(--paper);
}

.mode-idx {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ash-2);
  padding-top: 3px;
}

.mode[aria-selected="true"] .mode-idx { color: var(--safelight); }

.mode-name { font-size: 13px; letter-spacing: 0.04em; }
.mode-desc { display: block; font-size: 11px; color: var(--ash-2); margin-top: 1px; }

/* 参数 */

.params { display: flex; flex-direction: column; gap: 13px; }

.param-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.param-label { color: var(--ash); }
.param-val { color: var(--paper); }

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

input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--line); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--safelight);
  border: 1px solid rgba(23, 20, 15, 0.9);
  transition: box-shadow 0.15s ease;
}
input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(232, 134, 46, 0.18); }
input[type="range"]::-moz-range-track { height: 2px; background: var(--line); }
input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--safelight);
  border: 1px solid rgba(23, 20, 15, 0.9);
}

.param-actions { display: flex; gap: 8px; margin-top: 15px; }
.param-actions .btn { flex: 1; text-align: center; }

/* 相纸 */

.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.swatch {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.swatch:hover { border-color: var(--ash-2); }
.swatch.on { border-color: var(--safelight); background: rgba(232, 134, 46, 0.08); }

.chips { display: flex; gap: 3px; height: 13px; }
.chips i { flex: 1; border-radius: 1px; }

.swatch-name { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; color: var(--ash-2); }
.swatch.on .swatch-name { color: var(--paper); }

/* 快捷键 */

.block-quiet { margin-top: auto; }

.keys { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }

.keys li { display: flex; align-items: center; gap: 9px; font-size: 11px; color: var(--ash-2); }

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--paper);
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 2px 5px;
  min-width: 22px;
  text-align: center;
}

/* ---------- 舞台 ---------- */

.stage { position: relative; overflow: hidden; background: var(--ink); }

/* 只针对主画布；胶片条里的缩略图也是 canvas，不能被这条规则带走 */
.stage > canvas {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.stage-foot {
  position: absolute;
  right: 16px;
  bottom: 13px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  pointer-events: none;
}

.fps { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; color: var(--ash-2); }
.foot-hint { font-size: 11px; color: var(--ash-2); }

/* 定影胶片条 */

.filmstrip {
  position: absolute;
  left: 16px;
  bottom: 13px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  max-width: calc(100% - 32px);
}

.film {
  border: 1px solid var(--line);
  background: var(--ink-2);
  padding: 3px;
  opacity: 1;
  transform: none;
  filter: none;
  transition: opacity 0.5s ease, transform 0.5s ease, filter 0.9s ease;
}

.film.developing {
  opacity: 0;
  transform: translateY(8px);
  filter: blur(11px) contrast(0.3) brightness(1.55);
}

.film canvas { display: block; cursor: zoom-in; }

/* ---------- 提示条 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 10px);
  background: var(--ink-3);
  border: 1px solid var(--line);
  color: var(--paper);
  padding: 9px 15px;
  font-size: 12px;
  letter-spacing: 0.03em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 20;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 状态 ---------- */

body.paused .safelight-dot { animation: none; opacity: 0.3; box-shadow: none; }

body.ui-hidden .topbar,
body.ui-hidden .panel { display: none; }
body.ui-hidden .app { grid-template-columns: 0 1fr; }

/* ---------- 自适应 ---------- */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .topbar { order: 0; flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
  .stage { order: 1; min-height: 40vh; }
  .panel { order: 2; border-right: 0; border-top: 1px solid var(--line); max-height: 45vh; }
  .now { display: none; }
  .top-actions { margin-left: 0; width: 100%; }
  .seed { margin-right: auto; }
  .foot-hint { display: none; }
  .block-quiet { display: none; }
}

@media (max-height: 600px) {
  .block-quiet { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .safelight-dot { animation: none; }
  .film, .toast { transition: none; }
  .film.developing { filter: none; }
}
