:root {
  --bg: #f6f4ef;
  --panel: #fffefa;
  --ink: #202124;
  --muted: #70757a;
  --line: #dedbd2;
  --accent: #176b87;
  --accent-2: #b84a3a;
  --soft: #e8f2ef;
  --shadow: 0 10px 30px rgba(32, 33, 36, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button, input, textarea, select { font: inherit; }
button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}
button:disabled { opacity: .55; cursor: wait; }
.primary { background: var(--accent); color: white; font-weight: 700; }
.secondary { background: #ece8dc; color: var(--ink); }
.full { width: 100%; }
.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-panel {
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.login-panel h1 { margin: 14px 0 8px; font-size: 26px; }
.login-panel p { margin: 0 0 18px; color: var(--muted); line-height: 1.6; }
.wechat-qr {
  width: 100%;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 12px;
  padding: 16px;
  display: grid;
  place-items: center;
  gap: 10px;
}
.wechat-qr img {
  width: 220px;
  height: 220px;
  object-fit: contain;
}
.wechat-qr img:not([src]) { display: none; }
#wechatQrStatus {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

#app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(520px, 1fr) 360px;
}
.sidebar, .rightbar {
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #fbfaf5;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rightbar { border-right: 0; border-left: 1px solid var(--line); }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 4px; }
.mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.brand span, .meta, small { color: var(--muted); font-size: 12px; display: block; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.panel.compact { box-shadow: none; }
.panel.grow { flex: 1; min-height: 0; overflow: auto; }
label { display: flex; flex-direction: column; gap: 7px; color: #555; font-size: 13px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 11px;
  outline: none;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23, 107, 135, .12); }

.project-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
.project-list { display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.project-item {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.project-item.active { border-color: var(--accent); background: var(--soft); }
.project-item strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-item span { color: var(--muted); font-size: 12px; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  min-height: 78px;
  border-bottom: 1px solid var(--line);
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  background: rgba(255,255,255,.55);
}
.title-input {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 24px;
  font-weight: 800;
}
.title-input:focus { box-shadow: none; }
.stepper { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.user-info { color: var(--muted); font-size: 12px; font-weight: 700; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepper span {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: #eeeae0;
  font-size: 12px;
  font-weight: 800;
}
.stepper .active { background: var(--accent); color: #fff; }

.brief {
  padding: 18px 22px;
  display: grid;
  grid-template-columns: 1.3fr .5fr 1fr auto;
  gap: 12px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}
.brief .wide { grid-column: span 2; }
.content-grid {
  flex: 1;
  min-height: 0;
  padding: 18px 22px;
  display: grid;
  grid-template-columns: minmax(380px, 1fr) 330px;
  gap: 16px;
}
.script-area, .chat-area {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
h2 { margin: 0; font-size: 16px; }
.slides, .chat-log, .asset-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.empty {
  color: var(--muted);
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  min-height: 140px;
}
.slide-card, .asset-card, .message {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.slide-card h3 { margin: 0 0 10px; font-size: 16px; }
.field { margin-top: 10px; }
.field span { display: block; font-size: 12px; color: var(--muted); font-weight: 800; margin-bottom: 5px; }
.field p { margin: 0; line-height: 1.6; }
.message.user { border-left: 4px solid var(--accent); }
.message.assistant { border-left: 4px solid var(--accent-2); }
.message time { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }
.chat-input { display: flex; flex-direction: column; gap: 10px; }
.asset-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #eee;
}
.asset-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.split-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.audio-box audio { width: 100%; }
#videoBox video { width: 100%; margin-top: 12px; border-radius: 8px; background: #111; }
#videoBox a { display: inline-block; margin-top: 10px; color: var(--accent); font-weight: 800; }
#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(80px);
  background: #202124;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  opacity: 0;
  transition: .2s ease;
  max-width: min(520px, calc(100vw - 28px));
  z-index: 5;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1180px) {
  #app { grid-template-columns: 240px 1fr; }
  .rightbar { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  #app { display: block; }
  .sidebar, .rightbar { border: 0; }
  .brief, .content-grid { grid-template-columns: 1fr; }
  .brief .wide { grid-column: auto; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
