/* 퀴즈냥 웹 — 모던 화이트 + 비비드 오렌지 (안드로이드 앱 Theme.kt 팔레트 동일) */

:root {
  --orange: #FF6D00;
  --orange-deep: #F24E00;
  --orange-light: #FF9A4D;
  --orange-soft: #FFE7D3;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --ink: #1B1C1F;
  --ink-sub: #7A828C;
  --hairline: #E9ECF1;
  --correct: #12B76A;
  --wrong: #F04438;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(27, 28, 31, .06);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
               "Noto Sans KR", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

#app {
  min-height: 100dvh;
  padding: calc(var(--safe-t) + 12px) 16px calc(var(--safe-b) + 24px);
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- 공통 ---------- */

.topbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; min-height: 40px;
}
.topbar h1 { font-size: 20px; font-weight: 800; margin: 0; flex: 1; letter-spacing: -.3px; }
.topbar .spacer { flex: 1; }

/* 손가락 기준 최소 44px — iOS 휴먼 인터페이스 가이드라인 */
.iconbtn {
  border: 0; background: transparent; color: var(--ink-sub);
  font-size: 26px; line-height: 1; border-radius: 12px; cursor: pointer;
  min-width: 44px; min-height: 44px; display: grid; place-items: center;
  margin-left: -10px;   /* 시각적 정렬은 유지하면서 탭 영역만 넓힌다 */
}
.topbar .iconbtn + h1 { margin-left: -2px; }
.iconbtn:last-child { margin-left: 0; margin-right: -10px; }
.iconbtn:active { background: var(--hairline); }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card.tap { cursor: pointer; transition: transform .08s; }
.card.tap:active { transform: scale(.985); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 16px; border: 0; border-radius: 16px;
  font-size: 17px; font-weight: 700; font-family: inherit;
  background: var(--hairline); color: var(--ink); cursor: pointer;
}
.btn:active { transform: scale(.985); }
.btn.primary {
  background: linear-gradient(135deg, #FF8A2B, var(--orange-deep));
  color: #fff; box-shadow: 0 6px 16px rgba(242, 78, 0, .28);
}
.btn.ghost { background: var(--card); box-shadow: var(--shadow); }
.btn:disabled { opacity: .45; }
.btn.sm { padding: 13px; min-height: 46px; font-size: 15px; border-radius: 13px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--ink-sub); margin-bottom: 6px; }

input[type="text"], textarea, select {
  width: 100%; padding: 14px; border: 1px solid var(--hairline); border-radius: 14px;
  font-size: 16px; /* 16px 미만이면 iOS가 자동 확대한다 */
  font-family: inherit; background: var(--card); color: var(--ink);
}
input[type="text"]:focus, textarea:focus, select:focus {
  outline: 2px solid var(--orange-light); outline-offset: -1px;
}
textarea { min-height: 160px; resize: vertical; line-height: 1.55; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 12px 16px; min-height: 44px; border-radius: 999px; border: 1px solid var(--hairline);
  background: var(--card); font-size: 15px; font-weight: 600; cursor: pointer;
  font-family: inherit; color: var(--ink);
}
.chip.on { background: var(--orange-soft); border-color: var(--orange-light); color: var(--orange-deep); }

.muted { color: var(--ink-sub); font-size: 14px; }
.center { text-align: center; }
.hint { font-size: 13px; color: var(--ink-sub); margin-top: 6px; }
.empty { text-align: center; color: var(--ink-sub); padding: 40px 20px; }

/* ---------- 마스코트 ---------- */

.mascot { display: block; margin: 0 auto; width: 132px; height: 132px; object-fit: contain; }
.mascot.sm { width: 88px; height: 88px; }
.mascot.pop { animation: pop .45s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes pop { 0% { transform: scale(.6); opacity: 0 } 100% { transform: scale(1); opacity: 1 } }
.mascot.bob { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-7px) } }

/* ---------- 홈 ---------- */

