/* PageCraft 작업 화면 공통. 색상은 pagecraft-tokens.css 변수를 쓴다. */
:root { --danger: #B42318; --warn: #B54708; --warn-bg: #FFF6EA; --info: #175CD3; --info-bg: #EEF4FF; --radius: 12px; --h: 46px; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.6 "Pretendard Variable", Pretendard, -apple-system, "Malgun Gothic", sans-serif; color: var(--color-pc-ink); background: var(--color-pc-canvas); word-break: keep-all; overflow-wrap: anywhere; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; letter-spacing: -.02em; }
h1 { font-size: 26px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--color-pc-muted); } .small { font-size: 14px; }
.sr { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: #fff; padding: 8px 12px; border-radius: 8px; }
.skip:focus { top: 8px; }

/* 상단 막대 */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; height: 60px; padding: 0 24px; background: var(--color-pc-surface); border-bottom: 1px solid var(--color-pc-rule); }
.brand { font-weight: 800; font-size: 19px; text-decoration: none; letter-spacing: -.03em; white-space: nowrap; }
.brand b { color: var(--color-pc-accent); }
.top .spacer { flex: 1; }
.usage-pill { font-size: 13px; color: var(--color-pc-muted); white-space: nowrap; text-decoration: none; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--color-pc-rule); border-radius: 999px; font-size: 15px; white-space: nowrap; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; display: block; line-height: 38px; }
.menu .drop { max-width: calc(100vw - 28px); }
.quota-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.quota-grid .field { margin: 0; }
.table-scroll { overflow-x: auto; max-width: 100%; position: relative; }
.menu .drop { position: absolute; right: 0; top: 46px; width: 240px; background: #fff; border: 1px solid var(--color-pc-rule); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.08); padding: 8px; z-index: 30; }
.menu .drop a, .menu .drop button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; color: inherit; }
.menu .drop a:hover, .menu .drop button:hover { background: var(--color-pc-canvas); }
.menu .drop form { margin: 0; }

