/* ═══════════════════════════════════════
   산남공지 모바일 — 다중 테마 시스템 (A/B/C)
   ─────────────────────────────────────── */

:root {
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, sans-serif;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bot: env(safe-area-inset-bottom, 0);
}

/* ── 테마 B (기본) — Graphite Dark · 무채색 + 에메랄드 포인트 ── */
body, body[data-theme="B"] {
  --bg: #0f1115;
  --card: #17191e;
  --card2: #1e2128;
  --card3: #262a33;
  --bd: rgba(255, 255, 255, 0.08);
  --bd2: rgba(16, 185, 129, 0.22);
  --tx: #f3f4f6;
  --tx2: #9ca3af;
  --tx3: #6b7280;
  --ac: #10b981;
  --ac2: #059669;
  --ac3: #064e3b;
  --acs: rgba(16, 185, 129, 0.14);
  --acs-strong: rgba(16, 185, 129, 0.22);
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --bg-grad: radial-gradient(ellipse at top right, rgba(16,185,129,0.05), transparent 55%);
  --on-ac: #031911;
}

/* ── 테마 C (라이트) — Pastel Academic · 아이보리 + 학교 톤 ── */
body[data-theme="C"] {
  --bg: #fafaf7;
  --card: #ffffff;
  --card2: #f5f3ee;
  --card3: #ece8df;
  --bd: #e8e4db;
  --bd2: rgba(45, 106, 79, 0.30);
  --tx: #2b2b2b;
  --tx2: #555555;
  --tx3: #8a8a8a;
  --ac: #2d6a4f;     /* 딥 포레스트 (학교 상징) */
  --ac2: #1b4332;
  --ac3: #081c15;
  --acs: rgba(45, 106, 79, 0.10);
  --acs-strong: rgba(45, 106, 79, 0.18);
  --success: #2d6a4f;
  --warn: #dc6b2f;
  --danger: #c73838;
  --info: #466e8f;
  --bg-grad: linear-gradient(180deg, rgba(176,137,104,0.04), transparent 30%);
  --on-ac: #ffffff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--tx);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: calc(24px + var(--safe-bot)); min-height: 100vh; }

/* SVG 아이콘 공통 */
.icn { width: 20px; height: 20px; flex-shrink: 0; }
.icn-sm { width: 16px; height: 16px; flex-shrink: 0; }
.icn-lg { width: 24px; height: 24px; flex-shrink: 0; }

/* ── 상단 헤더 ── */
.m-top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--bd);
}
.m-logo {
  width: 36px; height: 36px; border-radius: 10px;
  box-shadow: 0 0 0 1px var(--bd2), 0 4px 14px var(--acs-strong);
}
.m-title { flex: 1; min-width: 0; cursor: pointer; }
.m-title-main {
  font-size: 16px; font-weight: 800; letter-spacing: -0.3px;
  color: var(--tx);
}
.m-title-sub {
  font-size: 10px; color: var(--tx3); margin-top: 1px;
  display: flex; align-items: center; gap: 5px;
}
#m-sync-dot { color: var(--success); transition: color .3s; }
#m-sync-dot.syncing { color: var(--warn); animation: pulse 1.1s infinite; }
#m-sync-dot.error { color: var(--danger); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.m-refresh {
  width: 40px; height: 40px; border: 1px solid var(--bd);
  background: var(--card); border-radius: 12px;
  color: var(--tx); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.m-refresh:hover { background: var(--card2); }
.m-refresh:active { transform: scale(0.93); }
.m-refresh.syncing { background: rgba(234,179,8,0.12); border-color: rgba(234,179,8,0.35); }
.m-refresh.syncing svg { animation: m-spin 0.9s linear infinite; color: var(--warn); }
@keyframes m-spin { to { transform: rotate(360deg); } }
#m-last-sync { font-size: 10px; color: var(--tx3); white-space: nowrap; }
#m-last-sync.err { color: var(--danger); }

