/* styles.css 에서 떼어낸 조각. 원본 순서를 그대로 유지한다 —
   같은 선택자가 여러 파일에 있으면 뒤에 실린 쪽이 이긴다.
   로드 순서: styles.css → admin.css → profile.css → profile-editor.css → widgets.css */

/* ============================================================
   QR 스튜디오
   ============================================================ */
.result-qr { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 0 0 auto; }
.result-qr[hidden] { display: none; }
.qr-edit-btn {
  border: 1px solid var(--border-strong); background: transparent; color: var(--text);
  padding: 7px 12px; border-radius: 9px; font-size: 12.5px; font-weight: 700; cursor: pointer; transition: all .15s;
}
.qr-edit-btn:hover { background: var(--field-focus); }

.qrs-overlay {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(6, 6, 14, 0.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.qrs-overlay.open { display: flex; animation: qrs-fade .18s ease; }
@keyframes qrs-fade { from { opacity: 0; } to { opacity: 1; } }
.qrs-modal {
  width: 100%; max-width: 660px; max-height: 92vh; overflow-y: auto;
  background: var(--card-solid); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: 0 30px 80px -20px rgba(0,0,0,.7);
}
.qrs-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card-solid); }
.qrs-head h3 { margin: 0; font-size: 17px; font-weight: 800; }
/* 모달 닫기(✕) — 모든 모달이 이 한 규칙을 공유한다.
   예전에는 모달마다 같은 선언을 복붙했고, 그래서 새로 만든 모달
   (기간 연장·꾸미기·공통 로딩화면)은 규칙이 통째로 빠져 브라우저 기본
   회색 버튼이 그대로 나왔다. 새 모달을 만들면 여기 선택자만 추가할 것. */
.qrs-x,
.stats-x,
.edit-x,
.ext-x,
.sp-x,
.sd-x {
  border: 0; background: var(--field); color: var(--muted);
  width: 32px; height: 32px; border-radius: 9px;
  cursor: pointer; font-size: 15px; font-family: inherit;
  flex: 0 0 auto;
}
.qrs-x:hover,
.stats-x:hover,
.edit-x:hover,
.ext-x:hover,
.sp-x:hover,
.sd-x:hover { color: var(--text); background: var(--field-focus); }
.qrs-mount { padding: 22px; }

/* 패널 (모달/페이지 공용) */
.qrs-panel { display: flex; gap: 26px; }
.qrs-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.qrs-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.qrs-field > label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 7px; }
.qrs-dim { color: var(--faint); font-weight: 600; }
.qrs-color-row { display: flex; gap: 8px; align-items: center; }
.qrs-hex { width: 96px; flex: 0 0 auto; text-transform: uppercase; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; padding: 8px 10px; }
.qrs-chk { display: inline-flex; align-items: center; gap: 6px; margin-top: 9px; font-size: 13px; color: var(--muted); font-weight: 600; cursor: pointer; }
input[type="color"] { width: 46px; height: 38px; border: 1px solid var(--border-strong); border-radius: 8px; background: none; cursor: pointer; padding: 2px; flex: 0 0 auto; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
.qrs-seg { display: flex; gap: 4px; padding: 3px; background: var(--field); border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; }
.qrs-seg button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 8px 10px; border-radius: 7px; font-size: 13px; font-weight: 700; cursor: pointer; transition: all .15s; white-space: nowrap; }
.qrs-seg button:hover { color: var(--text); }
.qrs-seg button.on { background: var(--card-solid); color: var(--text); box-shadow: 0 2px 6px -2px rgba(0,0,0,.4); }

