:root {
  --bg: #f4f5f9;
  --panel: #ffffff;
  --border: #e5e7ee;
  --border-soft: #eef0f5;
  --text: #1a1d29;
  --muted: #6b7280;
  --muted-soft: #9aa1b2;
  --primary: #3b5bfd;
  --primary-hover: #2c46d6;
  --primary-soft: #eef1ff;
  --success: #12805c;
  --success-soft: #e3f6ee;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.07), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.12);
  --header-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  background: radial-gradient(circle at 12% -10%, #eef1ff 0%, var(--bg) 42%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top navigation ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 26px;
  height: var(--header-h);
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.topbar .brand .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #6a8bff);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  flex: none;
}
.topbar nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
}
.topbar nav a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  transition: color .15s ease, background .15s ease;
}
.topbar nav a:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.topbar nav a.active { color: var(--primary); background: var(--primary-soft); }
.topbar .userbox {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  flex: none;
}
.topbar .userbox .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex: none;
}
.topbar .userbox a { color: var(--muted); font-weight: 600; }
.topbar .userbox a:hover { color: var(--danger); text-decoration: none; }

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ---------- Page header ---------- */
.page-header,
.post-page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-kicker,
.post-page-kicker {
  margin: 0 0 7px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.page-header h1,
.post-page-heading h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.03em; }
.page-header p,
.post-page-description { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.page-header-actions,
.post-page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

h1 { font-size: 22px; margin: 0 0 16px; letter-spacing: -0.02em; }
h2 { font-size: 16px; margin: 0 0 14px; font-weight: 700; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.fixed-assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.fixed-asset-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: var(--bg);
}
.fixed-asset-slot-label { font-size: 12px; color: var(--muted); margin: 0 0 4px; text-transform: uppercase; letter-spacing: .04em; }
.fixed-asset-title { font-size: 16px; font-weight: 700; margin: 0 0 12px; }
.fixed-asset-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease, transform .05s ease, border-color .15s ease;
  box-shadow: 0 1px 2px rgba(59, 91, 253, 0.25);
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--panel); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn.secondary:hover { background: var(--bg); border-color: #d7dbe4; }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); box-shadow: none; }
.btn.danger:hover { background: #fbd7d8; border-color: #fbd7d8; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; color: #384152; }
.form-row input[type=text],
.form-row input[type=password],
.form-row input[type=url],
.form-row input[type=number],
.form-row select,
select.input-sm,
input.input-sm {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fbfbfd;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background .15s ease;
}
.form-row input:focus,
.form-row select:focus,
select.input-sm:focus,
input.input-sm:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
  background: #fff;
}
input.input-sm, select.input-sm { width: auto; min-height: 38px; }

.post-editor-form { padding-bottom: 12px; }
.post-settings-panel,
.download-settings-panel,
.editor-panel {
  box-shadow: var(--shadow-sm);
}
.panel-heading,
.editor-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-soft);
}
.panel-heading h2,
.editor-panel-header h2 { margin: 0 0 5px; font-size: 17px; }
.panel-heading p,
.editor-panel-header p,
.form-submit-bar p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.post-meta-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(120px, 0.65fr) minmax(140px, 0.8fr);
  gap: 16px;
}
.post-meta-grid .form-row,
.download-settings-grid .form-row { margin-bottom: 0; }
.download-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, 1fr);
  gap: 24px;
  align-items: start;
}
.field-help {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type=color] {
  width: 48px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.color-field input[type=text] {
  width: 120px;
  flex: 0 0 120px;
  font-family: "Consolas", "D2Coding", monospace;
}
.download-color-preview {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 18px;
  font-weight: 700;
}

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; }
th {
  color: var(--muted);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #fafbfd;
  border-bottom: 1px solid var(--border);
}
tbody tr { transition: background .1s ease; }
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges & messages ---------- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--success-soft);
  color: var(--success);
}
.badge.draft { background: #f1f2f6; color: var(--muted-soft); }

.error-box,
.msg-box.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f7c9ca;
  border-radius: 8px;
  padding: 11px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}
.msg-box.success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid #bfe8d6;
  border-radius: 8px;
  padding: 11px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}

/* ---------- Login ---------- */
.login-wrap { max-width: 380px; margin: 11vh auto 0; }
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
  font-weight: 800;
  font-size: 17px;
  color: var(--text);
}
.login-brand .mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #6a8bff);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  box-shadow: var(--shadow-md);
}
.login-wrap .panel { box-shadow: var(--shadow-lg); border-radius: 16px; padding: 34px 30px; }
.login-wrap h1 { text-align: center; font-size: 19px; margin-bottom: 22px; }

.actions-row { display: flex; gap: 8px; margin-bottom: 20px; align-items: center; flex-wrap: wrap; }
.category-filter { margin-left: auto; }
.inline-form { display: inline; }
.muted-note { font-size: 13px; color: var(--muted); }

/* ---------- Editor ---------- */
.editor-panel { padding-bottom: 20px; }
.editor-panel-header { align-items: center; }
.editor-view-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.editor-toolbar-extra {
  display: flex;
  align-items: center;
  gap: 12px 18px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8f9fb;
  flex-wrap: wrap;
}
.editor-tool-group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.editor-tool-label { color: #4b5563; font-size: 12px; font-weight: 700; white-space: nowrap; }
.editor-tool-help,
.editor-file-status { color: var(--muted); font-size: 12px; line-height: 1.4; }
.editor-file-status { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-jump-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}
.editor-jump-controls .btn { padding: 6px 10px; font-size: 12px; }
.editor-scroll-note { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
#quill-editor {
  height: clamp(460px, 68vh, 760px);
  overflow: hidden;
  background: #fff;
  border: 2px solid #000;
  border-radius: 0 0 6px 6px;
}
#quill-editor .ql-editor {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 50px;
  border: 0;
  box-sizing: border-box;
  font-family: "나눔바른고딕", "Nanum Barun Gothic", "맑은 고딕", "Malgun Gothic", "돋움", sans-serif;
  font-size: 16px;
  color: #111;
}

