/* LEMIT 디자인 시스템 — Calm & Friendly (#45, docs/SCREENS.md §5)
   색·간격·글자·모서리는 :root 변수로만 관리한다. 컴포넌트는 이 변수만 참조한다.

   목차
   1. 토큰   2. 기본   3. 레이아웃(사이드바·헤더)   4. 컴포넌트(카드·버튼·입력·배지·알림·빈 상태)
   5. 대시보드   6. 메시지함   7. 수강생   8. 로그인·회원가입   9. 반응형 */

/* 1. 토큰 ------------------------------------------------------------------ */
:root {
  /* 기본 팔레트 (#45 지정 색) */
  --bg: #f8fafc;
  --surface: #ffffff;
  --primary: #4263eb;
  --primary-soft: #dde9ff;
  --mint-soft: #d9f3e7;
  --text: #273449;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-input: #858d9a;      /* 입력란 테두리: 흰 배경 3.4:1, 페이지 배경 3.2:1 (WCAG 1.4.11) */

  /* 보조 (명도 대비 4.5:1 이상을 맞춘 글자색) */
  --primary-hover: #3451d1;
  --primary-text: #3047b8;      /* 연한 블루 배경 위 글자 */
  --mint-text: #146c43;         /* 연한 민트 배경 위 글자 */
  --warning-soft: #fef3c7;
  --warning-text: #8a4b06;
  --danger-soft: #fee4e2;
  --danger-text: #b42318;
  --danger: #d92d20;
  --violet-soft: #ede9fe;
  --violet-text: #5b3cc4;
  --neutral-soft: #f1f5f9;
  --neutral-text: #4b5563;      /* 회색 배지 글자 (#f1f5f9 위 7:1) */
  --surface-hover: #f8fafc;
  --focus: #4263eb;

  /* 글자 */
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  --fs-num: 34px;

  /* 간격·모양 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-hover: 0 1px 2px rgba(39, 52, 73, 0.04), 0 4px 12px rgba(39, 52, 73, 0.06);
  --touch: 44px;
  --sidebar-w: 232px;
  --content-max: 1120px;
}

/* 2. 기본 ------------------------------------------------------------------ */
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* .field 등 display 지정이 hidden 속성을 덮지 않게 */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
p { margin: 0; }
svg.icon { width: 20px; height: 20px; flex: 0 0 auto; }
.icon-sm { width: 16px !important; height: 16px !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.conv:focus-visible, a.row:focus-visible, .card-flush a:focus-visible { outline-offset: -2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--space-4); top: -48px; z-index: 100;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm);
  background: var(--primary); color: #fff; font-weight: 600;
}
.skip-link:focus { top: var(--space-3); }

.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.pre { white-space: pre-line; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }

/* 3. 레이아웃 -------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

/* 사이드바 */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--space-5) var(--space-3);
}
.logo {
  display: inline-flex; align-items: baseline;
  font-size: 24px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--text);
}
.logo:hover { text-decoration: none; }
.logo-dot { color: var(--primary); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--space-3) var(--space-6); }

.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--touch); padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500;
}
a.nav-item:hover { background: var(--neutral-soft); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary-text); font-weight: 700; }
.nav-item.is-active svg { color: var(--primary); }
.nav-item.is-disabled { cursor: default; opacity: 0.75; }
.nav-item .nav-meta { margin-left: auto; }
.nav-count {
  margin-left: auto; min-width: 22px; padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--primary); color: #fff;
  font-size: var(--fs-xs); font-weight: 700; line-height: 22px; text-align: center;
}
.sidebar-foot { margin-top: auto; padding: var(--space-4) var(--space-3) 0; border-top: 1px solid var(--border); }

