/* =========================================================
   SSO'S HUB — 3차 잠금 · 기기 동기화 (Supabase) 화면
   ─ 9개 페이지 공통 도구 줄(auth-gate.js) 옆의 ☁️ 칩,
     칩을 누르면 열리는 동기화 패널, 03 파일 창고의 기기 관리 안쪽 패널.
   ========================================================= */

/* ── 도구 줄의 ☁️ 동기화 칩 ─────────────────────────────── */

.ag-sync {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 8px 12px 8px 11px;
  border: 1px solid rgba(255, 105, 165, .28);
  border-radius: 999px;
  background: rgba(20, 16, 26, .84);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text-3, #a99aa6);
  font-family: inherit;
  font-size: 11.5px;
  line-height: 1;
  letter-spacing: -.01em;
  cursor: pointer;
  box-shadow: 0 12px 26px -20px #000;
  transition: color .16s, border-color .16s, background .16s, transform .16s;
  animation: ag-pill-in .4s .15s cubic-bezier(.22, 1, .36, 1) both;
}
.ag-sync:hover {
  color: var(--text, #f5edf2);
  border-color: rgba(255, 105, 165, .6);
  background: rgba(28, 22, 36, .92);
  transform: translateY(-1px);
}
.ag-sync-ico { display: inline-grid; place-items: center; }
.ag-sync-ico svg { width: 13px; height: 13px; }
.ag-sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6d6169;
  transition: background .2s, box-shadow .2s;
}
.ag-sync.is-on { color: var(--text-2, #cbbcc8); border-color: rgba(120, 226, 200, .34); }
.ag-sync.is-on .ag-sync-dot {
  background: #79e3c6;
  box-shadow: 0 0 0 3px rgba(120, 226, 200, .14), 0 0 9px rgba(120, 226, 200, .7);
}
.ag-sync.is-busy .ag-sync-dot {
  background: var(--pink-2, #ff75a8);
  box-shadow: 0 0 0 3px rgba(255, 77, 141, .16), 0 0 9px rgba(255, 77, 141, .75);
  animation: sx-pulse 1.1s ease-in-out infinite;
}
.ag-sync.is-error { color: #ff9db1; border-color: rgba(255, 120, 150, .5); }
.ag-sync.is-error .ag-sync-dot { background: #ff6f8d; box-shadow: 0 0 0 3px rgba(255, 111, 141, .16); }
@keyframes sx-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.8); }
}

@media (max-width: 460px) {
  .ag-sync { padding: 8px 10px; }
  .ag-sync-txt { display: none; }
  .ag-sync .ag-sync-dot { display: none; }
}

/* ── 동기화 패널 (다이얼로그 · 인라인 공용) ──────────────── */

.sync-dlg {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text, #f5edf2);
  max-width: min(520px, calc(100vw - 24px));
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  overflow: visible;
}
.sync-dlg::backdrop {
  background: rgba(5, 4, 8, .74);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.sync-dlg-card {
  position: relative;
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 26px 24px 22px;
  border: 1px solid rgba(255, 105, 165, .26);
  border-radius: 24px;
  background:
    radial-gradient(120% 90% at 100% -6%, rgba(255, 77, 141, .14), transparent 60%),
    linear-gradient(168deg, #1c1524 0%, #141019 58%, #0d0a12 100%);
  box-shadow: 0 40px 100px -50px #000, inset 0 1px 0 rgba(255, 255, 255, .06);
  font-family: var(--font-body, 'Pretendard Variable', Pretendard, -apple-system, sans-serif);
  -webkit-font-smoothing: antialiased;
}
.sync-dlg-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-3, #a99aa6);
  font-size: 15px;
  cursor: pointer;
  transition: color .16s, background .16s;
}
.sync-dlg-close:hover { color: var(--text, #f5edf2); background: rgba(255, 255, 255, .06); }

.sync-panel { display: block; text-align: left; }

.sync-kicker {
  margin: 0 0 8px;
  font-size: 9.5px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--pink-2, #ff75a8);
}
.sync-title {
  margin: 0 0 6px;
  font-family: var(--font-title, 'Gowun Dodum', sans-serif);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: -.01em;
  color: var(--text, #f5edf2);
}
.sync-sub {
  margin: 0 0 18px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-3, #a99aa6);
  word-break: keep-all;
}
.sync-sub b { color: var(--text-2, #cbbcc8); font-weight: 500; }

/* 상태 줄 · 경고 */
.sync-line {
  margin: 0 0 12px;
  padding: 9px 12px;
  border: 1px solid rgba(120, 226, 200, .22);
  border-radius: 10px;
  background: rgba(120, 226, 200, .07);
  font-size: 11.5px;
  line-height: 1.5;
  color: #a8ecda;
}
.sync-line.is-busy { border-color: rgba(255, 105, 165, .3); background: rgba(255, 77, 141, .09); color: var(--pink-3, #ff9dba); }
.sync-line.is-err { border-color: rgba(255, 120, 150, .38); background: rgba(255, 90, 120, .1); color: #ff9db1; }
.sync-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: #79e3c6;
  box-shadow: 0 0 0 3px rgba(120, 226, 200, .13);
  vertical-align: 1px;
}
.sync-warn {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px dashed rgba(255, 190, 120, .38);
  border-radius: 10px;
  background: rgba(255, 190, 120, .07);
  font-size: 11.5px;
  line-height: 1.55;
  color: #f2cfa3;
  word-break: keep-all;
}
.sync-warn code,
.sync-foot code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .07);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
}

/* 로그인 폼 */
.sync-form { margin: 0; }
.sync-field { display: block; margin-bottom: 11px; }
.sync-field > span {
  display: block;
  margin: 0 2px 6px;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-4, #82737f);
}
.sync-field input,
.sync-code-form input,
.sync-adddev input,
.sync-adddev select {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 12px;
  background: rgba(255, 255, 255, .045);
  color: var(--text, #f5edf2);
  font-family: inherit;
  font-size: 13.5px;
  letter-spacing: -.01em;
}
.sync-field input::placeholder { color: var(--text-4, #82737f); }
.sync-field input:focus,
.sync-code-form input:focus,
.sync-adddev input:focus,
.sync-adddev select:focus {
  outline: none;
  border-color: rgba(255, 105, 165, .7);
  background: rgba(255, 255, 255, .06);
  box-shadow: 0 0 0 3px rgba(255, 77, 141, .15);
}
.sync-error {
  min-height: 16px;
  margin: 4px 2px 8px;
  font-size: 11.5px;
  line-height: 1.45;
  color: #ff8fa3;
}
.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 4px;
}
.sync-actions .btn { flex: 1 1 auto; min-width: 132px; justify-content: center; }

/* 매직 링크 · 코드 */
.sync-codebox {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed rgba(255, 255, 255, .12);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
}
.sync-code-note {
  margin: 0 0 9px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-3, #a99aa6);
  word-break: keep-all;
}
.sync-code-form { display: flex; gap: 8px; }
.sync-code-form input { flex: 1 1 auto; letter-spacing: .2em; }
.sync-code-form .btn { flex: 0 0 auto; }

/* 연결된 계정 */
.sync-account {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 12px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  background: rgba(255, 255, 255, .035);
}
.sync-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 77, 141, .28), rgba(255, 77, 141, .1));
  color: var(--pink-2, #ff75a8);
  font-family: var(--font-title, 'Gowun Dodum', sans-serif);
  font-size: 14px;
}
.sync-account-main { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.sync-account-main b {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text, #f5edf2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sync-account-main i { font-style: normal; font-size: 10.5px; color: var(--text-4, #82737f); }
.sync-account .btn { flex: 0 0 auto; }

/* 기기 목록 */
.sync-devices { margin-top: 16px; }
.sync-subhead {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  font-family: var(--font-title, 'Gowun Dodum', sans-serif);
  font-size: 12.5px;
  color: var(--text-2, #cbbcc8);
}
.sync-subhead em {
  font-style: normal;
  font-size: 9px;
  letter-spacing: .2em;
  color: var(--text-4, #82737f);
}
.sync-subhead b { margin-left: auto; font-size: 11px; color: var(--text-4, #82737f); }
.sync-devlist { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sync-dev {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 11px;
  background: rgba(255, 255, 255, .025);
}
.sync-dev.is-now { border-color: rgba(255, 105, 165, .3); background: rgba(255, 77, 141, .06); }
.sync-dev-ico { flex: 0 0 auto; font-size: 13px; }
.sync-dev-main { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 1px; }
.sync-dev-main b {
  font-size: 12px;
  font-weight: 500;
  color: var(--text, #f5edf2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sync-dev-main i { font-style: normal; font-size: 10px; color: var(--text-4, #82737f); }
.sync-dev-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255, 77, 141, .16);
  color: var(--pink-3, #ff9dba);
  font-size: 9.5px;
}
.sync-dev-del {
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid rgba(255, 120, 150, .28);
  border-radius: 8px;
  background: transparent;
  color: #ff9db1;
  font-family: inherit;
  font-size: 10.5px;
  cursor: pointer;
  transition: background .16s, border-color .16s;
}
.sync-dev-del:hover { background: rgba(255, 90, 120, .14); border-color: rgba(255, 120, 150, .5); }
.sync-dev-empty {
  padding: 10px;
  border: 1px dashed rgba(255, 255, 255, .1);
  border-radius: 11px;
  font-size: 11px;
  color: var(--text-4, #82737f);
  text-align: center;
}
.sync-adddev { display: flex; flex-wrap: wrap; gap: 7px; }
.sync-adddev input { flex: 1 1 150px; }
.sync-adddev select { flex: 0 0 auto; width: auto; min-width: 98px; }
.sync-adddev .btn { flex: 0 0 auto; }

.sync-foot {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px dashed rgba(255, 255, 255, .08);
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--text-4, #82737f);
  word-break: keep-all;
}

/* 03 파일 창고 기기 관리 안쪽에 들어갈 때 — 조금 더 작게 */
.device-modal-cloud {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px dashed rgba(255, 255, 255, .08);
}
.device-modal-cloud .sync-hero { margin-bottom: 10px; }
.device-modal-cloud .sync-kicker { font-size: 9px; margin-bottom: 5px; }
.device-modal-cloud .sync-title { font-size: 15px; }
.device-modal-cloud .sync-sub { margin-bottom: 12px; font-size: 11.5px; }
.device-modal-cloud .sync-devices { margin-top: 12px; }
.device-modal-cloud .sync-foot { font-size: 10px; }

@media (max-width: 460px) {
  .sync-dlg-card { padding: 22px 16px 18px; border-radius: 20px; }
  .sync-actions .btn { min-width: 0; flex: 1 1 46%; }
  .sync-adddev input { flex: 1 1 100%; }
  .sync-adddev select { flex: 1 1 40%; }
}

@media (prefers-reduced-motion: reduce) {
  .ag-sync { animation: none !important; }
  .ag-sync.is-busy .ag-sync-dot { animation: none !important; }
}
