@font-face {
  font-family: 'JoseonGulim';
  src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-04@1.0/ChosunGu.woff') format('woff');
  font-weight: normal;
  font-display: swap;
}
:root {
  --bg: #faf8f3; --card: #fff; --fg: #1a1714; --sub: #4a4640; --mute: #7a7470;
  --line: #ddd8cf; --soft: #ede9e1; --today: #7F77DD; --exam: #E24B4A; --exam-bg: #fff3f2;
  --shadow: 0 1px 4px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514; --card: #211f1d; --fg: #f1ede6; --sub: #cfc8bd; --mute: #9a938a;
    --line: #3a3632; --soft: #2c2926; --exam-bg: #3a1f1e; --shadow: none;
  }
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'JoseonGulim', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  word-break: keep-all; overflow-wrap: anywhere;
  background: var(--bg); color: var(--fg); font-size: 14px; line-height: 1.5;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px 16px 24px; }

/* 헤더 */
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.head h1 { font-size: 18px; font-weight: 700; }
.head .now { font-size: 12px; color: var(--mute); white-space: nowrap; }
.bar { height: 7px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--c, var(--today)); transition: width .3s; }
.bar-label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--mute); margin-bottom: 4px; }

/* 하단 탭 */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
  background: var(--card); border-top: 1.5px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  flex: 1; max-width: 160px; border: 0; background: none; padding: 9px 0 8px; font-size: 11px; color: var(--mute);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.nav button span { font-size: 19px; line-height: 1; }
.nav button.on { color: var(--today); font-weight: 700; }

/* 공통 카드 */
.card { background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.sect { font-size: 13px; font-weight: 700; color: var(--sub); margin: 18px 0 8px; }
.tip { font-size: 12px; color: var(--sub); line-height: 1.7; }
.warn { font-size: 12px; padding: 8px 11px; border-radius: 9px; background: var(--exam-bg); color: var(--exam); border: 1.5px solid var(--exam); margin-bottom: 8px; font-weight: 600; }

/* D-day 스트립 */
.dstrip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 6px; margin: 12px -16px 0; scrollbar-width: none; }
.dstrip::-webkit-scrollbar { display: none; }
.dcard { flex: 0 0 auto; min-width: 104px; background: var(--card); border: 1.5px solid var(--line); border-left: 4px solid var(--c); border-radius: 10px; padding: 8px 11px; }
.dcard b { display: block; font-size: 17px; color: color-mix(in srgb, var(--c) 70%, var(--fg)); }
.dcard span { display: block; font-size: 12px; font-weight: 600; }
.dcard small { font-size: 11px; color: var(--mute); }
.dcard.past { opacity: .45; }