/* 본문 열 */
.main-col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 64px; padding: 0 var(--space-8);
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-logo { display: none; font-size: 20px; }
.btn.menu-toggle, .btn.sidebar-close { display: none; }  /* .btn보다 우선: PC에서는 숨김 */
.user-menu { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
.user-chip { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.avatar {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--primary-soft); color: var(--primary-text);
  font-size: var(--fs-sm); font-weight: 700;
}
.avatar-mint { background: var(--mint-soft); color: var(--mint-text); }
.user-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-name { font-weight: 600; font-size: var(--fs-sm); }
.user-email { color: var(--text-muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.user-menu form { margin: 0; }

.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--space-8); flex: 1 0 auto; }
.content-wide { max-width: none; }

/* 페이지 머리 */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }
.page-heading { min-width: 0; }
.page-title { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.page-desc { margin-top: var(--space-1); color: var(--text-muted); }
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.back-link {
  display: inline-flex; align-items: center; gap: var(--space-1);
  min-height: 32px; margin-bottom: var(--space-2);
  color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500;
}
.back-link:hover { color: var(--text); text-decoration: none; }

/* 섹션 */
.section { margin-top: var(--space-8); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); flex-wrap: wrap; }
.section-title { font-size: var(--fs-lg); font-weight: 700; display: flex; align-items: center; gap: var(--space-2); }
.section-link { font-size: var(--fs-sm); font-weight: 600; display: inline-flex; align-items: center; gap: 2px; min-height: 32px; }

/* 4. 컴포넌트 -------------------------------------------------------------- */
/* 카드 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.card-flush { padding: 0; overflow: hidden; }
.card-link { display: block; color: inherit; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.card-link:hover { text-decoration: none; border-color: #c9d6fb; box-shadow: var(--shadow-hover); }
.card-title { font-size: var(--fs-lg); font-weight: 700; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--touch); padding: 0 var(--space-5);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; line-height: 1; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--neutral-soft); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--neutral-soft); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--danger-text); border-color: #f4c7c3; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 36px; padding: 0 var(--space-3); font-size: var(--fs-sm); }
.btn-block { width: 100%; }
.btn-icon { width: var(--touch); padding: 0; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

/* 입력 */
.form { display: flex; flex-direction: column; gap: var(--space-5); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.req { color: var(--danger-text); margin-left: 2px; }
.field-note { color: var(--text-muted); font-weight: 400; margin-left: 4px; }
.input, .form input[type="email"], .form input[type="text"], .form input[type="password"],
.form input[type="search"], .form input[type="tel"], .form select, .form textarea {
  width: 100%; min-height: var(--touch); padding: 10px var(--space-3);
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-input); border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.form select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input:hover, .form input:hover, .form select:hover, .form textarea:hover { border-color: var(--text-muted); }
.input:focus, .form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(66, 99, 235, 0.18);
}
.form input[type="checkbox"]:focus { box-shadow: none; }
.form input[type="checkbox"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.form [aria-invalid="true"] { border-color: var(--danger); }
.form [aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.15); }
.form input:disabled, .form select:disabled, .form textarea:disabled { background: var(--neutral-soft); color: var(--text-muted); cursor: not-allowed; }
.helptext, .field .helptext { color: var(--text-muted); font-size: var(--fs-sm); }
.helptext ul { margin: 4px 0 0; padding-left: 18px; }
.errorlist { list-style: none; margin: 0; padding: 0; color: var(--danger-text); font-size: var(--fs-sm); font-weight: 500; }
.errorlist.nonfield { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--danger-soft); }
.check-field label, .check {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: var(--touch); font-size: var(--fs-md); color: var(--text); cursor: pointer;
}
.check-field input, .check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; padding-top: var(--space-2); }
.form-card { max-width: 640px; }
.form-gap-top { margin-top: var(--space-6); }

