* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  color: #1f2430;
  background: #f4f5f7;
}
a { color: #1565c0; text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: #8a8f99; font-weight: normal; }

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #1f2430; color: #fff; padding: 12px 20px;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 18px; }
.topbar nav a { color: #cfd3dc; margin-left: 16px; }
.topbar nav a:hover { color: #fff; }

.container { max-width: 1180px; margin: 24px auto; padding: 0 20px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 20px 0 10px; }

.error { background: #fdecea; color: #b71c1c; padding: 10px 14px; border-radius: 6px; }
.warn { background: #fff8e1; color: #8a6d00; padding: 8px 12px; border-radius: 6px; font-size: 14px; }
.hint { color: #6b7280; line-height: 1.6; }
.hint.small { font-size: 13px; margin: 4px 0 10px; }

/* buttons */
.btn, button {
  display: inline-block; cursor: pointer; border: 1px solid #c4c9d4;
  background: #fff; color: #1f2430; padding: 9px 16px; border-radius: 6px;
  font-size: 14px; font-family: inherit;
}
.btn:hover, button:hover { background: #f0f1f4; text-decoration: none; }
.btn.primary, button.primary { background: #1565c0; border-color: #1565c0; color: #fff; }
.btn.primary:hover, button.primary:hover { background: #0d4d9c; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn.danger, button.danger { background: #b71c1c; border-color: #b71c1c; color: #fff; }
.btn.danger:hover, button.danger:hover { background: #8e1414; }
.btn.small, button.small { padding: 4px 10px; font-size: 13px; }

/* login */
.login-box { max-width: 360px; margin: 60px auto; background: #fff; padding: 32px;
  border-radius: 10px; box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.login-box input { width: 100%; padding: 11px; font-size: 15px; border: 1px solid #c4c9d4;
  border-radius: 6px; margin-bottom: 12px; }
.login-box button { width: 100%; }

/* upload */
.upload-form { background: #fff; padding: 24px; border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.05); max-width: 560px; }
.filedrop { display: block; border: 2px dashed #c4c9d4; border-radius: 8px;
  padding: 28px; text-align: center; cursor: pointer; margin-bottom: 16px; color: #6b7280; }
.filedrop:hover { border-color: #1565c0; color: #1565c0; }
.filedrop input { display: none; }

/* editor */
.editor-layout { display: flex; gap: 20px; align-items: flex-start; }
.pages { flex: 1; min-width: 0; }
.page { background: #fff; padding: 12px; border-radius: 8px; margin-bottom: 16px;
  box-shadow: 0 1px 6px rgba(0,0,0,.05); }
.page-label { font-size: 13px; color: #6b7280; margin-bottom: 8px; }
.page-img-wrap { position: relative; display: inline-block; width: 800px; max-width: 100%;
  line-height: 0; }
.page-img { display: block; width: 100%; user-select: none; }
.overlay { position: absolute; inset: 0; cursor: crosshair; }

/* 가로 구분선 */
.divider { position: absolute; left: 0; right: 0; height: 11px; margin-top: -5px;
  cursor: row-resize; z-index: 3; }
.divider::before { content: ""; position: absolute; left: 0; right: 0; top: 4px; height: 2px;
  background: #e6007a; }
.divider-del { position: absolute; right: 4px; top: -4px; width: 18px; height: 18px;
  line-height: 17px; text-align: center; background: #e6007a; color: #fff; border-radius: 50%;
  font-size: 13px; cursor: pointer; z-index: 4; }
/* 잘릴 구간(시각화) — 클릭이 통과하도록 pointer-events 없음 */
.band { position: absolute; left: 0; right: 0; pointer-events: none; box-sizing: border-box;
  border-top: 1px solid rgba(230,0,122,.45); z-index: 1; }
.band.alt { background: rgba(230,0,122,.06); }
.band-badge { position: absolute; left: 6px; top: 6px; background: #e6007a; color: #fff;
  font-size: 12px; line-height: 16px; padding: 1px 8px; border-radius: 10px; pointer-events: none; }

/* panel */
.panel { width: 320px; flex: none; background: #fff; padding: 18px; border-radius: 8px;
  box-shadow: 0 1px 6px rgba(0,0,0,.05); position: sticky; top: 16px; }
.panel label { display: block; font-size: 13px; color: #4b5160; margin-bottom: 12px; }
.panel label input { display: block; width: 100%; margin-top: 4px; padding: 8px;
  border: 1px solid #c4c9d4; border-radius: 6px; font-size: 14px; }
.count { background: #1565c0; color: #fff; border-radius: 10px; font-size: 13px; padding: 1px 8px; }

.region-list { list-style: none; padding: 0; margin: 0 0 14px; max-height: 360px; overflow-y: auto; }
.region-item { border: 1px solid #e3e6ec; border-radius: 6px; padding: 8px; margin-bottom: 8px; }
.region-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 14px; }
.region-head .del { margin-left: auto; padding: 2px 8px; font-size: 12px; color: #b71c1c; border-color: #f0c4c0; }
.region-item input { width: 100%; padding: 6px; border: 1px solid #c4c9d4; border-radius: 5px; font-size: 13px; }
.link-control select { width: 100%; padding: 6px; border: 1px solid #c4c9d4; border-radius: 5px; font-size: 13px; background: #fff; }
.link-control .link-custom { margin-top: 6px; }
#generate-btn { width: 100%; }
.status { font-size: 13px; margin: 10px 0 0; min-height: 18px; }
.status.busy { color: #1565c0; }
.status.error { color: #b71c1c; }

/* result */
.result-meta { display: flex; flex-wrap: wrap; gap: 16px; color: #4b5160; font-size: 14px; margin-bottom: 16px; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
#source { width: 100%; font-family: "Consolas", "D2Coding", monospace; font-size: 13px;
  border: 1px solid #c4c9d4; border-radius: 6px; padding: 12px; background: #fbfbfd; }
.preview { width: 100%; max-width: 840px; height: 600px; border: 1px solid #c4c9d4;
  border-radius: 6px; background: #fff; }

/* history */
.history { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden;
  box-shadow: 0 1px 6px rgba(0,0,0,.05); }
.history th, .history td { text-align: left; padding: 10px 14px; border-bottom: 1px solid #eef0f4; font-size: 14px; }
.history th { background: #f7f8fa; color: #4b5160; }
