/* 1. 나눔바른고딕(NanumBarunGothic) 폰트 불러오기 (Naver CDN) */
@import url("https://hangeul.pstatic.net/hangeul_static/css/nanum-barun-gothic.css");

/* [핵심 수정] 모든 요소의 너비 계산에 테두리와 여백을 포함시킴 (넘침 방지) */
*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  /* 메인 컬러 팔레트 */
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --bg-color: #f3f4f6;
  --card-bg: #ffffff;
  
  /* 텍스트 컬러 */
  --text-main: #1f2937;
  --text-sub: #6b7280;
  --text-placeholder: #9ca3af;

  /* 상태 컬러 */
  --danger-bg: #fee2e2;
  --danger-text: #ef4444;
  --warning-bg: #fef3c7;
  --warning-text: #f59e0b;
  --info-bg: #e0f2fe;
  --info-text: #0ea5e9;
  --success-bg: #d1fae5;
  --success-text: #059669;
  
  /* 버튼용 소프트 컬러 (빨강) */
  --soft-red-bg: #fff1f2;
  --soft-red-text: #be123c;
  --soft-red-border: #fda4af;

  /* 버튼용 소프트 컬러 (초록 - 메모 저장용) */
  --soft-green-bg: #f0fdf4;       
  --soft-green-text: #15803d;     
  --soft-green-border: #86efac;   
  --soft-green-hover: #dcfce7;    

  /* UI 요소 */
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-soft: 0 10px 40px -10px rgba(0,0,0,0.05);
  --shadow-hover: 0 20px 40px -10px rgba(0,0,0,0.1);
}

body {
  font-family: 'NanumBarunGothic', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  min-height: 100vh;
  margin: 0;
  width: 100%;
  line-height: 1.5;
  letter-spacing: 0;
  
  /* PC 기본: 단어 단위 줄바꿈 유지 (가독성) */
  word-break: keep-all; 
  -webkit-font-smoothing: antialiased;
  
  /* 가로 스크롤 방지 안전장치 */
  overflow-x: hidden; 
}

a {
  color: var(--text-sub);
  transition: color 0.2s;
}
a:hover {
  color: var(--primary-color);
}

h2 {
  color: var(--text-main);
  font-weight: 800;
  margin-bottom: 25px;
  text-align: center;
  letter-spacing: -0.5px;
  /* [수정] 한글 제목 줄바꿈 정책 */
  word-break: keep-all;
}

/* ─── 박스 공통 스타일 ─── */
.login-box, .result-box {
  background-color: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-box {
  padding: 40px;
  width: 100%;
  max-width: 480px;
  /* [수정] 모바일 화면(stretch 정렬)에서도 중앙에 오도록 margin: auto 적용 */
  margin: 20px auto 0;
}
.login-box:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}

.result-box {
  margin-top: 20px;
  width: 100%;
  max-width: 1300px; 
  padding: 40px;
}

/* ─── 입력 필드 ─── */
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  margin: 10px 0;
  border: 1px solid #e5e7eb;
  background-color: #f9fafb;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--primary-color);
  background-color: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* ─── 버튼 스타일 ─── */
button {
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  font-family: inherit;
}

.login-box button,
.upload-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  border-radius: var(--radius-md);
  font-size: 16px;
  margin-top: 15px;
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.login-box button:hover,
.upload-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 12px -1px rgba(79, 70, 229, 0.3);
}

.header-btn, .back-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  background-color: white;
  color: var(--text-sub);
  border: 1px solid #e5e7eb;
}

.header-btn:hover, .back-btn:hover {
  background-color: #f3f4f6;
  color: var(--text-main);
  border-color: #d1d5db;
}

.change-btn {
  background-color: var(--primary-color);
  color: white;
}
.change-btn:hover {
  background-color: var(--primary-hover);
}

/* [NEW] 학생 상태 버튼 (헤더용) */
.student-status-btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #e5e7eb;
    background-color: white;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.student-status-btn:hover {
    background-color: #f9fafb;
    border-color: #d1d5db;
}

