/* ========================================================
   MissNote - Clean Light Theme System (White Background)
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Noto+Sans+KR:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f1f5f9;
  
  --border-subtle: #e2e8f0;
  --border-focus: #4f46e5;
  
  --accent-primary: #4f46e5;
  --accent-hover: #4338ca;
  --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #8b5cf6 100%);
  --accent-glow: 0 4px 14px rgba(79, 70, 229, 0.25);
  
  --success: #059669;
  --success-glow: 0 4px 14px rgba(5, 150, 105, 0.2);
  --warning: #d97706;
  --danger: #dc2626;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  
  --shadow-card: 0 4px 20px -2px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(15, 23, 42, 0.05);
  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', 'Noto Sans KR', -apple-system, sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  line-height: 1.5;
}

/* 스마트폰 전용 컨테이너 (최대 540px) */
.app-container {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 0 auto;
}

/* ========================================================
   Header & Status Bar
   ======================================================== */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--accent-glow);
  color: #ffffff;
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #0f172a;
}

.brand-badge {
  font-size: 11px;
  font-weight: 600;
  color: #4f46e5;
  background: #eef2ff;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid #c7d2fe;
}

.server-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px rgba(5, 150, 105, 0.4);
}

.status-dot.mock {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(217, 119, 6, 0.4);
}

/* ========================================================
   Main Upload Card
   ======================================================== */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #0f172a;
}

/* 사진 업로드 영역 */
.upload-dropzone {
  position: relative;
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--accent-primary);
  background: #eef2ff;
}

.upload-icon-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #e0e7ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #4f46e5;
}

.upload-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.upload-subtext {
  font-size: 12px;
  color: var(--text-dim);
}

.upload-btn-row {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

.btn-camera {
  flex: 1;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-camera:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #94a3b8;
}

/* 이미지 미리보기 */
.preview-container {
  display: none;
  position: relative;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
}

.preview-container img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  display: block;
}

.btn-remove-preview {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #cbd5e1;
  color: #dc2626;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* ========================================================
   과목 선택 칩 (Subject Chips)
   ======================================================== */
.subject-chips-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.subject-chip {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.subject-chip:hover {
  border-color: #94a3b8;
  color: #0f172a;
  background: #f1f5f9;
}

.subject-chip.active {
  background: #eef2ff;
  border-color: #4f46e5;
  color: #4f46e5;
  font-weight: 700;
  box-shadow: 0 0 0 1px #4f46e5;
}

/* 문제 출처 정보 입력란 스타일 */
.source-inputs-container {
  margin-bottom: 16px;
}

.source-hint-text {
  font-size: 11px;
  color: #6366f1;
  margin-top: -2px;
  margin-bottom: 10px;
}

.btn-clear-source {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.btn-clear-source:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

.source-inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.source-input-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.source-label {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
}

.source-input {
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-main);
  font-family: inherit;
  transition: var(--transition);
}

.source-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.source-input::placeholder {
  color: #94a3b8;
  font-size: 12px;
}

/* 학생 오답 메모 입력창 */
.note-input-container {
  margin-bottom: 18px;
}

.note-input {
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-main);
  resize: none;
  font-family: inherit;
  transition: var(--transition);
}

.note-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.note-input::placeholder {
  color: #94a3b8;
}

/* 메인 실행 버튼 */
.btn-submit-main {
  width: 100%;
  padding: 15px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  cursor: pointer;
  box-shadow: var(--accent-glow);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-submit-main:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
}

.btn-submit-main:active:not(:disabled) {
  transform: translateY(0);
}

.btn-submit-main:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ========================================================
   Background Tasks Card & Progress Cards
   ======================================================== */
.bg-tasks-card {
  border: 1px solid #c7d2fe;
  background: #f5f7ff;
  animation: fadeIn 0.3s ease;
}

.bg-tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e0e7ff;
}

.bg-tasks-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #3730a3;
}