.qrs-side { flex: 0 0 auto; width: 272px; display: flex; flex-direction: column; gap: 16px; }
.qrs-preview {
  position: relative; padding: 14px; border-radius: 14px; border: 1px solid var(--border);
  background-color: #fff;
  background-image: linear-gradient(45deg, #e6e6ee 25%, transparent 25%), linear-gradient(-45deg, #e6e6ee 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e6e6ee 75%), linear-gradient(-45deg, transparent 75%, #e6e6ee 75%);
  background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.qrs-live { position: absolute; top: 10px; right: 10px; z-index: 1; font-size: 10px; font-weight: 800; letter-spacing: .08em; padding: 3px 8px; border-radius: 999px; background: var(--grad); color: #fff; }
.qrs-preview canvas { display: block; width: 100%; height: auto; border-radius: 4px; }
.qrs-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 92px; padding: 14px; border: 2px dashed var(--border-strong); border-radius: 12px;
  background: var(--field); cursor: pointer; text-align: center; transition: border-color .15s, background .15s;
}
.qrs-drop:hover, .qrs-drop.over { border-color: var(--primary); background: var(--field-focus); }
.qrs-drop input { display: none; }
.qrs-drop-text { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.qrs-drop-img { max-width: 72px; max-height: 72px; border-radius: 8px; }
.qrs-note { font-size: 12px; color: var(--faint); line-height: 1.5; margin: 2px 0 0; }
.qrs-dl { display: flex; gap: 10px; }
.qrs-dl .btn-submit { margin-top: 0; flex: 1; padding: 12px; }
.qrs-dl .icon-btn { padding: 12px 18px; }

/* 독립 QR 페이지 */
.qr-page { max-width: 860px; margin: 0 auto; }
.qr-studio-card { padding: 26px; }

@media (max-width: 720px) {
  .qrs-panel { flex-direction: column; }
  .qrs-side { width: 100%; }
  .qrs-preview { max-width: 320px; margin: 0 auto; width: 100%; }
}
@media (max-width: 460px) {
  .qrs-grid2 { grid-template-columns: 1fr; }
}

/* ============================================================
   클릭 통계 모달
   ============================================================ */
.stats-overlay {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(6, 6, 14, 0.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.stats-overlay.open { display: flex; animation: qrs-fade .18s ease; }
.stats-modal {
  width: 100%; max-width: 640px; background: var(--card-solid);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.7); overflow: hidden;
}
.stats-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.stats-head h3 { margin: 0; font-size: 17px; font-weight: 800; }
.stats-x { margin-left: 12px; }   /* 코드가 길면 제목과 붙는다 */
.stats-code { font-size: 13px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.stats-summary { display: flex; padding: 20px 22px 6px; }
.stats-summary div { flex: 1; text-align: center; }
.stats-summary b { display: block; font-size: 24px; font-weight: 900; letter-spacing: -.02em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stats-summary span { font-size: 12px; color: var(--muted); }
.stats-chart-wrap { padding: 12px 20px 22px; }
.stats-chart { min-height: 150px; }
.stats-svg { width: 100%; height: auto; display: block; overflow: visible; }
.stats-svg rect { transition: opacity .1s; }
.stats-svg rect:hover { opacity: .75; }
.stats-loading { text-align: center; color: var(--muted); padding: 54px 20px; font-size: 14px; }

/* ============================================================
   PRO 뱃지 + 목적지 수정 모달
   ============================================================ */
.pro-badge {
  display: inline-block; vertical-align: middle; font-size: 9.5px; font-weight: 800; letter-spacing: .06em;
  padding: 1px 6px; border-radius: 5px; background: var(--grad); color: #fff; line-height: 1.5;
}
.pro-badge.lg { font-size: 12px; padding: 2px 9px; border-radius: 6px; margin-left: 4px; vertical-align: 3px; }
/* 수정·연장 버튼: PRO 뱃지를 버튼 위쪽에 살짝 걸치게 */
.edit-btn { position: relative; overflow: visible; }
.edit-btn .pro-badge { position: absolute; top: -8px; right: -6px; font-size: 8px; padding: 1px 4px; letter-spacing: .04em; box-shadow: 0 2px 6px -1px rgba(0,0,0,.5); pointer-events: none; }
.li-actions { padding-top: 5px; }

/* 링크 아이템: 코드+뱃지 뒤에 원본 URL 길게 */
.li-code-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.li-code-row .li-code { flex: 0 0 auto; }
.li-orig { flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 비밀번호 고급옵션 */
.pw-advanced { margin-top: 12px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--field); border: 1px solid var(--border); }
.pw-advanced[hidden] { display: none; }
.pw-adv-head { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.pw-adv-field { margin-top: 10px; }
.pw-adv-field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.pw-adv-field .input { padding: 10px 12px; font-size: 14px; }
.pw-adv-lock { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

/* 게이트 비밀번호 힌트 */
.gate-hint { margin: 12px 0 0; font-size: 13.5px; color: var(--muted); background: var(--field); border: 1px solid var(--border); padding: 8px 14px; border-radius: 10px; display: inline-block; }

/* 통계 모달 — 유입경로 */
.stats-refs { padding: 4px 22px 22px; }
.stats-sub { margin: 0 0 12px; font-size: 14px; font-weight: 800; }
/* 무엇을 센 수치인지 제목 옆에 한 단어로 밝힌다 */
.stats-note {
  margin-left: 6px; padding: 2px 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  background: var(--field); border: 1px solid var(--border);
  vertical-align: 1px;
}
.stats-hint { margin: 10px 0 0; font-size: 12px; color: var(--faint); line-height: 1.6; }
.stats-hint b { color: var(--muted); }
.ref-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ref-name { flex: 0 0 86px; font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ref-bar { flex: 1; height: 12px; background: var(--field); border-radius: 999px; overflow: hidden; }
.ref-bar span { display: block; height: 100%; background: var(--grad); border-radius: 999px; }
.ref-val { flex: 0 0 auto; font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.ref-val em { color: var(--faint); font-style: normal; font-weight: 500; }
.ref-empty { color: var(--muted); font-size: 13px; padding: 4px 0; }
.icon-btn.pro-grant { border-color: color-mix(in srgb, var(--primary) 50%, transparent); color: var(--text); background: var(--grad-soft); }

.edit-overlay {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(6, 6, 14, 0.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.edit-overlay.open { display: flex; animation: qrs-fade .18s ease; }
.edit-modal {
  width: 100%; max-width: 480px; background: var(--card-solid);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.7); overflow: hidden;
}
.edit-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.edit-head h3 { margin: 0; font-size: 17px; font-weight: 800; }
.edit-body { padding: 22px; }
.edit-code { margin: 0 0 16px; padding: 9px 13px; border-radius: 10px; background: var(--field); border: 1px solid var(--border); font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; font-size: 14px; word-break: break-all; }
.edit-label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 7px; }
.edit-note { margin: 12px 0 0; font-size: 12.5px; color: var(--faint); line-height: 1.5; }

/* 수정 모달 · 비밀번호 보호 + 눈 아이콘 + 고급 옵션 */
.edit-pw-row { margin-top: 16px; }
.edit-pw-fields { margin-top: 4px; }
.pw-input { position: relative; }
.pw-input .input { padding-right: 42px; }
.pw-eye {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 30px; height: 30px; display: grid; place-items: center; padding: 0;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 7px;
}
.pw-eye:hover { color: var(--text); background: var(--field); }
.pw-eye svg { width: 18px; height: 18px; }
.edit-pw-hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.edit-adv { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.edit-adv-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 10px 0 6px; }
.edit-adv-label:first-child { margin-top: 0; }
.edit-adv-opt { font-weight: 500; color: var(--faint); }
.edit-adv .input { width: 100%; }
.edit-err { margin-top: 12px; }
.edit-save { margin-top: 16px; }

.edit-locked { text-align: center; padding: 14px 6px 6px; }
.edit-locked .lock-ic { font-size: 40px; margin-bottom: 10px; }
.edit-locked h4 { margin: 0 0 10px; font-size: 18px; font-weight: 800; }
.edit-locked p { margin: 0 auto 10px; max-width: 360px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.edit-locked .upgrade-hint { color: var(--text); font-weight: 600; font-size: 13px; }
.upgrade-hint a { color: var(--accent); text-decoration: underline; }
.ext-current { margin: 0 0 16px; font-size: 13px; color: var(--muted); padding: 8px 13px; border-radius: 10px; background: var(--field); border: 1px solid var(--border); }
.ext-opts { grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); }
.ext-err, .ext-save { margin-top: 14px; }

/* ---- 반응형 ---- */
@media (max-width: 860px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-create { position: static; }
}
@media (max-width: 560px) {
  .site-main { padding: 24px 0 56px; }
  .wrap { padding: 0 16px; }
  .pw-fields { grid-template-columns: 1fr; }
  .seg { grid-template-columns: repeat(2, 1fr); }
  .result-body { flex-direction: column; align-items: stretch; }
  .qr-box { align-self: center; }
  .link-item { flex-wrap: wrap; }
  .brand-name { font-size: 18px; }
  .header-inner { gap: 8px; }
  .site-nav { gap: 6px; }
  .nav-link { padding: 7px 8px; font-size: 13.5px; }
  .theme-toggle { padding: 2px; }
  .theme-toggle button { width: 26px; height: 26px; font-size: 13px; }
  .brand-mark { width: 30px; height: 30px; font-size: 17px; }
}

/* ---- 모션 축소 ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