/* 손들기 활성화 상태 (깜빡임) */
.student-status-btn.btn-help.active {
    background-color: #fffbeb;
    border-color: #f59e0b;
    color: #d97706; /* 진한 주황 텍스트 */
    animation: pulse-warning 1.5s infinite; /* 깜빡임 애니메이션 */
    box-shadow: 0 0 0 1px #f59e0b;
}

/* 완료 활성화 상태 (녹색) */
.student-status-btn.btn-done.active {
    background-color: #ecfdf5;
    border-color: #10b981;
    color: #059669; /* 진한 녹색 텍스트 */
    box-shadow: 0 0 0 1px #10b981;
}

/* 깜빡임 애니메이션 정의 */
@keyframes pulse-warning {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}


/* ─── 상단 헤더 영역 ─── */
.top-box {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  width: 100%;
  max-width: 1300px;
}

.title-box {
  text-align: center;
  width: 100%;
  /* [수정] 모바일에서 긴 제목이 잘리지 않고 줄바꿈 되도록 수정 */
  white-space: normal; 
  word-break: keep-all;
}

.title-text {
  cursor: pointer;
  margin: 0;
  display: inline-block;
}

/* ─── 내부 헤더 ─── */
.header-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  border-bottom: 2px solid #f3f4f6;
  padding-bottom: 15px;
  flex-wrap: wrap; /* 반응형 줄바꿈 */
  gap: 15px;
}

