/* 공통 스타일. 5-1 A: UI 개편 토큰(UI_SPEC.md, Figma "School Bridge UI renewal") + 위쪽 이름 줄(TopBar) + 아래 탭(BottomNav) + 왼쪽 메뉴 + 공통 부품(ui-*).
   옛 변수 이름(--bg·--card·--line·--primary·--primary-soft·--text·--text-sub)은 그대로 둔다: 다른 화면 CSS와 시험이 그 이름을 쓴다.
   --card는 --surface의 별칭이고, 나머지는 같은 이름에 새 값을 넣었다. 공통 부품(ui-*)은 여기서 정의만 하고 화면에는 B 단계부터 붙인다.
   글꼴은 기기에 있는 것만 쓴다 (웹 글꼴·외부 주소 없음). 마우스를 올려야만 보이는 것은 없다 (hover는 마우스가 있는 기기에서 꾸밈으로만). */
:root {
  /* 색 (10/27 Figma v3 Bridge/Color: 따뜻한 종이색 바탕 + 진남색 + 노랑 포인트 + 산호색 위험) */
  --bg: #f6f3ec;
  --surface: #ffffff;
  --card: var(--surface); /* 옛 이름 (별칭) */
  --line: #e4dfd3; /* 꾸밈 구분선만 */
  --border-strong: #7b8199; /* 입력칸 테두리 (흰 바탕 위 3.86:1) */
  --text: #0f1a2e;
  --text-sub: #566074;
  --primary: #17265c; /* 진남색: 흰 글자 14.30:1 */
  --primary-dark: #0f1a45;
  --primary-soft: #dce8ff;
  --on-primary: #ffffff;
  --accent: #ffc845; /* accent-soft 위 1.39:1: 그림에만, 늘 글자 옆에 */
  --accent-soft: #fff3cc;
  --success: #19a589;
  --success-soft: #ddf5ee; /* 글자색으로 쓰지 않는다 */
  --warning: #7a5400;
  --warning-soft: #fff3cc;
  --danger: #a63a27;
  --danger-soft: #ffe9e4;
  --hero-gradient: linear-gradient(135deg, #17265c 0%, #24357e 100%);
  /* 부드러운 색 (바탕 -soft + 글자·그림 -ink, 자기 바탕과 흰 바탕 위 모두 5.5:1 이상) */
  --sky-soft: #dce8ff;
  --sky-ink: #2447b5;
  --mint-soft: #ddf5ee;
  --mint-ink: #0b6b58;
  --peach-soft: #ffe9e4;
  --peach-ink: #a63a27;
  --lemon-soft: #fff3cc;
  --lemon-ink: #7a5400;
  --rose-soft: #ffe9e4;
  --rose-ink: #a63a27;
  /* 히어로 위 학교 칩 바탕 (값은 v2 그대로): v2의 밝은 파랑 끝에서는 흰 반투명이면 흰 글자가 4.5:1 밑으로 떨어져서 남색 반투명으로 어둡게 했다.
     v3 그라데이션 두 끝(#17265c · #24357e)에서는 이 칩 위 흰 글자가 14.78:1 · 12.16:1이다. tests/test_ui_tokens.py가 두 끝에서 계산해서 확인한다 */
  --hero-chip-bg: rgba(15, 27, 61, 0.18);
  /* 간격 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  /* 둥근 모서리 · 그림자 */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 28px;
  --r-pill: 999px;
  --shadow-card: 0 4px 16px rgba(23, 38, 92, 0.08);
  --shadow-hero: 0 14px 32px rgba(23, 38, 92, 0.28);
  --shadow-nav: 0 8px 24px rgba(15, 27, 61, 0.14);
  /* 글자 */
  --font-sans: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-display: 30px;
  --fs-title: 24px;
  --fs-heading: 18px;
  --fs-body: 16px;
  --fs-caption: 13px; /* 본문 글자는 이보다 작게 쓰지 않는다 */
  --fs-label: 12px;
  --lh-display: 1.25;
  --lh-title: 1.3;
  --lh-heading: 1.35;
  --lh-body: 1.5;
  --lh-caption: 1.45;
  --lh-label: 1.4;
  /* 틀 */
  --nav-height: 72px;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: var(--lh-body);
}

/* 같은 한자도 언어에 맞는 글꼴로 (html lang은 common.js가 바꾼다) */
html:lang(zh-Hans) body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", system-ui, sans-serif;
}
html:lang(ja) body {
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
}
html:lang(vi) body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