/* ── 플로팅 메뉴바 ── */
.m-menubar {
  position: sticky;
  top: calc(56px + var(--safe-top));
  z-index: 9;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  padding: 10px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--bd);
}
.m-menu-btn {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px;
  padding: 9px 3px 8px;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 12px;
  color: var(--tx3);
  cursor: pointer;
  transition: all .18s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 56px;
  position: relative;
  overflow: hidden;
}
.m-menu-btn::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 40%, var(--acs));
  opacity: 0; transition: opacity .2s;
}
.m-menu-btn:active { transform: scale(0.93); }
.m-menu-btn.on {
  background: var(--acs);
  border-color: var(--ac);
  color: var(--ac);
  box-shadow: 0 0 0 3px var(--acs), 0 2px 10px var(--acs-strong);
}
.m-menu-btn.on::before { opacity: 1; }
.m-menu-ic { line-height: 0; position: relative; }
.m-menu-ic svg { width: 20px; height: 20px; }
.m-menu-lbl { font-size: 10px; font-weight: 700; letter-spacing: 0.3px; position: relative; }

/* ── 뷰 컨테이너 ── */
.m-view[hidden] { display: none; }

/* ── 카드 공통 ── */
.m-card {
  margin: 12px;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 16px;
  overflow: hidden;
}
.m-card-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 14px 9px;
  font-size: 13px; font-weight: 700; color: var(--tx);
}
.m-card-head > span:first-child {
  display: inline-flex; align-items: center; gap: 7px;
}
.m-card-head svg { color: var(--ac); }
.m-card-head .m-card-sub { font-size: 10.5px; color: var(--tx3); font-weight: 500; }
.m-empty {
  padding: 18px 16px; text-align: center; color: var(--tx3); font-size: 12.5px;
  line-height: 1.7;
}

.m-search, .m-select {
  padding: 7px 10px;
  background: var(--card2);
  border: 1px solid var(--bd);
  border-radius: 9px;
  color: var(--tx);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  max-width: 62%;
  transition: border-color .15s;
}
.m-search:focus, .m-select:focus { border-color: var(--ac); }

