/* ============================================================
   LOANWORD — 공통 디자인 토큰 + 베이스 + 헤더/푸터/공통 컴포넌트
   ============================================================
   카테고리별 페이지에서 import:
     <link rel="stylesheet" href="/shared/base.css">
   카테고리별 추가 스타일은 자기 디렉토리의 style.css 에.
   ============================================================ */

:root[data-theme="light"] {
  --bg: #fafaf7;
  --bg-elev: #ffffff;
  --bg-card: #f4f3ed;
  --bg-hover: #ececec;
  --ink: #18181b;
  --ink-strong: #000000;
  --ink-dim: #71717a;
  --ink-mute: #a1a1aa;
  --line: #e4e4e0;
  --line-strong: #d4d4d0;
  --accent: #2563eb;
  --accent-bg: #dbeafe;
  --correct: #16a34a;
  --correct-bg: #dcfce7;
  --wrong: #dc2626;
  --wrong-bg: #fee2e2;
  --shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04);
}
:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-elev: #111113;
  --bg-card: #161618;
  --bg-hover: #1f1f23;
  --ink: #e4e4e7;
  --ink-strong: #fafafa;
  --ink-dim: #a1a1aa;
  --ink-mute: #71717a;
  --line: #27272a;
  --line-strong: #3f3f46;
  --accent: #60a5fa;
  --accent-bg: #1e3a8a33;
  --correct: #4ade80;
  --correct-bg: #14532d33;
  --wrong: #f87171;
  --wrong-bg: #7f1d1d33;
  --shadow: 0 1px 2px 0 rgb(0 0 0 / 0.5);
}

/* ============================================================
   BASE
   ============================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', 'Pretendard', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

::selection {
  background: var(--accent);
  color: var(--bg-elev);
}

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

.hidden {
  display: none !important;
}

/* ============================================================
   HEADER (공통)
   ============================================================ */
.app-header {
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg);
  flex-wrap: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
}

.brand:hover { color: var(--ink-strong); }

.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.brand-sub {
  color: var(--ink-mute);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.stat-label {
  color: var(--ink-mute);
  text-transform: uppercase;
  font-size: 10px;
}

.stat-value {
  color: var(--ink);
  font-weight: 700;
}

.stat-divider {
  color: var(--ink-mute);
  opacity: 0.4;
}

/* ============================================================
   THEME TOGGLE (공통)
   ============================================================ */
.theme-toggle {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px;
  flex-shrink: 0;
}

.theme-toggle button {
  background: transparent;
  border: none;
  color: var(--ink-mute);
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  min-width: 28px;
  min-height: 28px;
}

.theme-toggle button:hover { color: var(--ink); }

.theme-toggle button.active {
  background: var(--bg-elev);
  color: var(--ink-strong);
  box-shadow: var(--shadow);
}

.theme-toggle svg {
  width: 14px;
  height: 14px;
}

/* ============================================================
   MAIN LAYOUT (공통)
   ============================================================ */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 32px 24px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  gap: 24px;
}

/* ============================================================
   AD SLOT (공통 — 모든 카테고리에서 같은 위치)
   ============================================================ */
.ad-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 0 auto;
}

.ad-slot {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  background: var(--bg-card);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.ad-slot:has(.adsbygoogle[data-adsbygoogle-status]) .ad-placeholder {
  display: none;
}

.ad-placeholder {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  padding: 16px;
  line-height: 1.6;
}

.ad-placeholder .ad-tag {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.6;
}

.adsbygoogle {
  display: block;
  width: 100%;
}

/* ============================================================
   FOOTER (공통)
   ============================================================ */
.app-footer {
  border-top: 1px solid var(--line);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.05em;
  flex-wrap: wrap;
}

.keys {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 2px 6px;
  color: var(--ink);
  min-width: 18px;
  text-align: center;
}

.footer-version {
  white-space: nowrap;
}

/* ============================================================
   STATE PAGES (공통 — loading, blocked, error)
   ============================================================ */
.state-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 16px;
}

.state-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.state-msg {
  color: var(--ink-dim);
  max-width: 400px;
  font-size: 14px;
}

.state-loading-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
}

.state-loading-text::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 1; }
}

/* ============================================================
   RESPONSIVE (공통)
   ============================================================ */
@media (max-width: 768px) {
  .app-header { padding: 12px 18px; }
  .brand-sub { display: none; }
  .header-meta { gap: 12px; }
  .app-main { padding: 24px 18px; gap: 20px; }
  .app-footer { padding: 10px 18px; }
}

@media (max-width: 480px) {
  .app-header { padding: 10px 14px; gap: 8px; }
  .brand { font-size: 11px; gap: 8px; }
  .header-meta { gap: 8px; font-size: 10px; }
  .stat-label { display: none; }
  .stat { gap: 0; }
  .app-main { padding: 16px 14px; gap: 16px; }
  .ad-slot { min-height: 70px; }
  .keys { display: none; }
  .app-footer { padding: 10px 14px; justify-content: center; }
}

@media (min-width: 1280px) {
  .app-main { max-width: 880px; }
}
