/* ============ AI 故事放映机 · 影院暗色主题 ============ */
:root {
  --bg: #14100d;
  --bg2: #1d1712;
  --card: #241c15;
  --line: #3a2e22;
  --amber: #e8b04b;
  --amber-dim: #a97e34;
  --cream: #f5e6c8;
  --text: #e9ddc8;
  --muted: #9b8a70;
  --accent: #7ec8b5;
  --danger: #e07a5f;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(232,176,75,.10), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
textarea, input, select { font-family: inherit; }
.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(232,176,75,.06), transparent);
  position: sticky; top: 0; z-index: 50; backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.brand-reel { font-size: 22px; color: var(--amber); letter-spacing: -2px; }
.brand h1 { font-size: 18px; letter-spacing: 2px; color: var(--cream); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.badge {
  font-size: 12px; color: var(--muted); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 20px; background: var(--bg2);
}
.icon-btn {
  background: none; border: 1px solid var(--line); border-radius: 10px;
  width: 36px; height: 36px; font-size: 16px; color: var(--text);
  transition: .2s;
}
.icon-btn:hover { border-color: var(--amber-dim); transform: rotate(30deg); }

/* ---------- 视图切换 ---------- */
.view { display: none; max-width: 1080px; margin: 0 auto; padding: 26px 20px 60px; }
.view.active { display: block; animation: fadein .35s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* ---------- 首页 ---------- */
.hero { text-align: center; margin: 18px 0 26px; }
.hero-sub { color: var(--muted); font-size: 15px; line-height: 1.9; }
.hero-sub b { color: var(--amber); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.input-card { max-width: 640px; margin: 0 auto; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin: 16px 0 8px; }
.field-label:first-child { margin-top: 0; }
.field-label b { color: var(--amber); font-size: 15px; }

#storyInput {
  width: 100%; resize: none; background: var(--bg2); color: var(--cream);
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; font-size: 17px;
  outline: none; transition: .2s; line-height: 1.6;
}
#storyInput:focus { border-color: var(--amber-dim); box-shadow: 0 0 0 3px rgba(232,176,75,.12); }
#storyInput::placeholder { color: #6b5d49; }

.style-choices { display: flex; gap: 10px; flex-wrap: wrap; }
.style-btn {
  flex: 1; min-width: 130px; padding: 10px 8px; border-radius: 10px; font-size: 13px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--muted); transition: .2s;
}
.style-btn.active { border-color: var(--amber); color: var(--cream); background: rgba(232,176,75,.12); box-shadow: inset 0 0 12px rgba(232,176,75,.08); }

input[type=range] { width: 100%; accent-color: var(--amber); }

.primary-btn {
  width: 100%; margin-top: 20px; padding: 14px; font-size: 16px; font-weight: 600;
  border: none; border-radius: 12px; color: #241a08; letter-spacing: 2px;
  background: linear-gradient(135deg, #f2c14e, #d99a2b);
  box-shadow: 0 6px 20px rgba(232,176,75,.3); transition: .2s;
}
.primary-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(232,176,75,.4); }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; }
.primary-btn.small { width: auto; padding: 9px 26px; margin-top: 0; font-size: 14px; }

