/* 초기화·글자·배치 틀. 값은 tokens.css 변수만 쓴다(직접 값 금지). */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh);
  font-weight: var(--fw-normal);
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
  word-break: keep-all; /* 한국어는 어절 단위로 줄을 바꿈 */
  overflow-wrap: break-word;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, pre { margin: 0; }
h1 { font-size: var(--fs-xl); line-height: 1.35; font-weight: var(--fw-bold); }
h2 { font-size: var(--fs-lg); line-height: 1.4; font-weight: var(--fw-bold); }
h3 { font-size: var(--fs-md); line-height: 1.4; font-weight: var(--fw-bold); }
ul, ol { padding: 0; list-style: none; }
a { color: var(--c-primary); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--c-primary-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.icon { flex: none; display: inline-block; vertical-align: middle; }
table { border-collapse: collapse; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--sp-3); top: -64px; z-index: 100; padding: var(--sp-2) var(--sp-4);
  background: var(--c-surface); border: 2px solid var(--c-focus); border-radius: var(--radius); color: var(--c-text);
}
.skip-link:focus { top: var(--sp-3); }
.muted { color: var(--c-text-sub); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.bold { font-weight: var(--fw-bold); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, "D2Coding", monospace; }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.align-start { align-items: flex-start; }
.stack-lg { display: flex; flex-direction: column; gap: var(--sp-5); }
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row-nowrap { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.spacer { flex: 1 1 auto; }
.fill { flex: 1 1 240px; min-width: 0; }
.c-merit { color: var(--c-merit); }

/* ───── 앱 틀 ───── */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 56px; flex: none;
  display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-4);
  background: var(--c-surface); border-bottom: 1px solid var(--c-line);
}
.topbar-school { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; flex: 1 1 auto; }
.topbar-school .icon { color: var(--c-primary); }
.topbar-school-name { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.topbar-year { flex: none; }
.app-body { flex: 1 1 auto; display: flex; min-width: 0; }
.sidebar {
  display: none; flex: none; width: var(--w-side); background: var(--c-surface); border-right: 1px solid var(--c-line);
  padding: var(--sp-4) var(--sp-3); position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
}
.main { flex: 1 1 auto; min-width: 0; padding-bottom: 72px; }
.page { max-width: var(--w-content); margin: 0 auto; padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); }
.page-head { display: flex; align-items: flex-start; gap: var(--sp-3); flex-wrap: wrap; }
.page-head-text { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.page-head-sub { color: var(--c-text-sub); font-size: var(--fs-sm); }
.page-head-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }

.nav { display: flex; flex-direction: column; gap: var(--sp-1); }
.nav-group { margin: var(--sp-4) var(--sp-3) var(--sp-1); font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--c-text-sub); }
.nav-group:first-child { margin-top: 0; }
.nav-link {
  display: flex; align-items: center; gap: var(--sp-3); height: var(--h-control); padding: 0 var(--sp-3);
  border-radius: var(--radius); color: var(--c-text); text-decoration: none; font-size: var(--fs-md);
  transition: background var(--dur);
}
.nav-link:hover { background: var(--c-bg); color: var(--c-text); }
.nav-link[aria-current="page"] { background: var(--c-primary-soft); color: var(--c-primary); font-weight: var(--fw-bold); }
.nav-link .icon { color: var(--c-text-sub); }
.nav-link[aria-current="page"] .icon { color: var(--c-primary); }
.sidebar-foot { margin-top: var(--sp-5); padding: var(--sp-3); border-top: 1px solid var(--c-line); font-size: var(--fs-xs); color: var(--c-text-sub); word-break: break-all; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: 56px;
  display: grid; grid-template-columns: repeat(4, 1fr); background: var(--c-surface); border-top: 1px solid var(--c-line);
  padding-bottom: env(safe-area-inset-bottom);
  box-sizing: content-box;
}
.tabbar-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--c-text-sub); text-decoration: none; font-size: var(--fs-xs); min-width: 0; background: none; border: 0; padding: 0;
}
.tabbar-item:hover { color: var(--c-text); }
.tabbar-item[aria-current="page"] { color: var(--c-primary); font-weight: var(--fw-bold); box-shadow: inset 0 2px 0 var(--c-primary); }

@media (min-width: 960px) {
  .sidebar { display: block; }
  .tabbar { display: none; }
  .main { padding-bottom: 0; }
  .page { padding: var(--sp-5); gap: var(--sp-5); }
}

/* ───── 로그인 전 화면(가운데 카드) ───── */
.center-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: var(--sp-6) var(--sp-4); gap: var(--sp-5); }
.brand { display: flex; align-items: center; gap: var(--sp-2); color: var(--c-primary); font-weight: var(--fw-bold); font-size: var(--fs-lg); }
.center-card { width: 100%; max-width: 480px; }
.center-card.wide { max-width: 720px; }
@media (min-width: 960px) { .center-page { padding-top: var(--sp-7); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
body.no-scroll { overflow: hidden; }
.main:focus { outline: none; }