.streak {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #FFF3E8, #FFE7D3);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.streak .big { font-size: 26px; font-weight: 900; color: var(--orange-deep); line-height: 1; }
.streak .dots { display: flex; gap: 3px; margin-top: 6px; }
.streak .dots i { width: 8px; height: 8px; border-radius: 3px; background: #fff; opacity: .7; }
.streak .dots i.on { background: var(--orange); opacity: 1; }

.subject-title {
  font-size: 13px; font-weight: 800; color: var(--ink-sub);
  margin: 18px 4px 8px; letter-spacing: .2px;
}
.set-row { display: flex; align-items: center; gap: 12px; }
.set-row .meta { flex: 1; min-width: 0; }
.set-row .name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-row .sub { font-size: 13px; color: var(--ink-sub); margin-top: 2px; }
.badge {
  font-size: 12px; font-weight: 800; padding: 4px 9px; border-radius: 999px;
  background: var(--orange-soft); color: var(--orange-deep);
}
.badge.wrong { background: #FEE4E2; color: var(--wrong); }
.badge.ok { background: #D1FADF; color: #027A48; }

.fab-row { position: sticky; bottom: calc(var(--safe-b) + 8px); display: flex; gap: 10px; margin-top: 18px; }

/* ---------- 풀기 ---------- */

.progress { height: 6px; background: var(--hairline); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--orange-light), var(--orange)); transition: width .25s; }

.qtext { font-size: 19px; font-weight: 700; line-height: 1.45; margin: 6px 0 18px; word-break: keep-all; }

.opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left;
  padding: 15px; margin-bottom: 10px; border-radius: 16px;
  border: 1.5px solid var(--hairline); background: var(--card);
  font-size: 16.5px; font-family: inherit; color: var(--ink); cursor: pointer; line-height: 1.45;
}
.opt .no {
  flex: 0 0 26px; height: 26px; border-radius: 999px; background: var(--hairline);
  display: grid; place-items: center; font-size: 13px; font-weight: 800; color: var(--ink-sub);
}
.opt.sel { border-color: var(--orange); background: #FFF8F2; }
.opt.correct { border-color: var(--correct); background: #ECFDF3; }
.opt.correct .no { background: var(--correct); color: #fff; }
.opt.wrong { border-color: var(--wrong); background: #FEF3F2; }
.opt.wrong .no { background: var(--wrong); color: #fff; }
.opt:disabled { cursor: default; }

.verdict { text-align: center; font-size: 20px; font-weight: 900; margin: 4px 0 8px; }
.verdict.ok { color: var(--correct); }
.verdict.no { color: var(--wrong); }
.explain {
  background: #F8F9FB; border-radius: 14px; padding: 14px;
  font-size: 15px; line-height: 1.6; color: #454B54; margin-bottom: 12px;
}
.explain b { color: var(--ink); }

/* ---------- 결과 ---------- */

.score { font-size: 44px; font-weight: 900; line-height: 1; color: var(--orange-deep); }
.score small { font-size: 18px; color: var(--ink-sub); font-weight: 700; }

/* ---------- 생성 진행 ---------- */

.loading { text-align: center; padding: 30px 0; }
.loading .bar { height: 8px; background: var(--hairline); border-radius: 999px; overflow: hidden; margin: 18px auto 8px; max-width: 260px; }
.loading .bar > i { display: block; height: 100%; width: 30%; background: var(--orange); border-radius: 999px; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -30% } 100% { margin-left: 100% } }

/* ---------- 공유 코드 박스 ---------- */

.codebox {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.45; word-break: break-all;
  background: #F8F9FB; border-radius: 12px; padding: 12px;
  max-height: 120px; overflow: auto; color: #454B54;
}

/* ---------- 토스트 ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 28px); transform: translateX(-50%) translateY(20px);
  background: rgba(27, 28, 31, .93); color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: 15px; font-weight: 600; opacity: 0; pointer-events: none; transition: .22s; z-index: 50;
  max-width: 88vw; text-align: center;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 홈 화면에 추가 안내 (iOS 첫 방문) ---------- */

.a2hs-sheet {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(27, 28, 31, .55);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 16px 12px calc(var(--safe-b) + 8px);
  overflow-y: auto;
}
.a2hs-card {
  background: var(--card); border-radius: 22px; padding: 22px 20px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .22); text-align: center;
  max-width: 460px; width: 100%; margin: auto auto 0;
}
.a2hs-card h2 { font-size: 21px; margin: 10px 0 8px; letter-spacing: -.3px; }
.a2hs-card p { margin: 0 0 14px; font-size: 14.5px; line-height: 1.6; }

.a2hs-steps { list-style: none; margin: 0 0 14px; padding: 0; text-align: left; }
.a2hs-steps li {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px; margin-bottom: 8px;
  background: #F8F9FB; border-radius: 14px; font-size: 15px; line-height: 1.5;
}
.a2hs-steps li span {
  flex: 0 0 24px; height: 24px; border-radius: 999px; background: var(--orange); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
}
.a2hs-steps .share-ico { font-style: normal; }

/* 사파리 공유 버튼(화면 아래 가운데)을 가리키는 화살표 */
.a2hs-arrow {
  color: #fff; font-size: 30px; text-align: center; line-height: 1;
  margin-top: 10px; animation: point 1.3s ease-in-out infinite;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}
@keyframes point { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(8px) } }

/* ---------- 인쇄(=PDF 저장) ---------- */

#print-area { display: none; }

@media print {
  body.printing #app, body.printing .toast, body.printing .a2hs-sheet { display: none !important; }
  body.printing #print-area { display: block; padding: 0; }
  body { background: #fff; }
  .p-head { margin-bottom: 18px; border-bottom: 2px solid #222; padding-bottom: 8px; }
  .p-head h1 { font-size: 20pt; margin: 0 0 4px; }
  .p-sub { font-size: 10pt; color: #555; }
  .p-q { margin-bottom: 14pt; page-break-inside: avoid; }
  .p-qtext { font-size: 11.5pt; font-weight: 700; line-height: 1.5; }
  .p-num { color: #F24E00; }
  .p-opts { margin: 6pt 0 0 18pt; padding: 0; font-size: 11pt; line-height: 1.7; }
  .p-blank { margin: 10pt 0 0 6pt; font-size: 11pt; color: #666; }
  .p-ans { margin: 6pt 0 0 6pt; font-size: 10.5pt; color: #027A48; }
  .p-exp { color: #444; margin-top: 3pt; line-height: 1.55; }
  @page { margin: 14mm; }
}
