:root {
  --bg: #f5f6f9;
  --surface: #ffffff;
  --ink: #1b2437;
  --sub: #667085;
  --line: #e4e7ee;
  --accent: #3b6cf6;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefe;
  --danger: #d4351c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; height: 56px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; }
.topbar nav { display: flex; align-items: center; gap: 18px; font-size: 14px; color: var(--sub); }
.topbar nav a:not(.btn):hover { color: var(--ink); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; transition: background .12s, border-color .12s, transform .05s; white-space: nowrap; }
.btn:hover { background: #f1f3f8; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #2f5ae0; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--sub); }
.btn-danger { color: var(--danger); }
.icon-btn { width: 28px; height: 28px; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--sub); display: inline-grid; place-items: center; font-size: 14px; padding: 0; }
.icon-btn:hover { background: #eef0f6; color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }

/* generic page */
.page { max-width: 1080px; margin: 0 auto; padding: 40px 24px 80px; }
.page h1 { font-size: 28px; letter-spacing: -.02em; margin: 0 0 6px; }
.page .lead { color: var(--sub); margin: 0 0 28px; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { justify-content: space-between; }

/* library */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.pcard .thumb { display: block; width: 100%; cursor: pointer; background: #e9ecf3; overflow: hidden; }
.pcard .meta { padding: 14px 16px 6px; }
.pcard .meta strong { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .meta span { color: var(--sub); font-size: 13px; }
.pcard .actions { padding: 8px 12px 12px; display: flex; gap: 6px; }
.empty { text-align: center; padding: 72px 24px; background: var(--surface); border: 1px dashed #c9cfdb; border-radius: var(--radius); }
.empty h2 { margin: 0 0 8px; font-size: 20px; }
.empty p { color: var(--sub); margin: 0 0 22px; }
.notice { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; font-size: 13.5px; color: #274bb5; }
.notice.warn { background: #fff4e5; color: #8a4b00; }

/* new */
.new-wrap { display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; align-items: start; }
.drop { border: 2px dashed #c3cadb; border-radius: var(--radius); background: var(--surface); padding: 34px 20px; text-align: center; cursor: pointer; transition: border-color .12s, background .12s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { display: block; font-size: 16px; margin-bottom: 4px; }
.drop span { color: var(--sub); font-size: 13.5px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font-size: 15px; }
label.f { display: block; font-size: 12.5px; font-weight: 600; color: var(--sub); margin-bottom: 10px; }
label.f > span { display: block; margin-bottom: 4px; }
.in, textarea.in, select.in { width: 100%; border: 1px solid #d5dae6; border-radius: 8px; padding: 8px 10px; background: #fff; font-size: 14px; color: var(--ink); font-weight: 400; }
textarea.in { resize: vertical; line-height: 1.5; min-height: 70px; }
.in:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(59,108,246,.15); }
.steps { margin: 0; padding-left: 20px; color: var(--sub); font-size: 14px; }
.steps li { margin-bottom: 6px; }
.steps b { color: var(--ink); }
.privacy { font-size: 12.5px; color: var(--sub); margin-top: 10px; }

/* editor */
.editor { display: grid; grid-template-columns: 440px 1fr; height: calc(100vh - 56px); }
.panel { overflow-y: auto; padding: 16px; border-right: 1px solid var(--line); background: #fafbfd; display: flex; flex-direction: column; gap: 14px; }
.stage-wrap { overflow-y: auto; padding: 0 28px 60px; }
.stage-head { position: sticky; top: 0; z-index: 5; margin: 0 -28px 18px; padding: 12px 28px; background: rgba(245,246,249,.94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stage-head .title { flex: 1; min-width: 180px; font-weight: 700; font-size: 17px; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 6px 8px; }
.stage-head .title:hover, .stage-head .title:focus { background: #fff; border-color: #d5dae6; outline: none; }
.save-state { font-size: 12.5px; color: var(--sub); min-width: 84px; text-align: right; }
.stage { --k: .6; display: flex; flex-direction: column; gap: 22px; align-items: center; }
.slide-card { margin: 0; position: relative; }
.slide-card .no { position: absolute; left: -2px; top: -22px; font-size: 12px; color: var(--sub); }
.frame { width: calc(1280px * var(--k)); height: calc(720px * var(--k)); background: #fff; border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); cursor: pointer; border: 1px solid rgba(16,24,40,.08); }
.frame > .pm-slide { transform: scale(var(--k)); transform-origin: 0 0; }
.slide-card:hover .frame { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.tip { font-size: 13px; }

.sec { border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-bottom: 8px; }
.sec > summary, .entry > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 9px 10px; cursor: pointer; user-select: none; }
.sec > summary::-webkit-details-marker, .entry > summary::-webkit-details-marker { display: none; }
.sec > summary .caret, .entry > summary .caret { color: var(--sub); transition: transform .12s; font-size: 11px; width: 12px; }
details[open] > summary .caret { transform: rotate(90deg); }
.sec > summary .name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec > summary .count { font-size: 12px; color: var(--sub); }
.sec.off > summary .name { color: #9aa3b5; text-decoration: line-through; }
.sec-body { padding: 4px 12px 12px; border-top: 1px solid var(--line); }
.entry { border: 1px solid var(--line); border-radius: 9px; margin: 8px 0; background: #fcfcfe; }
.entry > summary .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; }
.entry > summary .name em { color: #9aa3b5; font-style: normal; font-weight: 400; }
.entry-body { padding: 4px 10px 10px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hint { font-size: 12.5px; color: var(--sub); margin: 4px 0 10px; }
.switch { position: relative; width: 34px; height: 20px; flex: none; }
.switch input { appearance: none; position: absolute; inset: 0; margin: 0; background: #cfd5e2; border-radius: 20px; cursor: pointer; transition: background .15s; }
.switch input:checked { background: var(--accent); }
.switch::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; pointer-events: none; }
.switch:has(input:checked)::after { transform: translateX(14px); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatch span { display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; border: 1px solid var(--line); border-radius: 20px; font-size: 13px; background: #fff; }
.swatch i { width: 16px; height: 16px; border-radius: 50%; display: block; }
.swatch input:checked + span { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,108,246,.2); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: 0 0 0 0 rgba(59,108,246,0); } }

#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #1b2437; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: min(520px, 92vw); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); }

@media (max-width: 960px) {
  .new-wrap { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; height: auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); max-height: none; overflow: visible; }
  .stage-wrap { overflow: visible; padding: 0 12px 60px; }
  .stage-head { margin: 0 -12px 18px; padding: 10px 12px; position: static; }
  .topbar { padding: 0 14px; }
}
