/* ============ 全局 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: #eef1f6; color: #2c3e50; font-size: 14px;
}
button { font-family: inherit; }
a { color: #3b6cd4; text-decoration: none; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #1f2a44; color: #fff; padding: 10px 18px;
  position: sticky; top: 0; z-index: 50;
}
.brand { font-size: 16px; font-weight: 600; }
.brand a { color: #9fb6e8; font-size: 13px; font-weight: 400; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.topbar nav a { color: #cdd8f0; margin-left: 16px; }
.topbar nav a:hover { color: #fff; }

.container { max-width: 1000px; margin: 24px auto; padding: 0 16px; }
.container.narrow { max-width: 720px; }
.card {
  background: #fff; border-radius: 10px; padding: 22px 26px;
  box-shadow: 0 2px 10px rgba(30,50,90,.08); margin-bottom: 20px;
}
.card h2 { font-size: 17px; margin-bottom: 10px; color: #1f2a44; }
.hint { color: #8a94a6; font-size: 13px; line-height: 1.7; }
.hint code { background: #f0f3f8; padding: 1px 5px; border-radius: 4px; }

.row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.row input[type=text], .row input[type=file] { flex: 1; }
input[type=text], input[type=password], input[type=number], textarea, select {
  border: 1px solid #cfd8e6; border-radius: 6px; padding: 8px 10px; font-size: 14px;
  outline: none; font-family: inherit;
}
input:focus, textarea:focus { border-color: #3b6cd4; }
.settings-form label { display: block; margin: 12px 0 4px; font-size: 13px; color: #556; }
.settings-form input, .settings-form textarea { width: 100%; }

.btn {
  background: #fff; border: 1px solid #c8d2e4; color: #33415e;
  border-radius: 6px; padding: 8px 16px; font-size: 14px; cursor: pointer;
  transition: all .15s; user-select: none;
}
.btn:hover { border-color: #3b6cd4; color: #3b6cd4; }
.btn.primary { background: #3b6cd4; border-color: #3b6cd4; color: #fff; }
.btn.primary:hover { background: #2f58b4; }
.btn.danger { color: #d33; border-color: #e0b4b4; }
.btn.danger:hover { background: #fdf0f0; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.status { color: #888; font-size: 12.5px; }

/* ============ 首页试卷列表 ============ */
.steps {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px;
}
.steps span {
  background: #f0f4fb; border: 1px solid #dfe8f6; color: #44536e;
  border-radius: 14px; padding: 3px 12px; font-size: 12.5px;
}

#dropZone {
  border: 2px dashed #b9c6e0; border-radius: 10px; background: #f8faff;
  padding: 28px 16px; text-align: center; cursor: pointer;
  transition: all .15s; margin: 6px 0 12px;
}
#dropZone:hover, #dropZone.drag {
  border-color: #3b6cd4; background: #eef3fd;
}
#dropZone .dz-icon { font-size: 34px; margin-bottom: 6px; }
#dropZone .dz-text { color: #33415e; font-size: 14.5px; }
#dropZone .dz-sub { margin-top: 6px; }