/* ── 공지 (게시판 스타일 리스트) ── */
.m-notice-list { padding: 4px 12px 12px; }
.m-notice-item {
  display: block;
  padding: 10px 13px; margin-bottom: 6px;
  background: var(--card2);
  border-left: 3px solid var(--ac);
  border-radius: 10px;
  text-decoration: none; color: inherit;
  transition: background .12s;
}
.m-notice-item:hover { background: var(--card); }
.m-notice-item:active { transform: scale(.997); }
.m-notice-item.pinned { border-left-color: #f0933c; background: rgba(240,147,60,.06); }
.m-notice-item-title {
  font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--tx);
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.m-notice-item-meta {
  margin-top: 5px; font-size: 11px; color: var(--tx3);
  display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap;
}
.m-notice-item-meta .sep { color: var(--bd); }
/* 구 버전 호환 */
.m-notice-item-text { font-size: 13px; line-height: 1.55; white-space: pre-wrap; color: var(--tx); }

/* ── 개인 메모 ── */
.m-memo-list { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.m-memo-item {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  cursor: pointer;
  transition: transform .05s;
}
.m-memo-item:active { transform: scale(.996); }
.m-memo-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px;
}
.m-memo-body {
  font-size: 13px; line-height: 1.55; color: var(--tx);
  word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* 메모 팝업 */
.m-memo-pop-bg {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.m-memo-pop {
  background: var(--bg); border: 1px solid var(--bd);
  border-radius: 14px; width: 100%; max-width: 420px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.m-memo-pop-head { display: flex; justify-content: space-between; align-items: center; }
.m-memo-pop-close {
  background: transparent; border: none; color: var(--tx3);
  font-size: 18px; cursor: pointer; padding: 4px 8px;
}
.m-memo-pop-colors { display: flex; gap: 6px; flex-wrap: wrap; }
.m-memo-pop-swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
  transition: transform .08s;
}
.m-memo-pop-swatch.on { border-color: var(--tx); transform: scale(1.12); }
.m-memo-pop-text {
  width: 100%; resize: vertical; min-height: 100px;
  padding: 10px 12px; font-size: 14px; line-height: 1.55; font-family: inherit;
  background: var(--card); color: var(--tx);
  border: 1px solid var(--bd); border-radius: 10px; outline: none;
}
.m-memo-pop-text:focus { border-color: var(--ac); }
.m-memo-pop-foot { display: flex; justify-content: space-between; align-items: center; }

/* ── iframe 팝업 (공지 게시판/쓰기) ── */
.m-iframe-pop-bg {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
}
.m-iframe-pop {
  background: var(--bg); color: var(--tx);
  border: 1px solid var(--bd);
  border-radius: 14px;
  width: 100%; max-width: 900px; height: min(92vh, 900px);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 15px 50px rgba(0,0,0,.5);
}
.m-iframe-pop-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--bd);
  flex-shrink: 0;
}
.m-iframe-pop-title { font-weight: 700; font-size: 15px; }
.m-iframe-pop-close {
  background: transparent; border: none; color: var(--tx3);
  font-size: 20px; cursor: pointer; padding: 4px 10px; line-height: 1;
}
.m-iframe-pop-close:hover { color: var(--tx); }
.m-iframe-pop-frame {
  flex: 1; width: 100%; border: none;
  background: var(--bg);
}

/* ── 캘린더 ── */
.m-cal-nav { display: flex; align-items: center; gap: 5px; }
.m-nav-btn {
  width: 30px; height: 30px; border: 1px solid var(--bd);
  background: var(--card2); border-radius: 9px; color: var(--tx);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.m-nav-btn:active { transform: scale(0.9); }
.m-cal-title { font-size: 12px; color: var(--tx2); min-width: 76px; text-align: center; font-weight: 700; }
.m-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 3px; padding: 0 11px 13px;
  font-size: 11px;
}
.m-cal-dow {
  text-align: center; color: var(--tx3); font-weight: 600; padding: 6px 0;
  font-size: 10px;
}
.m-cal-dow.sun { color: var(--danger); }
.m-cal-dow.sat { color: var(--info); }
.m-cal-cell {
  aspect-ratio: 1 / 1;
  background: var(--card2);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 4px 3px 2px;
  display: flex; flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  min-height: 42px;
}
.m-cal-cell.other { opacity: 0.32; }
.m-cal-cell.today {
  border-color: var(--ac);
  background: var(--acs);
}
.m-cal-cell.sun .m-cal-day-num { color: var(--danger); }
.m-cal-cell.sat .m-cal-day-num { color: var(--info); }
.m-cal-day-num { font-size: 10.5px; font-weight: 700; color: var(--tx2); }
.m-cal-dots { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
.m-cal-dot { width: 5px; height: 5px; border-radius: 50%; }
.m-cal-more { font-size: 8px; color: var(--tx3); line-height: 1; }
.m-cal-ev-line {
  display: block;
  font-size: 8.5px; line-height: 1.2;
  padding: 1px 3px;
  border-radius: 3px;
  margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 100%;
  background: var(--acs);
  color: var(--ac);
  font-weight: 600;
}

/* ── 다가오는 일정 ── */
.m-upcoming-list { padding: 4px 10px 12px; }
.m-up-item {
  padding: 10px 12px; margin-bottom: 6px;
  background: var(--card2);
  border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color .15s;
}
.m-up-item:active { border-color: var(--bd2); }
.m-up-date {
  font-size: 10px; font-weight: 800;
  min-width: 46px; text-align: center;
  padding: 7px 4px; border-radius: 8px;
  background: var(--acs); color: var(--ac);
  line-height: 1.25;
}
.m-up-body { flex: 1; min-width: 0; }
.m-up-title { font-size: 13px; font-weight: 600; color: var(--tx); }
.m-up-title.done { text-decoration: line-through; opacity: 0.5; }
.m-up-meta { font-size: 10px; color: var(--tx3); margin-top: 3px;
  display: inline-flex; align-items: center; gap: 5px; }
.m-up-badge {
  font-size: 9.5px; padding: 2px 7px; border-radius: 10px;
  font-weight: 700;
  display: inline-flex; align-items: center; gap: 3px;
}
.m-up-badge svg { width: 11px; height: 11px; }
.m-up-badge.shared { background: var(--acs); color: var(--ac); }
.m-up-badge.todo { background: rgba(251,191,36,0.15); color: var(--warn); }
.m-up-badge.event { background: rgba(96,165,250,0.15); color: var(--info); }

/* ── 날짜 상세 팝업 / 편집 / 프로필 ── */
.m-day-popup, .m-edit-modal, .m-profile-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end;
}
.m-day-popup[hidden], .m-edit-modal[hidden], .m-onboard[hidden], .m-profile-modal[hidden] {
  display: none !important;
}
.m-day-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0, 0.6);
  backdrop-filter: blur(5px);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes slideUp { from{transform:translateY(100%)} to{transform:translateY(0)} }
