/* ============================================================
   CSS 변수 & 리셋
   ============================================================ */
:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-400: #9CA3AF;
  --gray-600: #4B5563;
  --gray-800: #1F2937;
  --white: #ffffff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

/* Custom bundled font: place BinggraeMelona.ttf under /fonts/ */
@font-face {
  font-family: 'BinggraeMelona';
  src: url('../fonts/BinggraeMelona.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

body {
  font-family: 'BinggraeMelona', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}
/* iPad 전체화면 */
html, body { height: 100%; }
#app { height: 100%; }
.sv-wrap { height: 100vh; overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ============================================================
   레이아웃
   ============================================================ */
.container { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 16px;
  position: sticky; top: 0; z-index: 100;
}
.page-header h1 { font-size: 1.1rem; font-weight: 700; }
.page-header .subtitle { font-size: .85rem; color: var(--gray-600); }

/* ============================================================
   로딩 & 에러
   ============================================================ */
.loading-screen, .error-screen, .welcome-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 80vh; padding: 32px; text-align: center; gap: 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-icon { font-size: 3rem; }
.error-message { color: var(--gray-600); max-width: 320px; }
.welcome-icon { font-size: 3.5rem; }
.welcome-screen h1 { font-size: 1.5rem; font-weight: 700; }
.welcome-screen p { color: var(--gray-600); }
.welcome-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.welcome-hint { font-size: .8rem; color: var(--gray-400); max-width: 300px; }

/* ============================================================
   버튼
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-sm); border: none;
  font-size: .9rem; font-weight: 600; transition: all .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--gray-100); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #DC2626; }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-icon { padding: 8px; border-radius: 50%; background: var(--gray-100); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   폼
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: .85rem; font-weight: 600; color: var(--gray-600); }
.input, .select, .textarea {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .95rem; background: var(--white);
  transition: border-color .15s;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.textarea { resize: vertical; min-height: 80px; }
.input-row { display: flex; gap: 10px; align-items: flex-end; }
.input-row .form-group { flex: 1; margin-bottom: 0; }

/* ============================================================
   카드
   ============================================================ */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-100);
}
.card-header h3 { font-size: 1rem; font-weight: 700; }

/* ============================================================
   탭
   ============================================================ */
.tabs {
  display: flex; overflow-x: auto; gap: 4px;
  background: var(--white); border-bottom: 1px solid var(--gray-200);
  padding: 0 16px; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0; padding: 12px 16px;
  border: none; background: none;
  font-size: .9rem; font-weight: 500; color: var(--gray-600);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all .15s;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.tab-content { display: none; padding: 16px; }
.tab-content.active { display: block; }

/* ============================================================
   배지 / 상태
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 99px;
  font-size: .75rem; font-weight: 600;
}
.badge-available { background: var(--success-light); color: #065F46; }
.badge-away     { background: var(--gray-100); color: var(--gray-600); }
.badge-busy     { background: var(--warning-light); color: #92400E; }
.badge-pending  { background: var(--primary-light); color: #3730A3; }
.badge-confirmed{ background: var(--warning-light); color: #92400E; }
.badge-done     { background: var(--success-light); color: #065F46; }
.badge-approved { background: var(--success-light); color: #065F46; }
.badge-rejected { background: var(--danger-light); color: #991B1B; }
.badge-waiting  { background: var(--warning-light); color: #92400E; }

/* ============================================================
   토스트
   ============================================================ */
#toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius); font-size: .9rem; font-weight: 500;
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(10px);
  transition: all .3s; pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-info    { background: var(--gray-800); color: var(--white); }
.toast-success { background: var(--success); color: var(--white); }
.toast-error   { background: var(--danger); color: var(--white); }
.toast-warning { background: var(--warning); color: var(--white); }

/* ============================================================
   모달
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000; padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--white); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.modal-message { margin-bottom: 16px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }

/* ============================================================
   학생 화면
   ============================================================ */
.student-header {
  background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%);
  color: var(--white); padding: 24px 16px 20px;
}
.student-header h1 { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.student-header .office-name { font-size: .9rem; opacity: .85; }

.office-tabs {
  display: flex; gap: 0; background: var(--gray-100);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; border-bottom: 1px solid var(--gray-200);
}
.office-tabs::-webkit-scrollbar { display: none; }
.office-tab {
  flex-shrink: 0; padding: 12px 20px; background: none; border: none;
  font-size: .9rem; font-weight: 500; color: var(--gray-600);
  border-bottom: 2px solid transparent; transition: all .15s;
}
.office-tab.active { color: var(--primary); border-bottom-color: var(--primary);
  background: var(--white); font-weight: 700; }

.student-info-bar {
  background: var(--white); padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; gap: 10px; align-items: center;
}
.student-info-bar .input { flex: 1; }

.teachers-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  padding: 16px;
}
@media (min-width: 480px) { .teachers-grid { grid-template-columns: repeat(3, 1fr); } }

.teacher-card {
  background: var(--white); border-radius: var(--radius); padding: 16px 12px;
  text-align: center; box-shadow: var(--shadow); cursor: pointer;
  transition: all .15s; border: 2px solid transparent;
}
.teacher-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.teacher-card.selected { border-color: var(--primary); }
.teacher-card.status-away { opacity: .55; cursor: not-allowed; }
.teacher-card.status-busy { opacity: .75; }
.teacher-emoji { font-size: 2.2rem; margin-bottom: 6px; }
.teacher-name { font-size: .9rem; font-weight: 700; margin-bottom: 6px; }

.call-form {
  background: var(--white); border-top: 1px solid var(--gray-200);
  padding: 16px; position: sticky; bottom: 0; z-index: 50;
  box-shadow: 0 -4px 12px rgba(0,0,0,.08);
}
.call-form h3 { font-size: .9rem; font-weight: 700; margin-bottom: 10px; color: var(--gray-600); }

.reason-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.reason-chip {
  padding: 6px 14px; border-radius: 99px; border: 1.5px solid var(--gray-200);
  background: var(--white); font-size: .85rem; cursor: pointer; transition: all .15s;
}
.reason-chip.selected {
  border-color: var(--primary); background: var(--primary-light); color: var(--primary);
  font-weight: 600;
}

.my-call-status {
  background: var(--white); margin: 12px 16px;
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); border-left: 4px solid var(--primary);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.my-call-status .status-text { font-size: .9rem; }
.my-call-close { background: none; border: none; font-size: 1.2rem; color: var(--gray-400); padding: 0; }

/* ============================================================
   교사 화면
   ============================================================ */
.teacher-header {
  background: var(--gray-800); color: var(--white);
  padding: 16px; display: flex; align-items: center; justify-content: space-between;
}
.teacher-header h1 { font-size: 1.05rem; font-weight: 700; }

.call-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 10px;
  border-left: 4px solid var(--gray-200); transition: border-color .2s;
}
.call-card.status-pending { border-left-color: var(--primary); }
.call-card.status-confirmed { border-left-color: var(--warning); }
.call-card.status-done { border-left-color: var(--success); opacity: .6; }

