/* 제과기능사 기출 PASS 웹 - Flutter Material 3 (seed #2A78D6) 화면을 따라 만든 스타일 */
:root {
  --primary: #2a78d6;
  --on-primary: #fff;
  --primary-container: #d6e3ff;
  --on-primary-container: #001b3e;
  --surface: #fdfbff;
  --surface-2: #f1f3fa;
  --card: #f4f6fc;
  --on-surface: #1a1c20;
  --muted: #5d6068;
  --divider: #c4c6cf;
  --correct: #2a78d6;
  --wrong: #e34948;
  --answer-red: #e34948;
  --wrong-gray: #8a8a8a;
  --neutral: #b9b8b2;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #a9c7ff;
    --on-primary: #003063;
    --primary-container: #00468c;
    --on-primary-container: #d6e3ff;
    --surface: #111318;
    --surface-2: #1d2024;
    --card: #1d2026;
    --on-surface: #e2e2e9;
    --muted: #a8abb4;
    --divider: #44474e;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--surface);
  color: var(--on-surface);
  font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
.container { max-width: 760px; margin: 0 auto; padding: 16px; }
.container.wide { max-width: 1100px; }

/* 앱바 */
.appbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface-2);
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; min-height: 56px;
}
.appbar .title { font-size: 20px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .icon-btn { font-size: 20px; }
.appbar .right { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.progress { height: 4px; background: var(--primary-container); position: sticky; top: 56px; z-index: 10; }
.progress > div { height: 100%; background: var(--primary); transition: width .2s; }

.icon-btn {
  border: 0; background: transparent; color: var(--on-surface); cursor: pointer;
  width: 40px; height: 40px; border-radius: 20px; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(127,127,127,.12); }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 20px; padding: 10px 22px; font-size: 15px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer; font-family: inherit; text-align: center;
}
.btn-filled { background: var(--primary); color: var(--on-primary); }
.btn-filled:hover { filter: brightness(1.07); }
.btn-filled:disabled { background: rgba(127,127,127,.2); color: var(--muted); cursor: default; }
.btn-outlined { background: transparent; color: var(--primary); border-color: var(--divider); }
.btn-outlined:hover { background: rgba(42,120,214,.08); }
.btn-text { background: transparent; color: var(--primary); }
.btn-text:hover { background: rgba(42,120,214,.08); }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-danger { color: var(--wrong); }

/* 카드 / 타일 */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card-title { font-size: 14px; font-weight: 600; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.card-title .grow { flex: 1; }
.tiles { display: flex; gap: 8px; margin: 4px 0; }
.tile { flex: 1; background: var(--card); border-radius: var(--radius); padding: 12px 8px; text-align: center; }
.tile .v { font-size: 24px; font-weight: 700; }
.tile .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.c-correct { color: var(--correct); }
.c-wrong { color: var(--wrong); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.primary { color: var(--primary); }

/* 홈 메뉴 */
.menu-card {
  display: flex; align-items: center; gap: 16px; background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; color: var(--on-surface);
}
.menu-card:hover { filter: brightness(.98); }
.menu-card .avatar {
  width: 40px; height: 40px; border-radius: 20px; background: var(--primary-container); color: var(--on-primary-container);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.menu-card .body { flex: 1; }
.menu-card .t { font-size: 16px; }
.menu-card .s { font-size: 13px; color: var(--muted); }
.badge { background: var(--wrong); color: #fff; border-radius: 10px; padding: 2px 10px; font-size: 13px; }
.chev { color: var(--muted); font-size: 20px; }

/* 목록 */
.list-head { padding: 12px 16px 4px; font-size: 14px; font-weight: 600; }
.list-item {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px; color: var(--on-surface); cursor: pointer;
  background: none; border: 0; width: 100%; text-align: left; font: inherit;
}
.list-item:hover { background: rgba(127,127,127,.08); }
.list-item .avatar {
  width: 40px; height: 40px; border-radius: 20px; background: var(--primary-container); color: var(--on-primary-container);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.list-item .body { flex: 1; }
.list-item .s { font-size: 13px; color: var(--muted); }

/* 칩 / 스위치 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; border: 1px solid var(--divider); border-radius: 8px; padding: 6px 12px; cursor: pointer;
  font-size: 14px; user-select: none;
}
.chip input:checked + span { background: var(--primary-container); color: var(--on-primary-container); border-color: transparent; }
.chip input:checked + span::before { content: "✓ "; }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; }
.switch-row .body { flex: 1; }
.switch-row .s { font-size: 13px; color: var(--muted); }
.switch { position: relative; width: 52px; height: 32px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--surface-2); border: 2px solid var(--divider); border-radius: 16px; transition: .15s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 6px; top: 6px; background: var(--muted);
  border-radius: 50%; transition: .15s;
}
.switch input:checked + .slider { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); width: 24px; height: 24px; left: 2px; top: 2px; background: var(--on-primary); }
.radio-row { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.radio-row input { margin-top: 4px; accent-color: var(--primary); width: 18px; height: 18px; }
.radio-row .s { font-size: 13px; color: var(--muted); }
input[type=range] { width: 100%; accent-color: var(--primary); }

/* 폼 */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.input, select.input {
  width: 100%; padding: 12px; border-radius: 6px; border: 1px solid var(--divider); background: var(--surface);
  color: var(--on-surface); font-size: 15px; font-family: inherit;
}
.input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.error { color: var(--wrong); font-size: 12px; margin-top: 4px; }
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--primary-container); color: var(--on-primary-container); }
.alert.err { background: #fde2e1; color: #8c1d18; }

/* 로그인 */
.auth-wrap { max-width: 420px; margin: 40px auto; padding: 16px; }
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo .emoji { font-size: 44px; }
.auth-logo h1 { font-size: 22px; margin: 8px 0 4px; }

/* 문제 카드 (question_card.dart) */
.q-header { font-size: 12px; color: var(--primary); margin-bottom: 8px; }
.q-text { font-size: 17px; font-weight: 500; line-height: 1.4; white-space: pre-wrap; margin: 0; }
.q-image { margin-top: 12px; background: #fff; border: 1px solid var(--divider); border-radius: 6px; padding: 6px; text-align: center; }
.q-image img { max-width: 100%; }
.q-imagetext { margin-top: 8px; padding: 10px; border-radius: 6px; background: rgba(127,127,127,.08); white-space: pre-wrap; }
.choices { margin-top: 16px; }
.choice {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; font: inherit; color: var(--on-surface);
  background: var(--surface); border: 1px solid var(--divider); border-radius: 10px; padding: 12px; margin-bottom: 8px; cursor: pointer;
}
.choice:hover:not(:disabled) { background: rgba(42,120,214,.06); }
.choice:disabled { cursor: default; }
.choice .no { font-weight: 700; font-size: 17px; }
.choice .txt { flex: 1; font-size: 16px; line-height: 1.35; white-space: pre-wrap; }
.choice .mark { font-size: 18px; }
.choice.correct { background: rgba(227,73,72,.18); border: 1.5px solid var(--answer-red); }
.choice.correct .mark { color: var(--answer-red); }
.choice.wrong { background: rgba(138,138,138,.18); border: 1.5px solid var(--wrong-gray); }
.choice.wrong .mark { color: var(--wrong-gray); }

/* 하단 바 */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid rgba(127,127,127,.15);
  padding: 8px 16px 12px;
}
.bottombar .inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.bottombar .hint { flex: 1; text-align: center; color: var(--muted); }
.spacer { flex: 1; }

/* 다이얼로그 */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; align-items: center; justify-content: center; z-index: 50; padding: 24px;
}
.dialog-backdrop.open { display: flex; }
.dialog {
  background: var(--surface-2); border-radius: 28px; padding: 24px; max-width: 560px; width: 100%; max-height: 80vh;
  display: flex; flex-direction: column;
}
.dialog .content { overflow-y: auto; }
.dialog h3 { margin: 0 0 12px; font-size: 20px; font-weight: 500; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.answer-big { font-size: 22px; font-weight: 700; color: var(--answer-red); line-height: 1.4; margin-bottom: 12px; }
.explain { white-space: pre-wrap; line-height: 1.5; }

/* 바텀시트 */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; z-index: 40; align-items: flex-end; justify-content: center; }
.sheet-backdrop.open { display: flex; }
.sheet {
  background: var(--surface-2); width: 100%; max-width: 640px; border-radius: 28px 28px 0 0; padding: 8px 16px 16px;
  max-height: 90vh; overflow-y: auto;
}
.sheet .handle { width: 32px; height: 4px; border-radius: 2px; background: var(--divider); margin: 8px auto 16px; }

/* 차트 */
.bars .bar-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.bars .bar-label { width: 88px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars .bar-track { flex: 1; height: 14px; border-radius: 4px; background: rgba(127,127,127,.15); overflow: hidden; }
.bars .bar-fill { height: 100%; background: var(--correct); }
.bars .bar-fill.hl { background: var(--wrong); }
.bars .bar-val { width: 96px; text-align: right; font-size: 12px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut {
  width: 140px; height: 140px; border-radius: 50%; position: relative; flex-shrink: 0;
}
.donut::after { content: ""; position: absolute; inset: 22%; background: var(--card); border-radius: 50%; }
.donut .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1; }
.donut .center b { font-size: 28px; }
.donut .center span { font-size: 11px; color: var(--muted); }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 4px 0; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
svg.line { width: 100%; height: 170px; }
svg.line text { fill: var(--muted); font-size: 9px; }

/* 펼침 목록 */
details.exp { border-top: 1px solid rgba(127,127,127,.15); padding: 8px 0; }
details.exp:first-child { border-top: 0; }
details.exp summary { cursor: pointer; list-style: none; }
details.exp summary::-webkit-details-marker { display: none; }
details.exp summary .q { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
details.exp[open] summary .q { -webkit-line-clamp: unset; }
details.exp .inner { padding: 12px 0 4px; }

/* 표 */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { padding: 8px 6px; border-bottom: 1px solid rgba(127,127,127,.18); text-align: left; vertical-align: middle; }
table.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.tbl td.num, table.tbl th.num { text-align: right; }
.tbl-wrap { overflow-x: auto; }
.inline-form { display: inline-flex; gap: 4px; align-items: center; margin: 0; }
.inline-form .input { padding: 6px 8px; font-size: 13px; width: auto; }
.role-pill { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--primary-container); color: var(--on-primary-container); white-space: nowrap; }

.nav-links { display: flex; gap: 4px; flex-wrap: wrap; }
.footer-space { height: 100px; }
@media (max-width: 480px) {
  .tile .v { font-size: 20px; }
  .bars .bar-label { width: 70px; }
  .bars .bar-val { width: 84px; }
  .donut-wrap { gap: 12px; }
  .donut { width: 120px; height: 120px; }
}