.spinner-icon {
  display: inline-block;
  animation: spin 2s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.bg-tasks-hint {
  font-size: 11.5px;
  color: #64748b;
}

.bg-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bg-task-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.25s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.bg-task-item.status-completed {
  border-color: #a7f3d0;
  background: #f0fdf4;
}

.bg-task-item.status-failed {
  border-color: #fecaca;
  background: #fef2f2;
}

.bg-task-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.bg-task-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.bg-task-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: #e0e7ff;
  color: #4338ca;
}

.bg-task-meta {
  font-size: 12px;
  color: #64748b;
}

.bg-task-percent {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-primary);
  white-space: nowrap;
}

.bg-task-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #334155;
}

.bg-task-message {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bg-task-track {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bg-task-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: 6px;
  transition: width 0.35s ease;
  position: relative;
}

.bg-task-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: shimmer 1.5s infinite;
}

.bg-task-item.status-completed .bg-task-bar-fill {
  background: #059669;
}

.bg-task-item.status-completed .bg-task-bar-fill::after {
  display: none;
}

.bg-task-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.btn-bg-task-action {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

.btn-bg-task-action:hover {
  background: #eef2ff;
  border-color: var(--accent-primary);
  color: #4338ca;
}

/* 토스트 알림 (Toast Notification) */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 90vw;
  width: 360px;
}

.toast-item {
  pointer-events: auto;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #0f172a;
  animation: toastSlideIn 0.3s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-item.toast-success {
  border-color: #a7f3d0;
  background: #f0fdf4;
}

.toast-item.toast-error {
  border-color: #fecaca;
  background: #fef2f2;
}

.toast-item.toast-info {
  border-color: #c7d2fe;
  background: #f5f7ff;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-icon {
  font-size: 16px;
  margin-top: 2px;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
  color: #0f172a;
}

.toast-desc {
  font-size: 11.5px;
  color: #475569;
  line-height: 1.4;
}

.toast-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}

.toast-close:hover {
  color: #0f172a;
}

/* ========================================================
   Result Success Card
   ======================================================== */
.result-card {
  display: none;
  border-color: #86efac;
  background: #f0fdf4;
  animation: fadeIn 0.4s ease;
}

.result-success-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #15803d;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.result-topic-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
}