.call-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.call-info-main { font-size: 1rem; font-weight: 700; }
.call-info-sub { font-size: .85rem; color: var(--gray-600); margin-top: 2px; }
.call-time { font-size: .75rem; color: var(--gray-400); white-space: nowrap; }
.call-actions { display: flex; gap: 8px; margin-top: 10px; }

/* PIN 화면 */
.pin-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; padding: 32px; gap: 20px;
}
.pin-screen h1 { font-size: 1.4rem; font-weight: 700; }
.pin-input {
  text-align: center; letter-spacing: .3em; font-size: 1.5rem; font-weight: 700;
  max-width: 200px;
}

/* 자리 배치도 */
.seat-grid-container { overflow-x: auto; padding: 16px; }
.seat-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(5, 1fr);
  min-width: 300px;
}
.seat-cell {
  aspect-ratio: 1; border-radius: var(--radius-sm);
  border: 2px dashed var(--gray-200);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: .7rem; text-align: center; padding: 4px;
  cursor: grab; transition: all .15s; position: relative;
  touch-action: none;
}
.seat-cell.occupied {
  background: var(--primary-light); border-color: var(--primary);
  border-style: solid; cursor: grab;
}
/* 재실: 파란색 / 부재중: 핑크색 / 바쁨: 노란색 */
.seat-cell.occupied.status-available {
  background: #DBEAFE !important; border-color: #3B82F6 !important;
}
.seat-cell.occupied.status-away {
  background: #FFE4E6 !important; border-color: #FB7185 !important;
}
.seat-cell.occupied.status-busy {
  background: #FEF3C7 !important; border-color: #F59E0B !important;
}
.seat-cell.drag-over { background: var(--warning-light); border-color: var(--warning); }
.seat-cell.move-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}
.seat-cell.dragging {
  opacity: .35;
}
.seat-cell .seat-emoji { font-size: 1.4rem; }
.seat-cell .seat-name { font-size: .65rem; font-weight: 600; line-height: 1.2; }
.seat-cell .seat-status { position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; }
.seat-cell .seat-status.available { background: var(--success); }
.seat-cell .seat-status.away { background: var(--gray-400); }
.seat-cell .seat-status.busy { background: var(--warning); }

