/* 照见 · 设计语言：暖纸底色 + 宋体标题 + 克制的朱红点缀
 * 皮肤通过 <html data-skin="..."> 切换，全部变量在这里定义 */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;

  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* ---------- 皮肤：素笺（默认，暖纸+朱红） ---------- */
:root, [data-skin="paper"] {
  --bg: #f7f3ea;
  --bg-2: #f1ebde;
  --card: #fffdf8;
  --text: #2c2a25;
  --text-2: #6d675b;
  --text-3: #a09884;
  --border: #e5dcc9;
  --border-2: #d8ccb3;
  --accent: #b3452e;
  --accent-2: #8f3523;
  --accent-soft: #f6e7e0;
  --gold: #c0a062;
  --danger: #b3452e;
  --shadow: 0 1px 2px rgba(70, 55, 30, .05), 0 6px 20px -8px rgba(70, 55, 30, .12);
  --shadow-lg: 0 2px 6px rgba(70, 55, 30, .07), 0 18px 40px -14px rgba(70, 55, 30, .2);
}

/* ---------- 皮肤：苔痕（青绿，禅意） ---------- */
[data-skin="moss"] {
  --bg: #f2f4ef;
  --bg-2: #e9ede4;
  --card: #fdfefb;
  --text: #232a24;
  --text-2: #5d6b5e;
  --text-3: #94a094;
  --border: #dde3d6;
  --border-2: #c7d1bd;
  --accent: #4a7256;
  --accent-2: #3a5c44;
  --accent-soft: #e2ece3;
  --gold: #9aa878;
  --danger: #a8543a;
  --shadow: 0 1px 2px rgba(40, 60, 45, .05), 0 6px 20px -8px rgba(40, 60, 45, .12);
  --shadow-lg: 0 2px 6px rgba(40, 60, 45, .07), 0 18px 40px -14px rgba(40, 60, 45, .2);
}

/* ---------- 皮肤：远山（黛蓝，清冷） ---------- */
[data-skin="mountain"] {
  --bg: #eff2f5;
  --bg-2: #e6ebf0;
  --card: #fcfdfe;
  --text: #222831;
  --text-2: #58636f;
  --text-3: #90999f;
  --border: #d9e0e7;
  --border-2: #c2ccd6;
  --accent: #47617d;
  --accent-2: #364c64;
  --accent-soft: #e2e9f0;
  --gold: #a8916a;
  --danger: #a8543a;
  --shadow: 0 1px 2px rgba(35, 50, 65, .05), 0 6px 20px -8px rgba(35, 50, 65, .12);
  --shadow-lg: 0 2px 6px rgba(35, 50, 65, .07), 0 18px 40px -14px rgba(35, 50, 65, .2);
}

/* ---------- 皮肤：夜读（暗色，暖琥珀） ---------- */
[data-skin="night"] {
  --bg: #16151a;
  --bg-2: #1d1c22;
  --card: #232228;
  --text: #ece8e0;
  --text-2: #a49e94;
  --text-3: #746e66;
  --border: #34323a;
  --border-2: #443f48;
  --accent: #cf8b5c;
  --accent-2: #e0a075;
  --accent-soft: #33261d;
  --gold: #c0a062;
  --danger: #d97757;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px -8px rgba(0, 0, 0, .5);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 40px -14px rgba(0, 0, 0, .6);
}

/* 没手动选皮肤时，跟随系统深色 */
@media (prefers-color-scheme: dark) {
  :root:not([data-skin]) {
    --bg: #16151a; --bg-2: #1d1c22; --card: #232228;
    --text: #ece8e0; --text-2: #a49e94; --text-3: #746e66;
    --border: #34323a; --border-2: #443f48;
    --accent: #cf8b5c; --accent-2: #e0a075; --accent-soft: #33261d;
    --gold: #c0a062; --danger: #d97757;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px -8px rgba(0,0,0,.5);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.35), 0 18px 40px -14px rgba(0,0,0,.6);
  }
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 400px at 50% -160px, var(--bg-2), transparent 70%),
    var(--bg);
  transition: background-color .4s var(--ease), color .4s var(--ease);
}

