/* 看片灯箱：冷灰蓝的灯箱底 + 黑色胶片边条 + 红色油性笔做强调。
   结果卡片底部的边条印着这次生成的真实信息（编号 / 类型 / 模型 / 耗时 / 尺寸），同时就是「AI 生成」标识。 */

:root {
  --bg: #eceff3;
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --ink: #14181e;
  --muted: #667180;
  --line: #d9dee5;
  --marker: #d63a2a;
  --marker-ink: #ffffff;
  --marker-soft: #fbe7e3;
  --film: #17191d;
  --edge: #edb246;
  --hole: #eceff3;
  --radius: 10px;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1115;
    --surface: #161a20;
    --surface-2: #1c2129;
    --ink: #e6e9ed;
    --muted: #8e97a4;
    --line: #272d36;
    --marker: #f05a44;
    --marker-soft: #3a1f1b;
    --film: #08090b;
    --edge: #e9ae45;
    --hole: #39404a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 20px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--marker); min-height: 1.4em; font-size: 13.5px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--marker); outline-offset: 2px; }

.primary {
  border: 0;
  border-radius: 8px;
  padding: 11px 18px;
  background: var(--marker);
  color: var(--marker-ink);
  font-weight: 600;
}
.primary:disabled { opacity: 0.55; cursor: progress; }
.ghost {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  background: var(--surface);
  color: var(--muted);
}
.ghost:hover { color: var(--ink); }
.link { border: 0; padding: 0; background: none; color: var(--marker); text-decoration: underline; text-underline-offset: 3px; }

input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
textarea { resize: vertical; line-height: 1.55; }
input[type="range"] { width: 100%; accent-color: var(--marker); }
input[type="file"] { font-size: 13px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; font-size: 13px; font-weight: 500; color: var(--muted); }
.field legend { padding: 0; margin-bottom: 6px; }
.label-row { display: flex; justify-content: space-between; }
.counter, .timer { font-family: var(--mono); font-size: 12px; font-weight: 400; }
.field-row { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- 品牌 ---------- */
.wordmark { display: flex; align-items: center; gap: 9px; font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
.mark { width: 12px; height: 12px; border-radius: 3px; background: var(--marker); }

/* ---------- 登录 ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.auth-card h1 { font-size: 26px; margin-top: 10px; }

/* ---------- 整体布局：左侧导航 + 舞台 ---------- */
.app { display: grid; grid-template-columns: 196px 1fr; min-height: 100%; }
.mobile-top { display: none; }

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.rail > .wordmark { padding: 0 8px; }
.tabs { display: flex; flex-direction: column; gap: 2px; }
.tabs button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 15px;
  text-align: left;
}
.tabs button:hover { color: var(--ink); background: var(--surface-2); }
.tabs button.active { color: var(--ink); background: var(--surface-2); font-weight: 600; }
.tabs button.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--marker); }
.tabs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 0 8px; }
.rail-foot #user-email { word-break: break-all; }
.rail-foot .link { font-size: 13px; color: var(--muted); }
.rail-foot p { margin-top: 10px; }

.stage { min-width: 0; padding: 28px clamp(16px, 3vw, 40px); }
.panel-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.panel-head select { width: auto; min-width: 240px; }

/* ---------- 创作页：左操作台 + 右灯箱 ---------- */
.studio { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: 28px; align-items: start; }
.console {
  position: sticky;
  top: 28px;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.console-body { display: flex; flex-direction: column; gap: 18px; }

.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -8px; }
.examples button {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 3px 9px;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  text-align: left;
}
.examples button:hover { color: var(--ink); border-color: var(--muted); }

.drop {
  padding: 12px 14px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--muted);
}
.drop.over { border-color: var(--marker); background: var(--marker-soft); }
.drop-hint strong { color: var(--ink); font-weight: 600; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs:not(:empty) { margin-top: 10px; }
.thumb { position: relative; }
.thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.thumb button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  font-size: 12px;
  line-height: 20px;
  padding: 0;
}

/* 单选：模型卡片和小圆角选项 */
.model-cards { display: flex; flex-direction: column; gap: 6px; }
/* 选项多时排两列，预计耗时挪到第三行 */
.model-cards.compact { display: grid; grid-template-columns: 1fr 1fr; }
.model-cards.compact .model-card { grid-template-columns: 1fr; }
.model-cards.compact .eta { grid-column: 1; grid-row: auto; align-self: start; }
.model-cards label, .chips label { position: relative; }
.model-cards input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.model-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.model-card .name { color: var(--ink); font-size: 14px; font-weight: 600; }
.model-card .meta { grid-column: 1; font-size: 12px; font-weight: 400; color: var(--muted); }
.model-card .eta { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-family: var(--mono); font-size: 11.5px; font-weight: 400; color: var(--muted); }
.model-cards input:checked + .model-card { border-color: var(--marker); box-shadow: inset 0 0 0 1px var(--marker); }
.model-cards input:focus-visible + .model-card, .chips input:focus-visible + span { outline: 2px solid var(--marker); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 400;
  cursor: pointer;
}
.chips input:checked + span { border-color: var(--marker); background: var(--marker-soft); color: var(--ink); }

.note { font-size: 12.5px; color: var(--marker); }