/* 5-1 E: 한국어 글자(화면 언어가 한국어이거나 lang="ko"인 메뉴·학교·행사 이름)는 낱말 중간에서 줄을 바꾸지 않는다 (예: "우유"가 "우/유"로 끊기지 않게).
   낱말 하나가 칸보다 길 때만 그 안에서 끊는다(가로 스크롤 없음). 중국어·일본어는 지금처럼 글자 사이에서, 베트남어·영어는 띄어쓰기에서 줄을 바꾼다 */
:lang(ko) { word-break: keep-all; overflow-wrap: anywhere; }

/* ---------- 모바일 (기본): 위에 이름 줄(TopBar), 가운데 내용, 아래 탭(BottomNav) ---------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* TopBar: 한 줄, 높이 64px (위아래 10px + 언어 칩 44px. 디자인의 12px로는 44px 칩과 합쳐 68px가 되어 10px로 맞췄다).
   언어 칩은 늘 같은 줄에 있다 (줄을 바꾸지 않는다). 앱 이름은 남은 칸에서 줄을 바꾼다: 2줄(18px × 1.2 × 2 = 43.2px)까지는 64px 그대로,
   어떤 언어가 아주 좁은 폰에서 3줄이 되면 그때만 높이가 늘어난다 (고정 높이 없음). 이름은 자르거나 줄이지 않는다 (… 없음, 글자 18px 그대로) */
.brand {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px 10px;
  min-height: calc(64px + env(safe-area-inset-top));
  padding: calc(10px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) 10px calc(20px + env(safe-area-inset-left));
  background: var(--bg);
}

.brand-logo {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: var(--on-primary);
}

/* 아이콘은 지금 그림(책) 그대로, 크기만 22px (그림 바꾸기는 나중 단계) */
.brand-logo svg {
  width: 22px;
  height: 22px;
}

.brand-name {
  flex: 1 1 0;
  min-width: 0;
  font-size: var(--fs-heading);
  font-weight: 700;
  line-height: 1.2; /* 두 줄이 44px 안에 들어가게 (스펙 1.35면 두 줄이 48.6px라 이름 줄이 64px를 넘는다) */
  overflow-wrap: anywhere;
}

/* 화면 언어 고르기: 흰 알약 + 1px 선 + 지구본 16 + 이름 + 화살표 14, 누르는 곳(select 자체) 44px 이상.
   1px 선은 테두리(border) 대신 안쪽 그림자로 그린다: 테두리는 안쪽 칸을 2px 줄여 select가 42px가 되기 때문이다.
   글자는 16px 그대로 둔다 (16px보다 작으면 아이폰에서 누를 때 화면이 저절로 확대된다). 왼쪽 12px+아이콘 16px+8px = 36px, 오른쪽 12px+14px+8px = 34px */
.lang-pill {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  min-height: 44px;
  border: 0;
  box-shadow: inset 0 0 0 1px var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
}

.lang-icon,
.lang-chevron {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.lang-icon { left: 12px; }
.lang-chevron { right: 12px; color: var(--text-sub); }

.lang-select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 44px;
  max-width: 100%;
  padding: 0 34px 0 36px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 16px; /* 16px 이상: 아이폰에서 누를 때 화면이 저절로 확대되는 것을 막는다 */
  font-weight: 500;
}

