/*
 * 색: 기본은 어두운 화면. 머리글 버튼으로 밝은 화면을 고르면 <html data-theme="light"> (app.js, localStorage 'theme').
 * 저장값은 Layout 의 <head> 스크립트가 그리기 전에 적용한다(깜빡임 방지).
 */
:root {
  --bg: #111317;
  --card: #1c1f25;
  --text: #eceef1;
  --muted: #9aa3ad;
  --line: #2c3038;
  --accent: #6ea0ff;
  --accent-soft: #1d2a44;
  /* 강조색 바탕 위 글자 (어두운 화면은 강조색이 밝아서 어두운 글자, 밝은 화면은 흰색) */
  --on-accent: #0b1220;
  --shadow: none;
  color-scheme: dark;
}
:root[data-theme='light'] {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #191f28;
  --muted: #6b7684;
  --line: #e5e8eb;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --on-accent: #fff;
  --shadow: 0 1px 2px rgb(15 23 42 / .04), 0 4px 14px rgb(15 23 42 / .05);
  color-scheme: light;
}
/*
 * 퀴즈별 구역 색: 페이지가 style="--hue:221" 로 색상각만 넘기면 여기서 채도·명도를 정한다.
 * (사용자 정의 속성의 var() 는 선언한 요소에서 계산되므로 --hue 를 받은 요소마다 다시 선언)
 */
[style*='--hue'] {
  --app: hsl(var(--hue) 80% 72%);
  --app-soft: hsl(var(--hue) 30% 17%);
  --app-line: hsl(var(--hue) 30% 28%);
}
:root[data-theme='light'] [style*='--hue'] {
  --app: hsl(var(--hue) 68% 46%);
  --app-soft: hsl(var(--hue) 85% 96%);
  --app-line: hsl(var(--hue) 60% 85%);
}
/* 화면 밝기 버튼: 어두운 화면엔 해, 밝은 화면엔 달 */
.theme-btn {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer;
}
.theme-btn:hover { border-color: var(--accent); }
.theme-moon { display: none; }
:root[data-theme='light'] .theme-sun { display: none; }
:root[data-theme='light'] .theme-moon { display: block; }
.header-end { display: flex; align-items: center; gap: 8px; }
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard', 'Noto Sans KR', sans-serif;
  word-break: keep-all;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 720px; margin: 0 auto; padding: 16px; }

.site-header {
  position: sticky; top: 0; z-index: 1;
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  padding: 10px 16px; display: flex; gap: 16px; align-items: center;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--text); white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 26px; height: 26px; flex: none; }

/* 퀴즈 아이콘: 사이트가 직접 그리는 색 타일 + 글자 (각 회사 로고 아님) */
.app-icon {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 30%;
  background: linear-gradient(145deg, hsl(var(--hue) 75% 60%), hsl(var(--hue) 72% 40%));
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / .12), 0 1px 3px rgb(0 0 0 / .12);
  color: #fff; font-size: 15px; font-weight: 800; line-height: 1; letter-spacing: -0.04em;
  text-shadow: 0 1px 1px rgb(0 0 0 / .18); user-select: none;
}
.app-icon svg { width: 62%; height: 62%; display: block; }
.app-icon-long { font-size: 12px; }
.app-icon-sm { width: 20px; height: 20px; border-radius: 6px; font-size: 10px; box-shadow: none; }
.app-icon-sm.app-icon-long { font-size: 8px; }
.app-icon-lg { width: 52px; height: 52px; font-size: 22px; margin-bottom: 10px; }
.app-icon-lg.app-icon-long { font-size: 17px; }

