:root {
  --accent: #a8322a;
  --accent-bg: rgba(168, 50, 42, .1);
  --bg: #f7f6f4;
  --card: #ffffff;
  --text: #1c1c1e;
  --sub: #6b6b70;
  --line: rgba(0, 0, 0, .1);
  --green: #1d9e75;
  --green-bg: rgba(29, 158, 117, .1);
  --red: #d64541;
  --red-bg: rgba(214, 69, 65, .09);
  --orange: #c77b1e;
  --orange-bg: rgba(199, 123, 30, .12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618; --card: #232326; --text: #ececee; --sub: #a0a0a6;
    --line: rgba(255, 255, 255, .12);
    --accent-bg: rgba(228, 100, 90, .16);
  }
}
* { box-sizing: border-box; margin: 0; }
body {
  font-family: "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.55;
}
button { font: inherit; cursor: pointer; }

#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 17px; cursor: pointer; display: flex; align-items: center; gap: 7px; }
.logo {
  background: var(--accent); color: #fff; width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; font-family: serif; font-size: 17px;
}
#nav { display: flex; gap: 2px; flex-wrap: wrap; }
#nav button, #profileBox button {
  border: none; background: none; color: var(--sub); padding: 7px 10px; border-radius: 8px; font-size: 14px;
}
#nav button.on { background: var(--accent-bg); color: var(--accent); font-weight: 700; }
#nav button:hover { background: var(--accent-bg); }
#profileBox { margin-left: auto; position: relative; }
#profileBox > button { border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; color: var(--text); }
#profileMenu {
  position: absolute; right: 0; top: 40px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 6px; min-width: 170px;
}
#profileMenu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: none; background: none; border-radius: 8px; color: var(--text); }
#profileMenu button:hover { background: var(--accent-bg); }

main { max-width: 880px; margin: 0 auto; padding: 20px 16px 90px; }
footer { max-width: 880px; margin: 0 auto; padding: 14px 16px 30px; color: var(--sub); font-size: 12px; }

h1 { font-size: 24px; margin-bottom: 4px; }
.sub { color: var(--sub); font-size: 14px; margin-bottom: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
}
.grid { display: grid; gap: 10px; }
.g2 { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.metric { text-align: left; }
.metric .v { font-size: 26px; font-weight: 800; }
.metric .l { font-size: 12px; color: var(--sub); }
.qc { cursor: pointer; transition: transform .06s; border: 1px solid var(--line); }
.qc:hover { transform: translateY(-1px); border-color: var(--accent); }
.qc h3 { font-size: 15px; margin-bottom: 3px; }
.qc p { font-size: 12px; color: var(--sub); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.btn {
  background: var(--accent); color: #fff; border: none; padding: 10px 18px; border-radius: 10px;
  font-weight: 700; font-size: 15px;
}
.btn.ghost { background: none; border: 1px solid var(--line); color: var(--text); font-weight: 500; }
.btn:disabled { opacity: .4; cursor: default; }
.chip {
  border: 1px solid var(--line); background: none; color: var(--text);
  padding: 6px 13px; border-radius: 999px; font-size: 14px;
}
.chip.on { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); font-weight: 700; }
.chip.sm { padding: 4px 9px; font-size: 12.5px; }
.lecgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 6px; margin-top: 8px; }
.lecgrid button { text-align: left; font-size: 12.5px; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line); background: none; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lecgrid button.on { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); font-weight: 700; }
.tag { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.tag.gray { background: rgba(128,128,128,.14); color: var(--sub); }
select, input[type=date], input[type=text] {
  font: inherit; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); color: var(--text);
}

/* 퀴즈 */
#quizHead { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
#quizHead .prog { flex: 1; height: 7px; background: var(--line); border-radius: 99px; overflow: hidden; min-width: 90px; position: relative; }
#quizHead .prog > div { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; }
#timer { font-weight: 800; font-variant-numeric: tabular-nums; padding: 4px 10px; border-radius: 8px; background: rgba(128,128,128,.12); }
#timer.warn { color: var(--orange); background: var(--orange-bg); }
#timer.danger { color: var(--red); background: var(--red-bg); }
/* 문제 이미지: 화면 높이에 맞춰 축소(선지가 스크롤 없이 보이게), 클릭하면 원본 크기 확대 */
.qimg {
  display: block; margin: 0 auto 10px;
  max-width: min(100%, 720px); width: auto;
  max-height: min(72vh, 900px); object-fit: contain;
  border-radius: 10px; border: 1px solid var(--line); background: #fff;
  cursor: zoom-in;
}
.qimg.zoom { max-height: none; max-width: 100%; cursor: zoom-out; }
.zoomhint { text-align: center; font-size: 12px; color: var(--sub); margin: -4px 0 10px; }
#choices {
  position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  margin: 14px -16px -70px; padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.cbtn {
  width: 52px; height: 46px; font-size: 20px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--text);
}
.cbtn:not(:disabled):hover { border-color: var(--accent); }
.cbtn.ok { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.cbtn.no { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.conf { display: flex; gap: 4px; }
.conf button { border: 1px solid var(--line); background: none; color: var(--sub); border-radius: 8px; padding: 5px 10px; font-size: 13px; }
.conf button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); font-weight: 700; }
.fb { border-radius: 12px; padding: 15px; margin-top: 14px; border: 1px solid; }
.fb.ok { background: var(--green-bg); border-color: var(--green); }
.fb.no { background: var(--red-bg); border-color: var(--red); }
.fb h2 { font-size: 17px; margin-bottom: 8px; }
.notes { background: var(--card); border-radius: 10px; padding: 12px; margin-top: 10px; font-size: 14px; }
.notes div { padding: 4px 2px; display: flex; gap: 7px; }
.notes .pick { background: var(--red-bg); border-radius: 7px; font-weight: 600; }
.concept { margin-top: 14px; }
.concept .kw { display: inline-block; margin: 3px 4px 0 0; font-size: 12px; background: rgba(128,128,128,.13); padding: 3px 9px; border-radius: 99px; }
.confuse { background: var(--orange-bg); border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 14px; }
.listrow { display: flex; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); align-items: center; font-size: 14px; }
.bar { height: 9px; border-radius: 99px; background: var(--line); flex: 1; overflow: hidden; }
.bar > div { height: 100%; border-radius: 99px; }
.center { text-align: center; padding: 40px 0; }
.big { font-size: 44px; }
kbd {
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  padding: 1px 6px; font-size: 12px; background: var(--card);
}
@media (max-width: 640px) {
  #nav button { padding: 6px 7px; font-size: 13px; }
  main { padding-bottom: 110px; }
}