.file-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.fl-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  background: #f7f9fc; border: 1px solid #e2e8f2; border-radius: 8px; font-size: 13px;
}
.fl-item img { width: 44px; height: 32px; object-fit: cover; border-radius: 4px; border: 1px solid #dde; }
.fl-badge {
  background: #d43b3b; color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 4px; padding: 5px 7px; letter-spacing: 1px;
}
.fl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #44536e; }
.fl-size { color: #98a2b3; font-size: 12px; }
.fl-item button {
  background: none; border: none; color: #98a2b3; cursor: pointer; font-size: 13px;
}
.fl-item button:hover { color: #d33; }

.paper-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.paper-card {
  border: 1px solid #e2e8f2; border-radius: 10px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px; transition: box-shadow .15s;
  background: #fff;
}
.paper-card:hover { box-shadow: 0 3px 12px rgba(30,50,90,.12); }
.pc-cover {
  display: block; height: 130px; border-radius: 8px; overflow: hidden;
  background: #f0f3f8; border: 1px solid #e6ebf3;
}
.pc-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.pc-cover-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: #b7c0cf; font-size: 13px; }
.pc-title { font-weight: 600; color: #1f2a44; word-break: break-all; }
.pc-meta { color: #8a94a6; font-size: 12px; }
.pc-actions { display: flex; gap: 8px; margin-top: auto; }

/* ============ 编辑器布局 ============ */
.editor-layout {
  display: flex; height: calc(100vh - 52px); overflow: hidden;
}
.sidebar {
  width: 168px; background: #f7f9fc; border-right: 1px solid #dde4ee;
  overflow-y: auto; flex-shrink: 0; padding-bottom: 20px;
}
.side-head { padding: 10px 12px; font-weight: 600; font-size: 13.5px; color: #44536e; border-bottom: 1px solid #e6ebf3; }
#thumbs { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.thumb {
  position: relative; border: 2px solid #dfe6f0; border-radius: 6px; cursor: pointer;
  overflow: hidden; background: #fff; transition: border-color .15s; flex-shrink: 0;
}
.thumb:hover { border-color: #9fb6e8; }
.thumb.active { border-color: #3b6cd4; }
.thumb img { width: 100%; display: block; }
.thumb.dragging { opacity: .4; }
.t-num {
  position: absolute; left: 4px; top: 4px; background: rgba(31,42,68,.75); color: #fff;
  font-size: 11px; padding: 1px 6px; border-radius: 3px;
}
.t-ai {
  position: absolute; right: 4px; top: 4px; background: #2e9e5b; color: #fff;
  font-size: 10px; padding: 1px 5px; border-radius: 3px; font-weight: 700;
}
.t-del {
  position: absolute; right: 4px; bottom: 4px; border: none; background: rgba(220,60,60,.85);
  color: #fff; width: 20px; height: 20px; border-radius: 4px; cursor: pointer; font-size: 11px;
  display: none;
}
.thumb:hover .t-del { display: block; }

.stage-col { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #47506a; }
.stage-toolbar {
  display: flex; align-items: center; gap: 6px; padding: 7px 12px;
  background: #eef1f7; border-bottom: 1px solid #d9dfeb; flex-wrap: wrap;
}
.tbtn {
  background: #fff; border: 1px solid #ccd5e5; border-radius: 5px; padding: 5px 10px;
  font-size: 13px; cursor: pointer; color: #33415e;
}
.tbtn:hover { border-color: #3b6cd4; }
.tbtn.active { background: #3b6cd4; border-color: #3b6cd4; color: #fff; }
.sep { width: 1px; height: 20px; background: #ccd5e5; margin: 0 4px; }
#penColor { width: 34px; height: 30px; border: 1px solid #ccd5e5; border-radius: 5px; padding: 1px; cursor: pointer; background: #fff; }

.stage-viewport {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 14px; position: relative;
}
#stage {
  width: 1280px; height: 720px; position: relative; background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,.35); flex-shrink: 0;
  transform-origin: center center;
}
#stage canvas, #elemLayer { position: absolute; inset: 0; }
#elemLayer { pointer-events: none; }
#elemLayer .te, #elemLayer .ie { pointer-events: auto; }

.page-nav {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 8px; background: #eef1f7; border-top: 1px solid #d9dfeb; color: #556;
}

/* ---------- 文本元素 ---------- */
.te { position: absolute; border: 1.5px dashed transparent; cursor: move; }
.te:hover { border-color: #9fb6e8; }
.te.sel { border-color: #3b6cd4; }
.te.editing { border-style: solid; background: rgba(255,255,255,.92); }
.te-body {
  line-height: 1.5; word-break: break-all; outline: none; white-space: pre-wrap;
  font-family: "Microsoft YaHei", sans-serif; min-height: 1.2em;
}
.te-rs {
  position: absolute; right: -5px; top: 50%; transform: translateY(-50%);
  width: 9px; height: 26px; background: #3b6cd4; border-radius: 4px; cursor: ew-resize;
  display: none;
}
.te.sel .te-rs { display: block; }

/* ---------- 图片元素 ---------- */
.ie { position: absolute; border: 1.5px dashed transparent; cursor: move; }
.ie:hover { border-color: #9fb6e8; }
.ie.sel { border-color: #3b6cd4; }
.ie img { width: 100%; height: 100%; display: block; object-fit: fill; }
.ie-rs {
  position: absolute; right: -6px; bottom: -6px; width: 13px; height: 13px;
  background: #3b6cd4; border: 2px solid #fff; border-radius: 50%; cursor: nwse-resize; display: none;
}
.ie.sel .ie-rs { display: block; }

/* ---------- 右侧面板 ---------- */
.right-panel {
  width: 280px; background: #f7f9fc; border-left: 1px solid #dde4ee;
  overflow-y: auto; flex-shrink: 0;
}
.ai-body { padding: 12px; }
.ai-loading { color: #3b6cd4; font-size: 13px; margin: 12px 0; }
.spinner {
  width: 22px; height: 22px; border: 3px solid #cdd9f2; border-top-color: #3b6cd4;
  border-radius: 50%; animation: spin 1s linear infinite; display: inline-block;
  vertical-align: middle; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ai-error { background: #fdf0f0; color: #c0392b; border: 1px solid #e8c6c6; border-radius: 6px; padding: 8px 10px; font-size: 12.5px; margin: 10px 0; }
.ai-result {
  background: #fff; border: 1px solid #e2e8f2; border-radius: 6px; padding: 10px;
  font-size: 13.5px; line-height: 1.8; margin-top: 8px; min-height: 60px; max-height: 420px; overflow: auto;
}
.ai-raw { width: 100%; margin-top: 8px; font-size: 12.5px; }
.prop-panel { padding: 10px 12px; font-size: 13px; }
.prop-panel label { display: flex; align-items: center; gap: 8px; margin: 8px 0; }

/* ---------- 倒计时 ---------- */
#countdown {
  position: fixed; right: 24px; bottom: 24px; z-index: 9000;
  background: rgba(20,26,40,.92); color: #fff; border-radius: 10px;
  padding: 8px 14px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.4);
  user-select: none; min-width: 190px;
}
.cd-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: #9fb0cc; cursor: move;
}
.cd-head button { background: none; border: none; color: #9fb0cc; cursor: pointer; font-size: 13px; }
.cd-display {
  font-size: 44px; font-weight: 700; text-align: center; letter-spacing: 2px;
  font-variant-numeric: tabular-nums; margin: 6px 0; color: #eaf2ff;
}
.cd-display.warn { color: #ffb74d; }
.cd-display.danger { color: #ff5252; animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: .45; } }
.cd-ctrl { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #9fb0cc; }
.cd-ctrl input { background: #2a3550; border-color: #435179; color: #fff; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(15,22,38,.55); z-index: 8000;
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: #fff; border-radius: 10px; padding: 18px 22px; max-width: 92vw;
  max-height: 92vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.modal-box.wide { width: 880px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 10px; }
.tabs { display: flex; gap: 6px; }
.tab {
  border: 1px solid #ccd5e5; background: #fff; padding: 4px 14px; border-radius: 5px;
  cursor: pointer; font-size: 13px;
}
.tab.active { background: #3b6cd4; color: #fff; border-color: #3b6cd4; }

#splitImgWrap { position: relative; margin-top: 6px; user-select: none; }
#splitLines { position: absolute; inset: 0; z-index: 2; }
.sline {
  position: absolute; left: 0; right: 0; height: 0; cursor: ns-resize;
  border-top: 2px dashed #ff4081; margin-top: -1px;
}
.sline:hover { border-color: #f50057; background: rgba(255,64,129,.08); }
.sl-del {
  position: absolute; right: 8px; top: -10px; width: 20px; height: 20px;
  border-radius: 50%; border: none; background: #ff4081; color: #fff; cursor: pointer; font-size: 11px;
}

/* 框选模式 */
.sbox {
  position: absolute; border: 2px dashed #3b6cd4; background: rgba(59,108,212,.12);
  cursor: move;
}
.sbox.drawing { cursor: crosshair; }
.sbox:hover { border-color: #2f58b4; background: rgba(59,108,212,.18); }
.sbox-no {
  position: absolute; left: -1px; top: -1px; background: #3b6cd4; color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 4px 0 4px 0;
}
.sbox-del {
  position: absolute; right: -9px; top: -9px; width: 20px; height: 20px;
  border-radius: 50%; border: none; background: #ff4081; color: #fff;
  cursor: pointer; font-size: 11px; display: none;
}
.sbox:hover .sbox-del { display: block; }
.sbox-rs {
  position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px;
  background: #3b6cd4; border: 2px solid #fff; border-radius: 50%;
  cursor: nwse-resize; display: none;
}
.sbox:hover .sbox-rs { display: block; }

/* 缩略图合并按钮 */
.t-merge {
  position: absolute; left: 4px; bottom: 4px; border: none;
  background: rgba(59,108,212,.9); color: #fff;
  padding: 2px 7px; border-radius: 4px; cursor: pointer; font-size: 11px;
  display: none;
}
.thumb:hover .t-merge { display: block; }
.t-merge:hover { background: #2f58b4; }

#cropImgWrap { position: relative; display: inline-block; max-width: 100%; user-select: none; overflow: hidden; }
#cropImg { display: block; max-width: 100%; }
#cropRect {
  position: absolute; border: 2px solid #3b6cd4; background: rgba(59,108,212,.18);
  pointer-events: none;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(31,42,68,.92); color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 13.5px; z-index: 9999; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}

/* ---------- 放映模式 ---------- */
body.presenting .topbar,
body.presenting .sidebar,
body.presenting .right-panel,
body.presenting .stage-toolbar,
body.presenting .page-nav { display: none; }
body.presenting .editor-layout { height: 100vh; }
body.presenting .stage-viewport { padding: 0; background: #000; overflow: hidden; cursor: pointer; }
body.presenting #stage { box-shadow: none; }

/* ---------- 放映控制条 ---------- */
#presentUI {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 10000; display: flex; align-items: center; gap: 8px;
  background: rgba(20,26,40,.88); color: #fff; border-radius: 26px;
  padding: 8px 18px; box-shadow: 0 4px 18px rgba(0,0,0,.4);
  opacity: 0; transition: opacity .3s; user-select: none;
}
#presentUI.show { opacity: 1; }
#presentUI button {
  background: none; border: none; color: #fff; font-size: 22px;
  cursor: pointer; padding: 2px 10px; line-height: 1;
}
#presentUI button:hover { color: #9fc0ff; }
#pvInfo { font-size: 13.5px; color: #cdd8f0; min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
#pvExit { font-size: 13px !important; border-left: 1px solid #44506e; }
