:root {
  --blue: #2f5bff; --blue-d: #1d43e0; --blue-50: #eef2ff; --blue-100: #dfe6ff;
  --ink: #111827; --sub: #4b5563; --muted: #8a93a3; --line: #e7eaf0; --bg: #f7f8fb; --card: #fff;
  --green: #16a34a; --red: #e11d48; --amber: #d97706;
  --rail: 60px; --side: 250px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Pretendard, -apple-system, "Malgun Gothic", sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; word-break: keep-all; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.layout { display: grid; grid-template-columns: var(--rail) var(--side) 1fr; height: 100vh; }
/* 아이콘 레일 */
.rail { background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 6px; }
.rail .home { margin-bottom: 10px; }
.rail .home img { width: 40px; display: block; }
.rail a, .rail button { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--sub); border: 0; background: none; position: relative; }
.rail a:hover, .rail button:hover { background: var(--bg); }
.rail a.on { background: var(--blue-50); color: var(--blue); }
.rail .spacer { flex: 1; }
.rail a[data-tip]:hover::after, .rail button[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 48px; white-space: nowrap; background: var(--ink); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; z-index: 30; }
/* 세부 메뉴 */
.side { background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; }
.side h2 { font-size: 16px; margin: 0; padding: 20px 20px 14px; border-bottom: 1px solid var(--line); }
.side nav { padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px; color: var(--sub); font-weight: 500; }
.side nav a:hover { background: var(--bg); }
.side nav a.on { background: var(--blue-50); color: var(--ink); font-weight: 600; }
.side nav hr { border: 0; border-top: 1px solid var(--line); margin: 10px 4px; }
.side nav .pill { margin-left: auto; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--blue-50); color: var(--blue); }
.side .foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--line); }
.budget { background: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 13px; }
.budget .bar { height: 6px; border-radius: 6px; background: var(--line); margin-top: 8px; overflow: hidden; }
.budget .bar i { display: block; height: 100%; background: var(--blue); }
.budget small { color: var(--muted); }
/* 본문 */
main { overflow-y: auto; padding: 24px 32px 60px; }
.head { display: flex; align-items: center; gap: 12px; margin: 6px 0 18px; flex-wrap: wrap; }
.head h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
.head .meta { color: var(--muted); font-size: 13px; }
.head .grow { flex: 1; }
.sec { margin: 34px 0 14px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sec h3 { font-size: 18px; margin: 0; letter-spacing: -.02em; }
.sec p { margin: 0; color: var(--muted); font-size: 13px; }
.sec .grow { flex: 1; }
.link { color: var(--muted); background: none; border: 0; font-size: 13px; }
.link:hover { color: var(--ink); }

/* 검색 박스 */
.searchbox { max-width: 1000px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 8px; display: flex; gap: 8px; align-items: center; box-shadow: 0 6px 24px rgba(17,24,39,.04); }
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; }
.seg button { border: 0; background: none; padding: 8px 14px; border-radius: 9px; color: var(--muted); display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.seg button.on { background: #fff; color: var(--blue); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.searchbox .q { flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 8px; color: var(--muted); min-width: 0; }
.searchbox input { border: 0; outline: 0; width: 100%; font-size: 15px; color: var(--ink); background: none; }
.btn { border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; background: var(--blue); color: #fff; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--blue-d); }
.btn.lg { padding: 13px 22px; border-radius: 12px; font-size: 15px; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.soft { background: var(--blue-50); color: var(--blue); }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #fecdd3; }
.btn:disabled { opacity: .5; cursor: default; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 16px 0 0; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; color: var(--sub); display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { border-color: var(--blue-100); color: var(--ink); }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip small { color: var(--blue); font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 18px 0 6px; }
.filters select, .field { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 12px; outline: 0; }
.field:focus, .filters select:focus { border-color: var(--blue); }
textarea.field { resize: vertical; min-height: 80px; width: 100%; }
label.chk { display: inline-flex; gap: 6px; align-items: center; color: var(--sub); }

/* 미디어 카드 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.mcard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; cursor: pointer; transition: box-shadow .15s; }
.mcard:hover { box-shadow: 0 10px 30px rgba(17,24,39,.08); }
.mcard .th { position: relative; aspect-ratio: 4/5; background: #eef0f5 center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.mcard .th .tl { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.badge { font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 7px; background: rgba(17,24,39,.72); color: #fff; display: inline-flex; gap: 4px; align-items: center; }
.badge.top { background: rgba(17,24,39,.8); }
.badge.ad { background: var(--amber); }
.mcard .th .tr { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 8px; background: rgba(17,24,39,.72); color: #fff; display: grid; place-items: center; }
.mcard .th .tr svg { width: 15px; height: 15px; }
.mcard .bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 0; gap: 6px; }
.plat { font-size: 12px; color: var(--sub); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }
.plat i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.mcard .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.mcard .name { font-weight: 600; font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mcard .date { color: var(--muted); font-size: 12px; }
.mcard .stats { display: flex; gap: 10px; color: var(--sub); font-size: 12px; margin-top: 4px; flex-wrap: wrap; }
.mcard .stats span { display: inline-flex; gap: 3px; align-items: center; }
.mcard .stats svg { width: 13px; height: 13px; }
.mcard .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.tag { font-size: 11px; background: var(--bg); color: var(--sub); padding: 2px 7px; border-radius: 6px; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; background: #fff; border: 1px dashed var(--line); border-radius: 16px; line-height: 1.7; }
.empty .btn { margin-top: 12px; }
.loading { color: var(--muted); padding: 30px; text-align: center; }

/* 브랜드 */
.tabs { display: flex; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin: 6px 0 14px; }
.tabs button { flex: 1; border: 0; background: none; padding: 10px; border-radius: 9px; color: var(--muted); }
.tabs button.on { background: var(--blue-50); color: var(--blue); font-weight: 600; }
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 16px; }
.bcard { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.bcard .top { display: flex; align-items: center; gap: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--blue-50) center/cover; display: grid; place-items: center; font-weight: 700; color: var(--blue); flex: none; }
.bcard .nm { font-weight: 700; font-size: 15px; display: flex; gap: 6px; align-items: center; }
.bcard .acc { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.bcard .grow { flex: 1; min-width: 0; }
.bcard .cnt { color: var(--sub); font-size: 13px; white-space: nowrap; }
.bcard h4 { margin: 16px 0 10px; font-size: 13px; color: var(--sub); }
.strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.strip .th { aspect-ratio: 4/5; border-radius: 10px; background: #eef0f5 center/cover; cursor: pointer; position: relative; }
.strip .th .badge { position: absolute; left: 6px; top: 6px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 10px 0 20px; }
.kv div { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.kv b { display: block; font-size: 22px; margin-top: 4px; letter-spacing: -.02em; }
.kv span { color: var(--muted); font-size: 12px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin-bottom: 16px; }
.panel h4 { margin: 0 0 12px; font-size: 15px; }
.hbar { display: grid; grid-template-columns: 120px 1fr 60px; gap: 10px; align-items: center; margin: 7px 0; font-size: 13px; }
.hbar .t { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.hbar .t i { display: block; height: 100%; background: var(--blue); border-radius: 6px; }
.hbar .n { text-align: right; color: var(--sub); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.md { line-height: 1.75; color: var(--sub); }
.md h1, .md h2, .md h3 { color: var(--ink); font-size: 16px; margin: 18px 0 6px; }
.md ul { padding-left: 18px; }
table.t { width: 100%; border-collapse: collapse; background: #fff; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
table.t th, table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
table.t th { background: var(--bg); color: var(--sub); font-weight: 600; }

/* 모달 */
.modal { position: fixed; inset: 0; background: rgba(17,24,39,.5); display: grid; place-items: center; z-index: 50; padding: 20px; }
.dlg { background: #fff; border-radius: 18px; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.dlg.wide { width: min(980px, 100%); }
.dlg header { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); gap: 10px; }
.dlg header h3 { margin: 0; font-size: 17px; flex: 1; }
.dlg .x { border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; }
.dlg .in { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg .in label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: var(--sub); }
.dlg footer { padding: 14px 22px 20px; display: flex; gap: 8px; justify-content: flex-end; }
.detail { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 22px; padding: 22px; }
.detail .pic { border-radius: 14px; background: #eef0f5 center/contain no-repeat; aspect-ratio: 4/5; }
.detail .cap { white-space: pre-wrap; line-height: 1.7; color: var(--sub); max-height: 260px; overflow-y: auto; background: var(--bg); padding: 12px 14px; border-radius: 12px; }
.detail dl { display: grid; grid-template-columns: 90px 1fr; gap: 8px 12px; margin: 0; font-size: 13px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 80; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.jobs { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.job { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.job b { display: block; margin-bottom: 2px; }
.job.error, .job.budget { border-color: #fecdd3; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--blue-100); border-top-color: var(--blue); border-radius: 50%; animation: s 1s linear infinite; vertical-align: -2px; }
@keyframes s { to { transform: rotate(360deg); } }

/* 소재 제작 */
.hero-ai { background: linear-gradient(90deg, #eef3ff, #f3f6ff); border-radius: 0; margin: -24px -32px 20px; padding: 36px 32px; text-align: center; border-bottom: 1px solid var(--line); }
.hero-ai p { font-size: 19px; line-height: 1.6; margin: 0 0 16px; font-weight: 500; }
.hero-ai em { font-style: normal; color: var(--blue); }
.hero-ai .row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.ccard { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; }
.ccard .th { aspect-ratio: 1; background: #eef0f5 center/cover; display: grid; place-items: center; color: var(--muted); }
.ccard .body { padding: 10px 12px; }
.ccard .body b { display: block; font-size: 14px; }
.ccard .body small { color: var(--muted); }
.list .ccard { display: grid; grid-template-columns: 70px 1fr; }
.list .ccard .th { aspect-ratio: 1; }
.list.grid { grid-template-columns: 1fr; }
.view-toggle { display: flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.view-toggle button { border: 0; background: none; padding: 6px 8px; border-radius: 7px; color: var(--muted); display: grid; }
.view-toggle button.on { background: var(--bg); color: var(--ink); }
.reflist { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; max-height: 240px; overflow-y: auto; }
.reflist .th { aspect-ratio: 4/5; border-radius: 8px; background: #eef0f5 center/cover; cursor: pointer; border: 3px solid transparent; }
.reflist .th.on { border-color: var(--blue); }
/* 에디터 */
.editor { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.stage-wrap { background: #e9ecf3; border-radius: 16px; padding: 24px; display: grid; place-items: center; min-height: 500px; }
.stage { position: relative; background: #3b6ff0 center/cover no-repeat; box-shadow: 0 20px 50px rgba(0,0,0,.18); overflow: hidden; user-select: none; }
.stage .ly { position: absolute; cursor: move; white-space: pre-wrap; line-height: 1.25; outline: 1px dashed transparent; padding: 2px 4px; }
.stage .ly.sel { outline-color: #fff; box-shadow: 0 0 0 1px var(--blue); }
.stage .ly.button { border-radius: 999px; padding: .5em 1.2em; font-weight: 700; }
.props { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; }
.props label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--sub); font-weight: 600; }
.props .row { display: flex; gap: 8px; }
.props .row > * { flex: 1; }
.props input[type=color] { height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* 로그인 */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(180deg, #689afd, #3b6ff0); padding: 20px; }
.login form { background: #fff; border-radius: 20px; padding: 34px 30px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; box-shadow: 0 30px 80px rgba(11,42,143,.35); }
.login img { height: 44px; align-self: center; margin-bottom: 6px; }
.login h1 { font-size: 18px; text-align: center; margin: 0 0 10px; }
.login .err { color: var(--red); font-size: 13px; min-height: 18px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: var(--rail) 1fr; }
  .side { display: none; }
  main { padding: 18px 16px 60px; }
  .bgrid { grid-template-columns: 1fr; }
  .detail { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; }
  .hero-ai { margin: -18px -16px 18px; }
  .searchbox { flex-wrap: wrap; }
}
