/* ============================================================
   语文日报 · 前端样式
   风格:简洁现代 + 中国风点缀(宣纸底、朱砂主色、楷体标题)
   无外部依赖,离线可用;移动端优先(老师手机操作是主场景)
   ============================================================ */

:root {
  --cinnabar: #9e2b22;        /* 朱砂主色 */
  --cinnabar-deep: #7b1f17;   /* 深朱砂(hover/渐变) */
  --paper: #f6f0e4;           /* 宣纸底色 */
  --card: #fffdf7;            /* 卡片底 */
  --ink: #33291f;             /* 墨色正文 */
  --muted: #8d8272;           /* 弱化文字 */
  --line: #e6dcc8;            /* 分隔线 */
  --gold: #a9772c;            /* 描金 */
  --indigo: #3d4c9e;          /* 靛蓝 */
  --green: #2f7d4f;
  --orange: #c2690f;
  --blue: #2563eb;
  --red: #b91c1c;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(60, 40, 20, .08), 0 4px 14px rgba(60, 40, 20, .06);
  /* 标题衬线字:系统楷体回退链 */
  --kai: "Kaiti SC", "STKaiti", "KaiTi", "楷体", "FangSong", "SimSun", serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  /* 顶部一层极淡的朱砂晕染,宣纸质感 */
  background-image: linear-gradient(180deg, rgba(158, 43, 34, .05), rgba(158, 43, 34, 0) 260px);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

h1, h2, h3 { font-family: var(--kai); }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--cinnabar), var(--cinnabar-deep));
  color: #fff;
  box-shadow: 0 2px 8px rgba(122, 31, 23, .28);
}
.topbar-inner {
  max-width: 880px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-seal {
  width: 30px; height: 30px; border: 1px solid rgba(255, 255, 255, .65);
  border-radius: 7px; background: rgba(255, 255, 255, .12);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--kai); font-size: 17px;
}
.brand-name { font-family: var(--kai); font-size: 20px; letter-spacing: 3px; }
.topnav { display: none; gap: 4px; }
body.authed .topnav { display: flex; }
.topnav a {
  color: rgba(255, 255, 255, .85); text-decoration: none;
  padding: 6px 13px; border-radius: 8px; font-size: 15px;
}
.topnav a.active { background: rgba(255, 255, 255, .18); color: #fff; }

/* ---------- 布局容器 ---------- */
.container { max-width: 880px; margin: 0 auto; padding: 18px 16px 60px; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 6px 0 16px; flex-wrap: wrap;
}
.page-title { margin: 0; font-size: 26px; color: var(--ink); letter-spacing: 1px; }
.loading { color: var(--muted); text-align: center; padding: 48px 0; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 19px; color: var(--cinnabar); }
/* 卡片标题下的虚线分隔,呼应课件里的虚线元素 */
.card h2::after {
  content: ""; display: block; margin-top: 8px;
  border-top: 1px dashed var(--line);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 9px;
  padding: 10px 18px; font-size: 15px; line-height: 1.3;
  cursor: pointer; background: #efe7d5; color: var(--ink);
  font-family: inherit; text-decoration: none; min-height: 42px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #e7dcc5; }
.btn-primary { background: var(--cinnabar); color: #fff; }
.btn-primary:hover { background: var(--cinnabar-deep); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: #f4eddc; border-color: #d8ccb2; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-mini {
  min-height: 30px; padding: 4px 10px; font-size: 13px; border-radius: 7px;
}

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field > span b { color: var(--cinnabar); } /* 必填星号 */
input[type="text"], input[type="password"], input[type="date"], input[type="search"],
textarea, select {
  width: 100%; font-size: 16px; /* ≥16px 防 iOS 聚焦自动放大 */
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); font-family: inherit;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--cinnabar);
  box-shadow: 0 0 0 3px rgba(158, 43, 34, .12);
}
select { width: auto; min-width: 110px; }
.form-err { color: var(--red); font-size: 13px; margin: 6px 0 12px; line-height: 1.6; }
.form-err ul { margin: 4px 0 0; padding-left: 18px; }
.form-hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

/* ---------- 登录 ---------- */
.login-wrap { display: flex; justify-content: center; padding: 7vh 0 40px; }
.login-card { position: relative; max-width: 380px; width: 100%; padding: 36px 28px; overflow: hidden; }
.login-title {
  margin: 0 0 6px; font-size: 32px; color: var(--cinnabar);
  letter-spacing: 4px; font-weight: 700;
}
.login-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; letter-spacing: .5px; }
/* 右上角「日报」竖排印章 */
.login-seal {
  position: absolute; top: 20px; right: 20px;
  width: 36px; height: 72px; background: var(--cinnabar); color: #fff;
  writing-mode: vertical-rl; letter-spacing: 5px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--kai); font-size: 15px; border-radius: 7px;
  transform: rotate(4deg); box-shadow: 0 2px 8px rgba(158, 43, 34, .4);
}

