/* HomeworkOS · 模板设置页样式（与编辑器/布置页同设计语言） */
/* @font-face 已迁移到 public/common/fonts.css，三阶段共享，不再单独声明 */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  background: #171a22; color: #e8ecf4; display: flex; flex-direction: column;
}
.bc-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #e9eef7; }
.bc-link:hover { opacity: 0.85; }
.bc-brand { font-size: 14px; font-weight: 700; color: #e9eef7; }
.bc-version { font-size: 10px; color: #8a97ad; margin-left: 4px; font-weight: 400; }
.bc-sep { color: #5a6478; font-size: 14px; margin: 0 2px; }
.bc-current { font-size: 14px; font-weight: 600; color: #dce4f3; }
.topbar {
  min-height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; gap: 12px; background: #1f2430; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 13px;
}
.brand-title { font-size: 14px; font-weight: 700; }
.brand-sub { font-size: 11px; color: #95a0b5; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tb-btn, .link-like {
  border: 1px solid rgba(255,255,255,0.12); background: #252b38; color: #dce4f3; border-radius: 8px;
  padding: 8px 12px; cursor: pointer; font-size: 12px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.tb-btn:hover, .link-like:hover { background: #2b3241; }
.tb-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.tb-btn.primary:hover { background: var(--accent-dark); }
.tb-btn.danger { color: #ffb4b4; }
.tb-btn.danger:hover:not(:disabled) { background: rgba(255,180,180,0.12); }
.tb-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.save-badge {
  font-size: 11px; padding: 4px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.save-badge[data-state="saved"] { color: #5dd39e; background: rgba(93,211,158,0.12); border-color: rgba(93,211,158,0.35); }
.save-badge[data-state="saving"] { color: var(--accent-2); background: rgba(var(--accent-2-rgb), 0.12); border-color: rgba(var(--accent-2-rgb), 0.35); }
.save-badge[data-state="dirty"] { color: #ffb86b; background: rgba(255,184,107,0.12); border-color: rgba(255,184,107,0.35); }
.save-badge[data-state="error"] { color: #ff8a8a; background: rgba(255,138,138,0.12); border-color: rgba(255,138,138,0.35); }
.main { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 260px; background: #1d222d; padding: 14px; overflow: auto;
}
/* 暗色细滚动条，避免左侧栏默认的白色滑块 */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
.left-sidebar { border-right: 1px solid rgba(255,255,255,0.08); }
.right-sidebar { border-left: 1px solid rgba(255,255,255,0.08); display: flex; flex-direction: column; }
.sidebar-title { font-size: 12px; color: #97a5bc; margin-bottom: 12px; font-weight: 700; letter-spacing: .04em; }
.sidebar-subtitle { font-size: 11px; color: #5a6580; margin-bottom: 8px; font-weight: 600; letter-spacing: .03em; }
.sidebar-section { margin-top: 18px; }
.sidebar-hint { color: #7f8aa0; font-size: 12px; line-height: 1.7; }
.sidebar-scroll { flex: 1; overflow-y: auto; }
.sidebar-footer { flex-shrink: 0; border-top: 1px solid rgba(255,255,255,0.06); padding: 8px 0 0; margin-top: 8px; }
.sidebar-footer-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.sidebar-footer-row:last-child { margin-bottom: 0; }
.props-group { margin-bottom: 12px; }
.props-group label { display: block; font-size: 11px; color: #9aa6bc; margin-bottom: 6px; }
.props-group input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), .props-group select {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1);
  background: #141922; color: #edf2fb; font-size: 12px;
}
/* checkbox / radio 恢复原生尺寸，不被上面的规则撑成整行大块（修复“出现页”文字竖排） */
.props-group input[type="checkbox"], .props-group input[type="radio"] {
  width: auto; height: auto; padding: 0; margin: 0;
  accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
}
.workspace { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.canvas-area {
  flex: 1; overflow: auto; padding: 24px; background: #12151c; position: relative;
  background-image: radial-gradient(circle, rgba(255,255,255,0.03) 1px, transparent 1px); background-size: 20px 20px;
}
.canvas-area::-webkit-scrollbar { display: none; }
.canvas-area { -ms-overflow-style: none; scrollbar-width: none; }
.canvas-wrap {
  width: 794px; height: 1123px; position: relative; margin: 0 auto;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45); background: white;
}
#bgCanvas { display: block; border-radius: 4px; }
/* 覆盖在画布上的 DOM 节点（变量） */
.tpl-node {
  position: absolute; border-radius: 4px; cursor: move; user-select: none;
  outline: 1.5px dashed rgba(var(--accent-rgb), 0.4);
  display: flex; align-items: center; justify-content: center;
  background: transparent;
}
.tpl-node:hover { outline-color: rgba(var(--accent-rgb), 0.7); }
.tpl-node.selected { outline: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15); }
.tpl-node .tpl-label {
  pointer-events: none;
  text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 0 4px; width: 100%;
}
.tpl-resize-handle {
  position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; cursor: se-resize;
  background: rgba(var(--accent-rgb), 0.4); border-radius: 0 0 4px 0;
}
.tpl-resize-handle:hover { background: var(--accent); }
/* 内容盒子覆盖层（蓝色虚线） */
.content-box-overlay {
  position: absolute; border: 2px dashed rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.04); pointer-events: none;
}
.content-box-edge {
  position: absolute; pointer-events: auto;
}
.content-box-edge.top, .content-box-edge.bottom { left: 0; right: 0; height: 4px; cursor: ns-resize; }
.content-box-edge.top { top: -2px; }
.content-box-edge.bottom { bottom: -2px; }
.content-box-edge.left, .content-box-edge.right { top: 0; bottom: 0; width: 4px; cursor: ew-resize; }
.content-box-edge.left { left: -2px; }
.content-box-edge.right { right: -2px; }
.hidden { display: none !important; }
.statusbar {
  min-height: 34px; display: flex; align-items: center; gap: 18px; padding: 0 16px;
  background: #1f2430; border-top: 1px solid rgba(255,255,255,0.08); color: #92a0b7; font-size: 12px;
}
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; background: #95a0b5; vertical-align: middle;
}
.status-dot.ok { background: #5dd39e; box-shadow: 0 0 6px rgba(93,211,158,0.5); }
.status-dot.err { background: #ff6b6b; box-shadow: 0 0 6px rgba(255,107,107,0.5); }
.toast-wrap { position: absolute; left: 18px; top: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 999; pointer-events: none; }
.toast {
  border-radius: 10px; padding: 10px 14px; max-width: 360px;
  font-size: 13px; font-weight: 500; pointer-events: auto; animation: toastIn 0.25s ease;
  background: linear-gradient(135deg, #252a20 0%, #1e2218 100%); border: 1px solid rgba(93,211,158,0.35); color: #a8f0c8;
  box-shadow: 0 4px 16px rgba(93,211,158,0.12);
}
.toast.toast-error {
  background: linear-gradient(135deg, #2a2020 0%, #221818 100%); border: 1px solid rgba(255,107,107,0.4); color: #ffb4b4;
  box-shadow: 0 4px 16px rgba(255,107,107,0.12);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
/* .measure-div 已统一迁移到 public/common/fonts.css */

/* ── Zoom controls ── */
.zoom-controls {
  display: flex; align-items: center; gap: 2px;
  background: #252b38; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; padding: 1px; margin-left: 8px;
}
.zoom-btn {
  width: 22px; height: 20px;
  border: none; background: transparent;
  color: #dce4f3; cursor: pointer;
  font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.zoom-btn:hover { background: rgba(255,255,255,0.08); }
.zoom-pct {
  font-size: 11px; color: #b8c4d9;
  min-width: 36px; text-align: center;
  user-select: none;
}
.canvas-area.zooming { cursor: grab; }
.canvas-area.zooming:active { cursor: grabbing; }

/* ── Magnetic alignment lines ── */
.align-line {
  position: absolute;
  background: var(--accent);
  z-index: 1000;
  pointer-events: none;
  opacity: 0.8;
}
.align-line.h { height: 1px; width: 100%; }
.align-line.v { width: 1px; height: 100%; }

/* ── Box selection ── */
.selection-rect {
  position: absolute;
  border: 1px dashed var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  z-index: 999;
  pointer-events: none;
}

/* ── 高级设置折叠区域 ── */
.props-advanced {
  margin-top: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 0;
  background: rgba(255,255,255,0.02);
}

.props-advanced summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #95a0b5;
  user-select: none;
}

.props-advanced summary:hover {
  color: #dce4f3;
  background: rgba(255,255,255,0.04);
}

.props-advanced-content {
  padding: 8px 12px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ── 画布拖拽光标样式 ── */
.canvas-area.pan-ready { cursor: grab; }
.canvas-area.pan-ready:active { cursor: grabbing; }
.canvas-area.panning { cursor: grabbing; }

/* ── 框选选择框 ── */
.selection-rect {
  position: absolute;
  border: 1px dashed var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  z-index: 999;
  pointer-events: none;
}

/* ── 磁吸对齐线 ── */
.align-line {
  position: absolute;
  background: var(--accent);
  z-index: 1000;
  pointer-events: none;
  opacity: 0.8;
}
.align-line.h { height: 1px; width: 100%; }
.align-line.v { width: 1px; height: 100%; }

/* ── 多选样式 ── */
.tpl-node.selected {
  outline: 2px solid var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

/* ── 画布拖拽光标样式 ── */
.canvas-area.pan-ready {
  cursor: grab;
}
.canvas-area.pan-ready:active {
  cursor: grabbing;
}
.canvas-area.panning {
  cursor: grabbing;
}

/* ── 框选选择框 ── */
.selection-rect {
  position: absolute;
  border: 1px dashed var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  z-index: 999;
  pointer-events: none;
}

/* ── 多选节点样式 ── */
.tpl-node.selected {
  outline: 2px solid var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

/* ── 模板列表（下拉框） ── */

/* ── 下拉选择框 ── */
.select-box {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12); background: #141922;
  color: #edf2fb; font-size: 12px; cursor: pointer;
}
.select-box:focus { border-color: var(--accent); outline: none; }

/* ── iOS 风格开关（替代默认 checkbox），主题色跟随 --accent ── */
.ios-toggle { position: relative; display: inline-block; width: 32px; height: 18px; flex-shrink: 0; }
.ios-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.ios-toggle .toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: rgba(255,255,255,0.18); border-radius: 999px; transition: background .18s;
}
.ios-toggle .toggle-slider::before {
  content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px;
  background: #fff; border-radius: 50%; transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
.ios-toggle input:checked + .toggle-slider { background: var(--accent); }
.ios-toggle input:checked + .toggle-slider::before { transform: translateX(14px); }

/* ── 自定义模态弹窗（替代 prompt/confirm，结构与 editor 模块保持一致） ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #1f2430; border: 1px solid rgba(255,255,255,0.1); border-radius: 16px;
  padding: 24px; max-width: 440px; width: 90%; box-shadow: 0 18px 50px rgba(0,0,0,0.45);
}
.modal-title { font-size: 15px; font-weight: 700; color: #e8ecf4; margin-bottom: 16px; }
.modal-body { font-size: 13px; color: #bcc5d6; line-height: 1.7; margin-bottom: 20px; }
.modal-body textarea, .modal-body input {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.12);
  background: #141922; color: #edf2fb; font-size: 13px; margin-top: 8px; resize: vertical;
}
.modal-body textarea { min-height: 100px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-actions .modal-btn {
  border: 1px solid rgba(255,255,255,0.12); background: #252b38; color: #dce4f3; border-radius: 8px;
  padding: 8px 16px; cursor: pointer; font-size: 12px;
}
.modal-actions .modal-btn:hover { background: #2b3241; }
.modal-actions .modal-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.modal-actions .modal-btn.primary:hover { background: var(--accent-dark); }
.modal-actions .modal-btn.danger { color: #ffb4b4; border-color: rgba(255,180,180,0.3); }
.modal-actions .modal-btn.danger:hover { background: rgba(255,180,180,0.12); }

/* ── 三段式分段选择（出现页等，风格对齐 zoom-controls）── */
.seg-control {
  display: flex; gap: 2px; background: #252b38;
  border: 1px solid rgba(255,255,255,0.12); border-radius: 8px; padding: 2px;
}
.seg-btn {
  flex: 1; border: none; background: transparent; color: #95a0b5;
  font-size: 11px; padding: 6px 2px; border-radius: 6px; cursor: pointer;
  white-space: nowrap; text-align: center;
}
.seg-btn:hover { color: #dce4f3; }
.seg-btn.active { background: var(--accent); color: #fff; font-weight: 600; }

/* ── 二维码样式瓷贴（真实 mini 码缩略图）── */
.qr-style-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.qr-style-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 2px 5px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.12); background: #252b38; color: #95a0b5;
  font-size: 11px; line-height: 1.2;
}
.qr-style-tile:hover { background: #2b3241; color: #dce4f3; }
.qr-style-tile.active {
  border-color: var(--accent); color: #dce4f3;
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
}
.qr-style-shot {
  width: 48px; height: 48px; padding: 2px; border-radius: 6px;
  background: #ffffff; /* 白底模拟纸面，透明底样式也能看清 */
  display: flex; align-items: center; justify-content: center;
}
.qr-style-shot img { width: 100%; height: 100%; object-fit: contain; }