.m-day-sheet, .m-edit-sheet, .m-profile-sheet {
  position: relative; z-index: 1;
  width: 100%; max-height: 88vh;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(22px + var(--safe-bot));
  overflow-y: auto;
  animation: slideUp .27s cubic-bezier(0.16, 1, 0.3, 1);
  border-top: 1px solid var(--bd2);
}
.m-day-head, .m-edit-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.m-day-date { flex: 1; font-size: 17px; font-weight: 800; color: var(--tx); }
.m-day-close {
  width: 34px; height: 34px; border: 1px solid var(--bd);
  background: var(--card2); border-radius: 11px;
  color: var(--tx2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.m-day-close:active { transform: scale(0.9); }

.m-day-events { margin-bottom: 10px; }
.m-day-ev {
  padding: 9px 12px; margin-bottom: 5px;
  background: rgba(96,165,250,0.12);
  border-left: 3px solid var(--info);
  border-radius: 9px;
  font-size: 13px;
  color: var(--tx);
  display: flex; align-items: center; gap: 8px;
}
.m-day-ev svg { color: var(--info); }

.m-day-add {
  width: 100%; padding: 13px; margin-top: 10px;
  background: var(--acs); color: var(--ac);
  border: 1px dashed var(--ac); border-radius: 11px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.m-day-add:active { background: var(--acs-strong); }

/* ── 편집 모달 ── */
#m-edit-title {
  flex: 1; padding: 9px 0; border: 0; border-bottom: 2px solid var(--bd);
  background: transparent; color: var(--tx); font-size: 17px; font-weight: 700;
  outline: none;
}
#m-edit-title:focus { border-bottom-color: var(--ac); }
.m-edit-row { display: flex; gap: 7px; margin-bottom: 10px; flex-wrap: wrap; }
.m-type-btn {
  flex: 1; padding: 11px; border: 1px solid var(--bd);
  background: var(--card2); color: var(--tx2);
  border-radius: 11px; font-size: 13px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.m-type-btn.on { background: var(--acs); color: var(--ac); border-color: var(--ac); }
.m-colors { gap: 8px; }
.m-color-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
}
.m-color-btn.on { border-color: var(--tx); box-shadow: 0 0 0 2px rgba(255,255,255,0.08); }
#m-edit-desc {
  width: 100%; padding: 11px; border: 1px solid var(--bd);
  background: var(--card2); color: var(--tx);
  border-radius: 11px; font-size: 13px; font-family: inherit;
  resize: vertical; outline: none; min-height: 80px;
}
#m-edit-desc:focus { border-color: var(--ac); }
.m-edit-meta {
  margin-top: 10px; padding: 9px 11px;
  background: rgba(251,191,36,0.08);
  border-left: 3px solid var(--warn);
  border-radius: 7px;
  font-size: 11.5px; color: var(--tx2); line-height: 1.55;
}
.m-edit-meta:empty { display: none; }
.m-edit-foot {
  display: flex; align-items: center; gap: 8px; margin-top: 14px;
  padding-top: 14px; border-top: 1px solid var(--bd);
}
.m-btn-primary, .m-btn-sec, .m-btn-danger {
  padding: 11px 16px; border: 0; border-radius: 11px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.m-btn-primary {
  background: linear-gradient(180deg, var(--ac), var(--ac2));
  color: var(--on-ac);
  box-shadow: 0 2px 8px var(--acs-strong);
}
.m-btn-primary:active { transform: translateY(1px); box-shadow: 0 1px 4px var(--acs-strong); }
.m-btn-sec { background: var(--card2); color: var(--tx2); border: 1px solid var(--bd); }
.m-btn-danger { background: rgba(248,113,113,0.1); color: var(--danger); border: 1px solid rgba(248,113,113,0.3); }

/* ── 토스트 ── */
#m-toast-host {
  position: fixed; bottom: calc(16px + var(--safe-bot)); left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 200; pointer-events: none;
}
.m-toast {
  padding: 11px 18px; max-width: min(420px, 88vw);
  background: var(--card);
  border: 1px solid var(--bd2);
  color: var(--tx);
  border-radius: 28px; font-size: 13px; font-weight: 600;
  box-shadow: 0 12px 36px rgba(0,0,0, 0.5);
  animation: toastIn .22s ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.m-toast svg { flex-shrink: 0; }
.m-toast.success { border-color: var(--success); color: var(--success); }
.m-toast.warn { border-color: var(--warn); color: var(--warn); }
.m-toast.error { border-color: var(--danger); color: var(--danger); }
@keyframes toastIn { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }

/* ── 온보딩 ── */
.m-onboard {
  position: fixed; inset: 0; z-index: 300;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.m-onboard-card {
  width: 100%; max-width: 420px;
  background: var(--card);
  border: 1px solid var(--bd2);
  border-radius: 20px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0, 0.5);
}
.m-onboard-card h2 { margin: 0 0 8px; font-size: 18px; color: var(--tx); }
.m-onboard-card p { margin: 0 0 16px; font-size: 13px; color: var(--tx2); line-height: 1.55; }
.m-onboard-hint { display: inline-block; margin-top: 6px; font-size: 11px; color: var(--tx3); line-height: 1.45; }
#m-onboard-name, #m-rename-name {
  width: 100%; padding: 13px; margin-bottom: 12px;
  border: 1px solid var(--bd); background: var(--card2);
  border-radius: 11px; color: var(--tx); font-size: 15px;
  outline: none; text-align: center;
  transition: border-color .15s;
}
#m-onboard-name:focus, #m-rename-name:focus { border-color: var(--ac); }
.m-onboard-ok { width: 100%; padding: 13px; font-size: 15px; }

/* ── 시간표 ── */
.m-tt-host { padding: 8px 12px 14px; }
.m-tt-table { width: 100%; border-collapse: separate; border-spacing: 3px; }
.m-tt-table th {
  padding: 5px 0; text-align: center;
  color: var(--tx3); font-weight: 700; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.m-tt-table th.today { color: var(--ac); }
.m-tt-table td {
  padding: 0; text-align: center; vertical-align: middle;
}
.m-tt-table td.m-tt-hour {
  color: var(--tx3); font-weight: 700; font-size: 10px;
  width: 20px;
}
.m-tt-cell {
  border-radius: 8px; padding: 5px 3px;
  min-height: 38px; display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  font-size: 10.5px; font-weight: 700;
  border: 1px solid transparent;
}
.m-tt-cell.today { border-color: var(--ac); }
.m-tt-cell-sub { line-height: 1.1; }
.m-tt-cell-cls { font-size: 9px; opacity: 0.85; margin-top: 2px; font-weight: 600; }

/* ── 급식 ── */
.m-meal-host { padding: 6px 14px 18px; }
.m-meal-sect { margin-bottom: 14px; }
.m-meal-sect h3 {
  margin: 0 0 7px; font-size: 14px; font-weight: 700;
  display: flex; justify-content: space-between; align-items: baseline;
  color: var(--tx);
}
.m-meal-sect h3 .kcal { font-size: 11px; color: var(--tx3); font-weight: 500; }
.m-meal-menu {
  padding: 11px 13px; background: var(--card2);
  border-radius: 11px;
  font-size: 13px; line-height: 1.75;
  color: var(--tx);
}
.m-meal-menu ul { padding: 0 0 0 4px; margin: 0; list-style: none; }
.m-meal-menu li {
  position: relative;
  padding-left: 14px;
}
.m-meal-menu li::before {
  content: ''; position: absolute; left: 3px; top: 9px;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--ac);
}

/* ── 공통 카드 그리드 (교직원/학급/수업) ── */
.m-staff-list, .m-roster-list, .m-subj-list { padding: 8px 10px 14px; }
.m-staff-group { margin-top: 10px; }
.m-staff-group-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 700; color: var(--tx2);
  padding: 6px 4px 8px;
  letter-spacing: 0.1px;
}
.m-staff-group-head svg { color: var(--ac); opacity: 0.9; }
.m-staff-group-head .count { color: var(--tx3); font-weight: 500; margin-left: auto; }

