/* ============================================================================
   메가티콘 — Design System
   3D abstraction + glassmorphism · dark-only · zero-build
   Single source of truth for tokens & shared components.
   ========================================================================== */

/* ---- Fonts (Pretendard KR + display) ---------------------------------- */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.css");

/* ---- Design tokens ----------------------------------------------------- */
:root {
  /* base surfaces */
  --bg:            #07080c;
  --bg-2:          #0c0e15;
  --panel:         #12151e;
  --line:          #232838;
  --line-soft:     #1a1e2b;

  /* text */
  --fg:            #eef1f8;
  --fg-dim:        #b7bfd0;
  --muted:         #8b93a7;
  --faint:         #616a80;

  /* brand — iridescent holographic */
  --brand:         #6c8cff;
  --brand-2:       #a06bff;
  --brand-3:       #38e0d8;
  --brand-pink:    #ff6bd6;
  --grad-brand:    linear-gradient(120deg, #6c8cff 0%, #a06bff 45%, #38e0d8 100%);
  --grad-brand-soft: linear-gradient(120deg, rgba(108,140,255,.18), rgba(160,107,255,.14) 50%, rgba(56,224,216,.16));
  --grad-text:     linear-gradient(100deg, #cfd8ff 0%, #b69bff 40%, #7ef0e6 100%);
  --grad-aurora:   radial-gradient(60% 80% at 20% 0%, rgba(108,140,255,.28), transparent 60%),
                   radial-gradient(50% 70% at 90% 10%, rgba(160,107,255,.22), transparent 55%),
                   radial-gradient(70% 90% at 60% 100%, rgba(56,224,216,.16), transparent 60%);

  /* status */
  --ok:            #37d67a;
  --warn:          #ffcc57;
  --err:           #ff5c74;

  /* glass */
  --glass-bg:      rgba(20, 24, 36, 0.55);
  --glass-bg-2:    rgba(28, 33, 48, 0.42);
  --glass-brd:     rgba(255, 255, 255, 0.09);
  --glass-hi:      rgba(255, 255, 255, 0.14);
  --blur:          18px;
  --blur-lg:       34px;

  /* radii */
  --r-sm: 8px;  --r-md: 14px;  --r-lg: 20px;  --r-xl: 28px;  --r-pill: 999px;

  /* spacing scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 128px;

  /* shadows */
  --sh-sm:  0 1px 2px rgba(0,0,0,.4);
  --sh-md:  0 10px 30px -12px rgba(0,0,0,.6);
  --sh-lg:  0 30px 80px -24px rgba(0,0,0,.7);
  --sh-glow: 0 0 0 1px rgba(108,140,255,.35), 0 18px 60px -18px rgba(108,140,255,.5);

  /* type scale */
  --f-display: "Pretendard Variable", Pretendard, system-ui, sans-serif;
  --f-body:    "Pretendard Variable", Pretendard, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono:    "SFMono-Regular", ui-monospace, "Cascadia Code", "Consolas", monospace;

  /* layout */
  --maxw: 1120px;
  --nav-h: 68px;

  /* z */
  --z-bg: 0; --z-base: 1; --z-nav: 100; --z-modal: 1000; --z-toast: 1100;
}

/* ---- Reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--f-body);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  font-size: 16px;
  letter-spacing: -0.01em;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 700; line-height: 1.12; letter-spacing: -0.03em; margin: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img, svg, canvas { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(108,140,255,.35); color: #fff; }

/* ---- Ambient page background ------------------------------------------ */
body::before {
  content: "";
  position: fixed; inset: 0;
  background: var(--grad-aurora);
  z-index: var(--z-bg);
  pointer-events: none;
  opacity: .9;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: .025;
  z-index: var(--z-bg);
  pointer-events: none;
  mix-blend-mode: overlay;
}

/* ---- Layout helpers ---------------------------------------------------- */
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.section { position: relative; z-index: var(--z-base); padding: clamp(64px, 10vw, 120px) 0; }
.section--tight { padding: clamp(40px, 6vw, 72px) 0; }
.stack > * + * { margin-top: var(--s-4); }
.center { text-align: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--brand); padding: 6px 14px; border-radius: var(--r-pill);
  background: rgba(108,140,255,.1); border: 1px solid rgba(108,140,255,.22);
}
.grad-text {
  background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---- Glass primitives -------------------------------------------------- */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--glass-brd);
  box-shadow: var(--sh-md), inset 0 1px 0 var(--glass-hi);
}
.glass-card {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md), inset 0 1px 0 var(--glass-hi);
  padding: var(--s-6);
  transition: transform .35s cubic-bezier(.2,.7,.2,1), box-shadow .35s, border-color .35s;
}
.glass-card--hover:hover {
  transform: translateY(-4px);
  border-color: rgba(108,140,255,.4);
  box-shadow: var(--sh-lg), inset 0 1px 0 var(--glass-hi);
}

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; line-height: 1;
  padding: 14px 24px; border-radius: var(--r-pill); border: 1px solid transparent;
  transition: transform .2s, box-shadow .3s, background .3s, border-color .3s, opacity .2s;
  white-space: nowrap; text-align: center;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn--primary {
  color: #0a0c12; background: var(--grad-brand); background-size: 160% 160%;
  box-shadow: 0 10px 30px -10px rgba(108,140,255,.6);
  font-weight: 700;
}
.btn--primary:hover { box-shadow: 0 14px 44px -8px rgba(108,140,255,.75); background-position: 100% 50%; }
.btn--glass {
  color: var(--fg); background: var(--glass-bg-2);
  -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
  border-color: var(--glass-brd);
}
.btn--glass:hover { border-color: var(--glass-hi); background: rgba(40,46,66,.55); }
.btn--ghost { color: var(--fg-dim); background: transparent; border-color: var(--line); }
.btn--ghost:hover { color: var(--fg); border-color: var(--muted); }
.btn--lg { padding: 17px 32px; font-size: 16px; }
.btn--sm { padding: 9px 16px; font-size: 13px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; pointer-events: none; }

