/* 페이지 뼈대 — 관리판 투: 짙은 왼쪽 메뉴 + 가는 위쪽 띠 + 회색 본문 */
#app { min-height: 100vh; }

.shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  min-height: 100vh;
  align-items: stretch;
}

/* 메뉴 오른쪽 전체 (위쪽 띠 + 내용) */
.main { display: flex; flex-direction: column; min-width: 0; }

.content {
  display: flex; flex-direction: column; gap: var(--gap);
  min-width: 0; flex: 1; width: 100%; max-width: 1480px; margin: 0 auto;
  padding: 14px max(14px, env(safe-area-inset-right, 0px)) 40px max(14px, env(safe-area-inset-left, 0px));
}

/* ── 위쪽 띠 ────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  min-height: 62px;
  padding: 8px max(14px, env(safe-area-inset-right, 0px)) 8px max(14px, env(safe-area-inset-left, 0px));
  background: var(--top-bg);
  border-bottom: 1px solid var(--top-line);
}
.topbar-title { font-size: 14px; font-weight: 600; margin: 0; }
.topbar-sub { color: var(--muted); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.topbar .btn { padding: 4px 10px; font-size: 12px; min-height: 28px; }

.top-total {
  display: flex; align-items: baseline; gap: 8px;
  background: none; border: 0; padding: 2px 6px; cursor: pointer; color: inherit;
  border-radius: var(--r-sm);
}
.top-total:hover { background: var(--surface-2); }
.top-total-value { font-size: 17px; font-weight: 600; }
.top-save { display: flex; align-items: center; gap: 5px; }
.top-save .light-dot { width: 8px; height: 8px; border-radius: 50%; margin: 0; flex: none; }

/* ── 왼쪽 메뉴 (라이트·다크 모두 짙게) ───────────────────────── */
.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding: 0 0 16px;
  background: var(--side-bg);
  color: var(--side-fg);
}

