/* 공통 레이아웃/컴포넌트 — 페이지 전용 스타일은 각 모듈 CSS 로 분리 */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* 헤더 */
.gn-header {
  display: flex; align-items: center; gap: var(--sp-6);
  max-width: var(--container); width: 100%;
  margin: 0 auto; padding: var(--sp-4) var(--sp-5);
  transition: opacity .2s ease;
}
.page-typing.typing-active .gn-header,
.page-typing.typing-active .gn-footer { opacity: .12; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .gn-header { transition: none; } }

.gn-logo { font-size: 22px; font-weight: 800; text-decoration: none; letter-spacing: -.01em; }
.gn-logo span { color: var(--brand-red); }
.gn-nav { display: flex; gap: var(--sp-4); }
.gn-nav a { color: var(--text-muted); text-decoration: none; font-size: var(--fs-sm); font-weight: 600; padding: var(--sp-1) var(--sp-2); border-radius: var(--radius-sm); }
.gn-nav a:hover { color: var(--text); background: var(--surface-sunken); }
.gn-header-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.gn-inline-form { display: inline; margin: 0; }
.gn-user-chip { font-size: var(--fs-sm); font-weight: 700; text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-full); padding: 5px 14px; }
.gn-icon-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-muted); cursor: pointer; font-size: var(--fs-xs); font-weight: 700; padding: 5px 9px; font-family: var(--font-ui); }
.gn-icon-btn:hover { color: var(--text); background: var(--surface-sunken); }

/* 메인/푸터 */
.gn-main { flex: 1; width: 100%; max-width: var(--container); margin: 0 auto; padding: var(--sp-5); }
.gn-footer {
  display: flex; justify-content: space-between; align-items: center;
  max-width: var(--container); width: 100%; margin: 0 auto;
  padding: var(--sp-4) var(--sp-5); color: var(--text-faint); font-size: var(--fs-xs);
  transition: opacity .2s ease;
}
.gn-footer nav { display: flex; gap: var(--sp-4); }
.gn-footer a { color: var(--text-faint); text-decoration: none; }

/* 버튼 */
.gn-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  background: var(--brand-red); color: #fff; border: none; cursor: pointer;
  font-family: var(--font-ui); font-size: var(--fs-md); font-weight: 700;
  padding: 10px 22px; border-radius: var(--radius-md); text-decoration: none;
}
.gn-btn:hover { background: var(--brand-red-hover); }
.gn-btn-sm { font-size: var(--fs-sm); padding: 6px 16px; }
.gn-btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.gn-btn-secondary:hover { background: var(--surface-sunken); }
.gn-btn-ghost { background: none; color: var(--text-muted); border: none; }
.gn-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 카드/폼 */
.gn-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-6); box-shadow: var(--shadow-1); }
.gn-field { display: flex; flex-direction: column; gap: var(--sp-1); margin-bottom: var(--sp-4); }
.gn-field label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.gn-input {
  background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font-ui); font-size: var(--fs-md); padding: 10px 12px;
}
.gn-input:focus { border-color: var(--focus-ring); outline: none; }
.gn-form-error { color: var(--err); font-size: var(--fs-sm); margin: var(--sp-2) 0; }
.gn-form-ok { color: var(--ok); font-size: var(--fs-sm); margin: var(--sp-2) 0; }

/* 필 버튼 그룹 (테스트 설정 등) */
.gn-pills { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.gn-pill {
  background: none; border: 1px solid transparent; border-radius: var(--radius-full);
  color: var(--text-faint); cursor: pointer; font-family: var(--font-ui);
  font-size: var(--fs-sm); font-weight: 600; padding: 4px 12px;
}
.gn-pill:hover { color: var(--text-muted); }
.gn-pill.on { background: var(--text); color: var(--bg); }

/* 언어 드롭다운 (헤더) */
.gn-locale { position: relative; }
.gn-locale-caret { font-size: .8em; margin-left: 2px; }
.gn-locale-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  list-style: none; margin: 0; padding: 4px; min-width: 150px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md, var(--radius-sm));
  box-shadow: var(--shadow-2);
}
.gn-locale-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text); font-family: var(--font-ui); font-size: var(--fs-sm); font-weight: 600; padding: 8px 10px;
}
.gn-locale-item:hover, .gn-locale-item:focus-visible { background: var(--surface-sunken); }
.gn-locale-item.on { color: var(--brand-red); }
.gn-locale-check { display: inline-block; width: 1em; text-align: center; }