/* ============ 顶栏 ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  max-width: 760px; width: 100%; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; flex: none;
  color: var(--accent);                       /* 钤印随皮肤走 */
  filter: drop-shadow(0 1px 2px rgba(70,55,30,.16));
}
.logo svg { width: 100%; height: 100%; display: block; }
.brand-name { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: .04em; }
.brand-sub { font-size: 11px; color: var(--text-3); letter-spacing: .1em; margin-top: 2px; }
.icon-btn {
  border: 1px solid transparent; background: none; font-size: 18px; color: var(--text-2);
  cursor: pointer; width: 38px; height: 38px; border-radius: 50%;
  transition: background .25s var(--ease), border-color .25s var(--ease), transform .25s var(--ease);
}
.icon-btn:hover { background: var(--card); border-color: var(--border); transform: rotate(45deg); }

/* ============ 步骤条 ============ */
.steps {
  display: flex; align-items: flex-start; position: relative;
  padding: 6px 26px 20px; max-width: 760px; width: 100%; margin: 0 auto;
}
.steps::before {
  content: ''; position: absolute; left: 12%; right: 12%; top: 19px;
  height: 1px; background: var(--border-2); z-index: 0;
}
.step {
  flex: 1; position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  border: none; background: none; cursor: pointer; padding: 0;
  font-size: 12px; color: var(--text-3); font-family: inherit;
  transition: color .3s var(--ease);
}
.step .n {
  width: 27px; height: 27px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border-2); color: var(--text-3);
  font-size: 12px; display: flex; align-items: center; justify-content: center;
  transition: all .35s var(--ease);
}
.step:hover { color: var(--text-2); }
.step.done .n { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.step.done { color: var(--text-2); }
.step.active { color: var(--accent); font-weight: 600; }
.step.active .n {
  background: var(--accent); border-color: var(--accent); color: #fff;
  transform: scale(1.14);
  box-shadow: 0 0 0 5px var(--accent-soft);
}

main { flex: 1; padding: 0 20px 110px; max-width: 760px; width: 100%; margin: 0 auto; }
.panel.hidden, .hidden { display: none !important; }
.panel { animation: rise .45s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============ 步骤 1：导入 ============ */
.dropzone {
  border: 1.5px dashed var(--border-2); border-radius: var(--radius);
  padding: 54px 20px; text-align: center; cursor: pointer;
  background: var(--card); box-shadow: var(--shadow);
  transition: all .3s var(--ease);
}
.dropzone:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { font-size: 36px; opacity: .85; }
.dz-title { font-family: var(--serif); font-size: 17px; font-weight: 600; margin-top: 12px; }
.dz-sub { font-size: 12px; color: var(--text-3); margin-top: 6px; letter-spacing: .02em; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 18px; }
.thumb {
  position: relative; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border); aspect-ratio: 9/16; background: var(--card);
  box-shadow: var(--shadow); animation: rise .4s var(--ease);
  transition: transform .3s var(--ease);
}
.thumb:hover { transform: translateY(-3px); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .del {
  position: absolute; top: 5px; right: 5px; width: 23px; height: 23px; border-radius: 50%;
  border: none; background: rgba(20, 18, 14, .6); color: #fff; font-size: 13px; cursor: pointer;
  line-height: 23px; backdrop-filter: blur(4px);
}
.icp-note { margin-top: 10px; text-align: center; font-size: 11px; letter-spacing: .04em; }
.icp-note a { color: var(--text-3); text-decoration: none; }
.icp-note a:hover { color: var(--text-2); }
.privacy-note { margin-top: 22px; font-size: 12px; color: var(--text-3); text-align: center; letter-spacing: .03em; }

/* ============ 工具栏 ============ */
.toolbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  padding: 12px 0 14px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.tool-row { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; flex-wrap: wrap; }
.tool-row:last-of-type { margin-bottom: 0; }
.tool-label { font-size: 12px; color: var(--text-3); flex: none; letter-spacing: .06em; }
.seg {
  display: inline-flex; border: 1px solid var(--border); border-radius: 999px;
  overflow: hidden; background: var(--card); box-shadow: var(--shadow);
}
.seg button {
  border: none; background: none; padding: 7px 16px; font-size: 13px;
  color: var(--text-2); cursor: pointer; font-family: inherit;
  transition: all .25s var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent); color: #fff; }
.mini-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 8px 16px; font-size: 13px; cursor: pointer;
  font-family: inherit; box-shadow: var(--shadow);
  transition: all .25s var(--ease);
}
.mini-btn:hover { border-color: var(--border-2); transform: translateY(-1px); }
.mini-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.mini-btn.hl { border-color: var(--accent); color: var(--accent); }
.mini-btn:disabled { opacity: .45; cursor: default; transform: none; }
.kw-input {
  flex: 1; min-width: 130px; border: 1px solid var(--border); background: var(--card);
  color: var(--text); border-radius: 999px; padding: 9px 16px; font-size: 13px;
  outline: none; font-family: inherit; transition: border-color .25s var(--ease);
}
.kw-input:focus { border-color: var(--accent); }
.kw-input::placeholder { color: var(--text-3); }
.tool-hint { font-size: 12px; color: var(--text-3); line-height: 1.75; }

/* ============ 步骤 2：画布 ============ */
.canvas-list { display: flex; flex-direction: column; gap: 20px; padding-top: 16px; }
.canvas-item {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); animation: rise .45s var(--ease);
}
.canvas-item .ci-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; font-size: 12px; color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.ocr-chip {
  font-size: 11px; padding: 3px 10px; border-radius: 999px;
  background: var(--bg-2); color: var(--text-3); letter-spacing: .02em;
}
.ocr-chip.ok { background: var(--accent-soft); color: var(--accent); }
.ocr-chip.err { background: var(--accent-soft); color: var(--danger); }
.canvas-item canvas { width: 100%; display: block; touch-action: pan-y; }
.canvas-item.brushing canvas { touch-action: none; cursor: crosshair; }