.lang-pill:focus-within {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* 고대비 모드(Windows)는 그림자를 지운다: 칩 테두리가 사라지지 않게 자리를 차지하지 않는 선을 대신 그린다 */
@media (forced-colors: active) {
  .lang-pill:not(:focus-within) {
    outline: 1px solid CanvasText;
    outline-offset: -1px;
  }
}

.content {
  flex: 1;
  min-width: 0;
  /* 아래는 떠 있는 탭(높이 + 아래 16px + 아이폰 여백)에 가리지 않게 탭 높이 + 32px + 아이폰 여백 */
  padding: 8px calc(20px + env(safe-area-inset-right)) calc(var(--nav-height) + 32px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
}

/* 화면 제목 (Title/Screen 24px) */
.content h1 {
  margin: 0;
  font-size: var(--fs-title);
  font-weight: 700;
  line-height: var(--lh-title);
  overflow-wrap: anywhere;
}

/* BottomNav (폭 768px 미만, Figma v3 10/27): 화면 아래에 떠 있는 남색 알약. 양옆·아래 16px(+ 아이폰 여백), 모서리 완전 둥근 알약, 그림자·선 없음(종이색 바탕 위 남색 12.91:1).
   높이 72px, 안쪽 위아래 8px·좌우 10px, 같은 폭 5칸, 아이콘 위·글자 아래 사이 3px, 글자 12px 흰색(남색 위 14.30:1) */
.tabs {
  position: fixed;
  left: calc(16px + env(safe-area-inset-left));
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  min-height: var(--nav-height);
  padding: 8px 10px;
  background: var(--primary);
  border: 0;
  border-radius: var(--r-pill);
  box-shadow: none;
}

.tab {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--on-primary);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: var(--lh-label);
  text-decoration: none;
  border-radius: 20px;
}

/* 아이콘 원: 아이콘 24px + 사방 4px = 32×32px 정사각, 모서리 50% = 원. 고른 탭만 노랑 원이 보인다 (자리는 늘 같아서 글자가 움직이지 않는다).
   아이콘 선은 currentColor라 고르지 않은 탭은 글자와 같은 흰색이다 */
.tab-icon {
  flex: none;
  box-sizing: content-box;
  width: 24px;
  height: 24px;
  padding: 4px;
  border-radius: 50%;
}

.tab[aria-current="page"] {
  color: var(--on-primary);
  font-weight: 700; /* 색 말고도 알 수 있게 굵게 (aria-current와 함께) */
}

/* 고른 탭: 노랑 원 + 남색 아이콘 (남색/노랑 9.26:1, 노랑 원/남색 바 9.26:1). 글자는 흰색 굵게 */
.tab[aria-current="page"] .tab-icon { background: var(--accent); color: var(--primary); }

.tab-label {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
}

/* 남색 바 위에서도 보이게 노랑 테두리 (노랑/남색 9.26:1). 왼쪽 메뉴(흰 바탕)에서는 남색으로 되돌린다 (아래 768px) */
.tab:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 20px;
}

/* 아주 좁은 폰(320px)에서도 원(32px)이 칸 안에 들어간다: 한 칸 (320 - 양옆 32 - 안쪽 20) / 5 = 53.6px. 그래서 좁은 폰 규칙은 따로 두지 않는다 */

/* ---------- 더보기 목록 (more.html): ListRow 카드 4개 (5-1 D, 넷째 줄은 5-3 메시지 도우미). 줄마다 흰 카드 + 그림자, 그림 칸 44×44 모서리 10, 이름 16px, 오른쪽 화살표 20px ----------
   그림은 HTML에 없어서 ::before에 이모지로 넣는다 (rules.md: 아이콘은 이모지나 SVG). 대체 글자를 비워(" / """) 화면 읽기 프로그램이 링크 이름에 섞어 읽지 않는다.
   이 문법을 모르는 옛 브라우저는 그 선언을 버려서 그림 칸만 안 보인다 (이름·화살표·누르는 곳은 그대로). 못 먹는 재료는 오늘 화면처럼 주황 칸 */