/* ---- Nav --------------------------------------------------------------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h); z-index: var(--z-nav);
  display: flex; align-items: center;
  transition: background .3s, border-color .3s, backdrop-filter .3s;
  border-bottom: 1px solid transparent;
}
.nav.is-scrolled {
  background: rgba(8,10,16,.6);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(150%);
  backdrop-filter: blur(var(--blur-lg)) saturate(150%);
  border-bottom-color: var(--line-soft);
}
.nav__inner { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-display);
  font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand__mark {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto;
  background: var(--grad-brand); box-shadow: 0 4px 14px -4px rgba(108,140,255,.7);
  display: grid; place-items: center; font-size: 16px;
}
.nav__links { display: flex; align-items: center; gap: 4px; }
.nav__link { padding: 9px 14px; border-radius: var(--r-pill); font-size: 14.5px; font-weight: 500;
  color: var(--fg-dim); transition: color .2s, background .2s; }
.nav__link:hover { color: var(--fg); background: rgba(255,255,255,.05); }
.nav__actions { display: flex; align-items: center; gap: 10px; }
.nav__toggle { display: none; background: transparent; border: 1px solid var(--line);
  color: var(--fg); width: 42px; height: 42px; border-radius: 12px; align-items: center; justify-content: center; }

@media (max-width: 860px) {
  .nav__links { display: none; }
  .nav__toggle { display: inline-flex; }
  .nav.is-open .nav__links {
    display: flex; flex-direction: column; align-items: stretch;
    position: absolute; top: var(--nav-h); left: 12px; right: 12px; padding: 12px;
    background: rgba(10,12,20,.85);
    -webkit-backdrop-filter: blur(var(--blur-lg)); backdrop-filter: blur(var(--blur-lg));
    border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  }
  .nav.is-open .nav__link { padding: 12px 14px; }
  .nav__actions .btn--ghost { display: none; }
  /* 좁은 화면에선 점만 남긴다 — 상태는 눌러서 본다 */
  .live__label { display: none; }
  .live__panel { width: min(320px, calc(100vw - 32px)); }
}

