* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft JhengHei", system-ui, sans-serif;
  background: #f2f4f7;
  color: #1f2933;
}
main { max-width: 960px; margin: 24px auto 80px; padding: 0 16px; }

#topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #1e3a5f; color: #fff; padding: 10px 24px;
}
#topbar h1 { font-size: 18px; margin: 0; }
#topbar .muted { color: #b9c8d8; }

.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.space-between { justify-content: space-between; }
.muted { color: #6b7a89; font-size: 14px; }
.error { color: #c62828; min-height: 1.2em; }
.center { text-align: center; }

.panel { background: #fff; border-radius: 10px; padding: 24px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.panel.narrow { max-width: 360px; margin: 60px auto; }
.panel h2 { margin-top: 0; }

label { display: block; margin: 12px 0; font-size: 14px; }
input, textarea {
  width: 100%; padding: 8px 10px; margin-top: 4px;
  border: 1px solid #cbd5e0; border-radius: 6px; font: inherit;
}
.row input { width: auto; margin-top: 0; }
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus { outline: 2px solid #3474b7; border-color: transparent; }

.btn {
  padding: 8px 16px; border: 1px solid transparent; border-radius: 6px;
  font: inherit; cursor: pointer; background: #e2e8f0; color: #1f2933;
}
.btn:hover { filter: brightness(.95); }
.btn.primary { background: #2563ab; color: #fff; }
.btn.ghost { background: transparent; color: inherit; border-color: currentColor; }
#topbar .btn.ghost { color: #fff; }
.btn.danger { background: #fdecea; color: #c62828; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.active { background: #1e7d44; color: #fff; }

/* 手冊列表 */
.manual-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 4px; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap;
}
.manual-row .title { font-weight: 600; }
.chip { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: #e2e8f0; }
.chip.published { background: #d9f2e3; color: #1e7d44; }

/* 步驟卡片 */
.step-card {
  background: #fff; border-radius: 10px; padding: 18px;
  margin-bottom: 24px; box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.step-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.step-number { font-weight: 700; color: #2563ab; }
.step-title-input { font-size: 16px; font-weight: 600; }

.img-wrap { position: relative; margin: 12px 0; border: 1px solid #e2e8f0; border-radius: 6px; overflow: hidden; }
.img-wrap img { display: block; width: 100%; height: auto; }
.img-wrap.adding { cursor: crosshair; outline: 3px solid #1e7d44; }

.ann {
  position: absolute; transform: translate(-50%, -50%);
  border: 3px solid #ff3b30; border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(255,255,255,.7);
}
.ann.default-marker { border-color: #ff9500; }
.ann.editable { pointer-events: auto; cursor: move; touch-action: none; }
.ann.selected { box-shadow: 0 0 0 3px rgba(37,99,171,.85); }
.ann-delete {
  position: absolute; top: -12px; right: -12px;
  width: 22px; height: 22px; border-radius: 50%; border: none;
  background: #c62828; color: #fff; font-size: 14px; line-height: 1;
  cursor: pointer; pointer-events: auto;
}
.ann-resize {
  position: absolute; right: -7px; bottom: -7px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #2563ab; border: 2px solid #fff;
  cursor: nwse-resize; pointer-events: auto; touch-action: none;
}

/* 遮罩（左上角定位，不做置中位移） */
.ann-mask {
  position: absolute;
  background: rgba(120,120,120,.45);
  backdrop-filter: blur(6px);
  border: 2px dashed #555;
  pointer-events: auto;
}
.ann-mask.preview { pointer-events: none; background: rgba(37,99,171,.25); border-color: #2563ab; }

.drag-handle { cursor: grab; color: #9aa8b5; font-size: 18px; user-select: none; }
.step-card.dragging { opacity: .5; }

.palette { display: inline-flex; gap: 6px; align-items: center; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px #cbd5e0;
  cursor: pointer; padding: 0;
}

/* 檢視頁 */
.viewer-body main { max-width: 860px; }
.viewer-step { background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 28px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.viewer-step h3 { margin: 0 0 10px; }
.viewer-step .desc { white-space: pre-wrap; margin-top: 10px; }