/* 공통 요소 */
.wrap { max-width: 1180px; margin: 0 auto; padding: 32px 24px 64px; }
.wrap.narrow { max-width: 960px; }
.card { background: var(--color-pc-surface); border: 1px solid var(--color-pc-rule); border-radius: var(--radius); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--h); padding: 0 20px; border-radius: 10px; border: 1px solid var(--color-pc-rule); background: #fff; color: var(--color-pc-ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #C9CED4; }
.btn:disabled, .btn[aria-disabled=true] { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--color-pc-accent); border-color: var(--color-pc-accent); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--color-pc-focus) 45%, transparent); outline-offset: 2px; }
label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
input, select, textarea { width: 100%; min-width: 0; min-height: var(--h); padding: 10px 14px; border: 1px solid #CFD4DA; border-radius: 10px; font: inherit; background: #fff; color: inherit; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
textarea { min-height: 96px; resize: vertical; }
.field { margin-bottom: 18px; min-width: 0; }
.hint { font-size: 14px; color: var(--color-pc-muted); margin-top: 6px; }
.err { font-size: 14px; color: var(--danger); margin-top: 6px; }
.invalid { border-color: var(--danger) !important; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 15px; }
.alert.bad { background: #FEF3F2; color: var(--danger); border: 1px solid #FECDCA; }
.alert.ok { background: var(--color-pc-wash); color: var(--color-pc-accent); border: 1px solid #CFE3DC; }
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--color-pc-canvas); color: var(--color-pc-muted); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.check { color: var(--warn); background: var(--warn-bg); }
.badge.ready { color: var(--color-pc-accent); background: var(--color-pc-wash); }
.badge.sent { color: var(--info); background: var(--info-bg); }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.bar { height: 6px; border-radius: 3px; background: var(--color-pc-stage); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--color-pc-accent); }
.bar.over i { background: var(--danger); }
table.plain { width: 100%; border-collapse: collapse; font-size: 15px; }
table.plain td, table.plain th { padding: 10px 8px; border-top: 1px solid var(--color-pc-rule); text-align: left; vertical-align: middle; }
table.plain th { font-size: 13px; color: var(--color-pc-muted); border-top: 0; font-weight: 600; }

/* 상품 목록 */
.usage { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.usage .card { padding: 14px 16px; }
.tools { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.tools .search { flex: 1; min-width: 200px; max-width: 420px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--color-pc-rule); background: #fff; font: inherit; font-size: 14px; cursor: pointer; }
.chip[aria-pressed=true] { background: var(--color-pc-ink); color: #fff; border-color: var(--color-pc-ink); }
.plist { overflow: hidden; }
.plist .row, .plist .head-row { display: grid; grid-template-columns: 64px minmax(0,1fr) 220px 130px; gap: 16px; align-items: center; padding: 14px 20px; }
.plist .head-row { padding: 10px 20px; font-size: 13px; color: var(--color-pc-muted); border-bottom: 1px solid var(--color-pc-rule); }
.plist .row { border-top: 1px solid var(--color-pc-rule); text-decoration: none; }
.plist .row:first-of-type { border-top: 0; }
.plist .row:hover { background: #FAFBFC; }
.thumb { width: 64px; height: 64px; border-radius: 10px; background: var(--color-pc-stage); overflow: hidden; display: grid; place-items: center; font-size: 12px; color: var(--color-pc-muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.pname { font-weight: 700; }
.meta { font-size: 14px; color: var(--color-pc-muted); }
.states { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 48px 24px; text-align: center; }

/* 상품 만들기 */
.step { padding: 24px; margin-bottom: 20px; }
.step > h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--color-pc-wash); color: var(--color-pc-accent); font-size: 14px; font-weight: 800; }
.step > p { margin-bottom: 18px; }
.drop { border: 2px dashed #C9CED4; border-radius: var(--radius); padding: 28px; text-align: center; background: #FAFBFC; }
.drop.over { border-color: var(--color-pc-accent); background: var(--color-pc-wash); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-top: 16px; }
.ph { position: relative; aspect-ratio: 1; border-radius: 10px; background: var(--color-pc-stage); overflow: hidden; }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph select { position: absolute; left: 6px; right: 34px; bottom: 6px; min-height: 30px; padding: 2px 6px; font-size: 13px; }
.ph .x { position: absolute; right: 6px; bottom: 6px; width: 26px; height: 30px; border: 0; border-radius: 6px; background: #fff; cursor: pointer; }
table.spec { width: 100%; border-collapse: collapse; }
.spec th { font-size: 13px; color: var(--color-pc-muted); text-align: left; font-weight: 600; padding: 0 4px 8px; }
.spec td { padding: 4px; vertical-align: top; }
.spec td input { min-height: 42px; }
.spec .x { width: 44px; }
.spec tr.auto input { background: #FFFAF0; border-color: #F0C27A; }
.autonote { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-radius: 10px; background: #FFFAF0; border: 1px solid #F5D9A8; margin-bottom: 14px; font-size: 14px; }
.compose-opt { display: flex; align-items: center; gap: 8px; }
.actions-bar { position: sticky; bottom: 0; display: flex; gap: 12px; justify-content: flex-end; align-items: center; padding: 16px 0; background: linear-gradient(transparent, var(--color-pc-canvas) 30%); }

/* 편집·미리보기 */
body.editor { background: var(--color-pc-stage); }
.top .ptitle { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .saved { font-size: 13px; color: var(--color-pc-muted); white-space: nowrap; }
.top .acts { display: flex; gap: 8px; }
.checks { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--warn-bg); border-bottom: 1px solid #F5D9A8; font-size: 15px; flex-wrap: wrap; }
.checks.ok { background: var(--color-pc-wash); border-color: #CFE3DC; }
.checks ul { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; flex-wrap: wrap; }
.checks button { min-height: 32px; padding: 0 12px; border-radius: 999px; background: #fff; border: 1px solid #F5D9A8; font: inherit; font-size: 14px; cursor: pointer; text-align: left; }
.ed-layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: calc(100vh - 60px - var(--checks-h, 0px)); }
.stage { overflow: auto; padding: 32px 24px 96px; display: flex; justify-content: center; }
.stage iframe { width: min(780px, 100%); border: 0; background: #fff; box-shadow: 0 2px 20px rgba(0,0,0,.08); align-self: flex-start; min-height: 600px; display: block; }
.panel { background: var(--color-pc-surface); border-left: 1px solid var(--color-pc-rule); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--color-pc-rule); }
.tabs button { flex: 1; min-height: 50px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--color-pc-muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tabs button[aria-selected=true] { color: var(--color-pc-ink); border-bottom-color: var(--color-pc-accent); }
.pbody { padding: 20px; overflow: auto; flex: 1; }
.crumb { font-size: 13px; color: var(--color-pc-muted); margin-bottom: 4px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; }
.fact { display: inline-flex; align-items: center; min-height: 34px; padding: 0 10px; border: 1px solid var(--color-pc-rule); border-radius: 8px; font: inherit; font-size: 14px; background: #fff; cursor: pointer; text-align: left; }
.fact[aria-pressed=true] { border-color: var(--color-pc-accent); background: var(--color-pc-wash); }
.compose-chip { margin-left: auto; min-height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--color-pc-accent); background: #fff; color: var(--color-pc-accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.suggest { border: 1px solid #CFE3DC; background: var(--color-pc-wash); border-radius: 10px; padding: 14px; margin: 14px 0; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--color-pc-rule); }
.pfoot { padding: 14px 20px; border-top: 1px solid var(--color-pc-rule); display: flex; gap: 8px; align-items: center; }
.pfoot .spacer { flex: 1; }
.pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick button { aspect-ratio: 1; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--color-pc-stage); cursor: pointer; }
.pick button[aria-pressed=true] { border-color: var(--color-pc-accent); }
.pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.seclist { list-style: none; margin: 0 0 16px; padding: 0; }
.seclist li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--color-pc-rule); }
.seclist .nm { flex: 1; min-width: 0; }
.progress { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 14px; background: #1D2329; color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 15px; min-width: 320px; max-width: calc(100vw - 28px); }
.progress .pb { flex: 1; height: 6px; background: #3A434C; border-radius: 3px; overflow: hidden; min-width: 60px; }
.progress .pb i { display: block; width: 30%; height: 100%; background: #5FD1A8; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) { .progress .pb i { animation: none; width: 100%; opacity: .6; } }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 31; background: #1D2329; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; max-width: calc(100vw - 28px); }
.toast.bad { background: var(--danger); }
dialog.sheet { width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 40px); border: 0; border-radius: 16px; padding: 24px; }
dialog.sheet::backdrop { background: rgba(15,20,25,.45); }
.steps { display: flex; gap: 8px; margin: 14px 0 18px; font-size: 13px; }
.steps span { flex: 1; padding: 6px 0; border-top: 3px solid var(--color-pc-rule); color: var(--color-pc-muted); }
.steps span.on { border-color: var(--color-pc-accent); color: var(--color-pc-ink); font-weight: 600; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.seg label { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--color-pc-rule); border-radius: 10px; padding: 12px; font-weight: 500; cursor: pointer; margin: 0; }
.summary { background: var(--color-pc-canvas); border-radius: 10px; padding: 14px 16px 14px 32px; margin: 6px 0 16px; }
.summary li { margin: 4px 0; }
.mtabs, .mbar { display: none; }

@media (max-width: 1024px) {
  .usage { grid-template-columns: repeat(2, 1fr); }
  .ed-layout { grid-template-columns: minmax(0, 1fr) 360px; }
}
@media (max-width: 760px) {
  h1 { font-size: 22px; }
  .top { padding: 0 14px; gap: 10px; }
  .usage-pill, .top .saved { display: none; }
  .wrap { padding: 20px 14px 96px; }
  .grid2, .seg { grid-template-columns: 1fr; }
  .quota-grid { grid-template-columns: 1fr 1fr; }
  .usage { gap: 8px; }
  .plist .head-row { display: none; }
  .plist .row { grid-template-columns: 56px minmax(0,1fr); padding: 14px; gap: 6px 12px; }
  .plist .thumb { width: 56px; height: 56px; grid-row: span 2; }
  .plist .when { display: none; }
  .page-head .btn.primary.float { position: fixed; left: 14px; right: 14px; bottom: 14px; z-index: 15; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
  .step { padding: 18px 14px; }
  .spec thead { display: none; }
  .spec tr { display: grid; grid-template-columns: 1fr 1fr 44px; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--color-pc-rule); }
  .spec td { padding: 0; }
  .spec td.k { grid-column: 1 / 3; }
  .spec td.s { grid-column: 1 / 4; }
  .spec td.x { grid-column: 3; grid-row: 1; }
  .actions-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 14px; background: #fff; border-top: 1px solid var(--color-pc-rule); z-index: 15; }
  .actions-bar .btn.primary { flex: 1; }
  .actions-bar { flex-wrap: wrap; }
  .actions-bar .compose-opt { flex-basis: 100%; display: flex; align-items: center; gap: 8px; }
  .actions-bar .compose-opt select { flex: 1; max-width: none !important; }
  .actions-bar .note { display: none; }
  /* 편집: 미리보기 / 수정 두 탭 */
  .top .acts .btn:not(.primary) { display: none; }
  .top .acts .btn.primary { min-height: 40px; padding: 0 14px; }
  .checks { padding: 10px 14px; font-size: 14px; }
  .mtabs { display: flex; background: #fff; border-bottom: 1px solid var(--color-pc-rule); }
  .mtabs button { flex: 1; min-height: 46px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--color-pc-muted); border-bottom: 2px solid transparent; }
  .mtabs button[aria-selected=true] { color: var(--color-pc-ink); border-bottom-color: var(--color-pc-accent); }
  .ed-layout { display: block; height: auto; }
  .stage { padding: 0 0 90px; }
  .stage iframe { box-shadow: none; width: 100%; }
  .panel { display: none; border-left: 0; }
  body.show-edit .panel { display: flex; padding-bottom: 80px; }
  body.show-edit .stage { display: none; }
  .mbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; gap: 8px; padding: 10px 14px; background: #fff; border-top: 1px solid var(--color-pc-rule); }
  .mbar .btn { flex: 1; padding: 0 10px; }
  .progress, .toast { bottom: 76px; min-width: 0; width: calc(100vw - 28px); }
  dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 16px 16px 0 0; max-height: 92vh; padding: 20px 16px; }
}