/* 生成进度 */
.gen-progress { margin-top: 20px; text-align: center; }
.reel-spin { font-size: 30px; animation: spin 2.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.gen-status { color: var(--muted); font-size: 13px; margin: 8px 0 12px; min-height: 18px; }
.gen-bar { height: 6px; border-radius: 3px; background: var(--bg2); overflow: hidden; border: 1px solid var(--line); }
.gen-bar > div { height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--amber-dim), var(--amber)); transition: width .5s ease; }
.gen-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.gen-chip {
  font-size: 12px; padding: 4px 10px; border-radius: 14px; border: 1px solid var(--line);
  color: var(--muted); background: var(--bg2); transition: .3s;
}
.gen-chip.done { color: var(--accent); border-color: rgba(126,200,181,.4); }
.gen-chip.writing { color: var(--amber); border-color: var(--amber-dim); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* 片库 */
.library { max-width: 860px; margin: 44px auto 0; }
.lib-title { font-size: 15px; color: var(--muted); font-weight: 500; letter-spacing: 2px; margin-bottom: 14px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.lib-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  cursor: pointer; transition: .2s; position: relative;
}
.lib-card:hover { transform: translateY(-3px); border-color: var(--amber-dim); }
.lib-card .thumb { aspect-ratio: 8/5; display: block; }
.lib-card .thumb svg { width: 100%; height: 100%; display: block; }
.lib-card .meta { padding: 10px 12px; }
.lib-card .meta h4 { font-size: 14px; color: var(--cream); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-card .meta p { font-size: 11px; color: var(--muted); margin-top: 3px; }
.lib-del {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.55); color: #ddd; font-size: 12px; display: none;
}
.lib-card:hover .lib-del { display: block; }
.lib-empty { color: #6b5d49; font-size: 13px; text-align: center; padding: 24px; border: 1px dashed var(--line); border-radius: 12px; }

/* ---------- 放映厅 ---------- */
.screen-wrap { display: flex; justify-content: center; }
.screen {
  position: relative; width: min(920px, 100%); aspect-ratio: 16/9.4;
  background: #f8f1e2; border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 0 10px #241c15, 0 0 0 12px #3a2e22, 0 30px 80px rgba(0,0,0,.6),
              0 0 120px rgba(255,235,190,.08);
}
.screen-inner { position: absolute; inset: 0; display: flex; }
.grain {
  position: absolute; inset: 0; pointer-events: none; opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}
.vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 90px rgba(120,90,40,.25); }

/* 屏幕内容：封面 / 章节页 */
.cover {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #4a3826; text-align: center; padding: 30px; gap: 10px;
}
.cover .kb { font-size: 13px; letter-spacing: 6px; color: #a98d5f; }
.cover h2 { font-size: clamp(24px, 4.5vw, 40px); letter-spacing: 4px; font-weight: 700; }
.cover p { font-size: 14px; color: #8a7355; max-width: 70%; line-height: 1.8; }
.cover .begin { margin-top: 14px; font-size: 13px; color: #b08b3e; animation: pulse 1.8s infinite; }

.chapter-page { flex: 1; display: flex; min-height: 0; }
.chapter-art { width: 52%; position: relative; }
.chapter-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.chapter-text {
  flex: 1; padding: 26px 30px 20px 26px; overflow-y: auto; color: #4a3a28;
  border-left: 2px dashed rgba(150,120,70,.25);
}
.chapter-text::-webkit-scrollbar { width: 6px; }
.chapter-text::-webkit-scrollbar-thumb { background: rgba(150,120,70,.3); border-radius: 3px; }
.chapter-kicker { font-size: 12px; letter-spacing: 4px; color: #b08b3e; margin-bottom: 6px; }
.chapter-text h3 { font-size: 20px; color: #5d4426; margin-bottom: 12px; font-weight: 700; }
.chapter-text .body { font-size: 15px; line-height: 2.0; white-space: pre-wrap; }
.chapter-text .body .sent { border-radius: 4px; padding: 0 1px; transition: background .2s; }
.chapter-text .body .sent.speaking { background: rgba(232,176,75,.35); }

/* 结束页 */
.ending { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #4a3826; gap: 12px; }
.ending h2 { font-size: 28px; letter-spacing: 4px; }
.ending p { color: #8a7355; font-size: 14px; }

/* 控制条 */
.controls {
  display: flex; align-items: center; gap: 10px; margin: 18px auto 6px;
  max-width: 920px; flex-wrap: wrap;
}
.ctrl-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 16px; transition: .15s;
}
.ctrl-btn:hover { border-color: var(--amber-dim); color: var(--amber); }
.ctrl-btn.big { width: 54px; height: 54px; font-size: 20px; background: linear-gradient(135deg,#f2c14e,#d99a2b); color: #241a08; border: none; }
.ctrl-btn.label { width: auto; padding: 0 14px; font-size: 13px; }
.ctrl-btn.playing { animation: pulse 1.4s infinite; }
.page-ind { color: var(--muted); font-size: 13px; min-width: 56px; text-align: center; }
.ctrl-spacer { flex: 1; }
.mini-select {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; height: 44px; padding: 0 8px; font-size: 13px;
}
.ctrl-btn:disabled, .mini-select:disabled { opacity: .4; cursor: not-allowed; }

/* 胶片条 */
.filmstrip-wrap {
  margin-top: 14px; background: #0d0a08; border-radius: 12px; padding: 10px 6px;
  border: 1px solid var(--line); position: relative; overflow: hidden;
}
.filmstrip-wrap::before, .filmstrip-wrap::after {
  content: ""; position: absolute; left: 0; right: 0; height: 8px;
  background-image: radial-gradient(circle at 4px 4px, #14100d 3px, transparent 3.5px);
  background-size: 22px 8px;
}
.filmstrip-wrap::before { top: 0; }
.filmstrip-wrap::after { bottom: 0; }
.filmstrip { display: flex; gap: 8px; overflow-x: auto; padding: 6px 14px; scrollbar-width: thin; }
.frame {
  flex: 0 0 auto; width: 96px; aspect-ratio: 16/10; border-radius: 4px; overflow: hidden;
  border: 2px solid transparent; cursor: pointer; opacity: .65; transition: .2s; position: relative;
  background: #1d1712;
}
.frame svg { width: 100%; height: 100%; display: block; }
.frame:hover { opacity: .9; }
.frame.active { border-color: var(--amber); opacity: 1; box-shadow: 0 0 14px rgba(232,176,75,.35); }
.frame .fno {
  position: absolute; left: 3px; top: 2px; font-size: 9px; color: #fff;
  background: rgba(0,0,0,.5); padding: 1px 5px; border-radius: 6px;
}

/* ---------- 弹窗 / Toast ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px);
}
.modal {
  width: min(440px, 92vw); max-height: 88vh; overflow-y: auto; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 24px;
}
.modal h3 { color: var(--cream); margin-bottom: 6px; font-size: 17px; }
.modal-tip { font-size: 12px; color: var(--muted); margin-bottom: 8px; line-height: 1.7; }
.text-input {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 10px 12px; font-size: 14px; outline: none;
}
.text-input:focus { border-color: var(--amber-dim); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.ghost-btn {
  padding: 9px 22px; border-radius: 12px; border: 1px solid var(--line);
  background: none; color: var(--muted); font-size: 14px;
}
.set-msg { font-size: 12px; color: var(--accent); margin-top: 10px; min-height: 16px; }
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #2c2419; color: var(--cream); border: 1px solid var(--amber-dim);
  padding: 10px 22px; border-radius: 30px; font-size: 13px; z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: fadein .25s;
}

@media (max-width: 760px) {
  .chapter-page { flex-direction: column; }
  .chapter-art { width: 100%; height: 38%; }
  .chapter-text { border-left: none; border-top: 2px dashed rgba(150,120,70,.25); padding: 14px 18px; }
  .screen { aspect-ratio: auto; height: 78vh; }
}