/* 검색창 */
.search { position: relative; flex: 1 1 220px; min-width: 0; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search input { padding-left: 40px !important; }

/* 배지 */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 18px; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral-text);
  vertical-align: middle;
}
.badge-blue { background: var(--primary-soft); color: var(--primary-text); }
.badge-mint { background: var(--mint-soft); color: var(--mint-text); }
.badge-amber { background: var(--warning-soft); color: var(--warning-text); }
.badge-red { background: var(--danger-soft); color: var(--danger-text); }
.badge-violet { background: var(--violet-soft); color: var(--violet-text); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.badge-outline { background: var(--surface); border: 1px dashed #cbd5e1; color: var(--text-muted); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* AI 분류 배지: 'AI' 표시 + 분류 글자 + 확신도 (색만으로 구분하지 않음) */
.ai-badge { border: 1px solid transparent; }
.ai-mark {
  display: inline-flex; align-items: center; padding: 0 4px; margin-left: -3px;
  border-radius: 4px; background: rgba(255, 255, 255, 0.7);
  font-size: 10px; font-weight: 800; letter-spacing: 0.02em; line-height: 14px;
}
.ai-makeup { background: var(--primary-soft); color: var(--primary-text); }
.ai-cancellation { background: var(--warning-soft); color: var(--warning-text); }
.ai-reschedule { background: var(--violet-soft); color: var(--violet-text); }
.ai-general { background: var(--neutral-soft); color: var(--neutral-text); }
.ai-badge.is-low { border-style: dashed; border-color: currentColor; }
.ai-none { background: var(--surface); border: 1px dashed #cbd5e1; color: var(--text-muted); font-weight: 500; }
.ai-note { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); font-size: var(--fs-xs); }

/* 알림 */
.alerts { list-style: none; margin: 0 0 var(--space-5); padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.alert {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  border: 1px solid transparent; font-size: var(--fs-md);
}
.alert-success { background: var(--mint-soft); color: var(--mint-text); border-color: #b7e4cf; }
.alert-info { background: var(--primary-soft); color: var(--primary-text); border-color: #c4d5fb; }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); border-color: #f6dd9a; }
.alert-error { background: var(--danger-soft); color: var(--danger-text); border-color: #f9c9c4; }
.notice {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-4); border-radius: var(--radius);
  background: var(--primary-soft); color: var(--primary-text); font-size: var(--fs-sm);
}
.notice svg { margin-top: 1px; }

/* 빈 상태 */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2);
  padding: var(--space-8) var(--space-6);
}
.empty-icon {
  width: 48px; height: 48px; margin-bottom: var(--space-2);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--primary-soft); color: var(--primary);
}
.empty-icon.is-mint { background: var(--mint-soft); color: var(--mint-text); }
.empty-icon.is-neutral { background: var(--neutral-soft); color: var(--text-muted); }
.empty-title { font-weight: 700; font-size: var(--fs-md); }
.empty-text { color: var(--text-muted); font-size: var(--fs-sm); max-width: 420px; }
.empty-state .btn { margin-top: var(--space-3); }

/* 정보 목록 */
.info { display: grid; grid-template-columns: 120px 1fr; gap: var(--space-3) var(--space-4); margin: 0; }
.info dt { color: var(--text-muted); font-size: var(--fs-sm); padding-top: 1px; }
.info dd { margin: 0; overflow-wrap: anywhere; }

/* 목록 행 (카드 안) */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li + li { border-top: 1px solid var(--border); }
.row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); color: inherit;
}
a.row:hover { background: var(--surface-hover); text-decoration: none; }
.row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--text-muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