/* 통계 */
.stat-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat-card {
  background: var(--white); border-radius: var(--radius);
  padding: 16px; text-align: center; box-shadow: var(--shadow);
}
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .8rem; color: var(--gray-600); }

/* ============================================================
   관리자 화면
   ============================================================ */
.admin-layout { min-height: 100vh; }
.admin-nav {
  background: var(--gray-800); color: var(--white);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
}
.admin-nav h1 { font-size: 1rem; font-weight: 700; }

.admin-section { padding: 16px; }
.admin-section h2 { font-size: 1rem; font-weight: 700; margin-bottom: 14px; color: var(--gray-800); }

.list-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--white); border-radius: var(--radius-sm);
  padding: 12px 16px; margin-bottom: 8px; box-shadow: var(--shadow);
}
.list-item-info { flex: 1; min-width: 0; }
.list-item-name { font-weight: 700; font-size: .95rem; }
.list-item-sub { font-size: .8rem; color: var(--gray-600); margin-top: 2px; }
.list-item-actions { display: flex; gap: 8px; flex-shrink: 0; }

.empty-state {
  text-align: center; padding: 40px 16px; color: var(--gray-400); font-size: .9rem;
}

/* 로그인 화면 */
.login-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; padding: 32px; gap: 20px; text-align: center;
}
.login-screen h1 { font-size: 1.4rem; font-weight: 700; }
.login-screen p { color: var(--gray-600); max-width: 300px; }
.google-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px; border-radius: var(--radius-sm);
  background: var(--white); border: 2px solid var(--gray-200);
  font-size: .95rem; font-weight: 600; cursor: pointer; transition: all .15s;
  box-shadow: var(--shadow);
}
.google-btn:hover { box-shadow: var(--shadow-md); }
.google-icon { width: 20px; height: 20px; }