.m-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
@media (max-width: 360px) { .m-card-grid { grid-template-columns: repeat(2, 1fr); } }

.m-pcard {
  display: flex; flex-direction: column; align-items: center;
  gap: 5px;
  padding: 9px 4px 10px;
  background: var(--card2);
  border: 1px solid var(--bd);
  border-radius: 12px;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
  overflow: hidden;
  min-height: 108px;
}
.m-pcard:active {
  transform: scale(0.96);
  background: var(--card3);
  border-color: var(--bd2);
}
.m-pcard-photo-wrap {
  width: 56px; height: 66px;
  border-radius: 10px;
  background: var(--card);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  flex-shrink: 0;
  border: 1px solid var(--bd);
}
.m-pcard-photo-wrap img { width: 100%; height: 100%; object-fit: cover; }
.m-pcard-photo-fb {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800;
  color: var(--ac);
  background: var(--card);
  letter-spacing: -1px;
}
.m-pcard-name { font-size: 12px; font-weight: 700; color: var(--tx); line-height: 1.2; }
.m-pcard-sub {
  font-size: 9.5px; color: var(--tx3); line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 100%;
  padding: 0 3px;
}

/* 헤더 박스 */
.m-roster-hdr {
  padding: 11px 13px; margin-bottom: 8px;
  background: var(--acs); border-radius: 11px;
  font-size: 12px; color: var(--ac); font-weight: 700;
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--bd2);
}