.more-list {
  display: grid;
  gap: var(--space-3);
  max-width: 640px;
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}

.more-list li { min-width: 0; }

.more-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  line-height: var(--lh-body);
  text-decoration: none;
}

.more-item::before {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  background: var(--primary-soft);
  font-size: 22px;
  line-height: 1;
}

.more-item[href="/school"]::before { content: "🏫" / ""; background: var(--sky-soft); }
.more-item[href="/ingredients"]::before { content: "🚫" / ""; background: var(--rose-soft); }
.more-item[href="/notice"]::before { content: "📄" / ""; background: var(--lemon-soft); }
.more-item[href="/message"]::before { content: "✉️" / ""; background: var(--mint-soft); } /* 5-3 메시지 도우미 */
.more-item[href="/help"]::before { content: "☎" / ""; background: var(--peach-soft); } /* 5-5 도움 받을 곳 */
.more-item[href="/about"]::before { content: "📘" / ""; background: var(--sky-soft); } /* 10/26 앱 소개 */

.more-item-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.more-item-arrow { flex: none; color: var(--text-sub); }

.more-item:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- 오류 안내 (error.html) ---------- */
.error-card {
  max-width: 480px;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.error-card h1 { font-size: 18px; }

.error-body {
  margin: 8px 0 16px;
  color: var(--text-sub);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.error-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 14px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
}

/* ---------- 공통 부품 (5-1 A에서 정의만, 화면에는 B 단계부터 붙인다) ---------- */

/* 카드 (v2): 흰 바탕, 1px 선, 모서리 24, 안쪽 16, 그림자 */
.ui-card {
  min-width: 0;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  overflow-wrap: anywhere;
}

/* 히어로 카드 (v2): 진한 파랑→파랑 바탕, 흰 글자(4.5:1 이상), 모서리 28, 안쪽 24, 사이 12 */
.ui-card-hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-6);
  background: var(--hero-gradient);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-hero);
  color: var(--on-primary);
  overflow-wrap: anywhere;
}

.ui-hero-chip {
  align-self: flex-start;
  max-width: 100%;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  background: var(--hero-chip-bg);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: var(--lh-label);
  overflow-wrap: anywhere;
}

/* 버튼: 높이 52 이상, 모서리 16, 16px. 폰에서는 칸을 꽉 채우고 넓은 화면에서는 글자만큼 */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  max-width: 100%;
  min-height: 52px;
  padding: 12px 20px;
  border: 0;
  border-radius: var(--r-md);
  font: inherit;
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: var(--lh-body);
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.ui-btn-primary { background: var(--primary); color: var(--on-primary); }
.ui-btn-secondary { background: var(--primary-soft); color: var(--primary-dark); }

/* 꺼진 버튼: 흐리게(opacity) 하지 않고 바탕·글자 색으로 (글자 명암비를 지킨다) */
.ui-btn:disabled,
.ui-btn[aria-disabled="true"] {
  background: var(--line);
  color: var(--text-sub);
  cursor: not-allowed;
}

/* 알림 띠: 모서리 16, 안쪽 12·16, 그림 20 + 글자 13px + (있으면) 바로 가기 글자 */
.ui-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-md);
  font-size: var(--fs-caption);
  line-height: var(--lh-caption);
  overflow-wrap: anywhere;
}

.ui-banner-icon { flex: none; width: 20px; height: 20px; }
.ui-banner-text { flex: 1 1 auto; min-width: 0; margin: 0; }

/* 바로 가기 글자: 누르는 곳은 44px 이상 */
.ui-banner-action {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: inherit;
  font-size: var(--fs-label);
  font-weight: 700;
  line-height: var(--lh-label);
  text-decoration: underline;
  overflow-wrap: anywhere;
}

.ui-banner-info { background: var(--primary-soft); color: var(--primary-dark); }
.ui-banner-warn { background: var(--warning-soft); color: var(--warning); }