/* ============ 步骤 3：挑选 ============ */
.panel-tip {
  font-size: 13px; color: var(--text-2); line-height: 1.85;
  padding: 16px 18px; margin: 4px 0 16px;
  background: var(--card); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
}
.msg-list { display: flex; flex-direction: column; gap: 12px; }
.msg-card {
  display: flex; gap: 12px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px; box-shadow: var(--shadow);
  transition: all .3s var(--ease); animation: rise .4s var(--ease);
}
.msg-card:hover { box-shadow: var(--shadow-lg); }
.msg-card.off { opacity: .42; }
.msg-check { flex: none; width: 21px; height: 21px; margin-top: 3px; accent-color: var(--accent); cursor: pointer; }
.msg-body { flex: 1; min-width: 0; }
.msg-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 9px; }
.role-chip {
  border: 1px solid var(--border-2); background: var(--bg-2); color: var(--text-2);
  border-radius: 999px; padding: 3px 11px; font-size: 11px; cursor: pointer;
  font-family: inherit; transition: all .25s var(--ease);
}
.role-chip:hover { border-color: var(--text-3); }
.role-chip.host { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.kw-tag {
  font-size: 11px; color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 3px 9px; letter-spacing: .02em;
}
.msg-crop { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; margin-bottom: 8px; }
.msg-text {
  width: 100%; border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px; font-size: 13px; line-height: 1.75;
  resize: vertical; font-family: inherit; outline: none;
  transition: border-color .25s var(--ease);
}
.msg-text:focus { border-color: var(--accent); background: var(--card); }
.msg-ops { display: flex; flex-direction: column; gap: 5px; flex: none; }
.msg-ops button {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text-2); cursor: pointer; font-size: 13px;
  font-family: inherit; transition: all .25s var(--ease);
}
.msg-ops button:hover { border-color: var(--accent); color: var(--accent); }
.msg-empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 60px 0; line-height: 2; }

/* ============ 步骤 4：成文 ============ */
.form-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.f-label { display: block; font-size: 12px; color: var(--text-2); margin: 16px 0 7px; letter-spacing: .06em; }
.f-label:first-child { margin-top: 0; }
.req { color: var(--accent); margin-left: 3px; }
.form-card input[type="text"], .form-card textarea, .modal-card input {
  width: 100%; border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 14px; outline: none;
  font-family: inherit; transition: all .25s var(--ease);
}
.form-card input:focus, .form-card textarea:focus, .modal-card input:focus {
  border-color: var(--accent); background: var(--card);
}
.form-card input::placeholder, .form-card textarea::placeholder { color: var(--text-3); }
.form-card .tool-row { margin-top: 16px; margin-bottom: 0; }