/* 필터 토글 */
.m-filter-row {
  display: flex; align-items: center; gap: 8px;
  padding: 0 2px 10px;
  font-size: 12px;
}
.m-chip-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  background: var(--card2);
  border: 1px solid var(--bd);
  border-radius: 22px;
  color: var(--tx2);
  font-size: 11.5px; font-weight: 700;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.m-chip-toggle.on {
  background: var(--acs);
  color: var(--ac);
  border-color: var(--ac);
}
.m-chip-toggle:active { transform: scale(0.96); }

/* Chip row (학년/반 선택용) */
.m-chip-row {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 6px 12px 2px;
}
.m-chip-row:empty { display: none; }
.m-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 13px;
  background: var(--card2);
  border: 1px solid var(--bd);
  border-radius: 10px;
  color: var(--tx2);
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: all .12s;
}
.m-chip.on {
  background: var(--acs);
  color: var(--ac);
  border-color: var(--ac);
}
.m-chip:active { transform: scale(0.95); }
.m-chip .sub { font-size: 10px; color: var(--tx3); font-weight: 500; }
.m-chip.on .sub { color: var(--ac); opacity: 0.75; }

.m-class-chips {
  padding-top: 8px; padding-bottom: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 5px;
  /* 스크롤바 숨김 */
  scrollbar-width: none;
}
.m-class-chips::-webkit-scrollbar { display: none; }
.m-chip-cls {
  flex: 1 0 0;
  min-width: 0;
  padding: 8px 0;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

/* 이동수업 카드 리스트 (한 줄에 하나) */
.m-subj-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px; align-items: center;
  padding: 12px 14px;
  margin-bottom: 6px;
  background: var(--card2);
  border: 1px solid var(--bd);
  border-radius: 12px;
  cursor: pointer;
  transition: all .12s;
}
.m-subj-card:active { transform: scale(0.98); border-color: var(--bd2); }
.m-subj-card.mine { border-color: var(--ac); background: var(--acs); }
.m-subj-group {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  background: var(--card); color: var(--ac);
  border-radius: 8px;
  border: 1px solid var(--bd);
}
.m-subj-body { min-width: 0; }
.m-subj-title {
  font-size: 13.5px; font-weight: 700; color: var(--tx);
  line-height: 1.2;
}
.m-subj-meta {
  font-size: 11px; color: var(--tx3); margin-top: 3px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.m-subj-meta .teach { color: var(--tx2); font-weight: 600; }
.m-subj-count {
  font-size: 11px; color: var(--tx2); font-weight: 700;
  padding: 4px 10px;
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--bd);
}
/* 검색 결과에서 학생 매칭 힌트 */
.m-subj-card .match-hint {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px; padding: 2px 7px;
  background: rgba(251,191,36,0.15);
  color: var(--warn);
  border-radius: 8px; font-weight: 700;
}