/* 고르는 칩 (예: 화면 언어): 알약, 높이 44 이상, 줄이 넘치면 다음 줄로. 고른 칩은 주색 바탕 + "✓" (색만으로 구분하지 않는다) */
.ui-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.ui-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: var(--lh-label);
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.ui-chip[aria-pressed="true"],
.ui-chip.is-selected {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.ui-chip[aria-pressed="true"]::before,
.ui-chip.is-selected::before {
  content: "✓ ";
  content: "✓ " / ""; /* 지원하는 브라우저에서는 화면 읽기 프로그램이 ✓를 따로 읽지 않는다 (고른 상태는 aria-pressed가 알린다) */
}

/* 표시용 작은 알약 (누르는 것이 아님): 끼니 종류·카드 칸 이름 등. 위험(danger)은 못 먹는 재료 표시 */
.ui-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 100%;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: var(--lh-label);
  overflow-wrap: anywhere;
}

.ui-pill-danger {
  padding: 3px 10px 3px 8px;
  background: var(--danger-soft);
  color: var(--danger);
}

/* 누르는 부품의 포커스: 3px 주색 테두리, 2px 띄움 */
.ui-btn:focus-visible,
.ui-chip:focus-visible,
.ui-banner-action:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- PC·태블릿(768px 이상): 왼쪽 메뉴 (240px) ---------- */
@media (min-width: 768px) {
  .app {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "brand content"
      "tabs  content";
    height: 100dvh;
    min-height: 0;
  }

  .brand {
    grid-area: brand;
    flex-wrap: wrap; /* 왼쪽 메뉴에서는 언어 고르기가 이름 아래 줄로 간다 */
    min-height: 0;
    padding: 24px 20px 12px;
    background: var(--surface);
    border-right: 1px solid var(--line);
  }

  .brand-name { line-height: var(--lh-heading); }

  /* 왼쪽 메뉴에서는 언어 고르기를 이름 아래에 가로로 꽉 채운다 */
  .lang-pill {
    flex: 1 1 100%;
    margin-left: 0;
  }

  .lang-select { width: 100%; }

  .tabs {
    grid-area: tabs;
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    min-height: 0;
    padding: 8px 12px;
    background: var(--surface);
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none; /* 왼쪽 메뉴는 떠 있지 않다 */
  }

  .tab {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: var(--r-md);
    font-size: 15px;
    color: var(--text-sub); /* 10/27: 폰의 흰 글자(남색 바)는 왼쪽 메뉴(흰 바탕)에서는 쓰지 않는다 */
  }

  /* 왼쪽 메뉴에서는 아이콘 알약 대신 줄 전체에 바탕색 */
  .tab-icon {
    padding: 0;
    border-radius: 0;
  }

  .tab[aria-current="page"] {
    background: var(--primary-soft);
    color: var(--primary-dark);
  }

  .tab[aria-current="page"] .tab-icon { background: transparent; color: inherit; } /* 10/27: 노랑 원·남색 아이콘은 폰에서만 */

  .tab:focus-visible { border-radius: var(--r-md); outline-color: var(--primary); } /* 10/27: 흰 바탕에서는 남색 테두리 (노랑은 폰의 남색 바 위에서만) */

  .tab-label { text-align: left; }

  .content {
    grid-area: content;
    overflow-y: auto;
    padding: 32px 40px;
  }

  .ui-btn { width: auto; }
}

/* 마우스가 있는 기기에서만, 꾸밈으로만: 고르지 않은 메뉴 줄에 옅은 바탕 (기능은 hover 없이도 다 쓸 수 있다) */
@media (min-width: 768px) and (hover: hover) {
  .tab:not([aria-current="page"]):hover { background: var(--bg); }
}

/* ---------- 안내 그림 (10/26): 연결 안 됨·찾지 못함 화면의 장식 그림. width·height 속성이 있어 불러오는 동안 자리가 밀리지 않는다 ---------- */
.page-illustration {
  display: block;
  width: 100%;
  max-width: 240px;
  height: auto;
  margin: 0 auto var(--space-4);
}

