/* 글꼴: Pretendard (OFL, public/fonts/LICENSE.txt) */
@font-face { font-family: "Pretendard"; font-weight: 400; font-display: swap; src: url("/fonts/Pretendard-Regular.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 500; font-display: swap; src: url("/fonts/Pretendard-Medium.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 600; font-display: swap; src: url("/fonts/Pretendard-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 700; font-display: swap; src: url("/fonts/Pretendard-Bold.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 800; font-display: swap; src: url("/fonts/Pretendard-ExtraBold.woff2") format("woff2"); }

:root {
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f9fafb;
  --danger: #ef4444;
  --ok: #16a34a;
  --warn: #d97706;
  --ig: linear-gradient(45deg, #f58529, #dd2a7b, #8134af, #515bd4);
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { font-size: 17px; }
body {
  margin: 0;
  background: #ffffff;
  color: var(--ink);
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 17px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
  padding-bottom: 64px; /* 아래 상태 줄 자리 */
}

h1, h2, h3 { line-height: 1.3; }
h2 { font-size: 22px; margin: 0 0 16px; }
h3 { font-size: 19px; margin: 0 0 12px; }

/* 머리 부분 */
.top { position: sticky; top: 0; z-index: 10; background: #fff; border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1120px; margin: 0 auto; padding: 14px 24px 6px; }
.brand {
  margin: 0; font-size: 26px; font-weight: 800;
  background: var(--ig); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tabs { display: flex; gap: 4px; max-width: 1120px; margin: 0 auto; padding: 0 16px; overflow-x: auto; scrollbar-width: thin; }
.tab {
  position: relative; flex: 0 0 auto; border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--muted); padding: 12px 14px; min-height: 48px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 4px; border-radius: 4px; background: var(--ig);
}

/* 본문 */
.page { max-width: 1120px; margin: 0 auto; padding: 24px; }
.panel-lead { margin: 0 0 24px; font-size: 19px; font-weight: 600; }
.panel-body > * + * { margin-top: 32px; }

/* 공통 부품 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 20px; border-radius: var(--radius);
  border: 1px solid #d1d5db; background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { border: 0; background: var(--ig); color: #fff; }
.btn-primary:hover { background: var(--ig); filter: brightness(1.05); }
.btn-danger { border: 1px solid var(--danger); color: var(--danger); background: #fff; }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { border-color: transparent; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 15px; }

.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.card + .card { margin-top: 24px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 15px; color: var(--muted); font-weight: 600; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 14px; font-weight: 600; background: #f3f4f6; color: var(--ink); }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-bad { background: #fee2e2; color: #991b1b; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 15px; background: #fff; }

.empty {
  text-align: center; padding: 56px 24px; border: 2px dashed var(--line); border-radius: 16px; color: var(--muted);
}
.empty small { display: block; margin-top: 8px; font-size: 14px; }

.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.field { margin-bottom: 20px; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: 15px; }
input[type="text"], input[type="number"], input[type="url"], input[type="password"], textarea, select {
  width: 100%; max-width: 560px; min-height: 48px; padding: 10px 14px; border: 1px solid #d1d5db; border-radius: 10px;
  font: inherit; color: var(--ink); background: #fff;
}
textarea { min-height: 120px; resize: vertical; max-width: none; }
input:focus, textarea:focus, select:focus { outline: 3px solid #c4b5fd; outline-offset: 1px; border-color: #8134af; }
.readonly { display: inline-block; padding: 8px 0; font-weight: 600; }
.error { color: var(--danger); font-weight: 600; }
.meta { color: var(--muted); font-size: 14px; margin: 16px 0 0; }

/* 설정 판 */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(17, 24, 39, .45); display: flex; justify-content: center; align-items: flex-start; padding: 32px 16px; overflow-y: auto; }
.sheet { width: 100%; max-width: 640px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.sheet-head h2 { margin: 0; }
.logs { max-height: 280px; overflow: auto; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 14px; white-space: pre-wrap; margin-top: 16px; }

.sep { border: 0; border-top: 1px solid var(--line); margin: 28px 0 20px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin-bottom: 16px; }
.kv span { color: var(--muted); }
.ok-text { color: var(--ok); }
.bad-text { color: var(--danger); }
.ai-result { margin-top: 12px; font-weight: 600; }

/* 아래 상태 줄 */
.status {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; min-height: 44px;
  display: flex; align-items: center; justify-content: center; padding: 8px 16px;
  background: #111827; color: #fff; font-size: 15px; text-align: center;
  transform: translateY(100%); transition: transform .2s;
}
.status.show { transform: translateY(0); }
.status.bad { background: #991b1b; }

@media (max-width: 720px) {
  .top-row { padding: 10px 16px 4px; }
  .brand { font-size: 22px; }
  .page { padding: 16px; }
  .card { padding: 20px; }
  .row > .btn { flex: 1 1 auto; }
  input[type="text"], input[type="number"], input[type="url"], input[type="password"], textarea, select { max-width: none; }
  .split { grid-template-columns: 1fr !important; }
}

/* ① 수집 */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.split3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 20px; }
.scroll-x { overflow-x: auto; margin-top: 16px; }
.warn-text { color: var(--warn); font-weight: 600; }
details.more { margin-bottom: 16px; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 8px 0; }
.swatches { display: flex; gap: 6px; margin: 10px 0; }
.swatch { width: 32px; height: 32px; border-radius: 8px; border: 1px solid rgba(0,0,0,.12); }
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 24px; }
.style-item { border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.style-item.is-active { border: 2px solid #8134af; }
.ref-list { display: grid; gap: 16px; }
.ref-item { padding: 16px; }
.ref-item > summary { display: flex; gap: 16px; cursor: pointer; list-style: none; }
.ref-item > summary::-webkit-details-marker { display: none; }
.ref-thumb { width: 96px; height: 120px; object-fit: cover; border-radius: 10px; flex: 0 0 auto; background: var(--soft); }
.ref-thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); border: 1px dashed var(--line); }
.ref-main { min-width: 0; flex: 1; }
.ref-main .row { gap: 6px; }
.ref-cap { margin: 0 0 8px; font-weight: 600; }
.ref-main .hint { margin: 6px 0 0; }
.ref-body { margin-top: 16px; }
.ref-full { white-space: pre-wrap; font-family: inherit; background: var(--soft); border-radius: 10px; padding: 14px; margin: 0 0 12px; }
.ref-shots { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 12px; }
.ref-shots img { height: 240px; border-radius: 10px; flex: 0 0 auto; }
@media (max-width: 720px) {
  .split3 { grid-template-columns: 1fr; }
}

/* ② 분석 */
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; }
.pattern-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.pattern-grid .card + .card { margin-top: 0; }
.pattern strong { display: block; font-size: 19px; margin: 4px 0 8px; }
.pattern p { margin: 0; }
.pattern-no { font-weight: 800; font-size: 28px; background: var(--ig); -webkit-background-clip: text; background-clip: text; color: transparent; }
.reco { font-weight: 600; margin: 16px 0 0; }
.dna-swatches { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 20px; }
.dna-chip { display: grid; justify-items: center; gap: 4px; }
.dna-chip .swatch { width: 56px; height: 56px; border-radius: 12px; }
.dna-chip code { font-size: 13px; }
.dna-layouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.dna-layouts > div { background: var(--soft); border-radius: 12px; padding: 14px; }
.dna-layouts p { margin: 6px 0 0; }
.an-table td { min-width: 110px; font-size: 15px; }
.an-thumb { width: 64px; height: 80px; object-fit: cover; border-radius: 8px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--soft); }
@media (max-width: 720px) {
  .pattern-grid, .dna-layouts { grid-template-columns: 1fr; }
}

/* ③ 내 계정 */
.is-bad { border-color: var(--danger) !important; outline: 2px solid #fecaca; }
.color-pick { width: 56px; height: 48px; padding: 4px; border: 1px solid #d1d5db; border-radius: 10px; background: #fff; cursor: pointer; }
input.color-text { max-width: 140px; font-family: ui-monospace, Consolas, monospace; }
.color-chip { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.acc-preview { width: 216px; height: 270px; border-radius: 16px; padding: 20px; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.acc-preview .pv-label { font-size: 13px; font-weight: 700; opacity: .85; margin-bottom: auto; }
.acc-preview .pv-name { font-size: 22px; font-weight: 800; line-height: 1.25; }
.acc-preview .pv-handle { font-size: 14px; opacity: .85; }

/* ④ 만들기 */
.style-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.style-pick { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 14px; cursor: pointer; font: inherit; display: grid; gap: 6px; min-height: 48px; }
.style-pick:hover { background: var(--soft); }
.style-pick.is-active { border: 2px solid #8134af; box-shadow: 0 0 0 3px #ede9fe; }
.style-pick small { color: var(--muted); font-size: 14px; line-height: 1.4; }
.style-pick .dots { display: flex; gap: 4px; }
.style-pick .dots i { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }
.mk-strip { display: flex; gap: 14px; overflow-x: auto; padding: 8px 2px 16px; margin: 16px 0; }
.mk-cell { flex: 0 0 auto; width: 240px; margin: 0; cursor: pointer; }
.mk-cell canvas { width: 100%; height: auto; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.12); display: block; }
.mk-cell.is-selected canvas { outline: 4px solid #8134af; outline-offset: 2px; }
.mk-cell figcaption { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: 14px; }
textarea.short { min-height: 72px; }
.chip.tag { cursor: pointer; }
.chip.tag:hover { background: #fef2f2; border-color: #fecaca; }

/* ⑤ 내보내기 */
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.ex-grid .card + .card { margin-top: 0; }
.ex-item { padding: 16px; display: grid; gap: 12px; }
.ex-item.is-active { border: 2px solid #8134af; }
.ex-pick { display: flex; gap: 14px; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit; }
.ex-thumb { width: 96px; height: 120px; border-radius: 8px; flex: 0 0 auto; box-shadow: 0 1px 6px rgba(0,0,0,.15); }
.ex-pick p { margin: 4px 0 8px; }
#ex-detail { margin-top: 32px; }
#ex-backup { margin-top: 32px; }

/* ⑥ 카드 편집 */
.cd-sub { margin-top: 16px; }
.cd-sub textarea { min-height: 220px; }
.cd-made-item { margin: 0 8px 8px 0; }
.cd-ratio { display: inline-flex; gap: 8px; align-items: center; margin-left: auto; font-weight: 600; }
.cd-ratio .chip { cursor: pointer; }
.cd-theme-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 200px)); gap: 16px; }
.cd-theme { display: grid; gap: 6px; text-align: left; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 10px; cursor: pointer; font: inherit; }
.cd-theme.is-active { border: 3px solid transparent; background: linear-gradient(#fff, #fff) padding-box, var(--ig) border-box; }
.cd-theme small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.cd-layout { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; margin-top: 16px; }
.cd-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; min-height: 120px; }
.cd-cell { margin: 0; min-width: 0; }
.cd-frame { position: relative; width: 100%; overflow: hidden; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.12); background: #eee; }
.cd-frame > .cn-card { position: absolute; left: 0; top: 0; transform: scale(var(--s, .25)); transform-origin: 0 0; }
.cd-mini { width: 100%; }
.cd-tiny { width: 96px; height: 120px; flex: 0 0 auto; }
.cd-meta { gap: 6px; margin-top: 8px; font-size: 14px; }
.cd-meta select { min-height: 36px; width: auto; padding: 4px 8px; font-size: 14px; }
.cd-actions { gap: 6px; margin-top: 6px; }
.cd-no { font-weight: 700; }
.cd-panel { position: sticky; top: 120px; }
.cd-panel .card + .card { margin-top: 0; }
.cd-slider label { display: flex; justify-content: space-between; font-size: 15px; }
.cd-slider input[type="range"] { width: 100%; }
.cd-toolbar { position: sticky; top: 112px; z-index: 20; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; margin-top: 24px; border-radius: 12px; background: #f3f4f6; border: 1px solid var(--line); opacity: .75; }
.cd-toolbar.is-on { background: #fff; border-color: #c4b5fd; box-shadow: 0 6px 18px rgba(129,52,175,.15); opacity: 1; }
.cd-toolbar select { min-height: 36px; width: auto; padding: 4px 8px; font-size: 14px; }
.cd-color input { width: 44px; height: 36px; padding: 2px; vertical-align: middle; }
.cd-sel { font-weight: 700; margin-right: 8px; }
.cd-scale { min-width: 44px; text-align: center; font-weight: 600; }
.cd-sets { display: grid; gap: 12px; margin-top: 16px; }
.cd-set { display: flex; gap: 16px; align-items: flex-start; padding: 14px; }
.cd-set.is-active { border: 2px solid #8134af; }
.cd-set p { margin: 4px 0 8px; }
/* 편집 표시 (상태 클래스·data-edit-ui — 저장할 때 지운다) */
.cn-card [data-field]:hover { outline: 3px dashed rgba(129, 52, 175, .35); outline-offset: 6px; }
.cn-card [data-field].is-editing { outline: 3px dashed #8134af; outline-offset: 6px; }
.cd-grid.is-moving .cn-label, .cd-grid.is-moving .cn-page { outline: 3px dashed #dd2a7b; outline-offset: 8px; cursor: move; touch-action: none; }
.cn-grip { display: inline-block; margin-left: 10px; padding: 0 10px; border-radius: 8px; background: #dd2a7b; color: #fff; font-size: 26px; }
@media (max-width: 1100px) { .cd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .cd-layout { grid-template-columns: 1fr; } .cd-panel { position: static; order: -1; } }
@media (max-width: 560px) { .cd-grid { grid-template-columns: 1fr; } .cd-theme-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; } .cd-ratio { margin-left: 0; } }

/* 입장 화면 */
body.locked .top .tabs, body.locked .page, body.locked #open-settings { display: none !important; }
.gate { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-card { width: 100%; max-width: 420px; }
.gate-title { font-size: 30px; margin: 0 0 8px; }
.top-right { gap: 4px; }
.ad-code { margin-top: 16px; padding: 20px; border-radius: 14px; background: #f5f3ff; border: 2px solid #c4b5fd; text-align: center; }
.ad-code-big { display: block; font-size: 40px; letter-spacing: .08em; margin: 8px 0; font-family: ui-monospace, Consolas, monospace; }
