html, body{ height:100%; }
body{ display:flex; flex-direction:column; }

.bar{ flex:none; display:flex; align-items:center; gap:14px; padding:10px 20px; padding-top:calc(10px + env(safe-area-inset-top,0px)); background:var(--surface); border-bottom:1px solid var(--line); position:sticky; top:0; z-index:20; }
.save{ font-size:12.5px; color:var(--soft); display:inline-flex; align-items:center; gap:6px; }
.save::before{ content:""; width:7px; height:7px; border-radius:50%; background:var(--line); }
.save[data-state=saved]::before{ background:var(--ok); }
.save[data-state=saving]::before{ background:#D9A441; }
.save[data-state=error]{ color:var(--danger); }
.save[data-state=error]::before{ background:var(--danger); }
.bar-actions{ margin-left:auto; display:flex; gap:8px; }

.workspace{ flex:1; min-height:0; display:grid; grid-template-columns:minmax(360px, 520px) 1fr; }
.panel{ overflow-y:auto; padding:22px 24px 120px; border-right:1px solid var(--line); background:var(--paper); }
.stage{ display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; padding:20px; background:#ECECE8; min-height:0; }
.phone{ width:390px; height:min(780px, calc(100vh - 150px)); max-width:100%; background:#fff; border-radius:34px; border:10px solid #1E1F24; overflow:hidden; box-shadow:0 30px 60px rgba(30,31,36,.18); }
.phone iframe{ width:100%; height:100%; border:0; display:block; }
.stage-note{ font-size:12px; color:var(--soft); margin:0; }

.editlink{ display:flex; gap:12px; align-items:flex-start; justify-content:space-between; background:var(--accent-soft); border-radius:var(--r); padding:14px 16px; margin-bottom:18px; }
.editlink strong{ font-size:14px; }
.editlink p{ margin:2px 0 6px; font-size:12.5px; color:#4A5470; }
.editlink code{ font-size:12.5px; word-break:break-all; color:var(--accent); font-family:ui-monospace, Menlo, monospace; }

/* 폼 섹션 */
.sec{ background:var(--surface); border:1px solid var(--line); border-radius:var(--r); margin-bottom:10px; }
.sec > summary{ list-style:none; cursor:pointer; display:flex; align-items:center; justify-content:space-between; padding:16px 18px; font-weight:600; font-size:15px; }
.sec > summary::-webkit-details-marker{ display:none; }
.sec > summary::after{ content:""; width:8px; height:8px; border-right:1.6px solid var(--soft); border-bottom:1.6px solid var(--soft); transform:rotate(45deg); margin-top:-4px; transition:transform .2s ease; }
.sec[open] > summary::after{ transform:rotate(-135deg); margin-top:4px; }
.sec-body{ padding:2px 18px 20px; display:flex; flex-direction:column; gap:14px; }
.grid2{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.person{ border-top:1px dashed var(--line); padding-top:14px; display:flex; flex-direction:column; gap:10px; }
.person:first-child{ border-top:0; padding-top:0; }
.person h4{ margin:0; font-size:13px; color:var(--accent); font-weight:600; }
.parent{ display:grid; grid-template-columns:1fr auto; gap:8px; align-items:end; }
.check{ display:inline-flex; align-items:center; gap:6px; font-size:13px; color:var(--soft); padding-bottom:10px; white-space:nowrap; cursor:pointer; }
.check input{ width:16px; height:16px; accent-color:var(--accent); }

/* 템플릿 선택 */
.tpl-pick{ border:0; padding:0; margin:0; display:grid; grid-template-columns:repeat(auto-fill, minmax(120px,1fr)); gap:8px; }
.tpl-pick legend{ font-size:13px; color:var(--soft); margin-bottom:6px; padding:0; }
.tpl-opt{ position:relative; }
.tpl-opt input{ position:absolute; opacity:0; }
.tpl-opt label{ display:flex; flex-direction:column; gap:2px; border:1.5px solid var(--line); border-radius:10px; padding:10px 12px; cursor:pointer; height:100%; }
.tpl-opt label b{ font-size:14px; }
.tpl-opt label small{ color:var(--soft); font-size:12px; line-height:1.4; }
.tpl-opt input:checked + label{ border-color:var(--accent); background:var(--accent-soft); }
.tpl-opt input:focus-visible + label{ outline:2px solid var(--accent); outline-offset:2px; }
.tpl-opt a{ font-size:12px; color:var(--accent); margin-top:4px; }

/* 사진 */
.photo-row{ display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.uploader{ display:flex; flex-direction:column; gap:6px; }
.uploader > span{ font-size:12.5px; color:var(--soft); }
.thumb{ position:relative; aspect-ratio:3/4; border-radius:8px; background:var(--paper) center/cover no-repeat; border:1px dashed #cfcfca; display:grid; place-items:center; overflow:hidden; }
.thumb.filled{ border-style:solid; border-color:var(--line); }
.thumb .pick{ position:absolute; inset:0; display:grid; place-items:center; font-size:12.5px; color:var(--soft); cursor:pointer; background:none; border:0; width:100%; }
.thumb.filled .pick{ opacity:0; }
.thumb .x{ position:absolute; top:4px; right:4px; width:24px; height:24px; border-radius:50%; border:0; background:rgba(0,0,0,.55); color:#fff; font-size:14px; line-height:1; cursor:pointer; display:grid; place-items:center; }
.thumb.busy::after{ content:"올리는 중…"; position:absolute; inset:0; background:rgba(255,255,255,.8); display:grid; place-items:center; font-size:12px; color:var(--soft); }
.gal{ display:grid; grid-template-columns:repeat(4,1fr); gap:6px; }
.gal .thumb{ aspect-ratio:1; }
.gal .move{ position:absolute; bottom:4px; left:4px; display:flex; gap:3px; }
.gal .move button{ width:22px; height:22px; border-radius:50%; border:0; background:rgba(0,0,0,.55); color:#fff; font-size:11px; cursor:pointer; }
.gal-add{ aspect-ratio:1; border:1px dashed #cfcfca; border-radius:8px; background:var(--surface); color:var(--soft); font-size:12.5px; cursor:pointer; display:grid; place-items:center; text-align:center; line-height:1.4; }
.gal-add:hover{ border-color:var(--accent); color:var(--accent); }

/* 반복 목록 */
.rows{ display:flex; flex-direction:column; gap:8px; }
.row{ display:grid; gap:6px; align-items:start; }
.row.way{ grid-template-columns:90px 1fr 32px; }
.row.acc{ grid-template-columns:1fr 1fr 1.3fr 32px; }
.row-x{ width:32px; height:40px; border:0; background:none; color:var(--soft); font-size:18px; cursor:pointer; border-radius:6px; }
.row-x:hover{ background:var(--paper); color:var(--danger); }
.add{ align-self:flex-start; background:none; border:1px dashed #c9c9c4; border-radius:999px; padding:7px 14px; font-size:13px; color:var(--soft); cursor:pointer; }
.add:hover{ border-color:var(--accent); color:var(--accent); }
.sub-h{ font-size:13px; font-weight:600; margin:4px 0 -4px; }
.presets{ display:flex; flex-wrap:wrap; gap:6px; }
.presets button{ background:var(--paper); border:1px solid var(--line); border-radius:999px; padding:5px 12px; font-size:12.5px; cursor:pointer; }
.presets button:hover{ border-color:var(--accent); color:var(--accent); }

/* 섹션 스위치 */
.toggles{ display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.toggle{ display:flex; align-items:center; justify-content:space-between; gap:10px; border:1px solid var(--line); border-radius:8px; padding:10px 12px; font-size:14px; cursor:pointer; }
.toggle input{ appearance:none; width:36px; height:22px; border-radius:999px; background:#D6D6D1; position:relative; cursor:pointer; flex:none; transition:background .15s ease; }
.toggle input::after{ content:""; position:absolute; top:3px; left:3px; width:16px; height:16px; border-radius:50%; background:#fff; transition:transform .15s ease; }
.toggle input:checked{ background:var(--accent); }
.toggle input:checked::after{ transform:translateX(14px); }

/* 참석·방명록 서랍 */
.drawer-bg{ position:fixed; inset:0; z-index:90; background:rgba(20,21,26,.35); display:flex; justify-content:flex-end; }
.drawer{ width:min(560px,100%); height:100%; background:var(--surface); overflow-y:auto; padding:22px 22px 60px; display:flex; flex-direction:column; gap:14px; }
.drawer-head{ display:flex; justify-content:space-between; align-items:center; }
.drawer h2{ margin:0; font-family:var(--serif); font-size:21px; }
.drawer h3{ margin:18px 0 0; font-size:15px; }
.icon-x{ width:36px; height:36px; border:0; background:var(--paper); border-radius:50%; font-size:20px; cursor:pointer; }
.stats{ display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.stat{ background:var(--paper); border-radius:10px; padding:12px; }
.stat small{ display:block; font-size:11.5px; color:var(--soft); }
.stat b{ font-size:22px; font-weight:600; font-variant-numeric:tabular-nums; }
.drawer-actions{ display:flex; gap:8px; justify-content:flex-end; }
.table-wrap{ overflow-x:auto; border:1px solid var(--line); border-radius:10px; }
table{ width:100%; border-collapse:collapse; min-width:440px; font-size:13.5px; }
th, td{ text-align:left; padding:9px 12px; border-bottom:1px solid var(--line); white-space:nowrap; }
th{ font-weight:500; color:var(--soft); font-size:12px; background:var(--paper); }
tr:last-child td{ border-bottom:0; }
.tag{ display:inline-block; padding:1px 8px; border-radius:999px; font-size:12px; }
.tag.yes{ background:#E2F0E8; color:var(--ok); } .tag.no{ background:#F8E4E0; color:var(--danger); }
.gb-admin{ display:flex; flex-direction:column; gap:8px; }
.gb-admin div{ background:var(--paper); border-radius:10px; padding:12px 14px; display:grid; grid-template-columns:1fr auto; gap:2px 12px; }
.gb-admin p{ margin:0; grid-column:1; white-space:pre-wrap; word-break:break-word; color:var(--soft); font-size:14px; }
.empty{ color:var(--soft); font-size:13.5px; text-align:center; padding:16px; background:var(--paper); border-radius:10px; margin:0; }

/* 모바일 */
.tabs{ display:none; }
@media (max-width: 960px){
  .workspace{ grid-template-columns:1fr; }
  .panel{ border-right:0; padding:16px 16px 110px; }
  .stage{ display:none; padding:12px 12px 90px; }
  body.show-preview .panel{ display:none; }
  body.show-preview .stage{ display:flex; }
  .phone{ height:calc(100vh - 190px); width:min(390px, 100%); border-width:8px; border-radius:28px; }
  .tabs{ position:fixed; left:50%; bottom:calc(18px + env(safe-area-inset-bottom,0px)); transform:translateX(-50%); z-index:30; display:flex; background:var(--ink); border-radius:999px; padding:4px; box-shadow:0 10px 30px rgba(0,0,0,.25); }
  .tabs[hidden]{ display:none; }
  .tabs button{ border:0; background:none; color:#fff; padding:10px 22px; border-radius:999px; font-size:14px; cursor:pointer; }
  .tabs button[aria-pressed=true]{ background:#fff; color:var(--ink); }
  .hide-sm{ display:none; }
  .bar{ padding-inline:14px; gap:10px; }
  .photo-row{ grid-template-columns:repeat(3,1fr); }
  .gal{ grid-template-columns:repeat(3,1fr); }
  .row.acc{ grid-template-columns:1fr 1fr 32px; }
  .row.acc .input:nth-child(3){ grid-column:1 / 3; grid-row:2; }
  .stats{ grid-template-columns:repeat(2,1fr); }
}
@media (max-width: 480px){
  .save{ display:none; }
  .grid2{ grid-template-columns:1fr; }
  .toggles{ grid-template-columns:1fr; }
}

/* 시작 · 로그인 창 닫기 */
.modal{ position:relative; }
.modal-x{ position:absolute; top:16px; right:16px; width:36px; height:36px; border-radius:50%; display:flex; align-items:center; justify-content:center; color:#555; transition:background .15s, color .15s; }
.modal-x:hover{ background:#F2F2F0; color:#111; }
.modal-x svg{ width:20px; height:20px; }
.modal h1{ padding-right:40px; }

/* 사진 위치 · 크기 조정 */
.pos-btn{ margin-top:2px; padding:7px 4px; border:1px solid var(--line); border-radius:6px; background:#fff; font-size:11.5px; color:var(--ink); cursor:pointer; font-family:inherit; }
.pos-btn:hover{ border-color:var(--ink); }
.pos-bg{ position:fixed; inset:0; z-index:200; background:rgba(0,0,0,.5); display:grid; place-items:center; padding:16px; }
.pos-modal{ background:#fff; border-radius:14px; padding:20px 18px 16px; width:min(100%, 380px); display:flex; flex-direction:column; align-items:center; gap:10px; box-shadow:0 20px 60px rgba(0,0,0,.25); }
.pos-modal h3{ margin:0; font-size:16px; }
.pos-modal .hint{ margin:0; text-align:center; }
.pos-frame{ border-radius:8px; background:#eee center/cover no-repeat; cursor:grab; touch-action:none; user-select:none; -webkit-user-select:none; box-shadow:inset 0 0 0 1px rgba(0,0,0,.08); }
.pos-frame:active{ cursor:grabbing; }
.pos-zoom{ display:flex; align-items:center; gap:10px; width:100%; max-width:300px; color:var(--soft); }
.pos-zoom input{ flex:1; accent-color:#111; }
.pos-actions{ display:flex; gap:6px; width:100%; margin-top:4px; }
.row.notice-row{ grid-template-columns:1fr 32px; }
.row.notice-row .input:nth-child(2){ grid-column:1; }
.row.notice-row .row-x{ grid-column:2; grid-row:1; }