/* ---- Live signal (웹 ↔ 브리지 ↔ 확장 연동 표시) ------------------------- */
.live { position: relative; }
.live__pill { display: inline-flex; align-items: center; gap: 8px; height: 34px;
  padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255,255,255,.03); color: var(--fg-dim); font-size: 13px; cursor: pointer; }
.live__pill:hover { color: var(--fg); border-color: var(--line-strong, var(--line)); }
.live__dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
  background: var(--muted); box-shadow: 0 0 0 0 currentColor; }
.live__dot--on { background: var(--ok); color: var(--ok); animation: livePulse 2s infinite; }
.live__dot--done { background: var(--brand); }
.live__dot--warn { background: var(--warn); }
.live__dot--off { background: var(--muted); }
/* 빨강은 "사람이 손을 대야 다음이 없다"에만 쓴다 — 지금은 확장 미설치 하나뿐이다.
   브리지 꺼짐은 회색이다(끄고 사이트만 둘러보는 게 정상 사용이라서). */
.live__dot--bad { background: var(--err); }
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(55,214,122,.45); }
  70% { box-shadow: 0 0 0 7px rgba(55,214,122,0); }
  100% { box-shadow: 0 0 0 0 rgba(55,214,122,0); }
}
@media (prefers-reduced-motion: reduce) { .live__dot--on { animation: none; } }

.live__panel { position: absolute; right: 0; top: calc(100% + 10px); width: 330px;
  padding: 16px; z-index: var(--z-nav, 50); background: rgba(14,17,26,.92);
  -webkit-backdrop-filter: blur(var(--blur-lg)); backdrop-filter: blur(var(--blur-lg));
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  font-size: 13px; }
.live__row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0;
  border-bottom: 1px solid var(--line-soft); }
.live__row:last-of-type { border-bottom: 0; }
.live__k { color: var(--muted); }
.live__v { font-family: var(--f-mono); text-align: right; word-break: break-all; }
.live__v--ok { color: var(--fg); }
.live__v--warn { color: var(--warn); }
.live__v--off { color: var(--muted); }
.live__v--bad { color: var(--err); }
/* 줄 앞 신호등 — 펼쳐진 상태판(다운로드 페이지)에서 색만으로 훑을 수 있게. */
.live__rowdot { display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  margin-right: 7px; vertical-align: middle; background: var(--muted); }
.live__rowdot--ok { background: var(--ok); }
.live__rowdot--warn { background: var(--warn); }
.live__rowdot--bad { background: var(--err); }
.live__rowdot--off { background: var(--muted); }
.live__bar { height: 5px; border-radius: 999px; background: rgba(255,255,255,.07);
  overflow: hidden; margin: 10px 0 4px; }
.live__bar i { display: block; height: 100%; background: var(--grad-brand); transition: width .4s ease; }
.live__hint { color: var(--fg-dim); font-size: 12.5px; line-height: 1.6; margin: 10px 0 0; }
.live__hint--warn { color: var(--warn); }
.live__hint--ok { color: var(--ok); }
.live__hint--bad { color: var(--err); }
.live__reload { margin-left: 6px; vertical-align: baseline; }
.live__go { display: block; width: 100%; margin-top: 10px; }
.live__pick { width: 100%; margin-top: 8px; padding: 7px 8px; border-radius: 7px;
  border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--fg);
  font-family: var(--f-mono); font-size: 12px; }
.live__hint a { color: var(--brand); }
.live__hint code { background: rgba(255,255,255,.06); border-radius: 5px; padding: 1px 5px;
  font-family: var(--f-mono); font-size: 11.5px; }
.live__code { position: relative; margin-top: 10px; }
.live__code pre { font-size: 11px; white-space: pre-wrap; word-break: break-all; padding: 10px 12px; }
.live__copy { position: absolute; top: 6px; right: 6px; }

/* ---- Update bar (새 배포 감지) ------------------------------------------ */
.updatebar { position: fixed; left: 50%; bottom: 24px; z-index: 999;
  transform: translateX(-50%) translateY(24px); opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  padding: 12px 14px 12px 18px; border-radius: var(--r-lg);
  background: rgba(14,17,26,.94); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(var(--blur-lg)); backdrop-filter: blur(var(--blur-lg));
  box-shadow: var(--sh-lg); font-size: 13.5px; color: var(--fg-dim); }
