/* OwnCard — studio chrome */

:root {
  --ui-bg: #F4F3F0;
  --panel: #FFFFFF;
  --ink: #17161A;
  --ink-2: #3B3941;
  --muted: #6F6C77;
  --faint: #9B98A2;
  --line: #E7E5E0;
  --line-2: #D9D6CF;
  --accent: #E2542C;
  --sans: 'Inter', 'Noto Sans CJK KR', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Noto Sans Mono CJK KR', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow-sm: 0 1px 2px rgba(20, 18, 15, .05);
  --shadow: 0 1px 2px rgba(20, 18, 15, .04), 0 10px 30px -16px rgba(20, 18, 15, .22);
  --shadow-lg: 0 30px 70px -30px rgba(20, 18, 15, .38);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ui-bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button, input, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: #F6D5C8; }

body[data-booting="1"] .app { visibility: hidden; }

/* ---------------------------------------------------------------- top bar */
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--ink); display: grid; place-items: center; flex: none;
}
.logo i {
  width: 14px; height: 9px; border: 1.6px solid #fff; border-radius: 2px; position: relative;
}
.logo i::after {
  content: ''; position: absolute; left: 2px; top: 2px; width: 2.4px; height: 2.4px; background: #fff; border-radius: 50%;
}

.brand-t { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-t strong { font-size: 15px; letter-spacing: -.015em; font-weight: 700; }
.brand-t small { font-size: 11px; color: var(--muted); letter-spacing: .01em; }

.top-actions { display: flex; align-items: center; gap: 10px; }

/* --------------------------------------------------------------- controls */
.seg {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: #EFEEE9;
}
.seg-btn {
  border: 0; background: none; cursor: pointer; padding: 6px 13px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .01em;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}
.seg-btn:hover { color: var(--ink-2); }
.seg-btn.is-on { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.seg--sm .seg-btn { padding: 5px 10px; font-size: 11.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  font-size: 13px; font-weight: 600; letter-spacing: -.005em; white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, transform .1s ease, box-shadow .16s ease;
}
.btn:hover { border-color: #C6C2B9; background: #FCFBF9; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: default; }
.btn:disabled:hover { background: transparent; border-color: transparent; }
.btn--primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--primary:hover { background: #000; border-color: #000; }
.btn--quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--quiet:hover { background: #EFEEE9; border-color: transparent; }
.btn--sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; }
.btn--add {
  width: 100%; height: 40px; background: #FBFAF7; border: 1px dashed var(--line-2);
  color: var(--muted); font-size: 12.5px; font-weight: 600;
}
.btn--add:hover { border-color: var(--faint); color: var(--ink-2); background: #F7F5F1; }

.linkbtn {
  border: 0; background: none; padding: 0; cursor: pointer; font-size: 12px;
  color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--line-2);
}
.linkbtn:hover { color: var(--ink); text-decoration-color: var(--faint); }

.hint { font-size: 11.5px; color: var(--muted); margin: 0 0 10px; line-height: 1.55; letter-spacing: .002em; }

/* ----------------------------------------------------------------- layout */
.layout {
  display: grid;
  grid-template-columns: minmax(390px, 540px) minmax(0, 1fr);
  align-items: start;
  max-width: 1560px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 24px 30px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.panel-scroll::-webkit-scrollbar { width: 8px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }

.sec { padding: 22px 0; border-bottom: 1px solid #F1EFEA; }
.sec--last { border-bottom: 0; padding-bottom: 18px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sec-head h2 { font-size: 14px; font-weight: 700; letter-spacing: -.012em; margin: 0 0 8px; }
.sec-head .hint { margin: 0 0 10px; }

/* -------------------------------------------------------------- templates */
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.tpl {
  display: block; text-align: left; cursor: pointer; padding: 7px 7px 9px;
  border: 1px solid var(--line-2); border-radius: 12px; background: #fff;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.tpl:hover { border-color: #BFBBB1; }
.tpl[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink), var(--shadow-sm);
  background: #FCFBF8;
}
.tpl-n { display: block; font-size: 12.5px; font-weight: 600; margin: 0 0 2px; letter-spacing: -.005em; }
.tpl-d { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.35; }

.thumb {
  display: block; position: relative; height: 66px; border-radius: 8px; overflow: hidden;
  margin-bottom: 8px; border: 1px solid rgba(20, 18, 15, .07);
}
.thumb i { position: absolute; display: block; border-radius: 2px; }

.t-ed { background: #FAF8F5; }
.t-ed .l1 { left: 9px; top: 15px; width: 30px; height: 6px; background: #26211A; }
.t-ed .l2 { left: 9px; top: 26px; width: 16px; height: 2px; background: #B4482A; }
.t-ed .l3 { left: 9px; top: 37px; right: 9px; height: 1px; background: #E3DACD; }
.t-ed .l4 { left: 9px; top: 44px; right: 34px; height: 1px; background: #E3DACD; }
.t-ed .l5 { left: 9px; top: 51px; right: 20px; height: 1px; background: #E3DACD; }

.t-mn { background: #0B0F19; }
.t-mn .l1 { left: 9px; top: 15px; width: 26px; height: 5px; background: #E7ECF7; }
.t-mn .l2 { left: 9px; top: 24px; width: 14px; height: 2px; background: #7B8CFF; }
.t-mn .l3 { left: 9px; top: 34px; right: 9px; height: 13px; border-radius: 4px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .09); }
.t-mn .l4 { left: 9px; top: 51px; right: 9px; height: 13px; border-radius: 4px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .09); }
.t-mn .l5 { display: none; }
.t-mn::after {
  content: ''; position: absolute; right: -10px; top: -14px; width: 62px; height: 62px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(123, 140, 255, .55), transparent 72%);
}

.t-mu { background: #FFFCF5; }
.t-mu .l1 { left: 50%; top: 12px; width: 34px; height: 5px; background: #241F1A; transform: translateX(-50%); }
.t-mu .l2 { left: 50%; top: 21px; width: 20px; height: 2px; background: #1F6B4F; transform: translateX(-50%); }
.t-mu .l3 { left: 9px; top: 32px; width: 22px; height: 2px; background: #2A241E; }
.t-mu .l4 { left: 9px; top: 42px; width: 26px; height: 2px; background: #2A241E; }
.t-mu .l5 { left: 9px; top: 52px; width: 18px; height: 2px; background: #2A241E; }
.t-mu::after {
  content: ''; position: absolute; left: 40px; right: 9px; top: 37px; height: 1px;
  background-image: radial-gradient(circle, #CDBFA8 1px, transparent 1px); background-size: 5px 1px;
}

.t-nc { background: #fff; border-left: 4px solid #2F4B8F; }
.t-nc .l1 { left: 12px; top: 14px; width: 32px; height: 6px; background: #17191E; }
.t-nc .l2 { left: 12px; top: 24px; width: 22px; height: 2px; background: #9BA2AE; }
.t-nc .l3 { left: 12px; top: 35px; right: 10px; height: 1px; background: #E6E9EE; }
.t-nc .l4 { left: 12px; top: 42px; width: 34px; height: 2px; background: #C9CED7; }
.t-nc .l5 { left: 12px; top: 50px; right: 10px; height: 9px; border-radius: 3px; background: #2F4B8F; opacity: .9; }

/* ---------------------------------------------------------------- profile */
.av-row { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }

.av-preview {
  width: 64px; height: 64px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; font-size: 19px; font-weight: 600; color: #fff;
  background: #B4482A; box-shadow: 0 0 0 1px rgba(20, 18, 15, .08);
}
.av-preview img { width: 100%; height: 100%; object-fit: cover; }

.av-actions { flex: 1; min-width: 0; }
.av-btns { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 6px; }
.av-actions .hint { margin: 0; }

.fields { display: grid; grid-template-columns: 1fr; gap: 10px; }
.fields--2 { grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 11.5px; font-weight: 600; color: #5B5865; letter-spacing: .005em; }
.field--full { grid-column: 1 / -1; }

.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field textarea,
.row input,
.share-row input {
  width: 100%; border: 1px solid var(--line-2); border-radius: 9px; background: #fff;
  padding: 0 11px; height: 38px; font-size: 13.5px; color: var(--ink);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.field textarea { height: auto; padding: 9px 11px; line-height: 1.55; resize: vertical; min-height: 76px; }
.field input::placeholder, .row input::placeholder { color: #B0ACB5; }
.field input:focus, .field textarea:focus, .row input:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(226, 84, 44, .13);
}

.field--check {
  flex-direction: row; align-items: center; gap: 9px; padding: 4px 0 0;
}
.field--check input { width: 16px; height: 16px; accent-color: var(--ink); margin: 0; flex: none; }
.field--check > span { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }

/* ------------------------------------------------------------- list rows */
.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 9px; }

.row {
  border: 1px solid var(--line); border-radius: 11px; background: #FCFBF8;
  padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 7px;
}
.row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-idx { font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; color: var(--faint); }
.row-act { display: flex; gap: 4px; }
.icobtn {
  width: 25px; height: 23px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: 6px; background: #fff; color: var(--muted);
  font-size: 10px; line-height: 1; padding: 0;
}
.icobtn:hover { color: var(--ink); border-color: #BFBBB1; background: #F7F5F1; }
.icobtn[disabled] { opacity: .3; cursor: default; }
.icobtn--del:hover { color: #B4342A; border-color: #E7B9B3; background: #FDF4F2; }

.row input { height: 34px; font-size: 13px; border-radius: 8px; padding: 0 9px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.row-2--price { grid-template-columns: minmax(0, 1fr) 104px; }

/* ----------------------------------------------------------------- accent */
.accent-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.sw {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2px solid #fff;
  background: var(--sw); box-shadow: 0 0 0 1px var(--line-2); padding: 0;
  transition: box-shadow .14s ease, transform .14s ease;
}
.sw:hover { transform: scale(1.06); }
.sw.is-on { box-shadow: 0 0 0 2px var(--ink); }
.sw--pick {
  display: grid; place-items: center; background: #fff; border-style: dashed; border-color: var(--line-2);
}
.sw--pick input[type="color"] {
  width: 22px; height: 22px; border: 0; padding: 0; background: none; cursor: pointer;
}
.sw--pick input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.sw--pick input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }

/* ---------------------------------------------------------------- exports */
.exp {
  border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px 14px;
  background: #FCFBF8; margin-top: 9px;
}
.exp h3 { font-size: 13px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.008em; }
.exp p { font-size: 11.5px; color: var(--muted); margin: 0 0 11px; line-height: 1.6; }
.exp-btns { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.share-row { display: flex; gap: 7px; align-items: center; }
.share-row input {
  flex: 1; min-width: 0; height: 34px; font-family: var(--mono); font-size: 11px;
  color: var(--ink-2); background: #fff; text-overflow: ellipsis;
}
.share-row .btn { flex: none; }

.qr-preview { margin-top: 11px; }
.qr-preview img {
  width: 100%; max-width: 260px; border-radius: 10px; border: 1px solid var(--line-2);
  display: block; box-shadow: var(--shadow-sm);
}

.legal { font-size: 10.5px; color: #A7A3AC; margin: 18px 0 0; letter-spacing: .01em; }

/* -------------------------------------------------------------- panel foot */
.panel-foot {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 11px 24px; border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px);
}
.foot-btns { display: flex; gap: 6px; }
.saved { font-size: 11px; color: var(--faint); letter-spacing: .01em; transition: color .2s ease; }
.saved.is-saving { color: var(--accent); }
.saved.is-flash { color: #1F6B4F; }

/* ------------------------------------------------------------------ stage */
.stage {
  position: sticky; top: 60px;
  height: calc(100vh - 60px);
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 22px 20px;
  min-width: 0;
}

.stage-top { display: flex; align-items: center; gap: 14px; padding: 0 2px; }
.stage-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--faint); font-weight: 600;
}
.stage-top .linkbtn { margin-left: auto; }

.stage-frame {
  flex: 1; min-height: 0; display: flex; justify-content: center; align-items: flex-start;
  overflow: hidden;
}

.device {
  background: #17161A; border-radius: 30px; padding: 9px;
  width: 388px; height: 100%; max-height: 100%;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, .06);
  transition: width .22s ease, border-radius .22s ease, padding .22s ease;
}
.device iframe { width: 100%; height: 100%; border: 0; border-radius: 22px; background: #fff; display: block; }

.stage-frame[data-view="desktop"] .device {
  width: 100%; max-width: 1140px; height: 100%; padding: 0;
  background: #fff; border-radius: 14px; border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
}
.stage-frame[data-view="desktop"] .device iframe { border-radius: 13px; }

/* ----------------------------------------------------------- mobile tabs */
.mobtabs {
  display: none; position: sticky; top: 60px; z-index: 25;
  background: rgba(255, 255, 255, .95); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 6px;
  gap: 6px;
}
.mobtab {
  flex: 1; height: 34px; border: 0; border-radius: 9px; background: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.mobtab.is-on { background: #F1EFEA; color: var(--ink); }

/* ----------------------------------------------------------------- viewer */
.viewer {
  position: fixed; inset: 0; z-index: 60; background: #0A0A0B;
  display: flex; flex-direction: column;
}
.viewer iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.viewer-bar {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
  background: #141317; color: #E9E7E2; font-size: 12px;
  border-top: 1px solid #262429;
}
.viewer-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.viewer-bar .btn { margin-left: 6px; }
.viewer-bar .btn--primary { background: #fff; border-color: #fff; color: #141317; }
.viewer-bar .btn--primary:hover { background: #EDEAE4; border-color: #EDEAE4; }

/* ----------------------------------------------------------------- dialog */
.dlg {
  border: 0; padding: 22px 22px 18px; border-radius: 16px;
  width: min(560px, 92vw); max-height: 86vh; overflow: auto;
  box-shadow: 0 40px 90px -30px rgba(10, 9, 8, .55);
  color: var(--ink); font-family: var(--sans);
}
.dlg::backdrop { background: rgba(20, 18, 15, .48); backdrop-filter: blur(3px); }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.dlg-head h2 { font-size: 17px; margin: 0; letter-spacing: -.02em; }
.xbtn {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; color: var(--muted); font-size: 12px; line-height: 1;
}
.xbtn:hover { background: #F5F3EF; color: var(--ink); }
.guide-list { list-style: none; margin: 14px 0 0; padding: 0; counter-reset: g; }
.guide-list li {
  position: relative; padding: 0 0 0 30px; margin-bottom: 15px; counter-increment: g;
}
.guide-list li::before {
  content: counter(g); position: absolute; left: 0; top: 1px;
  width: 20px; height: 20px; border-radius: 50%; background: #F1EFEA; color: var(--ink-2);
  font-size: 10.5px; font-weight: 700; display: grid; place-items: center;
}
.guide-list strong { display: block; font-size: 13px; margin-bottom: 3px; }
.guide-list p { font-size: 12px; color: var(--muted); margin: 0 0 2px; line-height: 1.55; }
.dlg-tip {
  font-size: 12px; line-height: 1.6; color: #6A5A3F; background: #FBF6EA;
  border-radius: 9px; padding: 10px 12px; margin: 4px 0 8px;
}
.dlg-fine { font-size: 11px; color: var(--faint); margin: 0; }
.dlg-foot { display: flex; justify-content: flex-end; margin-top: 14px; }

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 8px);
  background: #17161A; color: #fff; font-size: 12.5px; font-weight: 500;
  padding: 10px 16px; border-radius: 999px; z-index: 80;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5); max-width: 88vw; text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* 데스크톱: 앱처럼 — 미리보기는 고정, 편집 패널만 스크롤 */
@media (min-width: 981px) {
  html, body { height: 100%; }
  body { overflow: hidden; }
  .layout { height: calc(100vh - 60px); }
  .panel { height: 100%; min-height: 0; }
  .panel-scroll { overflow-y: auto; }
  .stage { position: static; height: 100%; }
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(340px, 460px) minmax(0, 1fr); }
  .panel-scroll { padding: 6px 20px 26px; }
}

@media (max-width: 980px) {
  .mobtabs { display: flex; }
  .layout { display: block; max-width: none; }
  .panel { border-right: 0; min-height: 0; }
  .panel-scroll { overflow: visible; padding: 4px 16px 26px; }
  .panel-foot { padding: 10px 16px; }
  .stage {
    display: none; position: fixed; top: 106px; left: 0; right: 0; bottom: 0;
    height: auto; padding: 10px 12px 14px; background: var(--ui-bg); z-index: 20;
  }
  body[data-pane="preview"] .panel { display: none; }
  body[data-pane="preview"] .stage { display: flex; }
  .device { width: 100%; max-width: 390px; }
  .stage-top { display: none; }
  .fields--2 { grid-template-columns: 1fr 1fr; }
  .top { padding: 0 14px; }
  .brand-t small { display: none; }
  #btn-guide-top { display: none; }
  .viewer-bar { flex-wrap: wrap; font-size: 11.5px; gap: 8px; }
  .viewer-bar .btn { margin-left: 0; }
}

@media (max-width: 560px) {
  .tpl-grid { grid-template-columns: 1fr 1fr; }
  .thumb { height: 56px; }
  .fields--2 { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .row-2--price { grid-template-columns: 1fr 92px; }
  .share-row { flex-wrap: wrap; }
  .share-row input { flex: 1 0 100%; }
  .share-row .btn { width: 100%; }
  .top-actions .seg-btn { padding: 6px 10px; font-size: 12px; }
  .brand-t strong { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