/* 대기 상태 배너 */
.status-banner {
  padding: 14px 16px; border-radius: var(--radius); margin-bottom: 16px;
  font-size: .9rem; font-weight: 500;
}
.status-banner.pending  { background: var(--warning-light); color: #92400E; }
.status-banner.rejected { background: var(--danger-light); color: #991B1B; }
.status-banner.approved { background: var(--success-light); color: #065F46; }

/* QR 코드 */
.qr-box {
  text-align: center; padding: 20px;
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.qr-box img { max-width: 200px; border-radius: var(--radius-sm); }
.qr-url { font-size: .75rem; color: var(--gray-600); word-break: break-all; margin: 10px 0; }

/* ============================================================
   반응형
   ============================================================ */
@media (min-width: 640px) {
  .container { padding: 0 24px; }
  .teachers-grid { grid-template-columns: repeat(4, 1fr); }
  .seat-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ============================================================
   푸터
   ============================================================ */
.site-footer {
  text-align: center;
  padding: 20px 16px;
  font-size: .78rem;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-100);
  margin-top: 32px;
}
.site-footer strong { color: var(--gray-600); }

/* ============================================================
   건의게시판
   ============================================================ */
.suggestion-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px;
}
.suggestion-content { font-size: .95rem; line-height: 1.6; white-space: pre-wrap; }
.suggestion-meta { font-size: .75rem; color: var(--gray-400); margin-top: 8px; }
.suggestion-replies { margin-top: 12px; border-top: 1px solid var(--gray-100); padding-top: 10px; }
.reply-item {
  background: var(--primary-light); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 8px; font-size: .88rem;
}
.reply-item .reply-author { font-weight: 700; color: var(--primary); font-size: .8rem; margin-bottom: 4px; }

/* ============================================================
   좌석 배치 컨트롤
   ============================================================ */
.sg-controls {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px; padding: 10px 16px;
  background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
}
.sg-ctrl-group {
  display: flex; align-items: center; gap: 4px;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); padding: 4px 8px;
}
.sg-label { font-size: .75rem; font-weight: 600; color: var(--gray-600); }
.sg-dim {
  min-width: 20px; text-align: center;
  font-size: .85rem; font-weight: 700; color: var(--gray-800);
}
.sg-btn { padding: 4px 10px !important; font-size: .8rem !important; }

/* 빈칸 좁게 */
.seat-grid.compact-empty .seat-cell:not(.occupied) {
  aspect-ratio: auto !important;
  min-height: 24px !important;
  height: 24px !important;
  border-style: dashed;
  opacity: .5;
}

/* ============================================================
   학생 화면 (iPad 최적화, sv- prefix)
   ============================================================ */
.sv-wrap {
  height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  overflow: hidden;
}

/* 헤더 */
.sv-header {
  display:flex; align-items:center; justify-content:space-between;
  gap:12px; padding:10px 14px; border-bottom:1px solid #E5E7EB;
}
.sv-bell { font-size:1.2rem; margin:0; }
.sv-title { font-size:1rem; font-weight:700; color:#111; margin:0; }
.sv-sub { font-size:.85rem; color:#6B7280; margin:0 0 0 8px; }
.sv-header .left { display:flex; align-items:center; gap:8px; }

/* 교무실 탭 */
.sv-office-tabs {
  display: flex; justify-content: center; gap: 8px; margin-top: 10px; flex-wrap: wrap;
}
.sv-otab {
  padding: 6px 18px; border-radius: 99px;
  border: 1.5px solid #D1D5DB; background: #fff;
  font-size: .85rem; font-weight: 600; color: #6B7280; cursor: pointer;
}
.sv-otab.active { border-color: #4F46E5; background: #EEF2FF; color: #4F46E5; }

/* 이름/반 입력 */
.sv-info-row {
  display: flex; gap: 10px; padding: 10px 20px;
  border-bottom: 1px solid #F3F4F6; background: #FAFAFA;
}
.sv-input, .sv-select {
  border: 1.5px solid #D1D5DB; border-radius: 8px;
  padding: 8px 12px; font-size: .95rem; background: #fff; outline: none;
  font-family: inherit;
}
.sv-input { flex: 1; }
.sv-select { flex: 1.2; }
.sv-input:focus, .sv-select:focus { border-color: #4F46E5; }

/* 호출 상태 바 */
.sv-status-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; font-size: .9rem; font-weight: 600;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.sv-status-close {
  background: none; border: none; font-size: 1.1rem;
  color: #9CA3AF; cursor: pointer; padding: 0 0 0 12px;
}

/* 본문 2열 레이아웃 */
.sv-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.sv-left {
  flex: 1.6;
  padding: 14px 16px;
  border-right: 1px solid #E5E7EB;
  overflow-y: auto;
}
.sv-right {
  flex: 1;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
}

.sv-section-label {
  font-size: .78rem; font-weight: 700; color: #9CA3AF;
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 10px;
}

/* 선생님 그리드 */
.sv-teacher-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.sv-teacher {
  border: 1.5px solid #E5E7EB; border-radius: 8px;
  background: #fff; padding: 10px 4px;
  display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  cursor: pointer; transition: all .12s; font-family: inherit;
}
.sv-teacher:hover:not(:disabled) {
  border-color: #4F46E5; background: #F5F3FF;
}
.sv-teacher.selected {
  border-color: #4F46E5; background: #EEF2FF;
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
.sv-teacher.away, .sv-teacher.disabled {
  opacity: .45; cursor: not-allowed; background: #F9FAFB;
}
.sv-teacher.busy { border-color: #FCD34D; background: #FFFBEB; }
.sv-t-name { font-size: .88rem; font-weight: 700; color: #111; }
.sv-top-line, .sv-sc-top-line { display:flex; align-items:center; gap:6px; }
.sv-top-line .sv-t-name, .sv-sc-top-line .sv-sc-name { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sv-top-line .sv-t-meta, .sv-sc-top-line .sv-sc-meta { color:var(--gray-600); font-size:.85rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sv-t-status, .sv-sc-status { font-size: .72rem; font-weight: 600; }
.sv-t-status.avail { color: #059669; }
.sv-t-status.busy  { color: #D97706; }
.sv-t-status.away  { color: #9CA3AF; }

/* 방문 사유 */
.sv-reason-list { display: flex; flex-direction: column; gap: 6px; flex: 1; margin-bottom: 12px; }
.sv-reason {
  width: 100%; padding: 12px 14px; text-align: left;
  border: 1.5px solid #E5E7EB; border-radius: 8px;
  background: #fff; font-size: .92rem; color: #374151;
  cursor: pointer; transition: all .12s; font-family: inherit; font-weight: 500;
}
.sv-reason:hover { border-color: #4F46E5; background: #F5F3FF; }
.sv-reason.selected {
  border-color: #4F46E5; background: #EEF2FF; color: #4F46E5; font-weight: 700;
}

/* 호출 버튼 */
.sv-call-btn {
  width: 100%; padding: 14px;
  border: none; border-radius: 10px;
  background: #E5E7EB; color: #9CA3AF;
  font-size: 1rem; font-weight: 700;
  cursor: not-allowed; transition: all .15s;
  font-family: inherit; flex-shrink: 0;
}
.sv-call-btn.ready {
  background: #4F46E5; color: #fff; cursor: pointer;
}
.sv-call-btn.ready:hover { background: #4338CA; }
.sv-call-btn.ready:active { transform: scale(.98); }

.sv-loading { color: #9CA3AF; font-size: .85rem; padding: 12px 0; }
.sv-empty   { color: #9CA3AF; font-size: .85rem; padding: 12px 0; }

/* 푸터 */
.sv-footer {
  text-align: center; padding: 12px;
  font-size: .75rem; color: #D1D5DB;
  border-top: 1px solid #F3F4F6;
  flex-shrink: 0;
}
.sv-footer strong { color: #9CA3AF; }

/* iPad 세로 (768px 이하) — 1열 레이아웃 */
@media (max-width: 767px) {
  .sv-wrap { height: auto; min-height: 100vh; overflow-y: auto; }
  .sv-body { flex-direction: column; overflow: visible; min-height: unset; }
  .sv-left, .sv-right { border-right: none; border-bottom: 1px solid #E5E7EB; overflow-y: visible; }
  .sv-teacher-grid { grid-template-columns: repeat(4, 1fr); }
  .sv-title { font-size: 1.4rem; }
}

/* iPad 가로 + 데스크톱 (768px 이상) — 한 페이지 맞춤 */
@media (min-width: 768px) {
  .sv-left {
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  #sv-teacher-area {
    flex: 1;
    overflow: hidden;
  }
  .sv-teacher-grid {
    height: 100%;
    grid-auto-rows: 1fr;
  }
  .sv-seat-grid {
    height: 100%;
    grid-auto-rows: 1fr;
  }
}

/* iPad 가로 + 데스크톱 (1024px 이상) */
@media (min-width: 1024px) {
  .sv-teacher-grid { grid-template-columns: repeat(5, 1fr); }
  .sv-left { flex: 1.8; }
  .sv-title { font-size: 2rem; }
}

/* 등록/대기 화면 푸터 */
.reg-footer {
  font-size: .78rem; color: var(--gray-400);
  margin-top: 24px; text-align: center;
}
.reg-footer strong { color: var(--gray-600); }

/* ============================================================
   학생 화면 — 좌석 배치 형태
   ============================================================ */
.sv-seat-grid {
  display: grid;
  gap: 6px;
}

.sv-seat-card {
  border: 2px solid #E5E7EB; border-radius: 10px;
  background: #fff; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: stretch; gap: 3px;
  cursor: pointer; transition: all .12s; font-family: inherit;
  min-height: 0;
}
.sv-seat-card:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.sv-seat-card.selected {
  border-color: #4F46E5;
  box-shadow: 0 0 0 3px rgba(79,70,229,.2);
}

/* 재실 — 초록 배경 강조 */
.sv-seat-card.avail {
  background: #F0FDF4; border-color: #86EFAC;
}
.sv-seat-card.avail.selected {
  background: #DCFCE7; border-color: #059669;
}
.sv-teacher.avail {
  background: #F0FDF4; border-color: #86EFAC;
}
.sv-teacher.avail.selected {
  background: #DCFCE7; border-color: #059669;
}

/* 바쁨 — 노란 배경 */
.sv-seat-card.busy { background: #FFFBEB; border-color: #FCD34D; }
.sv-teacher.busy   { background: #FFFBEB; border-color: #FCD34D; }

/* 자리없음 — 흐리게 */
.sv-seat-card.away, .sv-seat-card.disabled {
  opacity: .4; cursor: not-allowed; background: #F9FAFB;
}
.sv-teacher.away, .sv-teacher.disabled {
  opacity: .4; cursor: not-allowed; background: #F9FAFB;
}

.sv-seat-empty {
  border: 2px dashed #E5E7EB; border-radius: 10px;
  min-height: 0; background: #FAFAFA; opacity: .4;
}

.sv-sc-emoji { font-size: 1.3rem; line-height: 1; }
.sv-sc-top-line { display:flex; align-items:center; gap:6px; }
.sv-sc-name  { font-size: .78rem; font-weight: 700; color: #111; line-height: 1.2; }
.sv-sc-meta { color:var(--gray-600); font-size:.8rem; }
.sv-sc-status { font-size: .65rem; font-weight: 600; }
.sv-sc-status.avail { color: #059669; }
.sv-sc-status.busy  { color: #D97706; }
.sv-sc-status.away  { color: #9CA3AF; }

/* 빈칸 크기 직접 입력 */
.sg-num-input {
  width: 52px; padding: 3px 6px;
  border: 1.5px solid var(--gray-200); border-radius: 6px;
  font-size: .8rem; text-align: center; outline: none;
  font-family: inherit;
}
.sg-num-input:focus { border-color: var(--primary); }

/* 교사 카드 — 담당과목/학년 */
.sv-sc-subject {
  font-size: .65rem; font-weight: 700;
  color: #4F46E5; background: #EEF2FF;
  padding: 1px 6px; border-radius: 4px; line-height: 1.6;
}
.sv-sc-grade {
  font-size: .6rem; color: #9CA3AF; line-height: 1.4;
}
.sv-t-meta {
  font-size: .68rem; color: #6B7280; line-height: 1.3;
}
