:root{
  --bg:#f7f9fc;--surface:#fff;--muted:#6b7280;--ink:#0f172a;--line:#e5e7eb;
  --brand:#2563eb;--brand-2:#10b981;--accent:#f59e0b;--danger:#ef4444;
  --radius:14px;--shadow:0 10px 30px rgba(2,6,23,.08);--shadow-sm:0 4px 14px rgba(2,6,23,.06)
}
*{box-sizing:border-box}html,body{height:100%}
body{margin:0;background:linear-gradient(180deg,#eef5ff 0%, var(--bg) 32%, #fff 100%);color:var(--ink);font-family:Pretendard,system-ui,-apple-system,Segoe UI,Roboto,'Noto Sans KR',sans-serif;overflow-y:auto;overflow-x:hidden}

/* ====== Shell (No sidebar; explorer sits left) ====== */
.app{display:grid;grid-template-rows:auto 1fr;min-height:100vh}
.topbar{
  display:flex;align-items:center;gap:14px;padding:16px 20px;border-bottom:1px solid #e6edf7;
  backdrop-filter: blur(8px) saturate(1.05); background:linear-gradient(180deg,#f3f7ffcc,#f9fbffcc);
  position:relative; z-index:1000;
}
.topbar>.brand{flex:0 0 auto}
.topbar>.user{margin-left:auto}
.brand{display:flex;align-items:center;gap:12px}
.logo{width:40px;height:40px;border-radius:12px;background:linear-gradient(135deg,#2396ff,#2563eb);color:#fff;display:grid;place-items:center;font-weight:900;box-shadow:var(--shadow-sm)}
.brand .t1{font-weight:900}.brand .t2{font-size:12px;color:#475569}
.search{display:flex;gap:8px;align-items:center;background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:10px 14px;box-shadow:var(--shadow-sm)}
.search input{flex:1;border:0;outline:none;font:inherit}
.kbd{padding:4px 8px;background:#f3f4f6;border:1px solid #e5e7eb;border-radius:8px;font-size:12px;color:#334155}
.user{display:flex;align-items:center;gap:10px;background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:6px 10px;box-shadow:var(--shadow-sm);position:relative;margin-left:auto}
.avatar{width:28px;height:28px;border-radius:999px;background:#c7d2fe;display:grid;place-items:center;font-weight:800}

/* 모달 오버레이 */
.modal-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(0, 0, 0, 0.5) !important;
  z-index: 999998 !important;
  pointer-events: auto !important;
}

/* 인증 폼 스타일 */
.auth-form {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  background: white !important;
  border: 1px solid var(--line) !important;
  border-radius: 12px !important;
  padding: 20px !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
  min-width: 300px !important;
  z-index: 999999 !important;
  flex-direction: column !important;
  gap: 12px !important;
}

.auth-form h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
}

.auth-form input, .auth-form select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.auth-form input:focus, .auth-form select:focus {
  border-color: var(--brand);
}

.auth-form button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-form button:first-of-type {
  background: var(--brand);
  color: white;
}

.auth-form button:first-of-type:hover {
  background: #1d4ed8;
}

.login-form button:last-of-type, .register-form button:last-of-type {
  background: #f3f4f6;
  color: var(--ink);
}

.login-form button:last-of-type:hover, .register-form button:last-of-type:hover {
  background: #e5e7eb;
}

.switch-btn {
  background: #f3f4f6 !important;
  color: var(--ink) !important;
  font-size: 13px !important;
  padding: 8px 12px !important;
}

.switch-btn:hover {
  background: #e5e7eb !important;
}

/* 역할 선택 버튼 */
.role-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0;
}

.role-btn {
  padding: 12px 16px !important;
  background: #f3f4f6 !important;
  color: var(--ink) !important;
  border: 2px solid transparent !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: all 0.2s;
}

.role-btn:hover {
  background: #e5e7eb !important;
}

.role-btn.selected {
  background: var(--brand) !important;
  color: white !important;
  border-color: var(--brand) !important;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}

.user-profile-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info span {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
}

.user-info button {
  padding: 8px 14px;
  height: 36px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
}

.user-info button:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #475569;
}

.plan-dropdown{position:relative;display:flex;align-items:center}

.plan-badge {
  padding: 8px 16px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
  border: 1px solid #93c5fd;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.12);
}

.plan-badge:hover {
  background: linear-gradient(135deg, #c7d2fe 0%, #a5b4fc 100%);
  border-color: #818cf8;
}

.plan-arrow {font-size:12px;color:inherit;transition:transform .2s ease}
.plan-dropdown.open .plan-arrow{transform:rotate(180deg)}

.plan-badge.basic {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.plan-badge.pro {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  border: 1px solid #fbbf24;
}

.plan-menu{
  position:absolute;
  top:calc(100% + 8px);
  right:0;
  display:flex;
  flex-direction:column;
  gap:4px;
  padding:8px;
  background:#ffffff;
  border:1px solid #e2e8f0;
  border-radius:12px;
  box-shadow:0 12px 30px rgba(15,23,42,0.12);
  min-width:140px;
  z-index:1000;
}

.plan-dropdown:not(.open) .plan-menu{display:none!important}

.plan-option{
  padding:8px 12px;
  border-radius:8px;
  border:none;
  background:transparent;
  font-size:13px;
  font-weight:600;
  color:#1e293b;
  text-align:left;
  cursor:pointer;
  transition:background .2s,color .2s;
}

.plan-option:hover{
  background:#e0e7ff;
  color:#1d4ed8;
}

.plan-option.active{
  background:#1d4ed8;
  color:#ffffff;
}

.login-btn {
  padding: 8px 16px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-btn:hover {
  background: #1d4ed8;
}

.auth-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.register-btn {
  padding: 8px 16px;
  background: var(--brand-2);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.register-btn:hover {
  background: #059669;
}
.badge{padding:4px 8px;border-radius:999px;font-size:12px;background:#ecfeff;color:#0ea5e9;border:1px solid #bae6fd}

/* ====== Main Layout: Explorer (left) + Preview (right) ====== */
.main{display:grid;grid-template-columns:324px 1fr 1fr;gap:18px;padding:18px 20px;height:calc(100vh - 80px);overflow:hidden;position:relative}
.resize-handle{
  position:absolute;top:0;bottom:0;width:6px;background:#e5e7eb;cursor:col-resize;z-index:10;transition:background 0.2s;
}
.resize-handle:hover{
  background:#3b82f6;
}
.resize-handle:active{
  background:#1e40af;
}

/* Center floating signup button */
.center-signup-btn{display:none}
.section-signup-btn{display:none}
.explorer{
  display:flex;flex-direction:column;gap:0;height:calc(100vh - 100px);max-height:720px;
}
.explorer .ex-card{height:100%;display:flex;flex-direction:column;overflow:hidden}
.ex-card{background:#fff;border:1px solid #e6edf6;border-radius:16px;box-shadow:var(--shadow-sm)}
.ex-upload{padding:12px}
.ex-upload .upload-tile{
  position:relative;border:2px dashed #f59e0b;background:linear-gradient(135deg,#fffbeb,#fef3c7);
  border-radius:14px;display:flex;gap:12px;align-items:center;justify-content:center;height:96px;cursor:pointer;transition:.2s
}
.ex-upload .upload-tile:hover{border-color:#d97706;background:linear-gradient(135deg,#fef3c7,#fde68a)}
.ex-upload .upload-tile.drag-over{border-color:#92400e;background:linear-gradient(135deg,#fde68a,#fcd34d)}
.upload-icon{font-size:24px;color:#b45309}.upload-title{font-weight:900;color:#92400e}
.progress-container{
  position:absolute;
  left:12px;
  right:12px;
  bottom:8px;
  display:none;
  z-index:10;
  background:rgba(255,255,255,0.98);
  padding:10px 12px;
  border-radius:10px;
  box-shadow:0 4px 12px rgba(0,0,0,0.15);
  backdrop-filter:blur(4px);
}
.progress-bar{width:100%;height:8px;border-radius:999px;background:#e5e7eb;overflow:hidden;margin-bottom:6px;box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}
.progress-fill{
  height:100%;
  width:0%;
  background:linear-gradient(90deg,#34d399,#10b981);
  transition:width .3s ease;
  border-radius:999px;
  position:relative;
}
.progress-fill::after{
  content:'';
  position:absolute;
  top:0;left:0;bottom:0;right:0;
  background:linear-gradient(90deg,rgba(255,255,255,0) 0%,rgba(255,255,255,0.3) 50%,rgba(255,255,255,0) 100%);
  animation:progressShine 1.5s ease-in-out infinite;
}
@keyframes progressShine{
  0%{transform:translateX(-100%)}
  100%{transform:translateX(100%)}
}
.progress-text{font-size:12px;color:#475569;text-align:center;font-weight:600;line-height:1.4}

.ex-usage{display:flex;align-items:center;gap:8px;padding:10px 12px}
.usage-bar{flex:1;height:8px;border-radius:999px;background:#e5e7eb;overflow:hidden;box-shadow:inset 0 1px 2px rgba(0,0,0,.06)}
.usage-fill{height:100%;width:0%;border-radius:999px;background:linear-gradient(90deg,#60a5fa,#2563eb);transition:width .25s}
.usage-text{font-size:12px;color:#475569;font-weight:800}

.ex-breadcrumb{padding:8px 10px}
.breadcrumb{
  display:flex;align-items:center;gap:8px;padding:6px 8px;background:#fff;border:1px solid #e6edf6;border-radius:12px;box-shadow:var(--shadow-sm)
}
.breadcrumb .crumb{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:999px;font-weight:800;cursor:pointer;background:#f8fafc;border:1px solid #e5e7eb;color:#0f172a}
.breadcrumb .sep{opacity:.5}

.ex-toolbar{display:flex;align-items:center;gap:8px;padding:10px 12px;border-top:1px solid #eef2f7}
.btn{appearance:none;border:1px solid transparent;border-radius:12px;padding:8px 12px;font-weight:800;cursor:pointer;background:#eef2ff;color:#1e40af;transition:.2s}
.btn.primary{background:linear-gradient(135deg,#4f9aff,#2563eb);color:#fff;box-shadow:var(--shadow)}
.btn.ghost{background:#fff;border-color:#e5e7eb;color:#0f172a}
.btn.danger{background:#fee2e2;color:#991b1b}
.btn.small{padding:6px 10px;border-radius:10px;font-size:12px}
.btn:hover{transform:translateY(-1px);box-shadow:var(--shadow)}.btn:active{transform:translateY(1px)}
.btn.selected{background:#10b981;box-shadow:0 0 0 2px rgba(16,185,129,0.2)}
.btn.selected:hover{background:#059669}

.grid{display:grid;gap:12px}
.files-grid{display:flex;flex-direction:column;gap:8px;padding:8px 12px}
.tile{display:flex;gap:12px;align-items:center;background:#fff;border:1px solid #e6edf6;border-radius:14px;padding:10px 12px;box-shadow:var(--shadow-sm);transition:transform .05s,box-shadow .2s,background .2s,border-color .2s}
.tile:not(.selected):hover{transform:translateY(-1px);box-shadow:var(--shadow)}
.small-tile{min-height:52px;height:auto;cursor:pointer;user-select:none;position:relative}
.small-tile:not(.selected):hover{background:#f8fafc;border-color:#3b82f6}
.tile.selected{background:#e0f2fe;border:0;box-shadow:0 0 0 2px rgba(37,99,235,.25);transform:translateY(-1px)}
.small-tile .name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:200px}
/* Fixed toolbar layout */
.ex-dashboard{
  display:flex;
  flex-direction:column;
  padding:0;
  height:100%;
  overflow:hidden;
  position:relative;
}
.ex-dashboard .ex-upload{flex-shrink:0}
.ex-dashboard .ex-usage{flex-shrink:0}
.ex-dashboard.guest-locked{overflow:visible}
/* File list - scrollable */
.ex-dashboard .grid{
  flex:1;
  overflow-y:auto;
  overflow-x:hidden;
  min-height:0;
  max-height:none;
  border-bottom:1px solid #eef2f7;
  padding-bottom:8px;
}
.ex-dashboard .grid::-webkit-scrollbar{width:6px}
.ex-dashboard .grid::-webkit-scrollbar-track{background:#f1f5f9;border-radius:3px}
.ex-dashboard .grid::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:3px}
.ex-dashboard .grid::-webkit-scrollbar-thumb:hover{background:#94a3b8}
/* Toolbar - fixed at bottom */
.ex-dashboard .ex-toolbar{
  flex-shrink:0;
  background:#fff;
  z-index:10;
  border-radius:0 0 16px 16px;
  margin-top:auto;
}

/* í´ë” ì•„ì½”ë””ì–¸ */
.folder-item{display:flex;flex-direction:column;gap:6px}
.folder-header .chev{margin-left:auto;font-size:16px;color:#64748b;user-select:none;padding:8px;border-radius:6px;transition:background-color .2s;min-width:32px;display:flex;align-items:center;justify-content:center}
.folder-header .chev:hover{background-color:#f1f5f9}
.folder-children{display:flex;flex-direction:column;gap:6px;margin-left:24px;padding:8px 0 2px;border-left:2px dashed #e6edf6;position:relative}
.folder-children::before{content:'';position:absolute;left:-2px;top:0;width:2px;height:8px;background:#e6edf6}
.child-tile{padding:8px 10px;background:#f8f9fa;border-color:#e5e7eb}
.folder-children .folder-item{margin-left:0}
.icon{width:28px;height:28px;border-radius:8px;display:grid;place-items:center;color:#fff;font-weight:900;background:linear-gradient(135deg,#a78bfa,#6366f1)}
.icon.folder{background:linear-gradient(135deg,#34d399,#10b981)}
.drop-zone{position:relative}
.drop-zone.drag-over{background:#dbeafe;border-color:#2563eb}
.drop-indicator{position:absolute;inset:0;border:2px dashed #3b82f6;border-radius:12px;background:rgba(59,130,246,.08);display:none}
.up-tile .icon{background:linear-gradient(135deg,#94a3b8,#64748b)}

/* ====== Right: Exam Preview ====== */
.exam-preview{
  background:#fff;border:1px solid #e6edf6;border-radius:16px;box-shadow:var(--shadow-sm);overflow:hidden;min-height:400px;max-height:calc(100vh - 120px);
  display:flex;flex-direction:column;
}
.exam-preview.guest-disabled{filter:grayscale(100%);opacity:.85;pointer-events:none}
.exam-header{
  padding:16px 20px;border-bottom:1px solid #f1f5f9;display:flex;align-items:center;justify-content:space-between
}
.exam-header h2{
  margin:0;font-size:18px;font-weight:800;color:#1e40af
}
.exam-controls{
  display:flex;gap:8px
}
.exam-content{
  flex:1;display:flex;flex-direction:column;overflow:hidden
}
.exam-stats{
  display:flex;gap:20px;padding:12px 20px;background:#f8fafc;border-bottom:1px solid #e6edf6
}
.stat-item{
  display:flex;flex-direction:column;gap:2px
}
.stat-label{
  font-size:12px;color:#64748b;font-weight:600
}
.stat-value{
  font-size:16px;color:#1e40af;font-weight:800
}
.exam-problems{
  flex:1;overflow-y:auto;padding:20px;background:#f8fafc;
}
.exam-problems::-webkit-scrollbar{
  width:8px;
}
.exam-problems::-webkit-scrollbar-track{
  background:#f1f5f9;border-radius:4px;
}
.exam-problems::-webkit-scrollbar-thumb{
  background:#cbd5e1;border-radius:4px;
}
.exam-problems::-webkit-scrollbar-thumb:hover{
  background:#94a3b8;
}
.exam-page{
  width:794px;height:1123px;background:#fff;margin:0 auto 20px;box-shadow:0 4px 12px rgba(0,0,0,0.1);border-radius:8px;overflow:hidden;position:relative;
}
.exam-page:last-child{
  margin-bottom:0;
}
.exam-page-header{
  background:linear-gradient(135deg,#1e40af,#3b82f6);color:#fff;padding:20px;text-align:center;border-bottom:3px solid #1e40af;
}
.exam-page-title{
  font-size:24px;font-weight:800;margin:0 0 8px;text-shadow:0 1px 2px rgba(0,0,0,0.2);
}
.exam-page-subtitle{
  font-size:14px;opacity:0.9;margin:0;
}
.exam-page-content{
  padding:30px;display:flex;gap:20px;height:calc(1123px - 120px);
}
.exam-page-column{
  flex:1;display:flex;flex-direction:column;gap:16px;
}
.exam-page-footer{
  position:absolute;bottom:0;left:0;right:0;height:40px;background:#f8fafc;border-top:1px solid #e5e7eb;display:flex;align-items:center;justify-content:center;font-size:12px;color:#6b7280;
}
.exam-page-number{
  font-weight:600;
}
.empty-state{
  display:flex;flex-direction:column;align-items:center;justify-content:center;height:200px;color:#64748b;text-align:center
}
.empty-icon{
  font-size:48px;margin-bottom:12px;opacity:0.5
}
.empty-state p{
  margin:0;font-size:14px;font-weight:500
}
.exam-problem{
  border:1px solid #e2e8f0;border-radius:12px;padding:12px;background:#f8fafc;
  box-shadow:0 1px 3px rgba(0,0,0,0.1);font-size:13px;
  cursor:pointer;transition:all 0.2s ease;position:relative;word-break:break-word;
}

/* PDF 생성 모달 오버레이 */
.pdf-overlay{
  position:fixed;top:0;left:0;width:100vw;height:100vh;background:rgba(0,0,0,0.6);backdrop-filter:blur(6px);
  z-index:10000;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity 0.3s ease;
}
.pdf-overlay.show{opacity:1}

.pdf-progress-modal{
  background:#fff;padding:40px;border-radius:20px;box-shadow:0 25px 80px rgba(0,0,0,0.3);
  min-width:400px;max-width:500px;text-align:center;transform:scale(0.9);transition:transform 0.3s ease;
}
.pdf-overlay.show .pdf-progress-modal{transform:scale(1)}

.progress-spinner{margin-bottom:20px}
.spinner{
  width:48px;height:48px;border:4px solid #e5e7eb;border-top:4px solid #3b82f6;border-radius:50%;
  animation:spin 1s linear infinite;margin:0 auto;
}
@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}

.progress-title{font-size:20px;font-weight:700;color:#1e40af;margin-bottom:24px}

.progress-bar-container{display:flex;align-items:center;gap:16px;margin-bottom:16px}
.progress-bar-modal{
  flex:1;height:12px;background:#e5e7eb;border-radius:6px;overflow:hidden;position:relative;
}
.progress-fill-modal{
  height:100%;background:linear-gradient(90deg,#3b82f6,#1e40af);border-radius:6px;
  transition:width 0.4s ease;width:0%;position:relative;overflow:hidden;
}
.progress-fill-modal::after{
  content:'';position:absolute;top:0;left:0;right:0;bottom:0;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,0.3),transparent);
  animation:shimmer 1.5s infinite;
}
@keyframes shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}

.progress-percentage{font-size:18px;font-weight:800;color:#1e40af;min-width:60px}

.progress-text-modal{font-size:16px;color:#64748b;font-weight:500;margin-bottom:12px}
.progress-details{font-size:14px;color:#94a3b8;min-height:20px}

/* 기존 작은 진행바 (호환성 유지) */
.pdf-progress{
  background:linear-gradient(135deg,#f0f9ff,#e0f2fe);border:1px solid #0ea5e9;border-radius:6px;padding:8px;margin:6px 0;
  box-shadow:0 1px 4px rgba(14,165,233,0.1);
}
.progress-bar{
  width:100%;height:4px;background:#e0f2fe;border-radius:2px;overflow:hidden;margin-bottom:4px;
}
.progress-fill{
  height:100%;background:linear-gradient(90deg,#0ea5e9,#0284c7);border-radius:2px;transition:width 0.15s ease;width:0%;
}
.progress-text{
  font-size:11px;color:#0c4a6e;text-align:center;font-weight:600;
}
.exam-problem:hover{border-color:#3b82f6;background:#f1f5f9;transform:translateY(-1px);box-shadow:0 4px 8px rgba(0,0,0,0.12)}
.exam-problem::before{
  content:'✓';position:absolute;top:8px;right:8px;width:20px;height:20px;background:#10b981;color:#fff;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:800
}

/* ====== Right: Preview ====== */
.preview-wrap{
  display:grid;grid-template-rows:auto 1fr auto;gap:12px;height:100%;overflow:hidden
}
.preview-wrap.guest-disabled{filter:grayscale(100%);opacity:.85;pointer-events:none}
.preview-toolbar{
  background:#fff;border:1px solid #e6edf6;border-radius:16px;box-shadow:var(--shadow-sm)
}
.preview-header{
  padding:16px 20px 8px;border-bottom:1px solid #f1f5f9
}
.preview-title{
  margin:0;font-size:18px;font-weight:800;color:#1e40af
}
.tabs-container{
  display:flex;align-items:center;justify-content:space-between;padding:8px 12px
}
.tabs{
  display:flex;gap:4px;flex:1;min-width:0;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;scroll-behavior:smooth
}
.tabs::-webkit-scrollbar{height:0}
.tab{
  display:flex;align-items:center;gap:6px;padding:6px 12px;background:#f8fafc;border:1px solid #e5e7eb;border-radius:8px;cursor:pointer;transition:all 0.2s;white-space:nowrap;font-size:13px;color:#64748b;position:relative;flex:0 0 auto
}
.tab:hover{
  background:#e2e8f0;border-color:#cbd5e1
}
.tab.active{
  background:#fff;border-color:#3b82f6;color:#1e40af;box-shadow:0 1px 3px rgba(59,130,246,0.1)
}
.tab.active::after{
  content:'';position:absolute;bottom:-1px;left:0;right:0;height:2px;background:#3b82f6;border-radius:1px
}
.tab-icon{
  width:16px;height:16px;border-radius:4px;background:linear-gradient(135deg,#a78bfa,#6366f1);display:flex;align-items:center;justify-content:center;color:#fff;font-size:10px;font-weight:800
}
.tab-close{
  width:16px;height:16px;border-radius:50%;background:#e5e7eb;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all 0.2s;color:#64748b;font-size:12px;margin-left:4px
}
.tab-close:hover{
  background:#ef4444;color:#fff
}
.tab-controls{
  display:flex;align-items:center;gap:10px
}
.chkall{display:flex;align-items:center;gap:8px}
.preview{
  background:#fff;border:1px solid #e6edf6;border-radius:16px;box-shadow:var(--shadow-sm);overflow-y:auto;min-height:400px;max-height:calc(100vh - 200px);
  display:flex;gap:16px;padding:16px;
}
/* Preview empty state */
.preview-empty-container{display:flex;align-items:center;justify-content:center;width:100%}
.preview-empty{color:#64748b;text-align:center;padding:24px}
.preview-empty .empty-icon{font-size:28px;margin-bottom:8px}
.preview.empty{min-height:160px;align-items:center;justify-content:center}
.preview.empty .preview-column{display:none}
.preview::-webkit-scrollbar{
  width:8px;
}
.preview::-webkit-scrollbar-track{
  background:#f1f5f9;border-radius:4px;
}
.preview::-webkit-scrollbar-thumb{
  background:#cbd5e1;border-radius:4px;
}
.preview::-webkit-scrollbar-thumb:hover{
  background:#94a3b8;
}
.preview-column{
  flex:1 1 50%;display:flex;flex-direction:column;gap:12px;min-width:0;
}
.problem{
  border:1px solid #e2e8f0;border-radius:12px;padding:12px;background:#f8fafc;
  box-shadow:0 1px 3px rgba(0,0,0,0.1);font-size:13px;
  cursor:pointer;transition:all 0.2s ease;position:relative;word-break:break-word;
}
.problem:hover{border-color:#3b82f6;background:#f1f5f9;transform:translateY(-1px);box-shadow:0 4px 8px rgba(0,0,0,0.12)}
.problem.selected{border-color:#2563eb;background:#dbeafe;box-shadow:0 0 0 2px rgba(37,99,235,0.2);transform:translateY(-1px)}
.problem.selected::before{
  content:'✓';position:absolute;top:8px;right:8px;width:20px;height:20px;background:#2563eb;color:#fff;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:800
}
.pnum{font-weight:900;color:#1e40af;margin-right:6px;font-size:14px}
.pbody{line-height:1.5;color:#374151}
.preview .table{border:1px solid #111;border-collapse:collapse;margin:6px 0;width:100%;font-size:12px}
.preview .table td{border:1px solid #111;padding:4px 6px;font-size:12px}
.cta{display:flex;gap:8px;justify-content:flex-end}

.counter{color:var(--muted);font-weight:700}
.note{color:#64748b;margin-top:8px}

/* Desktop: match heights with exam preview by letting preview section fill and using same viewport calc */
/* ====== RESPONSIVE DESIGN v2 - Complete Rewrite ====== */

/* ========================================
   TABLET (769px - 1100px)
   ======================================== */
@media (min-width: 769px) and (max-width: 1100px) {
  .main {
    grid-template-columns: 260px 1fr 1fr;
    gap: 12px;
    padding: 12px 16px;
  }
  
  .brand .t2 {
    font-size: 10px;
  }
  
  .explorer {
    min-width: 240px;
  }
  
  .upload-tile {
    height: 80px;
  }
  
  .tab {
    padding: 5px 10px;
    font-size: 12px;
  }
  
  .preview-title {
    font-size: 16px;
  }
  
  .problem {
    padding: 10px;
    font-size: 12px;
  }
  
  .exam-page {
    transform: scale(0.95);
    transform-origin: top center;
  }
}

/* ========================================
   MOBILE LANDSCAPE & SMALL TABLET (601px - 768px)
   ======================================== */
@media (min-width: 601px) and (max-width: 768px) {
  .topbar {
    padding: 10px 14px;
  }
  
  .brand .t2 {
    display: none;
  }
  
  .main {
    display: flex;
    flex-direction: column;
    height: auto;
    padding: 10px;
    gap: 10px;
  }
  
  .resize-handle {
    display: none !important;
  }
  
  .explorer {
    width: 100%;
    max-height: 280px;
    overflow-y: auto;
  }
  
  .ex-card {
    border-radius: 12px;
  }
  
  .preview-wrap {
    width: 100%;
    min-height: 300px;
    border-radius: 12px;
  }
  
  .preview {
    flex-direction: row;
    gap: 10px;
    padding: 10px;
    max-height: 400px;
    overflow-y: auto;
  }
  
  .preview-column {
    flex: 1;
    min-width: 0;
  }
  
  .exam-preview {
    width: 100%;
    min-height: 300px;
    border-radius: 12px;
  }
  
  .exam-page {
    width: 100%;
    transform: scale(0.85);
    transform-origin: top center;
  }
  
  .exam-page-content {
    display: block;
  }
  
  .exam-page-column {
    width: 100%;
  }
}

/* ========================================
   MOBILE PORTRAIT (481px - 600px)
   ======================================== */
@media (max-width: 600px) {
  /* Reset any conflicting styles */
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }
  
  .app {
    overflow-x: hidden;
  }
  
  /* Topbar */
  .topbar {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  
  .brand {
    gap: 8px;
    flex-shrink: 0;
  }
  
  .logo {
    width: 32px;
    height: 32px;
    font-size: 14px;
    border-radius: 8px;
  }
  
  .brand .t1 {
    font-size: 14px;
  }
  
  .brand .t1 span {
    font-size: 8px !important;
    padding: 1px 4px !important;
  }
  
  .brand .t2 {
    display: none;
  }
  
  .user {
    padding: 4px 8px;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
  }
  
  .avatar {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }
  
  .plan-badge {
    padding: 4px 8px;
    font-size: 10px;
    height: auto;
  }
  
  .plan-arrow {
    font-size: 8px;
  }
  
  /* Main Layout - Vertical Stack */
  .main {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: unset !important;
    height: auto !important;
    min-height: calc(100vh - 60px);
    padding: 8px;
    gap: 8px;
    overflow-x: hidden;
  }
  
  .resize-handle {
    display: none !important;
  }
  
  /* Explorer Section */
  .explorer {
    width: 100%;
    order: 1;
    max-height: 250px;
    overflow-y: auto;
  }
  
  .ex-card {
    border-radius: 12px;
  }
  
  .ex-dashboard {
    display: flex;
    flex-direction: column;
  }
  
  .upload-tile {
    height: 60px;
    border-radius: 10px;
  }
  
  .upload-icon {
    font-size: 18px;
  }
  
  .upload-title {
    font-size: 12px;
  }
  
  .ex-usage {
    padding: 6px 10px;
  }
  
  .usage-text {
    font-size: 10px;
  }
  
  .ex-toolbar {
    padding: 8px;
    gap: 4px;
    flex-wrap: wrap;
  }
  
  .ex-toolbar .btn {
    padding: 6px 8px;
    font-size: 10px;
  }
  
  .counter {
    font-size: 11px;
  }
  
  .small-tile {
    padding: 8px 10px;
  }
  
  .small-tile .name {
    font-size: 12px;
    max-width: 150px;
  }
  
  /* Preview Section */
  .preview-wrap {
    width: 100%;
    order: 2;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e6edf6;
  }
  
  .preview-toolbar {
    padding: 8px 10px;
    border: none !important;
    border-radius: 0 !important;
  }
  
  .preview-header {
    padding: 0;
  }
  
  .preview-title {
    font-size: 14px;
    margin: 0;
  }
  
  .tabs-container {
    padding: 6px 8px;
  }
  
  .tabs {
    gap: 4px;
  }
  
  .tab {
    padding: 5px 8px;
    font-size: 11px;
    border-radius: 6px;
  }
  
  .tab-icon {
    width: 14px;
    height: 14px;
    font-size: 8px;
    border-radius: 3px;
  }
  
  .tab-close {
    width: 16px;
    height: 16px;
    font-size: 10px;
    margin-left: 2px;
  }
  
  .preview {
    display: flex;
    flex-direction: column !important;
    gap: 8px;
    padding: 8px;
    max-height: 350px;
    overflow-y: auto;
    overflow-x: hidden;
    border: none !important;
    border-radius: 0 !important;
  }
  
  .preview-column {
    width: 100% !important;
    flex: none !important;
  }
  
  .problem {
    padding: 10px;
    font-size: 12px;
    border-radius: 10px;
    margin-bottom: 0;
    word-break: break-word;
    overflow-wrap: break-word;
  }
  
  .problem.selected::before {
    width: 18px;
    height: 18px;
    font-size: 10px;
    top: 6px;
    right: 6px;
  }
  
  .pnum {
    font-size: 13px;
    min-width: 20px;
  }
  
  .pbody {
    font-size: 12px;
    line-height: 1.5;
  }
  
  /* Tables in preview */
  .preview .table {
    font-size: 10px;
    max-width: 100%;
    table-layout: fixed;
  }
  
  .preview .table td {
    padding: 3px 4px;
    font-size: 10px;
    word-break: break-word;
  }
  
  /* Exam Preview Section */
  .exam-preview {
    width: 100%;
    order: 3;
    border-radius: 12px;
    overflow: hidden;
    min-height: 300px;
  }
  
  .exam-header {
    padding: 10px;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .exam-title {
    font-size: 14px;
    width: 100%;
  }
  
  .exam-stats {
    font-size: 11px;
    gap: 12px;
  }
  
  .exam-controls {
    width: 100%;
    justify-content: flex-start;
    gap: 4px;
    flex-wrap: wrap;
  }
  
  .exam-controls .btn {
    padding: 6px 10px;
    font-size: 10px;
  }
  
  .exam-content {
    max-height: none;
    overflow-y: visible;
  }
  
  .exam-problems {
    padding: 8px;
  }
  
  .exam-page {
    width: 100%;
    height: auto;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
  }
  
  .exam-page-header {
    padding: 8px;
    margin-bottom: 8px;
  }
  
  .exam-page-title {
    font-size: 14px;
  }
  
  .exam-page-subtitle {
    font-size: 10px;
  }
  
  .exam-page-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: auto;
    padding: 0;
  }
  
  .exam-page-column {
    width: 100%;
  }
  
  .exam-problem {
    padding: 8px;
    font-size: 11px;
    margin-bottom: 6px;
  }
  
  .exam-problem .pnum {
    font-size: 12px;
  }
  
  .exam-page-footer {
    padding: 8px;
    font-size: 10px;
  }
  
  /* MathJax responsive */
  mjx-container {
    max-width: 100% !important;
    overflow-x: auto !important;
    display: inline-block !important;
  }
  
  mjx-container[jax="CHTML"] {
    font-size: 90% !important;
  }
  
  /* Auth forms */
  .auth-form {
    min-width: 280px !important;
    max-width: calc(100vw - 32px) !important;
    padding: 16px !important;
    margin: 16px !important;
  }
  
  .auth-form h3 {
    font-size: 16px;
  }
  
  .auth-form input {
    padding: 10px;
    font-size: 14px;
  }
  
  /* Inline register */
  .inline-register {
    padding: 12px;
    margin: 8px !important;
    border-radius: 12px;
  }
  
  .inline-register h3 {
    font-size: 14px;
    margin-bottom: 10px;
  }
  
  .inline-register input {
    padding: 10px;
    font-size: 13px;
  }
  
  /* Guide bubbles - hide on mobile */
  .guide-bubble {
    display: none !important;
  }
  
  /* Guest lock center */
  .guest-lock-center {
    padding: 16px;
  }
  
  .login-overlay-btn {
    padding: 10px 20px;
    font-size: 13px;
  }
  
  /* Footer */
  .site-footer {
    padding: 12px 10px 16px;
    margin-top: 16px;
  }
  
  .site-footer .footer-biz {
    font-size: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  
  .site-footer .biz-row {
    display: flex;
    gap: 6px;
  }
  
  .site-footer .footer-copy {
    font-size: 9px;
    margin-top: 8px;
  }
}

/* ========================================
   MOBILE SMALL (< 480px)
   ======================================== */
@media (max-width: 480px) {
  .topbar {
    padding: 6px 10px;
  }
  
  .logo {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  
  .brand .t1 {
    font-size: 13px;
  }
  
  .user {
    padding: 3px 6px;
  }
  
  .avatar {
    width: 22px;
    height: 22px;
  }
  
  .plan-badge {
    padding: 3px 6px;
    font-size: 9px;
  }
  
  .main {
    padding: 6px;
    gap: 6px;
  }
  
  .explorer {
    max-height: 220px;
  }
  
  .upload-tile {
    height: 50px;
  }
  
  .upload-icon {
    font-size: 16px;
  }
  
  .upload-title {
    font-size: 11px;
  }
  
  .preview {
    max-height: 300px;
    padding: 6px;
  }
  
  .problem {
    padding: 8px;
    font-size: 11px;
  }
  
  .tabs {
    gap: 3px;
  }
  
  .tab {
    padding: 4px 6px;
    font-size: 10px;
  }
  
  .tab-icon {
    width: 12px;
    height: 12px;
    font-size: 7px;
  }
  
  .tab-close {
    width: 14px;
    height: 14px;
  }
  
  .exam-controls .btn {
    padding: 5px 8px;
    font-size: 9px;
  }
}

/* ========================================
   LANDSCAPE MODE
   ======================================== */
@media (max-width: 900px) and (orientation: landscape) {
  .main {
    flex-direction: row !important;
    flex-wrap: wrap;
    align-items: flex-start;
  }
  
  .explorer {
    width: 35%;
    max-height: 50vh;
    flex-shrink: 0;
  }
  
  .preview-wrap {
    width: 63%;
    max-height: 60vh;
    overflow-y: auto;
  }
  
  .exam-preview {
    width: 100%;
    max-height: 50vh;
    overflow-y: auto;
  }
  
  .preview {
    max-height: 45vh;
  }
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .tab,
  .problem,
  .small-tile,
  .btn,
  .upload-tile {
    min-height: 44px;
  }
  
  .tab-close {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  
  .problem {
    padding: 12px;
  }
  
  .ex-toolbar .btn {
    min-height: 36px;
    padding: 8px 12px;
  }
  
  /* No hover effects on touch */
  .problem:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  }
  
  .tab:hover {
    background: #f8fafc;
  }
  
  /* Prevent text selection */
  .tabs,
  .mobile-tabs,
  .ex-toolbar {
    user-select: none;
    -webkit-user-select: none;
  }
  
  /* Smooth scrolling */
  .preview,
  .explorer,
  .exam-problems,
  .tabs {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  .topbar,
  .explorer,
  .preview-wrap,
  .mobile-tabs,
  .tabs-container,
  .exam-header,
  .site-footer,
  .guide-bubble {
    display: none !important;
  }
  
  .main {
    display: block !important;
    padding: 0 !important;
  }
  
  .exam-preview {
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
  }
  
  .exam-page {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 20px;
  }
  
  .exam-problems {
    padding: 0 !important;
  }
}

/* ========================================
   REDUCED MOTION
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========================================
   HIGH CONTRAST MODE
   ======================================== */
@media (prefers-contrast: high) {
  .problem {
    border-width: 2px;
  }
  
  .problem.selected {
    border-width: 3px;
  }
  
  .tab.active {
    border-width: 2px;
  }
}

/* 내 파일 관련 스타일 */
.file-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  background: white;
  transition: all 0.2s ease;
}

.file-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.file-icon {
  font-size: 24px;
  margin-right: 12px;
}

.file-info {
  flex: 1;
}

.file-name {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.file-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-light);
}

.file-actions {
  display: flex;
  gap: 8px;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-text {
  font-size: 16px;
  margin-bottom: 16px;
}

.file-problems-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.problems-list {
  max-height: 600px;
  overflow-y: auto;
}

.problem-item {
  display: flex;
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.problem-number {
  font-weight: bold;
  color: var(--primary);
  margin-right: 16px;
  min-width: 30px;
}

.problem-content {
  flex: 1;
}

.problem-text {
  margin-bottom: 12px;
  line-height: 1.5;
}

.problem-options {
  margin-bottom: 12px;
}

.option {
  margin-bottom: 4px;
  padding-left: 8px;
}

.problem-answer {
  font-weight: bold;
  color: var(--success);
  margin-bottom: 8px;
}

.problem-explanation {
  color: var(--text-light);
  font-style: italic;
  padding: 8px;
  background: var(--bg-light);
  border-radius: 4px;
}

/* Condition block styling (조건 블록 - 네모 박스) */
.condition-block {
  background: transparent;
  border: 1px solid #000000;
  padding: 12px;
  border-radius: 6px;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.6;
}


/* 로그인 필요 오버레이 */
.login-required-overlay{
  position:relative;
  background:#fff;
  border:1px solid #e6edf6;
  border-radius:16px;
  box-shadow:var(--shadow-sm);
  padding:24px 20px;
  display:block;
  margin-bottom:12px;
}
.login-overlay-stack{display:flex;flex-direction:column;gap:12px;align-items:center}
.login-message{
  text-align:center;
  padding:40px;
  max-width:300px;
}
.login-icon{
  font-size:48px;
  margin-bottom:16px;
}
.login-message h3{
  font-size:20px;
  font-weight:700;
  color:var(--ink);
  margin-bottom:12px;
}
.login-message p{
  font-size:14px;
  color:#64748b;
  line-height:1.6;
  margin-bottom:24px;
}
.login-overlay-btn{
  background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);
  color:white;
  border:none;
  padding:12px 32px;
  border-radius:8px;
  font-size:14px;
  font-weight:600;
  cursor:pointer;
  transition:all 0.2s;
  box-shadow:0 4px 12px rgba(102,126,234,0.3);
}
.login-overlay-btn:hover{
  transform:translateY(-2px);
  box-shadow:0 6px 16px rgba(102,126,234,0.4);
}

/* Inline register form (guest) */
.inline-register{background:#fff;background-image:linear-gradient(180deg,#f4f7ff,#ffffff);border:2px solid rgba(102,126,234,.55);border-radius:16px;padding:20px;box-shadow:0 10px 30px rgba(102,126,234,.18),0 1px 0 rgba(255,255,255,.6) inset;width:auto;max-width:360px;margin:12px auto;box-sizing:border-box}
.inline-register h3{margin:0 0 12px 0;font-size:18px;font-weight:700;color:var(--ink);text-align:center}
.inline-register input{width:100%;padding:7px 12px;border:1px solid var(--line);border-radius:8px;font-size:12px;margin-bottom:8px;outline:none}
.inline-register input:focus{border-color:var(--brand)}
.inline-register-btn{width:100%;padding:12px 16px;border:none;border-radius:8px;background:linear-gradient(135deg,#4f9aff,#2563eb);color:#fff;font-weight:800;cursor:pointer;margin-top:6px}
/* Guest locked state: show but disable (gray) dashboard parts, keep signup active */
.ex-dashboard.guest-locked .ex-upload,
.ex-dashboard.guest-locked .ex-usage,
.ex-dashboard.guest-locked .grid{
  filter:grayscale(100%);
  opacity:.55;
  pointer-events:none;
}
.ex-dashboard.guest-locked .ex-toolbar{display:none}
.ex-dashboard.guest-locked .inline-register{filter:none;opacity:1;pointer-events:auto}

/* Center lock + login for guest */
.guest-lock-center{
  position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);
  display:none;flex-direction:column;align-items:center;gap:12px;z-index:2
}
.guest-lock-center .login-icon{font-size:48px;line-height:1}
.guest-lock-center .login-overlay-btn{
  font-size:16px;font-weight:700;padding:14px 22px;border:none;border-radius:12px;cursor:pointer;
  background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);color:#fff;
  box-shadow:0 8px 20px rgba(102,126,234,.35);transition:transform .15s ease, box-shadow .15s ease
}
.guest-lock-center .login-overlay-btn:hover{transform:translateY(-1px);box-shadow:0 10px 24px rgba(102,126,234,.45)}

/* Emphasize inline signup card to match tone */
.inline-register{background:#fff;background-image:linear-gradient(180deg,#f4f7ff,#ffffff);border:2px solid rgba(102,126,234,.55);border-radius:16px;box-shadow:0 10px 30px rgba(102,126,234,.18),0 1px 0 rgba(255,255,255,.6) inset;
  width:100%;max-width:360px;padding:20px;display:flex;flex-direction:column;gap:10px;text-align:center}
.inline-register h3{margin:0 0 8px 0;font-size:18px;font-weight:800;color:var(--ink)}
.inline-register input{padding:10px 12px;border:1px solid var(--line);border-radius:10px;font-size:14px;outline:none;background:#f6f8ff}
.inline-register input:focus{border-color:var(--brand)}
.inline-register .inline-register-btn{
  padding:12px 18px;border:none;border-radius:12px;font-weight:700;font-size:15px;cursor:pointer;
  background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);color:#fff;box-shadow:0 8px 20px rgba(102,126,234,.35);
}
.inline-register .inline-register-btn:hover{transform:translateY(-1px);box-shadow:0 10px 24px rgba(102,126,234,.45)}

/* Gradient guide bubble (closable) */
.guide-bubble{position:fixed;z-index:10000;max-width:520px;color:#fff;padding:12px 16px;border-radius:12px;
  background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);box-shadow:0 10px 30px rgba(102,126,234,.35)}
.guide-bubble .close{position:absolute;top:6px;right:8px;background:transparent;border:0;color:#fff;opacity:.9;cursor:pointer;font-size:16px;line-height:1}
.guide-bubble .close:hover{opacity:1}
.guide-bubble:after{content:"";position:absolute;bottom:-8px;left:50%;transform:translateX(-50%);
  width:0;height:0;border-left:8px solid transparent;border-right:8px solid transparent;border-top:8px solid #764ba2}
@media (max-width:768px){.guide-bubble{display:none!important}}

/* ====== PDF 설정 모달 ====== */
.settings-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.settings-modal {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
  display: flex;
  flex-direction: column;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.settings-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.close-btn {
  background: none;
  border: none;
  font-size: 32px;
  color: #94a3b8;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
  line-height: 1;
  padding: 0;
}

.close-btn:hover {
  background: #f1f5f9;
  color: var(--ink);
}

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.settings-section {
  margin-bottom: 32px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

/* 템플릿 선택 */
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.template-card {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  background: white;
}

.template-card:hover:not(.disabled) {
  border-color: #cbd5e1;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.template-card.selected {
  border-color: var(--brand);
  background: #eff6ff;
}

.template-card.disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.template-preview {
  aspect-ratio: 3 / 4;
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* 실제 템플릿 미리보기 (시험지 1) */
.template-preview-actual {
  width: 100%;
  height: 100%;
  background: white;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  padding: 6px;
  font-size: 4px;
}

.actual-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding-bottom: 2px;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 2px;
}

.actual-left {
  font-size: 4px;
  font-weight: 700;
  color: #1e293b;
  text-align: left;
}

.actual-center {
  font-size: 5px;
  font-weight: 900;
  color: #1e293b;
  text-align: center;
}

.actual-right {
  font-size: 4px;
  font-weight: 600;
  color: #1e293b;
  text-align: right;
}

.actual-info-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  padding: 2px 0;
  margin-bottom: 3px;
  border-bottom: 1px solid #e5e7eb;
}

.actual-info-item {
  font-size: 3px;
  color: #64748b;
  padding: 1px;
  background: #f8fafc;
  border: 0.5px solid #e5e7eb;
  border-radius: 1px;
}

.actual-problems {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 2px;
}

.actual-problem-row {
  display: flex;
  gap: 2px;
  align-items: flex-start;
}

.actual-problem-number {
  font-size: 4px;
  font-weight: 700;
  color: #1e293b;
  width: 6px;
  flex-shrink: 0;
}

.actual-problem-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5px;
}

.actual-math-line {
  height: 1.5px;
  background: #cbd5e1;
  border-radius: 0.5px;
}

.actual-math-line.short {
  width: 70%;
}

.actual-choice {
  font-size: 3px;
  color: #64748b;
  margin-top: 1px;
  letter-spacing: 0.5px;
}

.actual-footer-notice {
  margin-top: auto;
  font-size: 2.5px;
  color: #94a3b8;
  text-align: right;
  padding-top: 2px;
  border-top: 0.5px solid #e5e7eb;
}

/* 흐림 처리 템플릿 (업데이트 예정) */
.template-preview-blur {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #e0e7ff 0%, #f0f9ff 100%);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.template-preview-blur::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,0.3) 10px, rgba(255,255,255,0.3) 20px);
  backdrop-filter: blur(2px);
}

.blur-text {
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  text-align: center;
}

.template-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}

.template-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: var(--brand);
  color: white;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
}

.template-card.selected .template-check {
  display: flex;
}

/* 정답/해설 블록 선택 */
.answer-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.answer-option {
  padding: 20px 16px;
  background: #f8fafc;
  border: 2px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  position: relative;
}

.answer-option:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.answer-option.selected {
  background: #eff6ff;
  border-color: var(--brand);
  border-width: 2px;
}

.answer-option.selected::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 8px;
  width: 20px;
  height: 20px;
  background: var(--brand);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

.option-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.answer-option.selected .option-text {
  color: var(--brand);
}

/* 설정 하단 버튼 */
.settings-footer {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

.settings-footer .btn {
  flex: 1;
}

/* 아이콘 버튼 스타일 */
.btn.icon-btn {
  padding: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.btn.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* 애니메이션 */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
/* 1. Tổng thể Footer: Màu nền sáng, sạch sẽ, có đường viền trên */
.site-footer {
  background-color: #f9fafb !important; /* Màu xám rất nhạt, sang trọng */
  border-top: 1px solid #e5e7eb !important;
  padding: 48px 0 !important;
  font-family: 'Pretendard', sans-serif;
  margin-top: 40px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* 2. Phần thông tin doanh nghiệp: Dùng Grid/Flex để căn chỉnh */
.footer-biz {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 30px; /* Khoảng cách: Hàng 8px, Cột 30px */
  margin-bottom: 24px;
}

/* 3. Từng dòng thông tin */
.biz-row {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  line-height: 1.6;
  color: #4b5563; /* Màu chữ xám trung tính */
}

/* 4. Nhãn (Label - ví dụ: "상호명"): Đậm hơn và thêm dấu hai chấm */
.biz-label {
  font-weight: 700;
  color: #1f2937; /* Màu chữ đậm */
  margin-right: 8px;
}

.biz-label::after {
  content: " :"; /* Thêm dấu hai chấm bằng CSS */
  font-weight: 400;
  color: #9ca3af;
}

/* 5. Giá trị (Value): Màu nhẹ hơn */
.biz-value {
  color: #6b7280;
}

/* 6. Phần bản quyền: Tách biệt bên dưới */
.footer-copy {
  border-top: 1px solid #f3f4f6;
  padding-top: 20px;
  margin-top: 16px;
  font-size: 12px;
  color: #9ca3af;
  text-align: left;
}

/* --- Responsive cho Mobile --- */
@media (max-width: 768px) {
  .site-footer {
    padding: 32px 0 !important;
  }
  
  .footer-biz {
    flex-direction: column; /* Xếp chồng dọc trên mobile */
    gap: 8px;
  }

  .biz-row {
    display: flex;
    align-items: flex-start; /* Căn lề trên nếu nội dung dài xuống dòng */
  }

  /* Cố định chiều rộng nhãn để thẳng hàng dọc */
  .biz-label {
    min-width: 110px; 
    flex-shrink: 0;
  }
  
  /* Giá trị không bị rớt xuống dòng xấu */
  .biz-value {
    flex: 1;
    word-break: keep-all;
  }
}
@media (max-width: 768px) {
  /* 1. Thiết lập lại khung bao ngoài (Main) */
  .main {
    gap: 16px !important; /* Khoảng cách giữa các khối (File, Chọn câu, PDF) vừa phải */
    padding: 12px !important;
    padding-bottom: 80px !important; /* Chừa chỗ trống ở đáy để dễ lướt */
  }

  /* 2. Tăng chiều cao cho 3 vùng chính */
  /* Sử dụng min-height lớn để vùng hiển thị rộng rãi hơn trên điện thoại */
  .explorer, 
  .preview-wrap, 
  .exam-preview {
    width: 100% !important;
    min-height: 550px !important; /* Cao lên: Đủ để xem ~5-6 file/câu hỏi cùng lúc */
    height: auto !important;      /* Tự động giãn nếu nội dung nhiều hơn */
    max-height: 80vh !important;  /* Không vượt quá 80% chiều cao màn hình */
    margin-bottom: 0 !important;  /* Reset margin cũ */
    display: flex !important;
    flex-direction: column !important;
  }

  /* 3. Tối ưu vùng "내 파일" (Explorer) */
  .explorer .ex-card {
    height: 100% !important;
    min-height: 500px !important;
  }
  .ex-dashboard .grid {
    flex: 1 !important; /* Chiếm hết khoảng trống còn lại */
    min-height: 350px !important; /* Đảm bảo vùng danh sách file đủ cao */
    overflow-y: auto !important;
  }

  /* 4. Tối ưu vùng "문항 선택하기" (Preview) */
  .preview {
    flex: 1 !important;
    min-height: 400px !important; /* Vùng list câu hỏi cao lên */
    max-height: none !important;
    overflow-y: auto !important;
  }

  /* 5. Tối ưu vùng "시험지 제작하기" (Exam Preview) */
  .exam-content {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 400px !important;
  }
  .exam-problems {
    flex: 1 !important;
    min-height: 350px !important;
    max-height: none !important; /* Cho phép scroll thoải mái trong vùng này */
  }

  /* 6. Ẩn các nút scroll ngang không cần thiết của Tab (nếu có) */
  .tabs::-webkit-scrollbar {
    display: none;
  }
}