.brand {
  display: flex; gap: 9px; align-items: center; min-width: 0;
  height: 62px; padding: 0 14px; margin-bottom: 6px;
  border-bottom: 1px solid var(--side-line);
}
.brand h1 { font-size: 16px; color: #fff; letter-spacing: -0.01em; }
.brand p { color: var(--side-fg-dim); font-size: 11px; }
/* 상표: 받침(배지) 위에 마크를 올려 '아이콘' 이 아니라 '상표' 로 보이게 */
.brand-badge {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #1d3250, #0b1725);
  box-shadow: inset 0 0 0 1px rgba(120, 200, 255, 0.18), 0 2px 10px rgba(0, 0, 0, 0.35);
}
.brand-mark { width: 24px; height: 24px; }
/* 24px 아래에서는 빛 번짐이 뭉개 보이므로 끕니다 */
.brand-mark .yf-glow { opacity: 0.55; }
.brand h1 { letter-spacing: 0.1em; font-weight: 700; }

.nav-groups { display: flex; flex-direction: column; gap: 4px; }
/* 묶음 사이 구분선 (첫 묶음 빼고) */
.nav-group + .nav-group { border-top: 1px solid var(--side-line); padding-top: 4px; }

.nav-group-title {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 7px 14px; background: none; border: 0; cursor: pointer; text-align: left;
  color: #9aa6b8; font-weight: 600;
}
.nav-group-title:hover { color: #fff; }
.nav-group-title .label-caps { color: inherit; }
.nav-caret { font-size: 9px; width: 9px; }
.nav-group-title .navitem-badge { margin-left: auto; }
.nav-items { display: flex; flex-direction: column; }

.navitem {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 14px 8px 16px; border-radius: 0;
  background: none; border: 0; border-left: 2px solid transparent; cursor: pointer; text-align: left;
  font-size: 13px; color: var(--side-fg);
}
.navitem:hover { background: var(--side-hover); color: #fff; }
/* 보고 있는 메뉴: 왼쪽 굵은 띠 + 옅은 파랑 바탕 (다크·딤에서도 또렷하게) */
.navitem-on { background: color-mix(in srgb, var(--side-on-bg) 26%, transparent); color: #fff; border-left: 3px solid var(--side-on-bg);
  padding-left: 15px; font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--side-on-bg) 35%, transparent); }
.navitem-on:hover { background: color-mix(in srgb, var(--side-on-bg) 34%, transparent); }
.navitem-on .navitem-icon { color: #8fc0ff; opacity: 1; }
.navitem-icon { width: 17px; height: 17px; flex: none; opacity: 0.9; }
.navitem-label { flex: 1; min-width: 0; }
/* 위험 경고가 있으면 아이콘 위에 빨간 점 (깜빡이지 않음) */
.navitem-alarm .navitem-icon { color: #ff7b82; }
.navitem { position: relative; }
.navitem-alarm::after { content: ''; position: absolute; left: 26px; top: 7px; width: 7px; height: 7px; border-radius: 50%;
  background: #ff5560; box-shadow: 0 0 0 2px var(--side-bg); }
.navitem-badge { font-size: 10px; padding: 0 5px; }
.navitem-on .navitem-badge { background: rgba(255, 255, 255, 0.22); color: #fff; border-color: transparent; }

.nav-ver { margin: auto 14px 0; color: var(--side-fg-dim); font-size: 10px; }

/* 메뉴 안에서는 포커스 테두리를 밝게 */
.sidebar :focus-visible { outline-color: #fff; outline-offset: -2px; }

/* ── 좁은 화면: 메뉴를 위로 ─────────────────────────────────── */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static; height: auto; gap: 8px; padding: 0 0 10px;
  }
  .brand { margin-bottom: 0; }
  .nav-groups { flex-direction: row; flex-wrap: wrap; gap: 6px 14px; padding: 0 12px; }
  .nav-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
  .nav-group-title { width: auto; padding: 2px 4px; }
  .nav-items { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .navitem {
    width: auto; padding: 5px 10px; border-radius: 999px; border-left: 0;
    background: var(--side-hover);
  }
  .navitem-on { border-left: 0; padding-left: 10px; }
  .nav-group + .nav-group { border-top: 0; padding-top: 0; }
  .navitem-alarm::after { left: 6px; top: 3px; }
  .nav-ver { margin: 0 12px; }
  .topbar { position: static; }
  .content { padding-top: 10px; }
}

/* ── 그 밖 ──────────────────────────────────────────────────── */
.light-ok-dot { background: var(--ok); }
.light-warn-dot { background: var(--warn); }
.light-bad-dot { background: var(--bad); }
.light-neutral-dot { background: var(--line-strong); }

.meter { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.meter-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.meter-bar { position: relative; height: 7px; background: var(--surface-2); border-radius: 999px; }
.meter-bar > .meter-fill { border-radius: 999px; }
.meter-fill { height: 100%; background: var(--ok); border-radius: 999px; min-width: 2px; }
.meter-warn .meter-fill { background: var(--warn); }
.meter-bad .meter-fill { background: var(--bad); }
.meter-warn.small, .meter-bad .meter-warn { color: var(--bad); }

/* ── 로그인·선택 전체 화면 ──────────────────────────────────── */
.gate-screen {
  position: relative; overflow: hidden;
  min-height: 100vh; display: grid; place-items: center;
  padding: 40px max(16px, env(safe-area-inset-left, 0px));
  background-color: #070e1a;
  color: #e8eef7;
  /* 사진이 오기 전에는 보이지 않습니다. 보이는 순간은 항상 사진까지 갖춘 모습입니다. */
  opacity: 0; transition: opacity 1.1s ease;
}
.gate-screen.is-ready { opacity: 1; }
/* 바탕 그림은 따로 한 층에 둡니다 — 움직이는 층(.gate-fx) 과 똑같이 확대돼야
 * 산 사진의 봉우리와 그 위를 오르는 길이 어긋나지 않습니다.
 * 사진이 다 내려오기 전에는 화면 전체를 투명하게 두었다가(.is-ready 전) 한꺼번에 띄웁니다.
 * 글귀 쪽은 어둡게 덮어 글자가 산 위에서도 또렷하게 읽히도록 합니다. */
.gate-screen::before {
  content: ''; position: absolute; inset: 0; z-index: 0;
  background-image:
    linear-gradient(135deg, rgba(10, 15, 25, 0.8) 0%, rgba(10, 15, 25, 0.4) 100%),
    url("../img/mountain-bg.jpg");
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}
/* 바탕과 그 위의 움직임이 아주 느리게 함께 다가옵니다 (44초에 4%) */
.gate-screen::before, .gate-fx { animation: gx-breathe-bg 44s ease-in-out infinite alternate; }
@keyframes gx-breathe-bg {
  from { transform: scale(1); }
  to   { transform: scale(1.04); }
}

/* 바탕 그림 위에 겹치는 움직이는 층 (login.js 의 backdrop()) */
.gate-fx {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.gate-inner {
  position: relative; z-index: 1;
  width: 100%; max-width: 1600px;
  padding: 0 clamp(16px, 8%, 150px);
  display: flex; justify-content: space-between; align-items: center; gap: 48px;
}
.brand-section { max-width: 560px; min-width: 0; }
.brand-section .gate-brand { margin-bottom: 60px; }
.gate-card { flex: 0 0 400px; max-width: 400px; }
.gate-creed { min-width: 0; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55); }

/* 넓은 화면의 자리 — 영상과 같습니다 (화면 폭·높이에 비례해 앉습니다):
 *   · 상표: 왼쪽 맨 위 구석 (왼쪽 7.8% · 위 8%)
 *   · 글귀: 왼쪽 아래 (왼쪽 12.5% · 아래 19%) — 영상보다 작게(4%), 위로·가운데 쪽으로 옮겼습니다 (v89)
 *   · 유리판: 오른쪽 (오른쪽 7.6%), 세로로는 한가운데보다 조금 위
 * 좁은 화면(860px 이하)에서는 아래쪽의 규칙대로 위에서 아래로 쌓입니다. */
@media (min-width: 861px) {
  .gate-inner {
    position: absolute; inset: 0; max-width: none;
    padding: 15vh 11.5vw 0 0; justify-content: flex-end;      /* 유리판: 안쪽으로 11.5% · 중심이 화면 세로 57% 쯤 */
    --gx-left: clamp(16px, 12.5vw, 330px);                      /* 상표 마크와 生 의 왼쪽 선 — 한 값으로 맞춥니다 */
  }
  .brand-section { display: contents; }
  .brand-section .gate-brand { margin-bottom: 0; }
  .gate-inner .gate-brand { position: absolute; left: calc(var(--gx-left) - 0.5vw); top: clamp(22px, 8vh, 100px); }
  .gate-inner .gate-creed { position: absolute; left: var(--gx-left); bottom: 19vh; }
  .gate-card { flex: 0 0 clamp(300px, 21.4vw, 430px); max-width: none; width: clamp(300px, 21.4vw, 430px); }   /* 안쪽 칸 폭은 그대로, 여백만 줄어 판이 조여집니다 */
}

/* 로그인 화면의 상표 — 영상의 자리·크기·글꼴.
 * 마크 | YAFO (은빛 세리프) / 영문 표어(YAFO 와 같은 폭으로 펼침) / 한글 이름(흰색) */
.gate-brand { position: relative; display: flex; align-items: flex-start; gap: clamp(8px, 0.8vw, 16px); --mark: clamp(52px, 5.6vw, 108px); }
.gate-mark {
  width: var(--mark); height: var(--mark); flex: none;
  filter: drop-shadow(0 0 18px rgba(79, 213, 255, 0.45)) drop-shadow(0 4px 14px rgba(0, 0, 0, 0.5));
}
.gate-word { display: flex; flex-direction: column; align-items: stretch; padding-top: calc(var(--mark) * 0.06); }
.gate-word strong {
  display: block; line-height: 1; letter-spacing: 0.03em;
  font-family: 'Cinzel', 'Trajan Pro', 'Times New Roman', Georgia, serif;
  font-size: clamp(34px, 3.8vw, 74px); font-weight: 700;
  color: #e6e9ee;
  background: linear-gradient(180deg, #ffffff 0%, #dfe3e9 42%, #8d96a4 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
}
.gate-word span {
  display: block; margin-top: 0.55em; white-space: nowrap;
  font-size: clamp(7px, 0.72vw, 13px); font-weight: 700; letter-spacing: 0.02em;
  text-align: justify; text-align-last: justify;
  color: #b7c0cc;
}
.gate-word em {
  display: block; font-style: normal; font-weight: 500; letter-spacing: 0.01em;
  font-size: clamp(14px, 1.45vw, 27px); color: #f1f5f9; margin-top: 0.7em;
}

/* 철학 글귀 — 영상처럼 크고 글자 사이가 성기며, 획은 중간 굵기의 흰 글씨입니다 */
.creed-han {
  font-size: clamp(30px, 4vw, 84px); font-weight: 500; letter-spacing: 0.26em; line-height: 1.15;
  color: #f6f9fd; margin-bottom: 0;
  text-shadow: 0 0 16px rgba(255, 255, 255, 0.16), 0 0 0 transparent, 0 0 0 transparent, 0 2px 18px rgba(0, 0, 0, 0.6);
}
.creed-ko {
  margin-top: clamp(8px, 0.9vw, 19px); font-size: clamp(12px, 1.08vw, 20px);
  color: #cdd4dd; line-height: 1.6; letter-spacing: 0.02em;
}
.creed-src { margin-top: 6px; font-size: 12px; color: #7f93ad; }

/* YAFO 의 뜻 (v202) — 글귀 아래 가는 금 하나 긋고 작게. 첫 글자 넷만 빛나게 해서 Y·A·F·O 가 읽히게 합니다. */
.creed-yafo {
  margin-top: clamp(14px, 1.5vw, 30px); padding-top: clamp(10px, 1.1vw, 20px);
  border-top: 1px solid rgba(205, 212, 221, 0.22); max-width: 34em;
}
.creed-yafo-en {
  margin: 0; font-family: 'Cinzel', 'Trajan Pro', 'Times New Roman', Georgia, serif;
  font-size: clamp(12px, 1.05vw, 20px); font-weight: 600; letter-spacing: 0.14em;
  color: #aeb8c5; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.55em;
}
.creed-yafo-en b { color: #8ff3ff; font-weight: 700; text-shadow: 0 0 12px rgba(0, 240, 255, 0.45); }
.creed-yafo-en .creed-dot { font-style: normal; color: #6f8094; }
.creed-yafo-ko { margin: 6px 0 0; word-break: keep-all; font-size: clamp(11px, 0.82vw, 15px); color: #93a3b7; letter-spacing: 0.02em; line-height: 1.6; }

/* 로그인 칸 — 글래스모피즘(유리 질감). 값은 Tunaki 가 보낸 .glass-login-card 그대로입니다. */
.gate-card {
  width: 100%; color: #e9f0f9;
  background: rgba(20, 25, 35, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);        /* 사파리 */
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 14px;
  padding: clamp(12px, 1.1vw, 22px) clamp(14px, 1.2vw, 24px);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  position: relative;
  /* 창 전체가 은은하게 맥박 뛰는 애니메이션 */
  animation: cardPulse 4s infinite alternate;
}
@keyframes cardPulse {
  0% {
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5), inset 0 0 0 rgba(0, 240, 255, 0);
    border-color: rgba(0, 240, 255, 0.2);
  }
  100% {
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 240, 255, 0.1);
    border-color: rgba(0, 240, 255, 0.5);
  }
}
.gate-card h1 {
  font-size: clamp(16px, 1.5vw, 26px); color: #fff; font-weight: 700;
  margin-bottom: clamp(14px, 1.3vw, 24px);
}
.gate-card .muted { color: #8a94a5; }
/* 입력칸 (.input-group) */
.gate-card input {
  min-height: 44px; padding: 12px 15px;
  background: rgba(0, 0, 0, 0.3); color: #fff; font-size: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px;
  transition: all 0.3s ease;
}
.gate-card input::placeholder { color: #5a6475; }
.gate-card input:focus-visible, .gate-card input:focus {
  outline: none; border-color: #00f0ff;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}
/* 네온 단추 (.neon-btn) */
.gate-card .btn { min-height: 44px; border-radius: 8px; transition: all 0.3s ease; }
.gate-card .btn-primary {
  width: 100%; padding: 12px;
  background: #00f0ff; color: #0a0f19; border: none;
  font-size: 1.1rem; font-weight: bold;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
}
.gate-card .btn-primary:hover:not(:disabled) {
  background: #33f3ff; filter: none;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.7);
  transform: translateY(-2px);
}
.gate-card .btn-ghost { background: transparent; color: #9fb3cc; border-color: rgba(255, 255, 255, 0.16); }
.gate-card .btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.07); }
.gate-card form { gap: 10px; }
.gate-card .banner-bad { background: rgba(192, 38, 44, 0.18); border-left-color: #ff7b82; color: #ffc9cc; }

@media (max-width: 860px) {
  .brand-section .gate-brand { margin-bottom: 22px; gap: 12px; }
  .gate-mark { width: 52px; height: 52px; }
  .gate-word strong { font-size: 34px; }
  .gate-word em { margin-top: 8px; font-size: 14px; }
  .gate-inner { min-height: 0; }
  .gate-creed { align-self: auto; }
  .gate-screen { padding: 28px 16px; align-items: start; }
  /* 좁은 화면: 위에서 아래로 쌓기 (v202 — 그전에는 가로 줄로 남아 유리판이 400px 을 먹고 글귀 칸이 0 으로 짓눌렸습니다) */
  .gate-inner { flex-direction: column; align-items: stretch; gap: 24px; max-width: 420px; margin: 0 auto; }
  .brand-section { max-width: none; }
  .creed-ko { font-size: 13px; }
  .creed-han { letter-spacing: 0.18em; }
  .gate-card { flex: none; width: 100%; max-width: none; padding: 26px 22px; border-radius: 14px; }
  .gate-card h1 { font-size: 1.2rem; margin-bottom: 20px; padding-bottom: 12px; }
  .creed-vow { margin-top: 16px; padding-top: 12px; }
}

/* ── 로그인 화면의 움직임 ───────────────────────────────────────
 * 사진 위에서 움직이는 것은 **안개 한 가지**뿐입니다.
 * 사진에 이미 은하수와 별이 가득해, 그 위에 가짜 별·별똥별·오르는 빛줄기를 더 얹으면
 * 사진이 지저분해집니다 (v81 에서 모두 걷어냈습니다).
 * 전부 CSS 라 자바스크립트가 매 프레임 도는 것이 없고,
 * 기기에서 "움직임 줄이기" 를 켜면 흐르지 않고 제자리에 섭니다. */

/* 구름: 왼쪽에서 오른쪽으로 흘러갑니다. 구름 그림은 clouds.js 가 구워 둔 canvas 이고,
 * 여기서는 transform 으로 밀기만 합니다 (그래픽 카드가 하므로 끊기지 않습니다).
 * 왼쪽 끝은 자기 폭만큼 화면 밖(-100%), 오른쪽 끝은 화면 폭만큼 더 나간 곳(100vw)입니다.
 * 그림 가장자리가 투명하게 사그라지므로 들어오고 나가는 자리가 보이지 않습니다. */
.gx-cloud {
  position: absolute; left: 0; height: auto;
  animation-name: gx-pass; animation-timing-function: linear; animation-iteration-count: infinite;
  will-change: transform;
}
/* 봉우리의 빛. "會當凌絕頂 一覽衆山小" — 언젠가 저 꼭대기에 서는 것이 이 사이트가 향하는 곳이므로,
 * 꼭대기는 구름에 가려지지 않고 늘 빛납니다. 자리는 login.js 가 사진 속 꼭대기에 맞춰 줍니다.
 *   halo : 꼭대기에서 번지는 청록빛이 숨 쉬듯
 *   beam : 꼭대기에서 하늘로 곧게 오르는 가는 빛줄기
 *   별빛 : 9초에 한 번 십자로 번쩍 (영상의 정상 섬광) */
.gx-summit { position: absolute; width: 0; height: 0; z-index: 2; pointer-events: none; }
.gx-summit::before {
  content: ''; position: absolute; left: -9vw; top: -9vw; width: 18vw; height: 18vw; border-radius: 50%;
  background: radial-gradient(circle, rgba(205, 253, 255, 0.62) 0, rgba(70, 235, 255, 0.28) 14%,
    rgba(0, 200, 255, 0.1) 40%, transparent 68%);
  mix-blend-mode: screen;
  animation: gx-halo 5.5s ease-in-out infinite;
}
.gx-summit::after {
  content: ''; position: absolute; left: -3.6vw; top: -3.6vw; width: 7.2vw; height: 7.2vw;
  background:
    radial-gradient(circle, #fff 0 2px, rgba(170, 250, 255, 0.7) 4px, transparent 14px),
    linear-gradient(90deg, transparent 0%, rgba(210, 252, 255, 0.95) 50%, transparent 100%) center / 100% 1.5px no-repeat,
    linear-gradient(0deg, transparent 0%, rgba(210, 252, 255, 0.95) 50%, transparent 100%) center / 1.5px 100% no-repeat;
  transform: scale(0.35); opacity: 0.55;
  animation: gx-summit-star 9s ease-in-out infinite;
}
.gx-beam {
  position: absolute; left: -1px; bottom: 0; width: 2px; height: 24vh;
  background: linear-gradient(0deg, rgba(210, 253, 255, 0.75), rgba(90, 240, 255, 0.28) 45%, transparent);
  opacity: 0.5;
  animation: gx-beam 5.5s ease-in-out infinite;
}
@keyframes gx-halo { 0%, 100% { opacity: 0.6; transform: scale(0.95); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes gx-beam { 0%, 100% { opacity: 0.32; } 50% { opacity: 0.7; } }
@keyframes gx-summit-star {
  0%, 62% { transform: scale(0.35); opacity: 0.55; }
  74%     { transform: scale(1.15); opacity: 1; }
  90%, 100% { transform: scale(0.45); opacity: 0.55; }
}
@keyframes gx-pass {
  from { transform: translate3d(-100%, 0, 0); }
  to   { transform: translate3d(100vw, 0, 0); }
}

/* 상표의 보석이 숨 쉬듯 빛납니다 */
.gate-mark .yf-glow { animation: gx-breathe 4.5s ease-in-out infinite; }
.gate-mark { animation: gx-mark-glow 4.5s ease-in-out infinite; }
@keyframes gx-mark-glow {
  0%, 100% { filter: drop-shadow(0 0 14px rgba(79, 213, 255, 0.3)) drop-shadow(0 4px 14px rgba(0, 0, 0, 0.5)); }
  50%      { filter: drop-shadow(0 0 26px rgba(79, 213, 255, 0.6)) drop-shadow(0 4px 14px rgba(0, 0, 0, 0.5)); }
}
@keyframes gx-breathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* 화면이 열릴 때 글귀와 유리판이 차례로 떠오릅니다 */
.gate-screen.is-ready .gate-creed { animation: gx-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
/* 유리판은 한 번 떠오른 뒤, 이어서 계속 맥박 뜁니다 (두 애니메이션을 함께 겁니다) */
.gate-screen.is-ready .gate-card { animation: gx-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.18s both,
              cardPulse 4s 1.1s infinite alternate; }
@keyframes gx-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* 영상의 한 바퀴(9초): 로고에 별빛이 번쩍 → 유리판 모서리에 빛이 맺히며 넓은 반사광이 비스듬히 쓸고 가고
 * → 단추 위로 흰 줄기가 지나고 → 입력칸 위로 청록 불빛 점들이 솟습니다.
 * 전부 한 박자(9초)에 맞춰 돌고, 사이사이는 조용합니다. */
.gx-sheen { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; }
.gx-sheen::before {                                   /* 넓은 반사광 */
  content: ''; position: absolute; top: -10%; bottom: -10%; left: 0; width: 34%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, 0.05) 18%,
    rgba(210, 252, 255, 0.2) 50%, rgba(255, 255, 255, 0.05) 82%, transparent 100%);
  transform: translateX(-130%) skewX(-16deg); opacity: 0;
  animation: gx-sheen 9s ease-in-out 1.4s infinite;
}
.gx-sheen::after {                                    /* 위 왼쪽 모서리의 별빛 */
  content: ''; position: absolute; top: -9px; left: -9px; width: 46px; height: 46px;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 2px, rgba(160, 250, 255, 0.55) 3px, transparent 12px),
    linear-gradient(90deg, transparent 0%, rgba(190, 250, 255, 0.9) 50%, transparent 100%) center / 100% 1px no-repeat,
    linear-gradient(0deg, transparent 0%, rgba(190, 250, 255, 0.9) 50%, transparent 100%) center / 1px 100% no-repeat;
  transform: scale(0.2); opacity: 0;
  animation: gx-glint 9s ease-out 1.4s infinite;
}
@keyframes gx-sheen {
  0%, 22% { transform: translateX(-130%) skewX(-16deg); opacity: 0; }
  26%     { opacity: 1; }
  40%     { transform: translateX(310%) skewX(-16deg); opacity: 1; }
  42%, 100% { transform: translateX(310%) skewX(-16deg); opacity: 0; }
}
@keyframes gx-glint {
  0%, 18% { transform: scale(0.2); opacity: 0; }
  24%     { transform: scale(1.1); opacity: 1; }
  34%, 100% { transform: scale(0.6); opacity: 0; }
}
.gate-card .btn-primary { position: relative; overflow: hidden; }
.gate-card .btn-primary::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 30%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, 0.7) 50%, transparent 100%);
  transform: translateX(-160%) skewX(-18deg); opacity: 0;
  pointer-events: none;
  animation: gx-sheen-btn 9s ease-in-out 1.4s infinite;
}
@keyframes gx-sheen-btn {
  0%, 52% { transform: translateX(-160%) skewX(-18deg); opacity: 0; }
  55%     { opacity: 1; }
  66%     { transform: translateX(460%) skewX(-18deg); opacity: 1; }
  68%, 100% { transform: translateX(460%) skewX(-18deg); opacity: 0; }
}

/* 입력칸에서 솟는 청록 불빛 점 — 가는 선 끝에 점이 달려 위로 오르다 사그라집니다 */
.gx-sparks { position: absolute; left: 0; right: 0; top: 47%; height: 0; pointer-events: none; }
.gx-sparks i {
  position: absolute; left: var(--x); bottom: 0; width: 2px; height: var(--h);
  background: linear-gradient(0deg, transparent, rgba(0, 240, 255, 0.55));
  opacity: 0; transform: translateY(0);
  animation: gx-spark 9s linear var(--d) infinite;
}
.gx-sparks i::before {
  content: ''; position: absolute; top: -2px; left: -1px; width: 4px; height: 4px; border-radius: 50%;
  background: #aefaff; box-shadow: 0 0 6px 1px rgba(0, 240, 255, 0.8);
}
@keyframes gx-spark {
  0%, 70% { opacity: 0; transform: translateY(0); }
  74%     { opacity: 1; }
  90%     { opacity: 0.7; transform: translateY(var(--r)); }
  96%, 100% { opacity: 0; transform: translateY(var(--r)); }
}

/* 상표 보석 위로 별빛이 한 번 번쩍 (영상의 그 섬광) */
.gate-brand::before {
  content: ''; position: absolute; pointer-events: none;
  left: calc(var(--mark) * -0.15); top: calc(var(--mark) * -0.45);
  width: calc(var(--mark) * 1.3); height: calc(var(--mark) * 1.3);
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.95) 0 3px, rgba(150, 245, 255, 0.5) 5px, transparent 22px),
    linear-gradient(90deg, transparent 0%, rgba(200, 250, 255, 0.85) 50%, transparent 100%) center / 100% 1.5px no-repeat,
    linear-gradient(0deg, transparent 0%, rgba(200, 250, 255, 0.85) 50%, transparent 100%) center / 1.5px 100% no-repeat;
  transform: scale(0.1); opacity: 0;
  animation: gx-flare 9s ease-out 0.9s infinite;
}
@keyframes gx-flare {
  0%, 12% { transform: scale(0.1); opacity: 0; }
  18%     { transform: scale(1.15); opacity: 1; }
  30%, 100% { transform: scale(0.5); opacity: 0; }
}

/* 글귀의 숨 — 영상의 그 박자(9초):
 *   번쩍(글자 둘레에 흰 빛이 번짐) → 가라앉음 → 한 번 흐려졌다가 → 또렷하게 되살아남
 * 위로 떠오르는 등장 효과(.gate-creed)와 겹치지 않도록 글자 줄 자체에 겁니다. */
.gate-screen.is-ready .creed-han { animation: gx-creed 9s ease-in-out 1.2s infinite; }
.gate-screen.is-ready .creed-ko  { animation: gx-creed-ko 9s ease-in-out 1.2s infinite; }
@keyframes gx-creed {
  0%, 22% { text-shadow: 0 0 16px rgba(255, 255, 255, 0.16), 0 0 0 transparent, 0 0 0 transparent, 0 2px 18px rgba(0, 0, 0, 0.6); opacity: 1; filter: none; }
  32%     { text-shadow: 0 0 10px rgba(255, 255, 255, 0.95), 0 0 28px rgba(130, 238, 255, 0.85), 0 0 62px rgba(0, 240, 255, 0.5), 0 2px 18px rgba(0, 0, 0, 0.6); }
  46%, 76% { text-shadow: 0 0 16px rgba(255, 255, 255, 0.16), 0 0 0 transparent, 0 0 0 transparent, 0 2px 18px rgba(0, 0, 0, 0.6); opacity: 1; filter: none; }
  85%     { opacity: 0.38; filter: blur(1.6px); }
  96%, 100% { opacity: 1; filter: none; }
}
@keyframes gx-creed-ko {
  0%, 22% { color: #cdd4dd; opacity: 1; }
  32%     { color: #ffffff; }
  46%, 76% { color: #cdd4dd; opacity: 1; }
  85%     { opacity: 0.38; }
  96%, 100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .gx-cloud, .gate-mark, .gate-mark .yf-glow, .gate-creed, .gate-card,
  .gate-screen, .gate-screen::before, .gate-fx, .gate-card .btn-primary::after,
  .gx-sheen::before, .gx-sheen::after, .gx-sparks i, .gate-brand::before, .creed-han, .creed-ko,
  .gx-summit::before, .gx-summit::after, .gx-beam {
    animation: none !important;
  }
  .gate-screen { transition: none; }
  /* 맥박을 멈추면 테두리가 흐린 쪽에 멈추므로, 또렷한 쪽으로 고정합니다 */
  .gate-card { border-color: rgba(0, 240, 255, 0.4); }
  /* 흐르지 않더라도 구름은 보여야 합니다 — 열릴 때의 자리에 그대로 섭니다 */
  .gx-cloud { transform: translate3d(calc(var(--gx-rest, 40vw) - 50%), 0, 0); }
}

/* 화면 색 고르기 (라이트 · 딤 · 다크 · 자동) */
.theme-wrap { position: relative; }
.theme-btn { display: inline-flex; align-items: center; gap: 6px; }
.theme-ico { flex: none; }
.theme-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 170px;
  display: grid; padding: 6px; gap: 2px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.theme-item {
  all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; font-size: 13px; color: var(--fg); cursor: pointer;
}
.theme-item:hover, .theme-item:focus-visible { background: var(--surface-2); }
.theme-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.theme-on { color: var(--accent); font-weight: 600; }
@media (max-width: 640px) { .theme-btn-label { display: none; } }