.chan-tabs { display: flex; gap: 9px; margin-bottom: 14px; }
.chan-tabs button {
  flex: 1; padding: 11px 0; border: 1px solid var(--border); background: var(--card);
  color: var(--text-2); border-radius: var(--radius-sm); font-size: 13px; cursor: pointer;
  font-family: inherit; box-shadow: var(--shadow); transition: all .28s var(--ease);
}
.chan-tabs button:hover { color: var(--text); transform: translateY(-1px); }
.chan-tabs button.on {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-soft); font-weight: 600;
}

.gen-row { display: flex; gap: 10px; }
.gen-row .big-btn { flex: 1; }
.big-btn {
  width: 100%; padding: 15px 0; border: none; border-radius: var(--radius);
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
  font-family: inherit; letter-spacing: .04em; box-shadow: var(--shadow);
  transition: all .28s var(--ease);
}
.big-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.big-btn:active { transform: translateY(0); }
.big-btn:disabled { opacity: .55; transform: none; cursor: default; }
.big-btn.ghost {
  background: var(--card); color: var(--accent);
  border: 1px solid var(--accent); font-weight: 500;
}

.gen-status { margin-top: 14px; font-size: 13px; color: var(--text-2); text-align: center; letter-spacing: .03em; }
.gen-status.err { color: var(--danger); }
.article-out {
  width: 100%; margin-top: 16px; border: 1px solid var(--border); background: var(--card);
  color: var(--text); border-radius: var(--radius); padding: 20px;
  font-family: var(--serif); font-size: 15px; line-height: 2.05; letter-spacing: .02em;
  resize: vertical; outline: none; box-shadow: var(--shadow);
  transition: border-color .25s var(--ease);
}
.article-out:focus { border-color: var(--border-2); }
.export-row { display: flex; gap: 9px; flex-wrap: wrap; margin: 14px 0 10px; }

/* ============ 历史稿件 ============ */
.history-box { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 18px; }
.hist-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-3); letter-spacing: .08em; margin-bottom: 12px;
}
.hist-list { display: flex; flex-direction: column; gap: 9px; }
.hist-item {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px;
  box-shadow: var(--shadow); transition: all .28s var(--ease);
}
.hist-item:hover { transform: translateX(3px); box-shadow: var(--shadow-lg); }
.hist-main { flex: 1; min-width: 0; }
.hist-title { font-family: var(--serif); font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; letter-spacing: .03em; }

/* ============ 底栏 ============ */
.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; gap: 12px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  max-width: 760px; margin: 0 auto;
}
.nav-btn {
  flex: 1; padding: 13px 0; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 15px; cursor: pointer;
  font-family: inherit; letter-spacing: .05em; transition: all .28s var(--ease);
}
.nav-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.nav-btn.primary {
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff; font-weight: 600;
}
.nav-btn:disabled { opacity: .35; transform: none; box-shadow: none; cursor: default; }

/* ============ 弹层 ============ */
.modal {
  position: fixed; inset: 0; background: rgba(28, 24, 18, .5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 24px;
  animation: fade .3s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 24px; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
  animation: pop .35s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(12px); } to { opacity: 1; transform: none; } }
.modal-card h3 { font-family: var(--serif); font-size: 18px; margin-bottom: 16px; font-weight: 600; letter-spacing: .04em; }
.modal-btns { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

/* 皮肤选择 */
.skin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.skin-opt {
  border: 1px solid var(--border); background: var(--bg-2); border-radius: var(--radius-sm);
  padding: 10px 4px 8px; cursor: pointer; font-family: inherit; font-size: 11px;
  color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 7px;
  transition: all .28s var(--ease);
}
.skin-opt:hover { transform: translateY(-2px); }
.skin-opt.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.skin-dot { width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(0,0,0,.1); }

/* ============ 提示 ============ */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: color-mix(in srgb, var(--text) 92%, transparent); color: var(--bg);
  font-size: 13px; padding: 11px 22px; border-radius: 999px; z-index: 99;
  max-width: 80vw; text-align: center; box-shadow: var(--shadow-lg);
  animation: toastIn .35s var(--ease); letter-spacing: .03em;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 420px) {
  .topbar { padding: 14px 16px 10px; }
  main { padding: 0 16px 108px; }
  .steps { padding: 4px 12px 18px; }
  .gen-row { flex-direction: column; }
}