/* 퀴즈 메뉴: 넓은 화면 한 줄(11칸), 좁은 화면 두 줄(6칸) — 스크롤 없이 한눈에 */
.app-nav {
  max-width: 720px; margin: 0 auto; padding: 12px 12px 0;
  display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 2px;
}
@media (max-width: 640px) { .app-nav { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.app-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; padding: 8px 2px 6px;
  border-radius: 12px; border: 1px solid transparent; color: var(--muted); font-size: 11.5px; line-height: 1.2;
  transition: background .15s, transform .15s;
}
.app-nav a:hover { text-decoration: none; background: var(--card); }
.app-nav a:hover .app-icon { transform: translateY(-1px); }
.app-nav .app-icon { transition: transform .15s; }
.app-nav a[aria-current='page'] { background: var(--card); border-color: var(--line); box-shadow: var(--shadow); color: var(--text); font-weight: 700; }
.app-nav-name { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.03em; }

h1 { font-size: 24px; margin: 12px 0 4px; }
h2 { font-size: 18px; margin: 28px 0 10px; }
.lead, .breadcrumb { color: var(--muted); margin: 0 0 16px; font-size: 14px; }

/* 첫 화면·퀴즈 페이지 머리 */
.hero:not([style]) { --app: var(--accent); --app-soft: var(--accent-soft); }
.hero {
  position: relative; overflow: hidden; margin: 8px 0 8px; padding: 20px 20px 18px; border-radius: 20px;
  background: linear-gradient(135deg, var(--app-soft), var(--card) 75%);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.hero::after {
  /* 오른쪽 위 장식 원 */
  content: ''; position: absolute; right: -40px; top: -50px; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--app) 22%, transparent), transparent 70%);
  pointer-events: none;
}
.hero h1 { margin: 2px 0 8px; font-size: 26px; letter-spacing: -0.02em; }
.hero-date { margin: 0; font-size: 13px; font-weight: 600; color: var(--app); }
.hero-stat { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--muted); }
.hero-stat strong { color: var(--text); }
.live-dot { position: relative; flex: none; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }
.live-dot::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; background: #22c55e;
  animation: live 1.8s ease-out infinite;
}
@keyframes live { from { transform: scale(1); opacity: .6; } to { transform: scale(2.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .live-dot::after { animation: none; } }

/* 첫 화면: 퀴즈 구역 제목 (색 점 + 오늘 개수) */
.app-head { display: flex; align-items: center; gap: 8px; }
.app-head a { display: flex; align-items: center; gap: 10px; color: var(--text); }
.app-head a::after { content: '›'; color: var(--muted); font-weight: 400; }
.app-head .app-icon { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; }
.app-head .app-icon-long { font-size: 10px; }
.app-count {
  font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: var(--app-soft); color: var(--app);
}
.app-title { display: flex; align-items: center; gap: 10px; }
.hero-app .app-icon { position: relative; z-index: 1; }

.cards { display: grid; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.card-app { font-size: 13px; font-weight: 600; }
/* 목록: 문제 카드 (누르면 문제 페이지). 왼쪽 띠는 퀴즈 색 */
.qcard {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 6px; padding-left: 20px;
  color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.qcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--app, var(--accent)); }
.qcard:hover { text-decoration: none; border-color: var(--app-line, var(--accent)); transform: translateY(-1px); }
.qcard:active { transform: scale(.99); }
.qcard .question { font-weight: 600; font-size: 16px; line-height: 1.5; }
.new-badge {
  display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 6px; vertical-align: 2px;
  font-size: 11px; font-weight: 800; letter-spacing: .03em; background: #ef4444; color: #fff;
}
.qcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.qcard .meta { margin: 0; color: var(--muted); font-size: 12px; }
.qcard .reveal { margin-left: auto; }
.reveal {
  flex: none; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--app-soft, var(--accent-soft)); color: var(--app, var(--accent)); white-space: nowrap;
}
.qcard:hover .reveal { background: var(--app, var(--accent)); color: var(--card); }

/* 문제 페이지 */
.q-hero { margin: 4px 0 16px; }
.q-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; background: var(--app-soft); color: var(--app); font-size: 13px; font-weight: 600; }
.q-hero h1 { font-size: 22px; line-height: 1.45; margin: 10px 0 0; }
.answer-box {
  position: relative; margin: 16px 0; padding: 18px 18px 14px; border-radius: 18px;
  background: linear-gradient(135deg, var(--accent-soft), var(--card) 70%);
  border: 1.5px solid var(--accent); box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 18%, transparent);
}
.answer-box h2 { margin: 0 0 6px; font-size: 14px; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.answer-count { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--on-accent); }
.answer-box .answers { border-top: none; margin: 0; }
.answer-box .answers li { padding: 10px 0; }
.answer-box .answers li:last-child { border-bottom: none; }
.answer-box .answer { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.answer-box .copy { padding: 8px 16px; font-size: 15px; font-weight: 600; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.answer-box .copy.done { background: var(--card); color: var(--accent); }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; }
.tags li { font-size: 13px; padding: 3px 10px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.answer-help { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.answer-box .meta { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

/* 광고 자리 */
.ad-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.ad-placeholder {
  display: flex; align-items: center; justify-content: center; min-height: 120px;
  border: 2px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 13px;
}

.answers { list-style: none; margin: 10px 0 0; padding: 0; border-top: 1px solid var(--line); }
.answers li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.answer { font-size: 20px; color: var(--accent); overflow-wrap: anywhere; }
.copy {
  margin-left: auto; flex: none; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 6px 12px; font-size: 14px; cursor: pointer;
}
.copy.done { color: var(--accent); border-color: var(--accent); }
.note { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.meta { margin: 8px 0 0; font-size: 12px; }
.meta a { color: var(--muted); }
/* 홈: 오늘 정답이 아직 없는 퀴즈를 한 칸에 */
.waiting h2 { font-size: 16px; }
.waiting-help { color: var(--muted); font-size: 14px; margin: 4px 0 10px; }
.waiting-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.waiting-list a {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 14px; font-weight: 600; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.waiting-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.waiting-list a:hover { text-decoration: none; border-color: var(--app, var(--accent)); }
.waiting-list .app-icon { width: 24px; height: 24px; border-radius: 7px; font-size: 11px; flex: none; }
.waiting-list .app-icon-long { font-size: 9px; }
.empty { color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 14px; padding: 14px 16px; margin: 0; }

.date-links { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.date-links a { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; color: var(--text); box-shadow: var(--shadow); }
.date-links a:hover { text-decoration: none; border-color: var(--accent); }
.count { color: var(--muted); font-size: 13px; }
.day-nav { display: flex; justify-content: space-between; margin-top: 24px; }
.ad { margin: 20px 0; min-height: 100px; }

.site-footer { max-width: 720px; margin: 40px auto 0; padding: 16px 16px 40px; color: var(--muted); font-size: 13px; }
.site-footer p { margin: 4px 0; }
.more {
  display: block; margin-top: 8px; padding: 10px; text-align: center; font-size: 14px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}

/* 관리자 페이지 */
.flash { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.admin-top { margin: 0 0 16px; }
.admin-top button, .bulk button, .cand-actions button {
  border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 10px; padding: 8px 14px; font-size: 15px; cursor: pointer;
}
.select-all { display: block; margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.cand { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px 14px; margin: 0 0 12px; min-width: 0; }
.cand legend { display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 14px; padding: 0 4px; }
.cand .src { font-weight: 400; font-size: 13px; }
.cand > label { display: block; font-size: 13px; color: var(--muted); margin-top: 8px; }
.cand textarea, .cand input:not([type=checkbox]) {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; font-size: 15px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; resize: vertical;
}
.cand input[name^='a_'] { font-weight: 700; color: var(--accent); }
.cand-actions { display: flex; gap: 8px; margin-top: 10px; }
button.pub { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.bulk { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 0; background: var(--bg); }
.bulk button { flex: 1; }

/* 새 정답 알림 받기 (웹 푸시) */
.push { margin-top: 12px; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.hero-actions .push { margin-top: 12px; }
.pin-btn { margin-top: 12px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.pin-btn[aria-pressed="true"] { border-color: var(--app, var(--accent)); color: var(--app, var(--accent)); font-weight: 700; }
.push-btn { padding: 8px 14px; border: 1px solid var(--line, #d0d7e2); border-radius: 999px; background: var(--card, #fff); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.push-btn[aria-pressed="true"] { color: var(--muted); }
.push-btn:disabled { opacity: 0.6; cursor: default; }
.push-help { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

/* 홈 화면에 추가 (머리글 오른쪽) */
.site-header { justify-content: space-between; }
.install-btn { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.install-help { margin: 0 auto; max-width: 720px; padding: 8px 16px; font-size: 13px; color: var(--muted); }

/* 다음 문제 공개 시각 */
.hero-next { margin: 6px 0 0; font-size: 14px; color: var(--text); }
.hero-next-left { color: var(--muted); }

/* 내 퀴즈 (자주 보는 퀴즈, 홈 위쪽) · 본 문제 */
.mine-badge { margin-left: auto; padding: 2px 8px; border-radius: 999px; background: var(--app-soft, var(--accent-soft)); color: var(--app, var(--accent)); font-size: 12px; font-weight: 700; }
.qcard.seen .question { color: var(--muted); }
.seen-mark { font-size: 12px; color: var(--muted); }

/* 맞았어요 / 틀렸어요 */
.vote { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.vote-q { font-size: 14px; color: var(--muted); margin-right: auto; }
.vote-btn { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.vote-btn:disabled { opacity: 0.55; cursor: default; }
.vote-msg { flex-basis: 100%; margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.vote-proof { margin: 8px 0 0; font-size: 14px; color: var(--text); }
.vote-warn { margin: 8px 0 0; font-size: 14px; color: #b45309; }