/* 모달 */
.gn-modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 16, 8, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.gn-modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3); max-width: 560px; width: calc(100% - 40px);
  max-height: 84vh; overflow-y: auto; padding: var(--sp-6);
}
.gn-modal h2 { margin-top: 0; }
.gn-modal-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; flex-wrap: wrap; margin-top: var(--sp-5); }
.gn-logout-modal { max-width: 400px; }
.gn-logout-modal h2 { font-size: var(--fs-lg, 1.125rem); }
.gn-logout-desc { margin: var(--sp-2) 0 0; color: var(--text-muted); }
[hidden] { display: none !important; }

/* 배지/칩 */
.gn-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-sunken); color: var(--text-muted); border-radius: var(--radius-full); padding: 3px 12px; font-size: var(--fs-xs); font-weight: 700; }
.gn-chip-gold { border: 2px solid var(--brand-gold); color: var(--brand-gold); background: none; }

/* 에러 페이지 */
.gn-error-page { text-align: center; padding: var(--sp-8) 0; }
.gn-error-page h1 { font-size: var(--fs-hero); margin: 0; color: var(--text-faint); }

/* 숫자 정렬 */
.num { font-variant-numeric: tabular-nums; }

/* 테이블 기본 */
.gn-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.gn-table th { text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: var(--sp-2) var(--sp-3); border-bottom: 2px solid var(--border); }
.gn-table td { padding: var(--sp-3); border-bottom: 1px solid var(--border); }

/* 모바일 헤더 — 좁은 화면에서 가로 넘침 방지(로고·우측 버튼 1줄, 메뉴는 아래 줄 가로 스크롤) */
@media (max-width: 640px) {
  .gn-header { flex-wrap: wrap; row-gap: var(--sp-2); }
  .gn-header-right { gap: var(--sp-1); }
  .gn-nav { order: 3; width: 100%; overflow-x: auto; gap: var(--sp-3); scrollbar-width: none; }
  .gn-nav::-webkit-scrollbar { display: none; }
  .gn-nav a { white-space: nowrap; }
  .gn-user-chip { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* devplan006: 로그인 직후 "방금 기록이 저장됐어요" 안내 바 — JS 없이 닫기(#gn-claim-closed:target), 색은 tokens.css 변수(라이트/다크 자동) */
.gn-claim-wrap { width: 100%; padding: 0 var(--sp-5); }
.gn-claim {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  max-width: var(--container); margin: var(--sp-3) auto 0; padding: var(--sp-3) var(--sp-4);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: var(--radius-md);
  box-shadow: var(--shadow-1); font-size: var(--fs-sm);
}
#gn-claim-closed:target + .gn-claim { display: none; }
.gn-claim-list { flex: 1; min-width: 0; margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp-2); }
.gn-claim-main { font-weight: 600; }
.gn-claim-sub { display: block; margin-top: 2px; color: var(--text-muted); font-size: var(--fs-xs); }
.gn-claim-close {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-size: var(--fs-lg); line-height: 1;
}
.gn-claim-close:hover { background: var(--surface-sunken); color: var(--text); }
.gn-claim-close:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
@media (max-width: 640px) { .gn-claim-wrap { padding: 0 var(--sp-3); } }

/* 보호자 동의 대기(만 14세 미만) 안내 바 */
.gn-guardian-bar {
  display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); justify-content: center; align-items: center;
  background: var(--brand-gold-soft); color: var(--text);
  font-size: var(--fs-sm); padding: var(--sp-2) var(--sp-4); text-align: center;
}
.gn-guardian-bar a { color: var(--text); font-weight: 700; }