/* ---------- 任务列表 ---------- */
.task-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 15px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow);
  text-decoration: none; color: inherit;
}
.task-row:active { border-color: var(--cinnabar); }
.task-main { flex: 1; min-width: 0; }
.task-title {
  font-weight: 600; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.task-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.task-step { color: var(--cinnabar); margin-left: 6px; }
.task-err {
  font-size: 12px; color: var(--red); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.task-arrow { color: var(--muted); font-size: 22px; line-height: 1; flex: none; }
.empty-tip { color: var(--muted); text-align: center; padding: 46px 12px; line-height: 1.8; }

/* ---------- 状态徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; flex: none;
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  color: #fff; white-space: nowrap; letter-spacing: .5px;
}
.st-created   { background: #8a8578; }
.st-blink     { background: var(--blue); animation: blink 1.3s ease-in-out infinite; }
.st-draft     { background: var(--orange); }
.st-confirmed { background: var(--indigo); }
.st-done      { background: var(--green); }
.st-failed    { background: var(--red); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------- 状态时间线(竖向,移动端友好) ---------- */
.tl { margin: 4px 0 0; }
.tl-item { position: relative; padding: 0 0 20px 30px; }
.tl-item:last-child { padding-bottom: 4px; }
.tl-item::before {
  content: ""; position: absolute; left: 8px; top: 18px; bottom: 2px;
  width: 2px; background: var(--line);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
  position: absolute; left: 1px; top: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; border: 2px solid var(--line);
}
.tl-item.past .tl-dot { background: var(--cinnabar); border-color: var(--cinnabar); }
.tl-item.cur .tl-dot {
  background: #fff; border-color: var(--cinnabar);
  box-shadow: 0 0 0 4px rgba(158, 43, 34, .16);
}
.tl-label { font-size: 14px; color: var(--muted); }
.tl-item.past .tl-label { color: var(--ink); }
.tl-item.cur .tl-label { color: var(--cinnabar); font-weight: 700; }
.tl-failed .tl-dot { background: var(--red); border-color: var(--red); }

.live-step { margin: 0; font-size: 14px; color: var(--ink); line-height: 1.7; }
/* 进行中小转圈 */
.spin {
  display: inline-block; width: 14px; height: 14px; margin-right: 8px;
  border: 2px solid rgba(158, 43, 34, .25); border-top-color: var(--cinnabar);
  border-radius: 50%; vertical-align: -2px;
  animation: rot .8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }
.err-card {
  background: #fdecec; border: 1px solid #f0c4c4; color: var(--red);
  border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.7;
  word-break: break-all;
}

/* ---------- 新建表单 ---------- */
.file-list { list-style: none; margin: 10px 0 0; padding: 0; }
.file-list li {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 13px; padding: 7px 10px; border-radius: 8px;
  background: #f8f2e4; margin-bottom: 6px; word-break: break-all;
}
.file-list li span { color: var(--muted); flex: none; }
.file-list li.bad { background: #fdecec; color: var(--red); }
.file-list li.bad span { color: var(--red); }
.file-list li.empty { background: transparent; color: var(--muted); justify-content: center; }
.file-total { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.file-total.too-big { color: var(--red); }

/* 上传进度条 */
.progress {
  height: 10px; background: #efe7d4; border-radius: 999px;
  overflow: hidden; margin: 12px 0 6px;
}
.progress-bar {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--cinnabar), #c04a3a);
  transition: width .2s;
}
.progress-text { font-size: 13px; color: var(--muted); margin: 0; text-align: center; }

/* ---------- 详情 ---------- */
.detail-head { margin-bottom: 14px; }
.back-link {
  display: inline-block; color: var(--muted); text-decoration: none;
  font-size: 14px; margin-bottom: 10px;
}
.back-link:hover { color: var(--cinnabar); }
.detail-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-title { margin: 0; font-size: 25px; letter-spacing: 1px; word-break: break-all; }
.detail-facts { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

/* ---------- 草稿编辑器 ---------- */
.editor-top { padding: 16px; }
.editor-meta {
  display: flex; align-items: flex-end; gap: 12px;
  flex-wrap: wrap; margin-bottom: 12px;
}
.editor-meta label { flex: 1; min-width: 220px; }
.editor-facts { color: var(--muted); font-size: 13px; padding-bottom: 11px; }
.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.editor-actions .btn { flex: 1; min-width: 140px; }

/* 全片字数提示条:不足红 / 达标绿 / 超红 */
.word-meter {
  padding: 10px 14px; border-radius: 10px; font-size: 14px;
  border: 1px solid; margin-bottom: 12px; text-align: center;
}
.word-meter.low  { background: #fdecec; border-color: #f0c4c4; color: var(--red); }
.word-meter.ok   { background: #e9f6ee; border-color: #bfe3cc; color: var(--green); }
.word-meter.over { background: #fdecec; border-color: #f0c4c4; color: var(--red); }

/* 页面卡片 */
.page-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.page-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.page-no {
  font-family: var(--kai); color: var(--cinnabar); font-weight: 700;
  font-size: 17px; min-width: 24px; text-align: center;
}
.page-kind-hint { font-size: 12px; color: var(--muted); flex-basis: 100%; }
.page-ops { margin-left: auto; display: flex; gap: 5px; }
.page-ops .btn-mini { background: #f4eddc; border: 1px solid var(--line); color: var(--ink); }
.page-ops .btn-mini:hover:not(:disabled) { border-color: var(--gold); background: #efe4c8; }
.page-ops .btn-mini:disabled { opacity: .35; cursor: default; }
.page-ops .btn-mini.danger { color: var(--red); }
.page-card input.p-title, .page-card input.p-subtitle { margin-bottom: 8px; }
.page-card input.p-subtitle { font-size: 14px; padding: 7px 12px; }

.bullets { margin: 4px 0 10px; }
.bullets-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: block; }
.bullet-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.bullet-row::before {
  content: "•"; color: var(--cinnabar); font-size: 20px; line-height: 1; flex: none;
}
.bullet-row input { flex: 1; min-width: 0; }
.bullet-del {
  flex: none; width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--line); background: #f4eddc; color: var(--red);
  font-size: 16px; cursor: pointer;
}
.bullet-del:hover { border-color: var(--red); }
.add-bullet {
  border: 1px dashed var(--line); background: transparent; color: var(--muted);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer;
}
.add-bullet:hover { border-color: var(--cinnabar); color: var(--cinnabar); }

.p-script { min-height: 92px; }
.script-count {
  font-size: 12px; color: var(--muted); margin-top: 5px; text-align: right;
}
.script-count.warn { color: var(--orange); }
.append-bar { text-align: center; margin: 4px 0 20px; }
.append-bar .btn { border-style: dashed; }

/* ---------- 只读草稿预览 ---------- */
.ro-page { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.ro-page:last-child { border-bottom: none; }
.ro-head { font-size: 14px; font-weight: 600; }
.ro-kind {
  font-weight: 400; font-size: 12px; color: #fff; background: var(--gold);
  border-radius: 6px; padding: 1px 7px; margin-left: 8px;
}
.ro-script { margin: 6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.7; }
.ro-bullets { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }

/* ---------- 产物区 ---------- */
.artifacts video {
  display: block; width: 100%; max-height: 58vh; margin: 0 0 14px;
  border-radius: var(--radius); background: #000;
}
.dl-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.dl {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; text-decoration: none; color: var(--ink); font-size: 14px;
  word-break: break-all;
}
.dl:hover { border-color: var(--cinnabar); }
.dl-icon {
  flex: none; width: 26px; height: 26px; border-radius: 6px;
  background: var(--cinnabar-soft, #f3e0dd); color: var(--cinnabar);
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.fact-line { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

/* ---------- toast ---------- */
#toast-root {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px;
  align-items: center; width: min(92vw, 440px); pointer-events: none;
}
.toast {
  background: #3a3128; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; line-height: 1.5; max-width: 100%;
  opacity: 0; transform: translateY(-8px);
  transition: opacity .25s, transform .25s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .22);
}
.toast.show { opacity: 1; transform: none; }
.toast-ok { background: var(--green); }
.toast-err { background: var(--red); }

/* ---------- 二次确认弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(40, 28, 18, .52);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--card); border-radius: 14px; max-width: 400px; width: 100%;
  padding: 24px 22px 18px; box-shadow: 0 12px 44px rgba(0, 0, 0, .28);
}
.modal h3 { margin: 0 0 10px; font-size: 19px; color: var(--ink); }
.modal p { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn { min-width: 96px; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 600px) {
  .container { padding: 14px 12px 50px; }
  .page-title { font-size: 22px; }
  .detail-title { font-size: 21px; }
  .card { padding: 14px; }
  .login-wrap { padding-top: 4vh; }
  .task-row { padding: 12px; }
  .editor-actions .btn { flex: 1 1 100%; }  /* 手机上保存/出片整行大按钮 */
  .dl-list { grid-template-columns: 1fr; }
  .brand-name { font-size: 18px; letter-spacing: 2px; }
}