.result-summary-box {
  background: #ffffff;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
  color: #334155;
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
  border-left: 3px solid var(--accent-primary);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-open-doc {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: #2563eb;
  color: #ffffff;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-open-doc:hover {
  background: #1d4ed8;
  transform: translateY(-2px);
}

.btn-open-sheet {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
}

.btn-open-sheet:hover {
  background: #d1fae5;
}

/* ========================================================
   KaTeX 수학 수식 렌더링 박스 (Result & Details)
   ======================================================== */
.math-details-box {
  margin-bottom: 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.math-details-title {
  font-size: 13px;
  font-weight: 700;
  color: #4338ca;
  margin-bottom: 8px;
}

.math-details-content {
  font-size: 13px;
  line-height: 1.7;
  color: #1e293b;
}

.math-solution-header {
  color: #3730a3;
  font-weight: 700;
}

.math-step-item {
  margin-bottom: 6px;
  color: #334155;
}

.math-quick-tip-box {
  padding: 8px 10px;
  background: #eef2ff;
  border-left: 3px solid #6366f1;
  border-radius: 4px;
  font-size: 12px;
  margin-top: 8px;
  color: #312e81;
}

/* ========================================================
   History Section (과목별 오답노트 보관함)
   ======================================================== */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.history-item-card:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateX(3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: #e0e7ff;
  color: #4338ca;
}

.history-time {
  font-size: 11px;
  color: var(--text-dim);
}

.history-item-title {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
}

.history-item-snippet {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-history-text {
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ========================================================
   오답노트 보관함 페이징 컨트롤 (Pagination)
   ======================================================== */
.history-pagination {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.pagination-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.pagination-count-text strong {
  color: #0f172a;
  font-weight: 700;
}

.pagination-page-indicator {
  color: var(--accent-primary);
  font-weight: 600;
  background: #eef2ff;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pagination-btn {
  height: 36px;
  min-width: 36px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.pagination-btn:hover:not(:disabled) {
  background: #f1f5f9;
  color: var(--text-main);
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.pagination-btn:active:not(:disabled) {
  transform: translateY(0);
}

.pagination-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-nav-btn {
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

.pagination-page-btn {
  min-width: 36px;
}

.pagination-page-btn.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

.pagination-ellipsis {
  color: var(--text-dim);
  font-size: 12px;
  padding: 0 4px;
  user-select: none;
}

/* 모바일 PWA 하단 여백 확보 */
.bottom-spacer {
  height: 24px;
}

/* ========================================================
   과목별 필터 그리드 (보관함)
   ======================================================== */
.history-subject-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-all-chip-row {
  width: 100%;
}

.history-subject-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.chip-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  margin-left: 2px;
}

.subject-chip.active .chip-count-badge {
  background: #4f46e5;
  color: #ffffff;
}

/* 출처 태그 배지 스타일 (카드 및 모달용) */
.history-source-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.history-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  font-size: 11px;
  color: #4338ca;
  font-weight: 500;
}

.modal-source-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  font-size: 11px;
  color: #15803d;
  font-weight: 600;
}

/* ========================================================
   문제영역 3가지 노출 모드 선택기 & 프레임 스타일
   (손글씨 지운 이미지 / 원본 그대로 / 사진에서 읽은 텍스트)
   ======================================================== */
.problem-mode-selector-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
}

.mode-selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.mode-selector-title {
  font-size: 12px;
  font-weight: 700;
  color: #4338ca;
  display: flex;
  align-items: center;
  gap: 4px;
}

.mode-selector-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.problem-mode-chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}

.problem-mode-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  user-select: none;
}

.problem-mode-chip:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

.problem-mode-chip.active {
  background: #eef2ff;
  border-color: var(--accent-primary);
  color: #4338ca;
  font-weight: 700;
  box-shadow: 0 0 0 1px #4f46e5;
}

/* 문제 영역 뷰 박스 */
.problem-view-box {
  border-radius: 12px;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 10px;
}

.problem-view-panel {
  animation: fadeIn 0.25s ease;
}

.problem-img-wrapper {
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  max-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.problem-img-wrapper img {
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: contain;
  display: block;
}

.problem-ocr-text-box {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.8;
  color: #0f172a;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow-y: auto;
}

.view-panel-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  text-align: center;
}

/* ========================================================
   오답 복습 상세 뷰어 모달 (선택 시 문제 -> 해설 토글)
   ======================================================== */
.problem-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.problem-modal {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
  animation: modalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.subject-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--accent-gradient);
  color: #fff;
}

.modal-topic {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-modal-delete {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-modal-delete:hover {
  background: #fecaca;
  border-color: #ef4444;
  color: #991b1b;
  transform: translateY(-1px);
}

.btn-close-modal {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-close-modal:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

/* 문제 섹션 */
.section-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #4338ca;
  margin-bottom: 8px;
}

.problem-image-wrapper {
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  max-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.problem-image-wrapper img {
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: contain;
}

/* 해설 토글 버튼 */
.solution-toggle-wrap {
  margin: 16px 0;
}

.btn-solution-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #3730a3;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-solution-toggle:hover {
  background: #e0e7ff;
  color: #312e81;
  border-color: #a5b4fc;
}

/* 해설 섹션 */
.solution-section {
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.solution-block {
  margin-bottom: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
}

.solution-subtitle {
  font-size: 13px;
  font-weight: 700;
  color: #4338ca;
  margin-bottom: 6px;
}

.steps-content, .tip-content, .trap-content, .concept-content {
  font-size: 13px;
  line-height: 1.7;
  color: #334155;
}

.modal-actions {
  margin-top: 16px;
}

/* 상세 모달 하단 삭제 버튼 영역 */
.modal-bottom-delete-wrap {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed #e2e8f0;
  display: flex;
  justify-content: center;
}

.btn-modal-delete-bottom {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #e11d48;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-modal-delete-bottom:hover {
  background: #ffe4e6;
  border-color: #fda4af;
  color: #be123c;
  transform: translateY(-1px);
}

.btn-modal-delete-bottom:active {
  transform: translateY(0);
}

/* ========================================================
   삭제 비밀번호 확인 모달 (Password Confirmation Modal)
   ======================================================== */
.delete-password-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.delete-password-card {
  width: 100%;
  max-width: 380px;
  background: #ffffff;
  border: 1px solid #fecaca;
  border-radius: 20px;
  padding: 24px 20px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
  animation: modalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}

.delete-password-icon-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 12px;
}

.delete-password-title {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
}

.delete-password-sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 18px;
}

.delete-password-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.delete-password-input {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  font-size: 15px;
  text-align: center;
  letter-spacing: 4px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.delete-password-input:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
  background: #ffffff;
}

.delete-password-error {
  font-size: 12px;
  color: #dc2626;
  font-weight: 600;
  margin: -4px 0 2px;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.delete-password-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.btn-cancel-password {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-cancel-password:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-confirm-delete {
  flex: 1.4;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #dc2626;
  border: 1px solid #b91c1c;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.btn-confirm-delete:hover {
  background: #b91c1c;
  transform: translateY(-1px);
}

/* ========================================================
   Header Actions & Logout Button
   ======================================================== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(8px);
}

.btn-logout:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
  transform: translateY(-1px);
}

/* ========================================================
   Login Section (NAS Administrator Login)
   ======================================================== */
.login-card {
  max-width: 440px;
  margin: 32px auto;
  padding: 32px 24px;
  text-align: center;
  animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-header {
  margin-bottom: 24px;
}

.login-icon-circle {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.12);
}

.login-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.login-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.login-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input-wrapper .input-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  pointer-events: none;
  color: #94a3b8;
}

.login-input {
  width: 100%;
  padding: 14px 44px 14px 42px;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  background: #ffffff;
  outline: none;
  transition: var(--transition);
  letter-spacing: 1px;
}

.login-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.login-input.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
  animation: shake 0.35s ease;
}

.btn-toggle-pw {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  color: #94a3b8;
  border-radius: 6px;
  transition: var(--transition);
}

.btn-toggle-pw:hover {
  color: #475569;
  background: #f1f5f9;
}

.login-error-msg {
  font-size: 12px;
  color: #dc2626;
  font-weight: 600;
  margin: 4px 0 0;
  animation: shake 0.35s ease;
}

.btn-login-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
  transition: var(--transition);
  margin-top: 6px;
}

.btn-login-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.38);
}

.btn-login-submit:active {
  transform: translateY(0);
}

/* ========================================================
   Main Navigation Bar (오답등록 / 오답조회 세그먼트 탭)
   ======================================================== */
.main-nav-bar {
  display: flex;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-md);
  padding: 5px;
  margin-bottom: 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  gap: 6px;
}

.nav-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: #64748b;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.nav-tab-btn:hover {
  color: #1e293b;
  background: rgba(241, 245, 249, 0.7);
}

.nav-tab-btn.active {
  background: #ffffff;
  color: var(--accent-primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.nav-tab-icon {
  font-size: 16px;
}

.nav-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: #eff6ff;
  color: var(--accent-primary);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  transition: var(--transition);
}

.nav-tab-btn.active .nav-tab-badge {
  background: var(--accent-primary);
  color: #ffffff;
}

/* ========================================================
   Page Container & Animations
   ======================================================== */
.app-page {
  width: 100%;
}

.app-page.active-page {
  animation: pageFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.btn-goto-history {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 18px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
  transition: var(--transition);
  margin-bottom: 8px;
}

.btn-goto-history:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.45);
}

.btn-goto-history:active {
  transform: translateY(0);
}