/* ── 연락처 상세 모달 ── */
.m-profile-photo-wrap {
  width: 128px; height: 160px;
  margin: 4px auto 14px;
  border-radius: 16px;
  background: var(--card2);
  overflow: hidden;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--bd);
}
.m-profile-photo-wrap img { width: 100%; height: 100%; object-fit: cover; }
.m-profile-photo-fb {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; font-weight: 800; color: var(--ac);
  background: var(--card2);
}
.m-profile-head { text-align: center; margin-bottom: 16px; }
.m-profile-name { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; color: var(--tx); }
.m-profile-sub { font-size: 12.5px; color: var(--tx2); margin-top: 5px; }

.m-profile-meta {
  display: flex; flex-direction: column; gap: 2px;
  padding: 4px 14px;
  background: var(--card2);
  border: 1px solid var(--bd);
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.m-profile-meta-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--bd);
}
.m-profile-meta-row:last-child { border-bottom: 0; }
.m-profile-meta-row .lbl { color: var(--tx3); font-size: 11.5px; font-weight: 600; }
.m-profile-meta-row .val { font-weight: 600; color: var(--tx); }

/* 연락처: 한 행 = 한 사람 (라벨 · 번호 · 버튼들) */
.m-profile-actions {
  background: var(--card2);
  border: 1px solid var(--bd);
  border-radius: 12px;
  overflow: hidden;
}
.m-contact-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--bd);
}
.m-contact-row:last-child { border-bottom: 0; }
.m-contact-label {
  font-size: 11.5px; font-weight: 700; color: var(--tx3);
  letter-spacing: 0.3px;
}
.m-contact-num {
  font-size: 13.5px; font-weight: 700;
  color: var(--tx);
  letter-spacing: 0.1px;
  word-break: keep-all;
}
.m-contact-btns { display: flex; gap: 6px; }
.m-contact-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--bd);
  background: var(--card);
  text-decoration: none; cursor: pointer;
  transition: transform .1s, background .15s;
}
.m-contact-btn:active { transform: scale(0.92); }
.m-contact-btn.tel {
  color: var(--success);
  border-color: rgba(52,211,153,0.3);
  background: rgba(52,211,153,0.08);
}
.m-contact-btn.sms {
  color: var(--info);
  border-color: rgba(96,165,250,0.3);
  background: rgba(96,165,250,0.08);
}
.m-contact-btn.ext {
  color: var(--ac);
  border-color: var(--ac);
  background: var(--acs);
  width: auto; padding: 0 14px;
  font-size: 11.5px; font-weight: 800; letter-spacing: 0.3px;
  gap: 5px;
}
.m-contact-btn svg { width: 16px; height: 16px; }

/* 작은 화면 */
@media (max-width: 360px) {
  .m-card { margin: 8px; }
  .m-cal-cell { min-height: 36px; }
  .m-cal-day-num { font-size: 9.5px; }
  .m-menu-lbl { font-size: 9.5px; }
  .m-menu-ic svg { width: 18px; height: 18px; }
}

/* ── 동기화 점 — partial 상태 추가 ── */
#m-sync-dot.partial { color: var(--warn); }

/* ── 라이트/다크 토글 버튼 — 부드러운 회전 전환 ── */
#m-theme-btn svg { transition: transform .35s cubic-bezier(0.16, 1, 0.3, 1); }
#m-theme-btn:active svg { transform: rotate(45deg) scale(0.9); }