/* 5. 대시보드 ------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.stat { display: flex; flex-direction: column; gap: var(--space-3); min-height: 168px; }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.stat-label { font-weight: 600; color: var(--text-muted); font-size: var(--fs-sm); }
.stat-icon {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; background: var(--primary-soft); color: var(--primary);
}
.stat-icon.is-mint { background: var(--mint-soft); color: var(--mint-text); }
.stat-icon.is-neutral { background: var(--neutral-soft); color: var(--text-muted); }
.stat-value { font-size: var(--fs-num); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat-unit { font-size: var(--fs-lg); font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.stat-pending { font-size: var(--fs-xl); font-weight: 700; color: var(--text-muted); line-height: 1.25; }
.stat-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); color: var(--text-muted); font-size: var(--fs-sm); }
.stat-go { color: var(--primary); font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.card-link:hover .stat-go { text-decoration: underline; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: var(--space-6); align-items: start; }
.dash-grid .section { margin-top: 0; }
.label-summary { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.summary-bar { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); background: #fbfcfe; }
a.badge:hover { text-decoration: none; filter: brightness(0.97); }

/* 6. 메시지함 ------------------------------------------------------------- */
.filter-tabs { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.filter-tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px;
  border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600;
}
.filter-tab:hover { color: var(--text); text-decoration: none; border-color: #cbd5e1; }
.filter-tab.is-active { background: var(--text); border-color: var(--text); color: #fff; }

.inbox { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.inbox-pane { min-width: 0; }
.card.inbox-list-pane { position: sticky; top: 80px; max-height: calc(100vh - 96px); overflow-y: auto; }
@media (max-height: 560px) { .card.inbox-list-pane { position: static; max-height: none; } }  /* 낮은 화면: 고정·높이 제한 해제 */
.conv {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-4); color: inherit; border-left: 3px solid transparent;
}
.conv:hover { background: var(--surface-hover); text-decoration: none; }
.conv.is-selected { background: #f3f6ff; border-left-color: var(--primary); }
.conv-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.conv-top { display: flex; align-items: baseline; gap: var(--space-2); }
.conv-title { flex: 1 1 auto; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.is-unread .conv-title { font-weight: 800; }
.conv-time { flex: 0 0 auto; color: var(--text-muted); font-size: var(--fs-xs); }
.conv-preview { color: var(--text-muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: 0 0 8px; margin-top: 8px; }
.read-spacer { width: 8px; flex: 0 0 8px; }

.detail-head { display: flex; gap: var(--space-4); align-items: flex-start; justify-content: space-between; padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.detail-title { font-size: var(--fs-xl); font-weight: 800; overflow-wrap: anywhere; }
.detail-people { display: flex; align-items: center; gap: var(--space-3); }
.detail-meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-top: 4px; color: var(--text-muted); font-size: var(--fs-sm); }
.thread { list-style: none; margin: 0; padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.bubble { max-width: min(560px, 88%); }
.bubble-card { padding: var(--space-3) var(--space-4); border-radius: 14px; border: 1px solid var(--border); }
.from-student { align-self: flex-start; }
.from-student .bubble-card { background: var(--surface); border-top-left-radius: 4px; }
.from-teacher { align-self: flex-end; }
.from-teacher .bubble-card { background: var(--primary-soft); border-color: #c9d8fb; border-top-right-radius: 4px; }
.bubble-meta { display: flex; flex-wrap: wrap; gap: 2px var(--space-2); align-items: center; margin-bottom: 4px; font-size: var(--fs-xs); color: var(--text-muted); }
.from-teacher .bubble-meta { justify-content: flex-end; }
.bubble-who { font-weight: 700; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.bubble-ai { margin-top: var(--space-2); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.reply { padding: var(--space-5) var(--space-6); border-top: 1px solid var(--border); background: #fbfcfe; }
.reply .form { gap: var(--space-3); }
.reply textarea { min-height: 72px !important; }
.reply-actions { display: flex; justify-content: flex-end; }
.inbox-placeholder { min-height: 420px; display: flex; align-items: center; justify-content: center; }

/* 7. 수강생 -------------------------------------------------------------- */
.toolbar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.toolbar .form { flex-direction: row; align-items: center; gap: var(--space-3); flex-wrap: wrap; flex: 1 1 auto; }
.count-text { color: var(--text-muted); font-size: var(--fs-sm); }

.table-wrap { overflow-x: auto; }  /* 아주 긴 값이 있어도 나머지 열에 접근 가능 */
.table { width: 100%; border-collapse: collapse; }
.table td { overflow-wrap: anywhere; }
.table th {
  text-align: left; padding: var(--space-3) var(--space-5);
  font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); letter-spacing: 0.02em;
  background: #fbfcfe; border-bottom: 1px solid var(--border);
}
.table td { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-hover); }
.person { display: flex; align-items: center; gap: var(--space-3); min-width: 0; flex-wrap: wrap; }
.person-name { font-weight: 700; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.person a.person-name:hover { color: var(--primary); }
.person-badges { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.cell-memo { color: var(--text-muted); font-size: var(--fs-sm); max-width: 260px; }
.is-archived td { color: var(--text-muted); }

.profile { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); }
.profile .avatar { width: 56px; height: 56px; flex-basis: 56px; font-size: var(--fs-xl); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.danger-zone form { margin: 0; }

/* 8. 로그인·회원가입 ------------------------------------------------------- */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-6) var(--space-4); background: var(--bg); }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: var(--space-6); }
.auth-brand .logo { font-size: 36px; }
.auth-tagline { margin-top: var(--space-1); color: var(--text-muted); }
.auth-card { padding: var(--space-8); }
.auth-title { font-size: var(--fs-xl); font-weight: 800; margin-bottom: var(--space-5); }
.auth-links { margin-top: var(--space-5); text-align: center; color: var(--text-muted); font-size: var(--fs-sm); }

/* 9. 반응형 --------------------------------------------------------------- */
/* 태블릿 이하: 사이드바를 접이식 메뉴로 (JS가 없으면 상단에 그대로 펼쳐 보임) */
@media (max-width: 1023px) {
  .topbar { padding: 0 var(--space-4); }
  .content { padding: var(--space-6) var(--space-5); }
  .topbar-logo { display: inline-flex; }
  .js .btn.menu-toggle { display: inline-flex; }
  .js .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; height: auto;
    width: 272px; box-shadow: 0 10px 40px rgba(15, 23, 42, 0.18);
    transform: translateX(-105%); visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;  /* 닫을 때: 밀려난 뒤 숨김 */
  }
  .js.nav-open .sidebar { transform: none; visibility: visible; transition: transform 0.2s ease, visibility 0s; }  /* 열 때: 즉시 보이게 해야 포커스 이동 가능 */
  .js .btn.sidebar-close { display: inline-flex; }
  .nav-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, 0.35); }
  .no-js .shell { flex-direction: column; }
  .no-js .sidebar { position: static; width: auto; height: auto; flex-basis: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .no-js .sidebar-foot { display: none; }

  .stats { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .dash-grid, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .inbox { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); }
}

/* 모바일: 메시지 목록·상세 분리, 표 → 카드, 요약 카드 세로 */
@media (max-width: 767px) {
  .content { padding: var(--space-5) var(--space-4) var(--space-8); }
  .page-header { align-items: flex-start; flex-direction: column; margin-bottom: var(--space-5); }
  .page-title { font-size: 24px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .user-text { display: none; }
  .card { padding: var(--space-5); }
  .card-flush { padding: 0; }
  .stats { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
  .stat { min-height: 0; }
  .info { grid-template-columns: 96px 1fr; }

  .inbox { grid-template-columns: minmax(0, 1fr); }
  .inbox-list-pane { position: static; max-height: none; }
  .inbox.has-selection .inbox-list-pane { display: none; }
  .inbox:not(.has-selection) .inbox-detail-pane { display: none; }
  .thread, .detail-head, .reply { padding-left: var(--space-4); padding-right: var(--space-4); }
  .bubble { max-width: 92%; }
  .reply-actions .btn { width: 100%; }
  .rows .row { flex-wrap: wrap; align-items: flex-start; }
  .rows .row-main { flex: 1 1 0; }  /* 아바타 옆에 남고, 배지 줄만 아래로 */
  .rows .row-side { flex-direction: row; flex-wrap: wrap; align-items: center; width: 100%; padding-left: 44px; }

  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: var(--space-4); border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { padding: 2px 0; border: 0; }
  .table td[data-label]::before { content: attr(data-label); display: inline-block; width: 72px; color: var(--text-muted); font-size: var(--fs-xs); }
  .table td.cell-person { margin-bottom: var(--space-2); }
  .table td:empty { display: none; }
  .cell-memo { max-width: none; white-space: normal; }

  .auth-card { padding: var(--space-6); }
  .toolbar .search { flex-basis: 100%; }
}

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