.greeting-area {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.greeting {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.info-text {
  margin-top: 30px;
  font-size: 15px;
  color: #555;
  text-align: center;
}

.error-msg {
  color: var(--danger-text);
  text-align: center;
  padding: 20px;
  background-color: var(--danger-bg);
  border-radius: var(--radius-sm);
}

/* ─── 공지사항 ─── */
.notices-row {
  /* [수정] Grid 대신 Flexbox 사용하여 마지막 요소가 꽉 차게 변경 */
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 30px;
}

.notice-box {
  /* [수정] Flex 아이템 설정: flex-grow: 1, flex-basis: 300px (최소 너비) */
  flex: 1 1 300px;
  padding: 20px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
}

.notice-box strong {
  font-size: 17px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.notice-box p {
  font-size: 16px;
  line-height: 1.6;
  color: #4b5563;
  margin: 0;
}

.notice-box.red { background-color: var(--danger-bg); }
.notice-box.red strong { color: var(--danger-text); }
.notice-box.yellow { background-color: var(--warning-bg); }
.notice-box.yellow strong { color: var(--warning-text); }
.notice-box.blue { background-color: var(--info-bg); }
.notice-box.blue strong { color: var(--info-text); }


/* ─── 점수 영역 ─── */
.score-section {
  background-color: white;
  border: 1px solid #f3f4f6;
  border-radius: var(--radius-md);
  padding: 25px;
  margin-bottom: 30px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.score-title {
  font-size: 18px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.score-section-title {
  font-size: 18px;
  font-weight: bold;
  color: #2c3e50;
}

.score-summary-badge {
  margin-left: 12px;
  display: flex;
  align-items: center;
  background-color: #fff;
  padding: 6px 16px;
  border-radius: 30px;
  border: 1px solid #e0e0e0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.score-summary-text {
  font-size: 16px;
  color: #555;
  font-weight: 500;
  display: flex;
  align-items: center;
}

.score-total-val { color: #2c3e50; font-weight: bold; }
.score-max-val { color: #aaa; font-size: 0.9em; }

.score-divider {
  width: 1px;
  height: 12px;
  background: #ddd;
  margin: 0 12px;
}

.grade-circle {
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: white;
  font-size: 14px;
  font-weight: bold;
}

.grade-A { background-color: #27ae60; }
.grade-B { background-color: #2980b9; }
.grade-C { background-color: #f39c12; }
.grade-D { background-color: #d35400; }
.grade-E { background-color: #e74c3c; }

.score-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.score-item {
  background-color: #f9fafb;
  padding: 15px 20px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid transparent;
}

.score-name {
  font-weight: 600;
  color: var(--text-main);
  width: 80px;
  flex-shrink: 0;
}

.score-desc {
  flex: 1;
  color: #555;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 15px;
}

.score-value {
  font-weight: 500;
  color: var(--primary-color);
  width: 90px;
  text-align: right;
  flex-shrink: 0;
}

/* ─── 계정/메모/파일 섹션 ─── */
.account-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-top: 30px;
  align-items: stretch;
}

/* [NEW] 진급생 등 3개 항목일 때 꽉 차게 표시 */
.account-section.promoted {
  grid-template-columns: repeat(3, 1fr);
}

.account-box, .memo-box, #downloadArea, .admin-box {
  background-color: #f9fafb;
  padding: 15px;
  border-radius: var(--radius-md);
  border: 1px solid #f3f4f6;
  display: flex;
  flex-direction: column;
  justify-content: flex-start; 
  gap: 10px;
  min-height: 240px; /* 기존 최소 높이 */
  min-width: 0; 
}

/* [NEW] 학생용 파일 다운로드 영역 고정 높이 */
#downloadArea {
    height: auto;
    max-height: 320px;
    overflow: hidden; /* 내부 스크롤을 위해 컨테이너 오버플로우 숨김 */
}

/* 관리자 섹션 스타일 (기존 Grid는 하위 호환을 위해 남겨두되 새로운 레이아웃에 맞춰 조정됨) */
.admin-grid-section {
  margin-bottom: 30px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.admin-box {
    background-color: #fff;
    border: 1px solid #e5e7eb;
    height: 280px; /* [NEW] 고정 높이 부여하여 확장 방지 */
}
.box-title {
    margin: 0 0 10px 0; 
    font-size: 16px;
    font-weight: bold;
    color: var(--text-main);
    border-bottom: 2px solid #f3f4f6;
    padding-bottom: 10px;
}

.field-header {
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 32px;
}

.field-label {
  font-size: 16px;
  color: var(--text-main);
  font-weight: bold;
}

.entry-btn-group, .google-btn-group {
  display: flex;
  gap: 5px;
  align-items: center;
}

.entry-btn-group .copy-btn,
.entry-btn-group .link-button,
.google-btn-group .copy-btn,
.google-btn-group .link-button {
  font-size: 13px;
  padding: 10px 10px;
  height: 30px;
  line-height: 15px;
  border: 1px solid #e5e7eb;
  background-color: white;
  color: var(--text-sub);
  border-radius: var(--radius-sm);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  box-sizing: border-box;
}

.entry-btn-group .copy-btn:hover,
.entry-btn-group .link-button:hover,
.google-btn-group .copy-btn:hover,
.google-btn-group .link-button:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.field-group { margin-bottom: 15px; }
.field-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 6px;
  display: block;
}

.editable-wrap { display: flex; gap: 8px; }

#not-edit{
    font-size:12px;
}
.editable {
  background-color: white;
  border: 1px solid #e5e7eb;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-main);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  word-break: break-all;
}

.editable:empty::before {
  content: attr(data-placeholder);
  color: var(--text-placeholder);
}

.copy-btn {
  background-color: white;
  border: 1px solid #e5e7eb;
  color: var(--text-sub);
  border-radius: var(--radius-sm);
  font-size: 12px;
  padding: 0 12px;
  white-space: nowrap;
}
.copy-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.account-box .change-btn.red {
  background-color: var(--soft-red-bg);
  color: var(--soft-red-text);
  border: 1px solid var(--soft-red-border);
  margin-top: auto;
  width: 100%;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  box-shadow: none;
}

.account-box .change-btn.red:hover {
  background-color: #ffe4e6;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#memoCell {
    margin-top: 0;
    font-size:15px;
    height: 100%; 
}

.save-btn {
  margin-top: 15px;
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  background-color: var(--soft-green-bg);
  color: var(--soft-green-text);
  border: 1px solid var(--soft-green-border);
  box-shadow: none;
}

.save-btn:hover { 
    background-color: var(--soft-green-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* 파일 다운로드 목록 */
.download-header { 
    font-size: 16px;
    color: var(--text-main);
    font-weight: bold;
}

/* [NEW] 내부 목록을 감싸는 wrapper 스타일 (JS에서 클래스 추가됨) */
.file-list-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* 내부 스크롤을 위해 필수 */
    overflow: hidden;
}

.download-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  
  /* [수정] 200px 제한 해제하고 flex 컨테이너에 맞춰 늘어나게 함 */
  overflow-y: auto;
  max-height: none; 
  flex: 1;
  width: 100%; 
  min-height: 0;
}

.download-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: white;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #e5e7eb;
  font-size: 13px;
  gap: 10px;
  overflow: hidden; 
  max-width: 100%;
  flex-shrink: 0; /* 리스트 아이템이 찌그러지지 않게 */
}

/* [NEW] 라디오 버튼 스타일 */
.file-select-radio {
  margin: 0;
  cursor: pointer;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--primary-color);
}

.download-item a {
  text-decoration: none;
  color: var(--text-main);
  /* Flexbox로 스마트 파일명 구조 적용 */
  flex: 1;
  display: flex; /* 내부를 Flex로 만들어 이름/확장자 분리 */
  align-items: center;
  min-width: 0; /* 부모 넘침 방지 */
}

.download-item:hover { border-color: var(--primary-color); }

/* [NEW] 스마트 파일명 구조 스타일 */
.smart-filename-wrap {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0; /* [중요] Flex 컨테이너가 부모보다 커지는 것 방지 */
}

.smart-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;       /* 남은 공간 차지 */
  min-width: 0;  /* [중요] 텍스트가 길어도 강제로 줄어들게 함 */
}

.smart-ext {
  white-space: nowrap;
  flex-shrink: 0; /* 확장자는 절대 줄어들지 않음 */
}

.download-item:hover .smart-name,
.download-item:hover .smart-ext {
    color: var(--primary-color);
}

.delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  margin-left: 0;
  padding: 4px;
  flex-shrink: 0; 
}

/* 파일 아이콘 등 */
.file-list-area {
    display: flex;
    flex-direction: column;
    flex: 1; 
}

.empty-file-msg {
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
  margin: 0;
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  align-items: center;
  justify-content: center; /* 중앙 정렬 */
  padding-bottom: 20px;
}

/* 드롭존 (관리자용 - small) */
.drop-zone.small-drop {
  border: 2px dashed #d1d5db;
  border-radius: var(--radius-md);
  background-color: #f9fafb;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  position: relative;
  
  /* [수정] 높이 유연하게 */
  flex: 1; 
  min-height: 80px;
  
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; 
}

.drop-zone.small-drop:hover, .drop-zone.small-drop.dragover {
  border-color: var(--primary-color);
  background-color: #eff6ff;
  color: var(--primary-color);
}

.drop-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--text-sub);
    max-width: 100%;
    width: 100%;
    min-width: 0; /* [중요] Flex Item 축소 허용 */
}

.drop-message .icon { font-size: 20px; flex-shrink: 0; }

/* [수정] 드롭존 파일명 텍스트 영역 */
.drop-message .text {
    width: 100%;
    padding: 0 10px;
    display: block; 
    min-width: 0; /* [중요] */
}

/* 드롭존 내 스마트 파일명 처리 */
.drop-message .smart-filename-wrap {
    justify-content: center; /* 드롭존은 중앙 정렬 */
}

.file-input {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-btn.small-btn {
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    font-size: 14px;
    flex-shrink: 0; /* 버튼 크기 고정 */
}

/* 즐겨찾기 섹션 */
.fav-box {
    background-color: #fffbeb; 
    border-color: #fcd34d;
}
.add-fav-btn {
    background-color: white;
    border: 1px solid #f59e0b;
    color: #f59e0b;
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 12px;
}
.add-fav-btn:hover {
    background-color: #f59e0b;
    color: white;
}
.fav-list {
    list-style: none;
    padding: 0;
    margin: 2px 0 0 0;
    flex: 1;
    overflow-y: auto;
    /* [수정] 즐겨찾기도 고정 높이 안에서 스크롤 */
    max-height: none; 
    display: flex;
    flex-direction: column;
}
.fav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0; /* 패딩 조정 */
    border-bottom: 1px solid #f3f4f6; 
}
.fav-item:last-child { border-bottom: none; }

/* [수정] 즐겨찾기 링크 스타일 개선 (버튼형 호버) */
.fav-link {
    text-decoration: none;
    font-size: 14px;
    color: var(--text-main);
    display: block;
    
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0; 
    
    padding: 8px 10px; /* 클릭 영역 확보 및 호버 배경용 */
    border-radius: 8px; /* 둥근 모서리 */
    transition: all 0.2s ease;
    margin-right: 8px;
    
    /* 기존 밑줄(after) 제거를 위해 position 초기화 */
    position: static; 
}

/* 기존 밑줄 제거 */
.fav-link::after {
    display: none;
}

/* 호버 시: 배경색 + 글자색 진하게 */
.fav-link:hover {
    background-color: rgba(0,0,0,0.05); /* 연한 회색 배경 */
    color: var(--primary-color);
    font-weight: 600; /* 살짝 강조 */
    transform: translateX(2px); /* 살짝 오른쪽 이동 효과 */
}

.fav-delete-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #fee2e2;
    color: #ef4444;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    padding: 0;
    flex-shrink: 0; 
    margin-right: 5px; /* 우측 여백 확보 */
}
.fav-delete-btn:hover { background-color: #ef4444; color: white; }
.empty-fav { 
    font-size: 13px; 
    color: #9ca3af; 
    text-align: center; 
    margin: 0;
    flex: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding-bottom: 10px;
}

/* 모달 및 토스트 (기존 유지) */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}
.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.modal-content h3 { margin: 0 0 10px 0; text-align: center; }
.modal-content input { margin: 0; } 
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* [추가] 모달 액션 수직 정렬 */
.modal-actions.vertical {
    flex-direction: column;
    gap: 10px;
}

.confirm-btn {
    flex: 1;
    background-color: var(--primary-color);
    color: white;
    padding: 12px;
    border-radius: var(--radius-sm);
}

/* [추가] 위험/기본 버튼 색상 */
.confirm-btn.danger { background-color: #ef4444; }
.confirm-btn.danger:hover { background-color: #dc2626; }
.confirm-btn.primary { background-color: var(--primary-color); }
.confirm-btn.primary:hover { background-color: var(--primary-hover); }

.cancel-btn {
    flex: 1;
    background-color: #e5e7eb;
    color: var(--text-main);
    padding: 12px;
    border-radius: var(--radius-sm);
}
.confirm-btn:hover { background-color: var(--primary-hover); }
.cancel-btn:hover { background-color: #d1d5db; }

/* [추가] 중복 확인 메시지 스타일 */
.conflict-msg {
    text-align: center;
    font-size: 15px;
    color: #4b5563;
    margin-bottom: 5px;
}
.conflict-msg strong {
    color: var(--danger-text);
    display: block;
    margin-bottom: 5px;
    word-break: break-all;
}

#toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20000; /* [핵심 수정] 모달(10000)보다 높게 설정 */
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-msg {
    background-color: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(20px);
    animation: toastFadeIn 0.3s forwards;
    pointer-events: auto;
    max-width: 300px;
}
.toast-msg.success { background-color: #10b981; }
.toast-msg.error { background-color: #ef4444; }

.toast-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.toast-btn {
    padding: 6px 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: background 0.2s;
}
.toast-btn.confirm { background: #fff; color: #333; }
.toast-btn.confirm:hover { background: #f3f4f6; }
.toast-btn.cancel { background: #555; color: #fff; }
.toast-btn.cancel:hover { background: #666; }

@keyframes toastFadeIn {
    to { opacity: 1; transform: translateY(0); }
}

.toast-msg.hide {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* ---------------------------------------------------- */
/* [NEW] 교사용 모니터링 대시보드 레이아웃 (좌: 파일, 우: 모니터) */
.teacher-dashboard-wrapper {
    display: flex;
    gap: 20px;
    /* [수정] stretch로 변경하여 좌우 높이 맞춤 (짧을 때 여백 제거) */
    align-items: stretch; 
    margin-bottom: 30px;
    flex-wrap: wrap; 
}

.teacher-right-col {
    flex: 1; /* 우측 모니터링 영역 */
    min-width: 483px; /* [수정] 최소 너비 483px 유지 */
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* [NEW] PC 기준 좌측 2행 높이(280*2 + 20)에 맞춰 최대 높이 설정 -> 넘치면 내부 스크롤 */
    max-height: none;
}

/* 모니터링 박스 스타일 */
.monitor-box {
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-md);
    padding: 20px;

    /* [핵심 수정] 부모 높이를 가득 채우도록 설정 */
    flex: 1;        /* 남은 공간을 모두 차지 */
    height: 100%;   /* 부모 높이의 100% */
    height: auto;
    min-height: 300px; /* 내용이 없을 때도 최소 높이 유지 */
    display: flex;
    flex-direction: column;
    
    /* 애니메이션용 */
    transition: all 0.3s ease;
}

.monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 2px solid #f3f4f6;
    padding-bottom: 10px;
    
    /* [수정] 모바일에서 줄바꿈 및 간격 허용 */
    flex-wrap: wrap; 
    gap: 10px; 
}

/* [NEW] 모니터링 헤더 내부 그룹 정렬 */
.monitor-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.monitor-header-right {
    display: flex;
    gap: 5px;
}


.monitor-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--text-main);
    margin: 0;
    white-space: nowrap;
}

.monitor-refresh-btn {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
    color: #4b5563;
    white-space: nowrap;
}
.monitor-refresh-btn:hover { background-color: #f3f4f6; }

.monitor-min-btn {
  display:none;
}

/* [변경] 기존 테이블 스타일 대신 그리드(카드) 스타일 적용 */
.monitor-grid {
    display: grid;
    /* [수정] 칸 너비 자동 조절 (이름이 길면 늘어남) */
    grid-template-columns: repeat(3, minmax(110px, 1fr)); 
    gap: 8px; /* 카드 사이 간격 */
    padding: 10px;
    overflow-y: visible;
    max-height: none;
}

/* 개별 학생 카드 */
.monitor-item {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 6px;
    display: flex;
    justify-content: space-between; /* 이름은 왼쪽, 점은 오른쪽 */
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    
    /* [핵심 수정] 텍스트 줄바꿈 방지 및 말줄임표 */
    white-space: nowrap;      
    overflow: hidden;         
    text-overflow: ellipsis;  
    
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer; /* 교사가 클릭 가능함을 암시 */
}

/* 1. 손들기 (도움 요청) - 주황/노랑 계열 */
.monitor-item.status-help {
    background-color: #fffbeb; 
    border-color: #f59e0b;     
    color: #92400e;            
}

/* 2. 완료 - 녹색 계열 */
.monitor-item.status-done {
    background-color: #ecfdf5; 
    border-color: #10b981;     
    color: #065f46;            
}

/* 3. 선택됨 (교사 클릭) - 파랑 계열 (강조) */
/* !important를 사용하여 다른 상태보다 우선순위를 높임 */
.monitor-item.is-selected {
    background-color: #eff6ff !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3) !important;
    z-index: 1;
}

.monitor-item-status {
    display: flex;
    gap: 8px; /* 점 사이 간격 */
    flex-shrink: 0; /* 점 영역은 줄어들지 않음 */
}

/* [반응형] 화면이 줄어들면 2단, 더 줄어들면 1단으로 변경 */
@media (max-width: 1300px) {
  .teacher-right-col {
    min-width: 340px; /* [수정] 최소 너비 348px 유지 */
}
    .monitor-grid {
        grid-template-columns: repeat(2, minmax(135px, 1fr));
    }
}

@media (max-width: 852px) {
    .monitor-grid {
        grid-template-columns: repeat(3, minmax(135px, 1fr));
    }
}

@media (max-width: 550px) {
    .monitor-grid {
        grid-template-columns: repeat(2, minmax(135px, 1fr));
    }
}

/* 신호등 상태 표시 점 */
.status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    vertical-align: middle;
}

.status-green { background-color: #22c55e; box-shadow: 0 0 4px #22c55e; } /* 녹색 */
.status-yellow { background-color: #eab308; box-shadow: 0 0 4px #eab308; } /* 노랑 */
.status-red { background-color: #ef4444; opacity: 0.8; } /* 빨강 */
.status-gray { background-color: #d1d5db; } /* 회색(미선택 등) */

/* [모니터링 하단 범례] */
.monitor-footer-info {
    margin-top: 10px; 
    font-size: 11px; 
    color: #666; 
    text-align: center; 
    display: flex; 
    justify-content: center; 
    gap: 10px;
}

/* [교사용 대시보드 그리드 영역 정의] */
/* 각 박스에 CSS 영역 이름 부여 */
.area-up-t   { grid-area: upT; }
.area-up-s   { grid-area: upS; }
.area-memo   { grid-area: memo; }
.area-down-t { grid-area: downT; }
.area-down-s { grid-area: downS; }
.area-fav    { grid-area: fav; }

/* [수정] 모니터링 테이블/그리드 래퍼 */
.monitor-table-wrap {
    flex: 1;
    overflow-x: hidden; 
    min-height: 0;
    width: 100%; 
    overflow-y: visible; /* 스크롤 해제 */
    
    /* [핵심] 긴 텍스트가 있어도 강제로 줄바꿈하여 가로폭을 넓히지 않음 */
    word-break: break-all; 
}

/* 1. PC 화면 (기본): 3열 */
.teacher-left-col {
    flex: 2;
    display: grid;
    gap: 20px;
    /* 3칸씩 배치: 메모와 즐겨찾기가 우측 끝에 위치 */
    grid-template-areas: 
        "upT   upS   memo"
        "downT downS fav";
    grid-template-columns: repeat(3, 1fr);
}

/* 2. 노트북/태블릿 화면 (1300px 이하): 2열 */
/* 이때 메모와 즐겨찾기를 '맨 아래'로 내립니다 */
@media (max-width: 1300px) {
    body { min-width: 0; }
    .result-box { padding: 25px 20px; width: 100%; }
    .account-section, .account-section.promoted { grid-template-columns: repeat(2, 1fr); }
    
    .account-section.promoted .memo-box {
        grid-column: span 2;
    }

    .admin-grid-section { grid-template-columns: repeat(2, 1fr); }
    
    .teacher-left-col {
        grid-template-columns: repeat(2, 1fr);
        grid-template-areas: 
            "upT   upS"
            "downT downS"
            "memo  fav";
    }
}

/* 3. 중간 화면 (870px 이하): 실시간 현황을 아래로 내리지만 2열 유지 */
/* [수정 2] 기존 1열 강제 변경 로직을 수정하여 2열 유지 + 모니터 박스 하단 이동 */
@media (max-width: 870px) {
    .teacher-dashboard-wrapper {
        flex-direction: column; /* 좌우 배치를 상하 배치로 변경 */
    }

    .monitor-min-btn {
    display:inline;
    }

    .teacher-left-col {
        width: 100%;
        /* [중요] 1열로 줄이지 않고 2열 유지 */
        grid-template-columns: repeat(2, 1fr);
        grid-template-areas: 
            "upT   upS"
            "downT downS"
            "memo  fav";
    }

    .teacher-right-col {
        width: 100%;
        order: 2; /* 아래로 이동 */
        
        /* [핵심 수정] 모바일에서 가로 스크롤/잘림 방지 (강제 너비 해제) */
        min-width: 0; 
        
        /* [NEW] 모바일은 상하 배치이므로 높이 제한 해제 */
        max-height: none;
    }

    /* 하단으로 내려갔을 때 높이 처리 */
    .monitor-box {
        height: auto; /* 고정 높이 해제하고 내용만큼 */
        min-height: auto;
    }

    /* [수정 3] 접기 기능 (Collapsed) 스타일 */
    .monitor-box.collapsed .monitor-table-wrap,
    .monitor-box.collapsed .monitor-footer-info {
        display: none; /* 내용 숨김 */
    }
    
    .monitor-box.collapsed {
        padding-bottom: 10px;
    }
}

/* 4. 모바일 화면 (600px 이하): 감당 안 되면 1열로 전환 */
/* [수정 2] 1열로 변환되는 시점을 852px -> 600px로 늦춤 */
@media (max-width: 600px) {
    .teacher-left-col {
        grid-template-columns: 1fr;
        /* 모바일에서도 순서 재배치 (파일 먼저 -> 메모 -> 즐겨찾기) */
        grid-template-areas: 
            "upT"
            "upS"
            "downT"
            "downS"
            "memo"
            "fav";
    }
}

/* [수정] 모바일 반응형 스타일 개선 (기타 요소들) */
@media (max-width: 900px) {
  body {
    align-items: stretch; 
    padding: 15px; 
    word-break: break-all;
    overflow-wrap: break-word;
    height: auto; 
  }

  h2 {
    font-size: 22px; 
    margin-bottom: 20px;
    word-break: keep-all; 
    overflow-wrap: anywhere; 
    line-height: 1.3;
  }

  .title-box {
    width: 100%;
    padding: 0 5px; 
  }

  .result-box {
    padding: 20px 15px;
    width: 100%;
    max-width: 100%;
    margin-top: 10px;
    box-shadow: 0 5px 15px -5px rgba(0,0,0,0.05);
  }

  .score-section, .notice-box {
    padding: 15px;
  }

  .score-summary-badge {
    margin-left: 0; margin-top: 10px;
    width: 100%; box-sizing: border-box;
    justify-content: center;
    flex-wrap: wrap;
    height: auto;
    padding: 8px 10px;
    gap: 5px;
  }

  .account-section, .account-section.promoted { grid-template-columns: 1fr; }
  
  .account-section.promoted .memo-box {
      grid-column: auto;
  }

  .admin-grid-section { grid-template-columns: 1fr; }

  .top-box { 
      flex-direction: column; 
      gap: 10px; 
      position: static; 
      margin-bottom: 10px;
  }
  
  .header-box { flex-direction: column; align-items: flex-start; gap: 15px; }
  .header-actions { width: 100%; justify-content: space-between; }

  .header-btn, .back-btn, .change-btn { 
      flex: 1; 
      text-align: center; 
      white-space: nowrap; 
  }
  .score-list { grid-template-columns: 1fr; }

  .notices-row {
    flex-direction: column; 
  }

  .score-list {
    grid-template-columns: 1fr;
  }

  .score-item {
    padding: 12px 10px; 
    gap: 8px; 
  }

  .score-desc {
    min-width: 0; 
    flex: 1;      
  }

  .score-name {
    width: 60px; 
    font-size: 14px;
    letter-spacing: -0.5px; 
  }

  .score-value {
    width: 75px; 
    font-size: 14px;
    text-align: right;
  }
  
  .toast-msg {
    width: max-content;    
    max-width: 90vw;       
    min-width: 250px;      
    white-space: nowrap;   
    text-align: center;    
    padding: 12px 20px;    
  }
  
  #toast-container {
    bottom: 50px; 
    width: 100%;       
    pointer-events: none; 
    display: flex;        
    flex-direction: column;
    align-items: center;  
    left: 0;              
    transform: none;      
  }

  .info-text {
      word-break: keep-all; 
  }
}

@media (max-width: 480px) {
  .field-header { flex-wrap: wrap; gap: 10px; }
  .entry-btn-group, .google-btn-group { width: 100%; justify-content: flex-end; }

  .score-item {
    padding: 10px 8px; 
    gap: 5px;          
  }

  .score-name, 
  .score-desc, 
  .score-value {
    font-size: 13px; 
  }

  .score-name {
    width: 45px; 
    white-space: nowrap;
  }

  .score-value {
    width: 60px; 
    text-align: right;
  }
  
  .score-desc {
    flex: 1;       
    min-width: 0;  
  }

  .account-box .field-header { 
    display: flex;
    flex-wrap: nowrap; 
    align-items: center;
    justify-content: space-between; 
    gap: 5px; 
  }

  .entry-btn-group, .google-btn-group { 
    width: auto; 
    flex-shrink: 0; 
    display: flex;
    gap: 5px;
  }

  .entry-btn-group .link-button,
  .entry-btn-group .copy-btn,
  .google-btn-group .link-button,
  .google-btn-group .copy-btn {
     padding: 6px 8px; 
     font-size: 12px;
  }
}

/* [추가] 로그인/비밀번호 변경 결과 메시지 중앙 정렬 */
#result {
  text-align: center !important; 
  width: 100%;                   
  margin-top: 20px;
  display: flex;                 
  flex-direction: column;        
  align-items: center;           
  justify-content: center;
}

#result p {
  text-align: center;
  margin: 5px 0;
  word-break: keep-all; 
  width: 100%;
}