.segmented { display: flex; padding: 3px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.segmented button { flex: 1; border: 0; border-radius: 7px; padding: 6px 10px; background: none; color: var(--muted); font-size: 14px; }
.segmented button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

.recorder { display: flex; align-items: center; gap: 14px; }
.record { display: inline-flex; align-items: center; gap: 9px; padding: 9px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 600; }
.record .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--marker); }
.record.on { border-color: var(--marker); color: var(--marker); }
.record.on .dot { animation: blink 1s steps(2, start) infinite; }

/* ---------- 灯箱和胶片帧 ---------- */
.lightbox { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.lightbox:empty::before, .contact-sheet:empty::before {
  content: attr(data-empty);
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 24px;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.frame { margin: 0; overflow: hidden; border-radius: var(--radius); background: var(--film); box-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px -12px rgb(20 24 30 / 0.25); }
.frame-media { display: grid; place-items: center; background: #0b0c0f; }
.frame-media a { display: block; width: 100%; }
.frame-media img, .frame-media video { display: block; width: 100%; height: auto; max-height: 72vh; object-fit: contain; }
.frame-media audio { width: calc(100% - 32px); margin: 22px 16px 6px; }
.frame-text { width: 100%; padding: 18px 20px; background: var(--surface); color: var(--ink); white-space: pre-wrap; font-size: 15px; }
.frame-caption { width: 100%; padding: 4px 20px 18px; color: #9aa3ae; font-size: 13px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.frame-media:has(audio) { place-items: stretch; }
.frame-error { padding: 28px 22px; color: #ff9b8c; font-size: 14px; }

.frame.processing .frame-media {
  min-height: 240px;
  background:
    linear-gradient(105deg, transparent 35%, rgb(237 178 70 / 0.14) 50%, transparent 65%) 0 0 / 220% 100%,
    #0b0c0f;
  animation: develop 2.4s ease-in-out infinite;
}
.developing { max-width: 34em; padding: 24px; color: #8b939d; font-size: 14px; text-align: center; }

.edge {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  padding: 15px 14px 11px;
  color: var(--edge);
  font: 11px/1.3 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
/* 齿孔：灯箱的光从孔里透出来 */
.edge::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 6px;
  right: 6px;
  height: 5px;
  background: radial-gradient(circle, var(--hole) 0 1.7px, transparent 2.1px) 0 0 / 14px 5px repeat-x;
  opacity: 0.85;
}
.edge .ai { padding: 1px 5px; border: 1px solid currentColor; border-radius: 3px; }
.edge a { margin-left: auto; color: inherit; text-decoration: none; border-bottom: 1px solid currentColor; }
.frame.failed .edge { color: #ff8a78; }
.frame.processing .live::before { content: "● "; animation: blink 1s steps(2, start) infinite; }

.contact-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
/* 印样：图片和视频统一画框比例，留黑边不裁切 */
.contact-sheet .frame-media:has(img), .contact-sheet .frame-media:has(video) { position: relative; display: block; aspect-ratio: 16 / 10; }
.contact-sheet .frame-media > a, .contact-sheet .frame-media > video { position: absolute; inset: 0; }
.contact-sheet .frame-media img, .contact-sheet .frame-media video { width: 100%; height: 100%; max-height: none; }
.contact-sheet .edge { letter-spacing: 0.05em; }

/* ---------- 对话 ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 56px); max-width: 900px; margin: 0 auto; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; padding: 4px 2px 20px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); }
.chat-empty .examples { justify-content: center; margin-top: 14px; }
.msg-user { align-self: flex-end; max-width: 78%; padding: 10px 14px; border-radius: 12px 12px 4px 12px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.msg-ai { max-width: 100%; word-break: break-word; }
.msg-ai .md > :first-child { margin-top: 0; }
.md p, .md ul, .md ol, .md pre, .md h4 { margin: 0 0 10px; }
.md ul, .md ol { padding-left: 1.4em; }
.md h4 { font-size: 15.5px; }
.md code { font-family: var(--mono); font-size: 0.9em; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); }
.md pre { padding: 12px 14px; overflow-x: auto; border-radius: 8px; background: var(--film); color: #e6e9ed; }
.md pre code { padding: 0; border: 0; background: none; color: inherit; }
.msg-meta { display: flex; align-items: center; gap: 12px; margin-top: 6px; font: 11px/1.4 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.msg-meta button { border: 0; padding: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.thinking { color: #b5822a; font: 12px var(--mono); }
.msg-ai.failed .md { color: var(--marker); }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.composer textarea { flex: 1; border: 0; padding: 6px 4px; resize: none; max-height: 220px; background: none; }
.composer textarea:focus-visible { outline: none; }
.composer:focus-within { border-color: var(--muted); }

@keyframes develop { from { background-position: 120% 0, 0 0; } to { background-position: -120% 0, 0 0; } }
@keyframes blink { to { visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; }
}

/* ---------- 手机：导航移到底部 ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .mobile-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 0; }
  .mobile-top .link { color: var(--muted); font-size: 13px; }
  .rail {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 10;
    height: auto;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .rail > .wordmark, .rail-foot { display: none; }
  .tabs { flex-direction: row; justify-content: space-around; }
  .tabs button { flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11.5px; text-align: center; }
  .tabs button.active { background: none; }
  .tabs button.active::before { left: 30%; right: 30%; top: -4px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .stage { padding: 16px 16px 96px; }
  .studio { grid-template-columns: 1fr; gap: 20px; }
  .console { position: static; max-height: none; overflow: visible; padding: 18px; }
  .chat { height: calc(100vh - 150px); }
  .panel-head select { min-width: 0; flex: 1; }
  .msg-user { max-width: 90%; }
}