.updatebar.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.updatebar b { color: var(--fg); }
@media (max-width: 560px) { .updatebar { flex-wrap: wrap; } }

/* ---- Footer ------------------------------------------------------------ */
.footer { position: relative; z-index: var(--z-base); border-top: 1px solid var(--line-soft);
  padding: 64px 0 40px; margin-top: 40px; }
.footer__grid { display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); gap: 32px; }
.footer__col h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 14px; font-family: var(--f-body); font-weight: 600; }
.footer__col a { display: block; color: var(--fg-dim); font-size: 14.5px; padding: 5px 0; transition: color .2s; }
.footer__col a:hover { color: var(--fg); }
.footer__about { color: var(--muted); font-size: 14px; max-width: 300px; margin-top: 14px; }
.footer__bottom { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 13px; }
@media (max-width: 1040px) { .footer__grid { grid-template-columns: 1.4fr repeat(2, 1fr); row-gap: 34px; } }
@media (max-width: 720px)  { .footer__grid { grid-template-columns: 1fr 1fr; gap: 28px; } }
.footer__col.is-empty { display: none; }   /* 링크가 전부 숨겨진 열(=제목만 남은 빈칸) */

/* ---- Forms ------------------------------------------------------------- */
.field { display: block; margin-bottom: 16px; }
.field__label { display: block; font-size: 13px; font-weight: 500; color: var(--fg-dim); margin-bottom: 7px; }
.input, .select, .textarea {
  width: 100%; font-size: 15px; font-family: inherit; color: var(--fg);
  background: rgba(8,10,16,.6); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 13px 15px; transition: border-color .2s, box-shadow .2s, background .2s;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(108,140,255,.18); background: rgba(8,10,16,.85);
}
.select { appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b93a7' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 15px center; padding-right: 38px; }
.field__hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.field__error { font-size: 12.5px; color: var(--err); margin-top: 6px; display: none; }
.field.is-error .input { border-color: var(--err); }
.field.is-error .field__error { display: block; }

/* ---- Chips / pills ----------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fg-dim);
  background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 6px 13px; }

/* ---- Banner (e.g. Supabase not configured) ----------------------------- */
.banner { position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-toast);
  background: linear-gradient(90deg, rgba(255,204,87,.16), rgba(255,92,116,.12));
  border-bottom: 1px solid rgba(255,204,87,.3); color: #ffe9b0;
  font-size: 13.5px; text-align: center; padding: 9px 16px; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.banner code { color: #fff; background: rgba(0,0,0,.3); padding: 2px 6px; border-radius: 5px; font-family: var(--f-mono); font-size: 12px; }
.has-banner { padding-top: 38px; }

/* ---- Toast ------------------------------------------------------------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: var(--z-toast); padding: 13px 22px; border-radius: var(--r-pill); font-size: 14px; font-weight: 500;
  background: rgba(20,24,36,.9); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border: 1px solid var(--glass-hi); box-shadow: var(--sh-lg); opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--ok { border-color: rgba(55,214,122,.4); }
.toast--err { border-color: rgba(255,92,116,.4); }

/* ---- Reveal-on-scroll -------------------------------------------------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s cubic-bezier(.2,.7,.2,1), transform .7s cubic-bezier(.2,.7,.2,1); }
.reveal.is-in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: .08s; }
.reveal[data-delay="2"] { transition-delay: .16s; }
.reveal[data-delay="3"] { transition-delay: .24s; }

/* ---- Utilities --------------------------------------------------------- */
.hide { display: none !important; }
.mono { font-family: var(--f-mono); }
.text-muted { color: var(--muted); }
.text-dim { color: var(--fg-dim); }
.mt-0 { margin-top: 0; }
.divider { height: 1px; background: var(--line-soft); border: 0; margin: var(--s-6) 0; }

/* ---- Reduced motion ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .reveal { opacity: 1; transform: none; }
}