.ql-editor [data-mailing="newsletter"] { margin: 0 0 24px; font-size: 20px; line-height: 1.5; }
.ql-editor [data-mailing="hero"] { margin: 0 0 30px; }
.ql-editor [data-mailing="hero"] img { width: 750px; max-width: 100%; height: auto; }
.ql-editor [data-mailing="headline"] { margin: 0; font-size: 24px; line-height: 1.8; }
.ql-editor [data-mailing="divider"] {
  margin: 42px 0;
  padding: 0;
  height: 2px;
  min-height: 2px;
  border-top: 2px solid #000;
  line-height: 1px;
  color: transparent;
}
.ql-editor [data-mailing="lead"],
.ql-editor [data-mailing="meta"],
.ql-editor [data-mailing="text"] { margin: 0 0 28px; line-height: 1.8; }
.ql-editor [data-mailing="lead"] { margin-bottom: 0; }
.ql-editor [data-mailing="meta"] { margin-bottom: 40px; }
.ql-editor [data-mailing="highlight"] {
  display: table;
  margin: 0 auto;
  padding: 5px 10px;
  background: #cedb00;
  color: #000;
  font-size: 22px;
  line-height: 1.8;
}
.ql-editor [data-mailing="highlight"] + [data-mailing="text"],
.ql-editor [data-mailing="highlight"] + [data-mailing="image"],
.ql-editor [data-mailing="highlight"] + [data-mailing="images"] { margin-top: 40px; }
.ql-editor [data-mailing="image"],
.ql-editor [data-mailing="images"] { margin: 28px 0; line-height: 1; }
.ql-editor [data-mailing="image"] img,
.ql-editor [data-mailing="images"] img { max-width: 100%; height: auto; }
.ql-editor [data-mailing="caption"] { margin: -16px 0 28px; color: #9b9b9b; font-size: 13px; line-height: 1.8; }
.ql-editor [data-mailing="section-title"] { margin: 30px 0; color: #cedb00; font-size: 30px; line-height: 1.8; }
.ql-editor [data-mailing="info-row"] { width: 420px; max-width: 100%; margin: 4px auto; line-height: 1.6; }
.ql-editor [data-mailing="synopsis"] { margin: 0 0 12px; line-height: 1.8; }
.ql-editor [data-mailing="about-title"] { margin: 30px 0 18px; text-align: center; line-height: 1.7; }
.ql-editor [data-mailing="about-row"] {
  width: 560px;
  max-width: calc(100% - 32px);
  margin: 4px auto;
  line-height: 1.7;
}
.ql-editor [data-mailing="about-list"] {
  width: 560px;
  max-width: calc(100% - 32px);
  margin: 8px auto;
  padding-left: 28px;
  line-height: 1.7;
  box-sizing: border-box;
}
.ql-editor img { cursor: pointer; }
.ql-editor img.image-link-selected { outline: 3px solid #3b5bfd; outline-offset: 3px; }
.editor-panel .ql-toolbar.ql-snow {
  border-radius: 6px 6px 0 0;
  background: #f8f9fb;
  border-color: #cfd4dc;
}
.editor-panel .ql-container.ql-snow { border-color: #000; }

@media (max-width: 640px) {
  .ql-editor [data-mailing="about-row"],
  .ql-editor [data-mailing="about-list"] { width: 100%; }
}

.ql-snow .ql-picker.ql-size .ql-picker-label::before,
.ql-snow .ql-picker.ql-size .ql-picker-item::before {
  content: attr(data-value) !important;
}
.ql-snow .ql-picker.ql-size .ql-picker-label { width: 60px; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 34, 0.45);
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  width: min(720px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 22px;
  box-shadow: var(--shadow-lg);
}
.modal-box textarea {
  flex: 1;
  min-height: 320px;
  font-family: "Consolas", "D2Coding", monospace;
  font-size: 13px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  white-space: pre;
}
.image-link-modal-box { width: min(620px, 92vw); }
.image-link-modal-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.copy-status { font-size: 13px; color: var(--muted); margin-right: auto; align-self: center; }

.form-submit-bar {
  position: sticky;
  bottom: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(210, 214, 222, 0.95);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}
.form-submit-bar > div { display: flex; align-items: center; gap: 8px; }

@media (max-width: 760px) {
  .topbar { padding: 0 16px; gap: 14px; }
  .container { padding: 24px 16px 48px; }
  .page-header,
  .post-page-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }
  .page-header-actions,
  .post-page-actions { width: 100%; justify-content: flex-start; }
  .post-meta-grid,
  .download-settings-grid { grid-template-columns: 1fr; gap: 14px; }
  .editor-panel-header { align-items: flex-start; flex-direction: column; }
  .editor-toolbar-extra { align-items: flex-start; flex-direction: column; }
  .editor-tool-group { width: 100%; flex-wrap: wrap; }
  .editor-file-status { max-width: 100%; }
  .editor-jump-controls {
    width: 100%;
    margin-left: 0;
    padding: 8px 0 0;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  #quill-editor { height: 62vh; min-height: 400px; }
  #quill-editor .ql-editor { padding: 24px; }
  .form-submit-bar { align-items: stretch; flex-direction: column; }
  .form-submit-bar > div { justify-content: flex-end; }
}

.share-link-row { display: flex; gap: 8px; align-items: center; }
.share-link-row input[type=text] {
  flex: 1;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
}