/* 날짜 이동 */
.daynav { display: flex; align-items: center; gap: 8px; margin: 16px 0 8px; }
.daynav h2 { flex: 1; font-size: 16px; font-weight: 700; }
.daynav button, .btn {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 18px; padding: 6px 13px; font-size: 12.5px; font-weight: 600;
}
.btn.pri { background: var(--today); border-color: var(--today); color: #fff; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 5px; margin-left: 5px; vertical-align: middle; }
.badge.t { background: var(--today); color: #fff; }
.badge.e { background: var(--exam); color: #fff; }
.badge.h { background: var(--soft); color: var(--sub); }

/* 타임라인 행 */
.row { display: flex; align-items: stretch; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--soft); }
.row:last-child { border-bottom: 0; }
.row .tm { flex: 0 0 44px; font-size: 11px; color: var(--mute); line-height: 1.35; padding-top: 3px; font-variant-numeric: tabular-nums; }
.row .body {
  flex: 1; min-width: 0; border-radius: 8px; padding: 6px 10px; font-size: 13px;
  background: color-mix(in srgb, var(--c, var(--mute)) 13%, var(--card)); border-left: 3px solid var(--c, var(--mute));
}
.row .body em { font-style: normal; font-weight: 700; color: color-mix(in srgb, var(--c) 72%, var(--fg)); margin-right: 5px; }
.row .body small { color: var(--mute); margin-left: 4px; white-space: nowrap; }
.row.task .body { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.row.task input { flex: 0 0 auto; width: 19px; height: 19px; margin-top: 1px; accent-color: var(--c); }
.row.task.done .body { opacity: .5; }
.row.task.done .txt { text-decoration: line-through; }
.row.meal .body, .row.rest .body { background: none; border-left: 3px dashed var(--line); color: var(--mute); font-size: 12px; padding: 3px 10px; }
.row.exam .body { background: var(--exam-bg); border-left-color: var(--exam); color: var(--exam); font-weight: 700; }
.row.due .body { font-weight: 700; }
.row .x { flex: 0 0 auto; border: 0; background: none; color: var(--mute); font-size: 16px; padding: 0 4px; }
.addrow { display: flex; gap: 6px; margin-top: 10px; }
.addrow select, .addrow input, .field {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 9px; padding: 8px 10px; font-size: 13px; min-width: 0;
}
.addrow input { flex: 1; }

/* 달력 */
.wtabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 10px; }
.wtabs button { border: 1.5px solid var(--line); background: var(--card); border-radius: 18px; padding: 6px 13px; font-size: 12px; font-weight: 600; color: var(--sub); }
.wtabs button.on { background: var(--soft); border-color: var(--mute); color: var(--fg); }
.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 10px; }
.day { background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.day.today { border: 2px solid var(--today); }
.day.examday { border: 2px solid var(--exam); }
.day.past { opacity: .5; }
.day h3 { font-size: 14px; font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; margin-bottom: 4px; cursor: pointer; }
.day h3 .hrs { margin-left: auto; font-size: 11.5px; font-weight: 500; color: var(--mute); }
.day .row { padding: 4px 0; border: 0; }
.day .row .body { font-size: 12.5px; padding: 5px 9px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.chip { font-size: 10.5px; padding: 2px 7px; border-radius: 5px; background: var(--soft); color: var(--sub); }
.chip.exam { background: var(--exam); color: #fff; font-weight: 700; }
.chip.due { background: color-mix(in srgb, var(--c) 25%, var(--card)); font-weight: 700; }

/* 주간 그리드 */
.wtabs .mode { margin-left: auto; display: flex; gap: 4px; }
.gridwrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px 6px; }
.wgrid { display: grid; grid-template-columns: repeat(7, minmax(124px, 1fr)); gap: 5px; }
.gcol { background: var(--card); border: 1.5px solid var(--line); border-radius: 8px; padding: 6px; min-height: 120px; }
.gcol.today { border: 2px solid var(--today); background: color-mix(in srgb, var(--today) 7%, var(--card)); }
.gcol.examday { border: 2px solid var(--exam); background: var(--exam-bg); }
.gcol.past { opacity: .45; }
.gcol .gh { font-size: 10.5px; color: var(--mute); font-weight: 600; }
.gcol .gd { font-size: 13px; font-weight: 700; margin-bottom: 5px; display: flex; align-items: center; flex-wrap: wrap; gap: 3px; }
.gcol .gd[data-day] { cursor: pointer; }
.gcol .badge { margin-left: 0; font-size: 9.5px; padding: 1px 5px; }
.pill { position: relative; display: block; font-size: 10.5px; line-height: 1.4; padding: 4px 6px; border-radius: 5px; margin-bottom: 3px;
  background: color-mix(in srgb, var(--c) 16%, var(--card)); color: color-mix(in srgb, var(--c) 70%, var(--fg)); }
.pill b { display: block; font-weight: 700; }
.pill span { opacity: .85; }
label.pill { cursor: pointer; }
.pill.fix { background: var(--soft); color: var(--mute); font-size: 9.5px; }
.pill.solid { background: var(--c); color: color-mix(in srgb, var(--c) 30%, #1a1714); font-weight: 700; }
.pill.solid.exam { color: #fff; }
.pill.alba { background: color-mix(in srgb, #B3B3B3 35%, var(--card)); }
.pill.done { opacity: .45; text-decoration: line-through; }

/* 과목 개요 */
.stabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 12px; }
.stabs button { border: 1.5px solid var(--line); background: var(--card); border-radius: 20px; padding: 6px 15px; font-size: 12.5px; font-weight: 600; color: var(--sub); }
.stabs button.on { background: var(--c, #B5B1A9); border-color: transparent; color: color-mix(in srgb, var(--c, #B5B1A9) 30%, #1a1714); }
.ovgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ov { text-align: left; background: var(--card); border: 1.5px solid var(--line); border-left: 4px solid var(--c); border-radius: 10px; padding: 10px 13px; box-shadow: var(--shadow); cursor: pointer; }
.ov .nm { font-size: 14px; font-weight: 700; color: color-mix(in srgb, var(--c) 75%, var(--fg)); }
.ov .dt { font-size: 12px; color: var(--sub); margin: 3px 0 5px; }
.ov .tp { font-size: 11.5px; color: var(--mute); line-height: 1.5; margin-bottom: 7px; }
.tag-exam { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: var(--exam-bg); color: var(--exam); font-weight: 700; margin-left: 4px; }
.metacards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.metacards .card { padding: 10px 13px; }
.metacards small { display: block; font-size: 11px; color: var(--mute); margin-bottom: 2px; }
.metacards b { font-size: 13.5px; font-weight: 700; }
.banner { font-size: 12px; padding: 8px 11px; border-radius: 9px; margin-bottom: 10px; line-height: 1.6;
  background: color-mix(in srgb, var(--c) 10%, var(--card)); border: 1.5px solid color-mix(in srgb, var(--c) 40%, var(--card)); color: color-mix(in srgb, var(--c) 70%, var(--fg)); }
@media (max-width: 560px) { .ovgrid { grid-template-columns: 1fr; } }

/* 과목 */
.subj { margin-bottom: 12px; border-left: 4px solid var(--c); }
.subj h3 { font-size: 15px; font-weight: 700; color: color-mix(in srgb, var(--c) 75%, var(--fg)); }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.meta div { background: var(--bg); border-radius: 8px; padding: 6px 9px; }
.meta small { display: block; font-size: 10.5px; color: var(--mute); }
.meta b { font-size: 12.5px; font-weight: 600; }
.stage { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--soft); font-size: 12.5px; color: var(--sub); }
.stage:last-of-type { border-bottom: 0; }
.stage span { flex: 0 0 auto; align-self: flex-start; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: color-mix(in srgb, var(--c) 20%, var(--card)); color: color-mix(in srgb, var(--c) 75%, var(--fg)); }
details { margin-top: 8px; }
summary { font-size: 12.5px; font-weight: 600; color: var(--sub); cursor: pointer; padding: 4px 0; }
textarea.field { width: 100%; min-height: 64px; margin-top: 8px; resize: vertical; }

/* 체크리스트 */
.lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.list { border-top: 4px solid var(--c); }
.list h3 { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.list h3 small { font-weight: 500; color: var(--mute); margin-left: auto; }
.item { display: flex; align-items: flex-start; gap: 9px; padding: 6px 0; border-bottom: 1px solid var(--soft); font-size: 13px; }
.item label { flex: 1; display: flex; gap: 9px; align-items: flex-start; cursor: pointer; min-width: 0; }
.item input { flex: 0 0 auto; width: 19px; height: 19px; accent-color: var(--c); }
.item.done span { text-decoration: line-through; opacity: .5; }
.x { border: 0; background: none; color: var(--mute); font-size: 16px; padding: 0 4px; }
.colors { display: flex; gap: 6px; }
.colors label { width: 24px; height: 24px; border-radius: 50%; background: var(--c); border: 2px solid transparent; cursor: pointer; }
.colors input { display: none; }
.colors input:checked + label { border-color: var(--fg); }

/* 시간표 */
.ttwrap { --px: 54px; display: grid; grid-template-columns: 40px repeat(5, 1fr); background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.tth { text-align: center; font-size: 12px; color: var(--mute); padding: 6px 0; border-bottom: 1px solid var(--line); }
.tth.on { color: var(--today); font-weight: 700; }
.tthr { position: relative; }
.tthr span { position: absolute; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--mute); line-height: 1.3; padding-top: 4px; }
.tthr span b { display: block; font-size: 11px; color: var(--sub); }
.ttcol { position: relative; border-left: 1px solid var(--soft);
  background: repeating-linear-gradient(to bottom, var(--line) 0, var(--line) 1px, transparent 1px, transparent calc(var(--px) * 1.5)); }
.tthr { background: repeating-linear-gradient(to bottom, var(--line) 0, var(--line) 1px, transparent 1px, transparent calc(var(--px) * 1.5)); }
.ttb { position: absolute; left: 0; right: 0; padding: 4px 5px; overflow: hidden; background: var(--c); color: color-mix(in srgb, var(--c) 28%, #1a1714); font-size: 11.5px; line-height: 1.3; }
.ttb b { display: block; font-weight: 700; word-break: keep-all; }
.ttb small { font-size: 10px; opacity: .85; }

/* 기타 */
.tt { display: grid; grid-template-columns: 34px 1fr; gap: 6px 10px; font-size: 13px; }
.tt b { color: var(--mute); }
.certrow { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--soft); font-size: 13px; flex-wrap: wrap; }
.certrow b { flex: 1; min-width: 90px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* 확인 필요(미입력) 강조 */
.todo { display: inline-block; font-weight: 700; color: #B26A00; background: #FFF1D6; border: 1px dashed #E0A040; border-radius: 5px; padding: 0 6px; }
.todobox { background: #FFF6E3; border: 1.5px dashed #E0A040; border-radius: 12px; padding: 10px 13px; margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: #7A4A00; }
.todobox b { flex: 1 0 100%; font-size: 13.5px; }
.todobox small { flex: 1 0 100%; font-size: 11.5px; opacity: .8; }
.todobox button { border: 1.5px solid #E0A040; background: var(--card); color: var(--fg); border-radius: 18px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; }
.todobox button em { font-style: normal; font-weight: 700; color: color-mix(in srgb, var(--c) 72%, var(--fg)); }
.metacards .card.need { border: 1.5px dashed #E0A040; background: #FFF6E3; }
.metacards .card.need small { color: #B26A00; font-weight: 700; }
.infoin { width: 100%; border: 0; border-bottom: 1.5px solid var(--line); background: none; font-size: 13.5px; font-weight: 700; padding: 2px 0; border-radius: 0; }
.infoin::placeholder { font-weight: 400; color: var(--mute); }
.infoin:focus { outline: none; border-bottom-color: var(--today); }
@media (prefers-color-scheme: dark) {
  .todo, .todobox, .metacards .card.need { background: #3a2e14; color: #F0C36A; }
  .metacards .card.need small { color: #F0C36A; }
}

.links a { display: block; padding: 7px 0; border-bottom: 1px solid var(--soft); font-size: 13px; color: color-mix(in srgb, var(--c) 65%, var(--fg)); font-weight: 600; text-decoration: none; }
.links a:last-child { border-bottom: 0; }

/* 달력: 수업·알바는 테두리만(할 일은 색 채움) */
.pill.cls { background: transparent; border: 1.5px solid var(--c); color: var(--sub); font-size: 9.5px; font-weight: 600; padding: 2px 5px; }
.pill.cls.alba { --c: #B3B3B3; border-style: dashed; color: var(--mute); }
.chip.cls { background: transparent; border: 1.5px solid var(--c); padding: 1px 6px; }
.pill, .row .body { overflow-wrap: anywhere; }

/* 밀린 일 */
.odbox { background: var(--exam-bg); border: 1.5px solid var(--exam); border-radius: 12px; padding: 10px 13px; margin-top: 12px; }
.odh { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: var(--exam); font-size: 13.5px; }
.odh b { flex: 1; }
.odbox button { border: 1.5px solid var(--line); background: var(--card); border-radius: 14px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.odrow { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid color-mix(in srgb, var(--exam) 20%, transparent); font-size: 12.5px; }
.odrow > span:first-child { flex: 1; min-width: 0; }
.odrow em, .odwarn em, .nowt em { font-style: normal; font-weight: 700; color: color-mix(in srgb, var(--c) 72%, var(--fg)); margin-right: 5px; }
.odrow small { color: var(--mute); white-space: nowrap; }
.odbtn { display: flex; gap: 4px; flex: 0 0 auto; }
.odwarn { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; font-weight: 600; }
.odh + .odwarn, .odrow + .odwarn { margin-top: 8px; }
.odwarn span { background: var(--card); border: 1.5px solid var(--exam); border-radius: 8px; padding: 2px 8px; }

/* 지금 할 일 + 타이머 */
.nowcard { margin-top: 12px; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 9%, var(--card)); }
.nowh { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--mute); margin-bottom: 6px; }
.nowh b { color: var(--sub); }
.nowt { font-size: 16px; font-weight: 700; line-height: 1.4; }
.nows { font-size: 12px; color: var(--mute); margin-top: 3px; }
.clock { font-size: 46px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; margin-top: 8px; line-height: 1.1; }
.clock + .nows { text-align: center; }
.nowbtn { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
label.btn { position: relative; cursor: pointer; }

/* AI 프롬프트 */
.prow { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--soft); }
.prow:last-child { border-bottom: 0; }
.prow details { flex: 1; min-width: 0; margin: 0; }
.prow pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 12px; color: var(--sub); background: var(--bg); border-radius: 8px; padding: 8px 10px; margin-top: 4px; }

/* 암기 카드 */
.flash { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 190px; padding: 18px;
  background: var(--card); border: 2px solid var(--c); border-radius: 14px; text-align: center; }
.flash small { font-size: 11.5px; color: var(--mute); }
.flash b { font-size: 22px; line-height: 1.4; overflow-wrap: anywhere; }
.flash i { font-style: normal; font-size: 13px; color: var(--mute); }
form[data-bulkcard] textarea { min-height: 110px; }

/* 여유 블록(밀리면 버려도 되는 것) */
.row.task.opt .body { background: transparent; border: 1.5px dashed var(--c); border-left-width: 3px; }
.pill.opt { background: transparent; border: 1.5px dashed var(--c); }
.txt u, .odrow u { text-decoration: none; font-size: 10.5px; font-weight: 700; border: 1px dashed var(--mute); color: var(--mute); border-radius: 4px; padding: 0 4px; margin-right: 5px; }
/* 백업 */
.bk { padding: 10px 0; border-top: 1px solid var(--soft); margin-top: 10px; }
.bk b { display: block; font-size: 13px; }
.bk small { display: block; font-size: 11.5px; color: var(--mute); }

/* 로그인 화면 */
.authbox { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.authbox .card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.authbox h1 { font-size: 20px; }
.authbox h2 { font-size: 15px; color: var(--sub); }
.authbox label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--sub); font-weight: 600; }
.authbox input { border: 1.5px solid var(--line); background: var(--card); border-radius: 9px; padding: 11px 12px; font-size: 16px; font-weight: 400; color: var(--fg); }
.authbox .btn { padding: 11px; font-size: 15px; }
.authmsg { font-size: 12.5px; color: var(--exam); min-height: 18px; }
.linkbtn { border: 0; background: none; color: var(--today); font-size: 13px; font-weight: 600; padding: 4px; }
[hidden] { display: none !important; }

/* 일정 설정 화면 */
.setrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.setrow label { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--mute); font-weight: 600; flex: 1 1 110px; min-width: 0; }
.setrow label.grow { flex: 1 1 100%; }
.setrow input, .setrow select { border: 1.5px solid var(--line); background: var(--card); border-radius: 9px; padding: 8px 10px; font-size: 16px; color: var(--fg); min-width: 0; width: 100%; font-weight: 400; }
.setrow .chk { flex-direction: row; align-items: center; gap: 6px; flex: 1 1 auto; font-size: 13px; color: var(--sub); }
.setrow .chk input { width: 18px; height: 18px; }
.setlist .item { align-items: center; }
.setlist .item > span { flex: 1; min-width: 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 6px; }
.backrow { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; }
.emptybox { text-align: center; padding: 28px 16px; margin-top: 16px; }
.emptybox b { display: block; font-size: 15px; margin-bottom: 6px; }
.emptybox .btn { margin-top: 12px; }

/* ══════════ 좁은 화면 다듬기: 글자가 밀리거나 넘치지 않게 ══════════ */
/* 머리글: 제목이 길면 말줄임, 오른쪽 날짜는 줄어들지 않음 */
.head { align-items: center; }
.head h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head .now { flex: 0 0 auto; }
#sync:not(:empty) { color: var(--exam); font-weight: 700; margin-right: 6px; }
/* 양끝 정렬 줄: 길어지면 겹치지 않고 다음 줄로 */
.bar-label, .nowh, .odh { flex-wrap: wrap; gap: 2px 10px; }
.daynav { flex-wrap: wrap; }
.daynav h2 { min-width: 0; }
/* 버튼 글자는 줄바꿈하지 않음 */
.btn, .daynav button, .odbox button, .wtabs button, .stabs button, .todobox button { white-space: nowrap; }
.btn.danger { color: var(--exam); margin-left: auto; }
.addrow { flex-wrap: wrap; }
.addrow select { max-width: 40%; }
.addrow input { flex: 1 1 120px; }
/* 할 일 줄의 시간·이월 표시는 통째로 다음 줄로 넘어가게 */
.row .body small { white-space: normal; display: inline-block; }
/* 밀린 일: 버튼이 글자를 밀어내지 않게 줄을 나눔 */
.odrow { flex-wrap: wrap; }
.odrow > span:first-child { flex: 1 1 170px; }
.odrow small { white-space: normal; }
.odbtn { margin-left: auto; }
/* D-day 카드, 단계 이름, 시간표 칸: 긴 글자도 칸 안에서 줄바꿈 */
.dcard { max-width: 168px; }
.stage span { max-width: 42%; }
.stage div { min-width: 0; }
.ttb, .ttb b { word-break: normal; overflow-wrap: anywhere; }
.metacards .card { min-width: 0; }
.metacards b { display: block; }
.ov { min-width: 0; width: 100%; font: inherit; color: inherit; }
.certrow .field { flex: 1 1 130px; }
.list h3 { min-width: 0; }
.item span { min-width: 0; }
/* 계정 줄 */
.acct { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; font-size: 13px; margin-bottom: 6px; }
.acct span { color: var(--mute); font-size: 12px; }
/* 입력칸: 이름표가 두 줄이 돼도 칸 높이가 어긋나지 않게 아래로 맞춤 */
.setrow { align-items: flex-end; gap: 8px 6px; }
.setrow .chk { align-self: center; }
.sect { line-height: 1.4; }
/* 폰에서 입력칸을 누를 때 화면이 확대되지 않게 (16px 미만이면 iOS가 확대함) */
@media (pointer: coarse) { input, select, textarea { font-size: 16px !important; } }
/* 범위·유형 입력칸: 긴 내용도 잘리지 않고 여러 줄로 */
textarea.infoin { display: block; resize: none; line-height: 1.45; field-sizing: content; min-height: 2.9em; overflow-wrap: anywhere; }

/* 수정 폼 */
.editrow { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; margin: 6px 0; border: 1.5px solid var(--c); border-radius: 10px; background: color-mix(in srgb, var(--c) 8%, var(--card)); }
.editrow input, .editrow select { border: 1.5px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 9px; font-size: 13px; min-width: 0; }
.editrow input[name="t"] { width: 100%; }
.editline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.editline input[type="time"] { flex: 1 1 90px; }
.optck { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; }
.row .x, .item .x, .list h3 .x { padding: 0 3px; }

/* 고정 시간표: 교시 선택 */
.setrow label[hidden] { display: none; }
.perpair { display: flex; align-items: center; gap: 6px; }
.perpair select { flex: 1 1 0; min-width: 0; }

/* 과목 상세: 시험일·목표 입력 */
.exrow { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.exrow .infoin { flex: 1 1 0; min-width: 0; }
.exrow span { font-size: 12px; color: var(--mute); }
.metacards .card > .infoin + .infoin, .metacards .card > .exrow + .infoin { margin-top: 4px; }
.metasub { display: block; margin-top: 4px; font-size: 11px; color: var(--mute); }
input.infoin[type="date"], input.infoin[type="time"] { font-weight: 700; min-height: 1.9em; }
/* 체크리스트 순서 바꾸기 */
.grip { flex: 0 0 auto; cursor: grab; touch-action: none; user-select: none; color: var(--mute); font-size: 16px; line-height: 1; padding: 2px 4px 0 0; }
.item.dragging { opacity: .6; background: var(--soft); border-radius: 8px; }
.item.dragging .grip { cursor: grabbing; }
/* 암기 카드 ⭐ */
.star { flex: 0 0 auto; border: 0; background: none; font-size: 17px; line-height: 1; color: var(--mute); padding: 1px 2px 0; cursor: pointer; }
.star.on { color: #E0A040; }
.starck { flex: 0 0 auto; display: flex; align-items: center; cursor: pointer; font-size: 20px; color: var(--mute); padding: 0 2px; }
.starck input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.starck input:checked + span { color: #E0A040; }
.starck input:checked + span::before { content: '★'; }
.starck input:checked + span { font-size: 0; }
.starck input:checked + span::before { font-size: 20px; }
.starck input:focus-visible + span { outline: 2px solid var(--today); border-radius: 4px; }

/* ══════════ SQLD 포도 ══════════ */
/* 포도알 색: 회독 0 → 3회 이상 (글자색 --gtN) */
:root {
  --g0: #E6E2DA; --g1: #DAD0F7; --g2: #A48FE6; --g3: #5F43BE;
  --gt0: #7a7470; --gt1: #4B3D86; --gt2: #fff; --gt3: #fff; --gshade: rgba(0,0,0,.09);
}
@media (prefers-color-scheme: dark) {
  :root { --g0: #36322e; --g1: #463c70; --g2: #7360cc; --g3: #ab95f7; --gt0: #9a938a; --gt1: #dcd2fa; --gt2: #fff; --gt3: #1d1640; --gshade: rgba(0,0,0,.25); }
}
.nav button[hidden] { display: none; }
#title { user-select: none; -webkit-user-select: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.gr0 { background: var(--g0); color: var(--gt0); }
.gr1 { background: var(--g1); color: var(--gt1); }
.gr2 { background: var(--g2); color: var(--gt2); }
.gr3 { background: var(--g3); color: var(--gt3); }
/* 빈 알: 아직 아무것도 안 적은 소단원 (회독 0회와 구분) */
.gr0.empty { background: transparent; color: var(--mute); box-shadow: none; border: 2px dashed var(--line); }
.grape.mini.gr0.empty { border-width: 1.5px; }
.sqleg em.empty { border-width: 1.5px; }

.sqtop { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; font-size: 12px; color: var(--mute); margin-bottom: 10px; }
.sqtop b { color: var(--fg); font-size: 14px; }
.sqkey { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.sqkey > span { display: inline-flex; align-items: center; gap: 4px; }
.sqkey .gdot, .sqkey .gbadge { position: static; }
.sqgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; align-items: start; }
.squnit { border-top: 4px solid var(--g2); }
.squnit h3 { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; min-width: 0; }
.squnit h3 small { margin-left: auto; font-weight: 500; font-size: 12px; color: var(--mute); white-space: nowrap; }
.sqid { flex: 0 0 auto; font-size: 11.5px; font-weight: 700; color: var(--gt1); background: var(--g1); border-radius: 5px; padding: 0 6px; }

/* 송이: 꼭지 + 위가 넓은 알 줄 */
.bunch { position: relative; display: flex; flex-direction: column; align-items: center; padding: 22px 0 8px; }
.stem { position: absolute; top: 4px; left: 50%; width: 3px; height: 18px; margin-left: -1px; background: #8a6a3a; border-radius: 2px; transform: rotate(14deg); }
.stem::after { content: ''; position: absolute; top: 1px; left: 3px; width: 17px; height: 10px; background: #7FB069; border-radius: 0 12px 0 12px; }
.grow { display: flex; gap: 3px; }
.grow + .grow { margin-top: -5px; }
.grape {
  position: relative; flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%; border: 0; font-size: 14px; font-weight: 700;
  box-shadow: inset -4px -5px 0 var(--gshade), inset 3px 3px 0 rgba(255,255,255,.28); transition: transform .12s;
}
.grape:hover { transform: scale(1.07); }
.grape:focus-visible { outline: 3px solid var(--today); outline-offset: 2px; }
.grape.on { outline: 3px solid var(--fg); outline-offset: 1px; }
.grape.mini { display: inline-block; width: 14px; height: 14px; box-shadow: inset -2px -2px 0 var(--gshade); vertical-align: middle; }
.gdot { position: absolute; top: 2px; right: 4px; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--exam); border: 1.5px solid var(--card); }
.gbadge {
  position: absolute; bottom: -3px; right: -5px; display: inline-block; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--fg); color: var(--bg); font-size: 10.5px; font-style: normal; font-weight: 700; line-height: 15px; text-align: center; border: 1.5px solid var(--card);
}
/* 송이 아래 이름표 (누르면 같은 패널) */
.sqleg { display: flex; flex-direction: column; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--soft); }
.sqleg button { display: flex; align-items: center; gap: 8px; border: 0; background: none; text-align: left; padding: 4px; border-radius: 6px; font-size: 12.5px; color: var(--sub); }
.sqleg button:hover { background: var(--soft); }
.sqleg em { flex: 0 0 18px; height: 18px; border-radius: 50%; font-style: normal; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
.sqleg span { min-width: 0; }

.sqimport summary, .sqwadd summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.sqimport textarea.field { min-height: 140px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.sqimport > .addrow { margin-top: 8px; }
.sqmode { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; }
.sqmode .optck { align-items: flex-start; color: var(--sub); }
.sqmode input { margin-top: 3px; accent-color: var(--today); }
.sqfmt { margin-top: 8px; }
.sqfmt summary { cursor: pointer; font-size: 12px; color: var(--mute); }
.sqfmt .tip { margin-top: 4px; }
.sqhide { text-align: center; margin-top: 20px; }
.sqhide .linkbtn { color: var(--mute); font-size: 12px; font-weight: 500; }

/* 포도알 패널: 넓은 화면은 오른쪽, 폰은 아래에서 올라오는 시트 */
body.sqlock { overflow: hidden; }
.sqback { position: fixed; inset: 0; z-index: 30; border: 0; background: rgba(0,0,0,.32); cursor: default; }
.sqpanel {
  position: fixed; z-index: 31; top: 0; right: 0; bottom: 0; width: min(440px, 100%); display: flex; flex-direction: column;
  background: var(--bg); border-left: 1.5px solid var(--line); box-shadow: -6px 0 24px rgba(0,0,0,.14);
}
.sqpanel.enter { animation: sqside .22s ease-out; }
@keyframes sqside { from { transform: translateX(100%); } }
@keyframes squp { from { transform: translateY(100%); } }
.sqphead { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 14px 12px 12px 16px; background: var(--card); border-bottom: 1.5px solid var(--line); }
.sqphead > .grape { margin-top: 5px; }
.sqphead > div { flex: 1; min-width: 0; }
.sqphead small { font-size: 11.5px; color: var(--mute); }
.sqphead h2 { font-size: 17px; font-weight: 700; line-height: 1.35; }
.sqclose { font-size: 17px; padding: 2px 8px; }
/* 회독 줄 양 끝의 이전/다음 소단원 버튼 */
.sqfoot .sqnav { flex: 0 0 auto; width: 36px; height: 34px; padding: 0; font-size: 19px; line-height: 1; }
.sqbody { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px 18px; }
.sqbody .sect small { color: var(--mute); margin-left: 6px; font-size: 12px; font-weight: 500; }
.sqsect { background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 2px 12px 10px; }
/* 출제 스타일 콜아웃 (노션 콜아웃처럼 색 배경 + 아이콘) */
.sqcall { --call: #E0A040; margin-top: 16px; padding-top: 10px; background: color-mix(in srgb, var(--call) 13%, var(--card)); border-color: color-mix(in srgb, var(--call) 45%, var(--card)); }
.sqcallh { display: flex; align-items: baseline; gap: 6px; font-size: 13px; font-weight: 700; color: color-mix(in srgb, var(--call) 55%, var(--fg)); }
.sqcallh small { color: var(--mute); font-size: 12px; font-weight: 500; }
.sqcall .sqitem { border-bottom-color: color-mix(in srgb, var(--call) 22%, var(--card)); }
.sqcall .sqitem:last-of-type { border-bottom: 0; }
.sqitem { display: flex; align-items: flex-start; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--soft); font-size: 13px; }
.sqt { flex: 1; min-width: 0; white-space: pre-line; line-height: 1.55; }
.sqitem.done .sqt { color: var(--mute); }
.sqact { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; }
.sqchip {
  position: relative; display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 14px; padding: 2px 9px; font-size: 11.5px; font-weight: 600; color: var(--mute); background: var(--card);
}
.sqchip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sqchip:has(input:focus-visible), .sqchip:focus-visible { outline: 2px solid var(--today); outline-offset: 1px; }
.sqchip.on { background: var(--g1); border-color: var(--g2); color: var(--gt1); }
.sqchip.bad { background: var(--exam-bg); border-color: var(--exam); color: var(--exam); }
.sqempty { padding: 8px 0 0; color: var(--mute); }
.sqsect > .addrow { margin-top: 8px; }
.sqedit, .sqwform { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
.sqedit textarea.field, .sqwform textarea.field { margin-top: 0; min-height: 0; }
.sqedit .addrow { margin-top: 0; }
.sqwrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sqwrow .field { flex: 1 1 110px; }
.sqwadd summary { padding: 8px 0 2px; color: var(--today); }
.sqfoot { display: flex; align-items: center; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1.5px solid var(--line); }
.sqfoot span { flex: 1; font-size: 13px; color: var(--sub); }
.sqfoot b { font-size: 18px; color: var(--fg); }
.btn:disabled { opacity: .4; cursor: default; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: var(--soft); border-radius: 4px; padding: 0 4px; overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .sqpanel { top: auto; left: 0; width: 100%; max-height: 88vh; max-height: 88dvh; border-left: 0; border-top: 1.5px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.16); }
  .sqpanel.enter { animation-name: squp; }
  .sqphead { border-radius: 16px 16px 0 0; padding-top: 20px; }
  .sqphead::before { content: ''; position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line); }
}
@media (prefers-reduced-motion: reduce) { .sqpanel.enter { animation: none; } .grape { transition: none; } }

/* 오답 카드 */
.sqw { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--soft); font-size: 13px; }
.sqwlist { padding-top: 2px; padding-bottom: 2px; }
.sqwlist .sqw:last-child { border-bottom: 0; }
.sqwck { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 10.5px; color: var(--mute); cursor: pointer; padding-top: 2px; }
.sqwck input { width: 19px; height: 19px; accent-color: var(--g3); }
.sqwbody { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.sqwbody > b { white-space: pre-line; line-height: 1.5; }
.sqw.done .sqwbody { opacity: .5; }
.sqans { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12.5px; color: var(--mute); }
.sqans s { color: var(--exam); font-weight: 600; }
.sqans em { font-style: normal; font-weight: 700; color: var(--fg); }
.sqwhy { align-self: stretch; white-space: pre-line; font-size: 12.5px; color: var(--sub); background: var(--soft); border-radius: 8px; padding: 5px 9px; }
.sqwbody small { font-size: 11.5px; color: var(--mute); }
.sqtopic { border: 0; border-radius: 6px; padding: 1px 8px; font-size: 11.5px; font-weight: 700; background: var(--g1); color: var(--gt1); }
.sqfilter { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-bottom: 10px; }
.sqfilter .wtabs { margin: 0; }

/* 기출 포도: 큰 송이 (알 하나 = 한 회분, 연도 작게 + 회차) */
.sqexam { --gs: min(64px, calc((100vw - 96px) / 6)); }
.bunch.big { padding-top: 30px; }
.bunch.big .stem { height: 26px; width: 4px; }
.bunch.big .stem::after { width: 24px; height: 14px; }
.bunch.big .grow { gap: 4px; }
.bunch.big .grow + .grow { margin-top: -6px; }
.grape.big { width: var(--gs); height: var(--gs); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; font-size: 13.5px; line-height: 1.1; }
.grape.big small { font-size: 9.5px; font-weight: 500; opacity: .75; }
.grape.big .gbadge { bottom: -2px; right: -3px; }
.sqexamtip { text-align: center; color: var(--mute); margin-top: 4px; }
/* 기출 오답 */
.sqwtags { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.sqsub { font-size: 12px; color: var(--mute); }
.sqnoin { flex: 0 0 64px !important; width: 64px; }
.sqwform select.field { flex: 1 1 110px; min-width: 0; }
.sqwhint { flex: 1 1 160px; margin-right: auto; color: var(--mute); font-size: 11.5px; }
textarea.field.sqmemo { margin-top: 0; min-height: 90px; }

/* 잠깐 뜨는 알림 */
.toast {
  position: fixed; z-index: 40; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px);
  transform: translate(-50%, 10px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
