/* AVIV LAB 디자인 토큰 — 포털·모든 앱의 단일 원본. 앱에서 값을 재정의하지 않는다. */
:root {
  color-scheme: light dark;

  /* 표면 */
  --bg: #f6f6f8;
  --bg-grad: radial-gradient(120% 90% at 50% -10%, #ffffff 0%, #f2f3f6 55%, #eceef2 100%);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --surface-2: #f1f2f5;
  --line: rgba(16, 18, 27, 0.10);
  --line-strong: rgba(16, 18, 27, 0.18);

  /* 글자 */
  --text: #14161d;
  --text-dim: #5b6070;
  --text-faint: #8b90a0;

  /* 강조 */
  --accent: #3b5bfd;
  --accent-ink: #ffffff;
  --accent-soft: rgba(59, 91, 253, 0.10);
  --accent-2: #00b3a4;
  --warn: #d97706;
  --danger: #d92d20;

  /* 형태 */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-full: 999px;
  --shadow-1: 0 1px 2px rgba(16, 18, 27, 0.06), 0 8px 24px rgba(16, 18, 27, 0.06);
  --shadow-2: 0 2px 6px rgba(16, 18, 27, 0.08), 0 20px 48px rgba(16, 18, 27, 0.12);
  --blur: saturate(180%) blur(20px);

  /* 간격 (8pt 그리드) */
  --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;

  /* 타이포 */
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
          "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;
  --t-display: clamp(2.1rem, 1.2rem + 3.2vw, 3.6rem);
  --t-h1: clamp(1.6rem, 1.1rem + 1.8vw, 2.4rem);
  --t-h2: clamp(1.25rem, 1rem + 0.9vw, 1.6rem);
  --t-body: 1rem;
  --t-sm: 0.875rem;
  --t-xs: 0.78rem;

  /* 모션 */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-1: 140ms;
  --dur-2: 260ms;
  --dur-3: 420ms;

  /* 터치 타깃 (Material 3 기준 최소 48) */
  --tap: 48px;
  --maxw: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c10;
    --bg-grad: radial-gradient(120% 90% at 50% -10%, #16181f 0%, #0e1016 55%, #08090d 100%);
    --surface: rgba(24, 26, 34, 0.66);
    --surface-solid: #14161d;
    --surface-2: #1b1e27;
    --line: rgba(255, 255, 255, 0.10);
    --line-strong: rgba(255, 255, 255, 0.20);
    --text: #f2f3f7;
    --text-dim: #a3a8b8;
    --text-faint: #71768a;
    --accent: #6a86ff;
    --accent-soft: rgba(106, 134, 255, 0.14);
    --accent-2: #2fd4c4;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.55), 0 24px 56px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --bg: #0b0c10;
  --bg-grad: radial-gradient(120% 90% at 50% -10%, #16181f 0%, #0e1016 55%, #08090d 100%);
  --surface: rgba(24, 26, 34, 0.66);
  --surface-solid: #14161d;
  --surface-2: #1b1e27;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.20);
  --text: #f2f3f7;
  --text-dim: #a3a8b8;
  --text-faint: #71768a;
  --accent: #6a86ff;
  --accent-soft: rgba(106, 134, 255, 0.14);
  --accent-2: #2fd4c4;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.55), 0 24px 56px rgba(0, 0, 0, 0.5);
}

/* ── 리셋 + 공통 ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* hidden 은 어떤 레이아웃 선언보다 세다. 이게 없으면 `.overlay{display:flex}` 같은
   클래스가 [hidden] 을 이겨, 숨긴 결과 화면이 판을 덮고 클릭을 가로챈다. */
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, canvas, svg { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 3px; }

:where(button, a, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: absolute; left: var(--s-4); top: calc(var(--s-4) * -4);
  padding: var(--s-3) var(--s-4); background: var(--accent); color: var(--accent-ink);
  border-radius: var(--r-sm); z-index: 100; transition: top var(--dur-1) var(--ease);
}
.skip-link:focus { top: var(--s-4); }

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--s-5); }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-5);
  border: 1px solid var(--line-strong); border-radius: var(--r-full);
  background: var(--surface-solid); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease),
              background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-1); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--ghost { background: transparent; border-color: var(--line); }
.btn--sm { min-height: 38px; padding: 0 var(--s-4); font-size: var(--t-sm); }

/* 카드 */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-full);
  background: var(--accent-soft); color: var(--accent);
  font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.02em;
}

/* 앱 공통 상단바 — 각 앱 index.html 에서 그대로 사용 */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  background: color-mix(in srgb, var(--surface-solid) 82%, transparent);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
}
.appbar__back {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 var(--s-3);
  border-radius: var(--r-full); text-decoration: none;
  color: var(--text-dim); font-size: var(--t-sm); font-weight: 600;
}
.appbar__back:hover { background: var(--surface-2); color: var(--text); }
.appbar__title { font-size: var(--t-sm); font-weight: 700; letter-spacing: -0.01em; }
.appbar__spacer { margin-left: auto; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
}