.offline-card .ui-btn { margin-top: var(--space-4); }

/* ---------- 움직임 (10/26): 화면 사이 부드러운 전환 + 누를 때 작은 반응 ----------
   움직임을 줄이라고 설정한 기기(prefers-reduced-motion: reduce)에서는 전환·애니메이션이 하나도 없다.
   크기·색·자리는 바꾸지 않는다 (transform만: 자리를 차지하지 않아 레이아웃이 밀리지 않고, 누르는 곳은 그대로 44px 이상).
   위 이름 줄(TopBar)과 아래 탭은 전환하는 동안 제자리에 있다 (view-transition-name). 마우스를 올려야만 보이는 기능은 없다 (hover는 꾸밈).
   10/27: 모든 버튼·바로가기 칸 누름 반응, 카드 나타남(한 번, 차례로), 아래 탭 겹쳐 바꾸기를 같은 블록 안에 더했다 (tests/test_motion.py가 이 블록 하나만 본다). */
@keyframes sb-page-out { to { opacity: 0; } }
@keyframes sb-page-in { from { opacity: 0; transform: translateY(8px); } }
/* 10/27 카드 나타남: transform이 아니라 translate 속성을 써서 누름 반응(transform: scale)과 겹치지 않는다. 끝 값은 원래 모습 그대로 (to 없음) */
@keyframes sb-card-in { from { opacity: 0; translate: 0 8px; } }

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }

  ::view-transition-old(root) { animation: sb-page-out 160ms ease-out both; }
  ::view-transition-new(root) { animation: sb-page-in 220ms ease-out both; }

  .brand { view-transition-name: sb-topbar; }
  .tabs { view-transition-name: sb-nav; }

  .ui-btn,
  .ui-chip,
  .ui-card,
  .more-item,
  .tab,
  .error-home {
    transition: transform 120ms ease-out, background-color 120ms ease-out, box-shadow 120ms ease-out;
  }

  .ui-btn:active,
  .ui-chip:active,
  .ui-card:active,
  .more-item:active,
  .tab:active,
  .error-home:active { transform: scale(0.98); }

  /* 10/27 (1) 누름 반응을 모든 버튼과 오늘 화면 바로가기 칸에도. 위 .ui-* 규칙이 더 구체적이라 그쪽 전환 값은 그대로다 */
  button,
  .today-link { transition: transform 120ms ease-out; }

  button:active,
  .today-link:active { transform: scale(0.98); }

  /* 10/27 (2) 화면이 열릴 때 주요 카드가 아래에서 8px 올라오며 나타난다 (240ms 한 번, 같은 줄의 카드는 40ms씩 차례로, 여섯째부터는 같이) */
  .ui-card,
  .today-hero,
  .today-card,
  .meals-day,
  .study-card,
  .about-card,
  .clear-card,
  .start-card,
  .error-card,
  .more-list > li,
  .today-links > li { animation: sb-card-in 240ms ease-out both; }

  .content :nth-child(2) { animation-delay: 40ms; }
  .content :nth-child(3) { animation-delay: 80ms; }
  .content :nth-child(4) { animation-delay: 120ms; }
  .content :nth-child(5) { animation-delay: 160ms; }
  .content :nth-child(n+6) { animation-delay: 200ms; }

  /* 10/27 (3) 아래 탭의 고른 칸 바탕: 탭을 누르면 새 화면을 불러오므로, 화면 전환 중 아래 탭의 옛 모습과 새 모습을 200ms 동안 겹쳐 바꾼다 */
  ::view-transition-old(sb-nav),
  ::view-transition-new(sb-nav) { animation-duration: 200ms; }
}

/* 마우스가 있는 기기에서만, 꾸밈으로만: 카드·버튼이 살짝 떠오른다 (2px, 그림자 색·크기는 그대로) */
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
  .ui-btn:hover,
  .ui-card:hover,
  .more-item:hover { transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}
