/* ============================================================================
   사설치기 — 중급반 리디자인과 통일된 디자인 언어 (20260704)
   토큰·사이드바·카드·버튼을 intermediate.css와 일치시키고,
   색상 위계(주 액션 1개), 입력창 위계(원문=참고 / 연습=무대),
   접이식 사용법, 맥락 있는 통계 스트립으로 개편.
   ========================================================================== */
:root {
  --ink: #171a2b;
  --text: #3a3f55;
  --muted: #767b92;
  --faint: #a2a7bb;
  --line: #e7e9f1;
  --line-strong: #d7dae6;
  --paper: #f4f5f9;
  --card: #ffffff;
  --wash: #fafafd;
  --violet: #5b3df0;
  --violet-deep: #4529ce;
  --violet-tint: #efecfe;
  --violet-wash: #f8f7ff;
  --green: #0e8a63;
  --green-tint: #e6f5ef;
  --amber: #b45309;
  --amber-tint: #fdf3e7;
  --red: #c2453f;
  --naver: #03c75a;
  --r-ctl: 10px;
  --r-card: 16px;
  --shadow-card: 0 10px 30px rgba(23, 26, 43, .05);
  --shadow-pop: 0 22px 60px rgba(23, 26, 43, .22);
  --sidebar-width: 240px;
  --font-sans: Pretendard, "Apple SD Gothic Neo", -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  --font-num: "Space Grotesk", Pretendard, sans-serif;
  --primary: var(--violet);
  --text-dark: var(--ink);
  --line-soft: var(--line);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; padding: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--paper);
  letter-spacing: -0.02em;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(91, 61, 240, .28); outline-offset: 2px;
}
a { color: inherit; text-decoration: none; }
svg { display: block; width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* 앱 셸 */
#app-wrapper { display: none; min-height: 100vh; width: 100vw; }
body[data-auth="approved"] #app-wrapper { display: flex; }
.main-content {
  flex: 1; min-width: 0; height: 100vh; overflow-y: auto;
  padding: 34px clamp(20px, 3.2vw, 44px) 48px;
}

/* 사이드바 (intermediate와 동일 언어) */
.sidebar {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-direction: column; gap: 14px;
  width: var(--sidebar-width); height: 100vh;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--line);
  background: var(--card);
  overflow-y: auto; flex-shrink: 0;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.logo { display: flex; align-items: center; gap: 8px; margin: 0; padding: 0; color: var(--ink); font-size: 1rem; font-weight: 800; letter-spacing: -0.03em; }
.sidebar-close-btn, .mobile-menu-btn { display: none; border: 0; background: transparent; color: var(--ink); }
.nav-list.nav-groups { display: grid; gap: 4px; align-content: start; flex: 1; }
.nav-section { border: 0; }
.nav-section-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 8px 5px; color: var(--faint);
  font-size: 0.6562rem; font-weight: 800; letter-spacing: .08em;
  list-style: none; cursor: pointer;
}
.nav-section-title::-webkit-details-marker { display: none; }
.nav-section-arrow { font-size: 0.75rem; transition: transform .18s ease; }
.nav-section[open] .nav-section-arrow { transform: rotate(180deg); }
.nav-section-list { display: grid; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  min-height: 36px; padding: 6px 10px; border-radius: 9px;
  color: var(--text); font-size: 0.8125rem; font-weight: 500;
  transition: background-color .13s ease, color .13s ease;
}
.nav-item:hover { background: var(--wash); color: var(--ink); }
.nav-item.active { color: var(--violet-deep); background: var(--violet-tint); font-weight: 700; }
.nav-icon { width: 18px; text-align: center; font-size: 0.875rem; filter: grayscale(.25); }
.nav-item.active .nav-icon { filter: none; }
.ai-nav-highlight .nav-text { background: linear-gradient(90deg, var(--violet), #8a6cf8); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700; }
.sidebar-footer { display: grid; gap: 8px; }
.profile-card { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; transition: border-color .15s ease; }
.profile-card:hover { border-color: var(--line-strong); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--violet-deep); background: var(--violet-tint); font-weight: 800; font-size: 0.8125rem; }
.profile-name { color: var(--ink); font-size: 0.8125rem; font-weight: 700; }
.profile-action { color: var(--faint); font-size: 0.6875rem; }
.admin-trigger { min-height: 34px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--muted); background: transparent; font-size: 0.75rem; }
.sidebar-overlay { display: none; }

/* 히어로: 제목 + 통계 스트립 + 네이버 링크(보조) */
.editorial-hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  margin-bottom: 18px;
}
.page-eyebrow { display: inline-block; margin-bottom: 8px; color: var(--violet); font-size: 0.6875rem; font-weight: 800; letter-spacing: .14em; }
.page-title-wrap h2 { margin: 0; color: var(--ink); font-size: clamp(24px, 2.2vw, 32px); font-weight: 800; letter-spacing: -0.045em; line-height: 1.12; }
.page-title-wrap p { margin: 8px 0 0; color: var(--muted); font-size: 0.875rem; }
.header-actions { display: flex; align-items: center; gap: 14px; flex: none; }

.status-display {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 18px;
  border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--card); box-shadow: var(--shadow-card);
}
.status-cell { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.status-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: var(--violet); background: var(--violet-tint); font-size: 1rem; }
.status-text { display: grid; gap: 0; }
.status-text strong { color: var(--ink); font-size: 1.25rem; font-weight: 600; line-height: 1.1; }
.status-text em { color: var(--faint); font-size: 0.6875rem; font-style: normal; font-weight: 600; }
.status-divider { width: 1px; height: 30px; background: var(--line); margin: 0 4px; }

/* 네이버 링크: 외부 이동이므로 보조 톤(테두리형). 브랜드 초록은 아이콘에만 */
.naver-banner {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  color: var(--text); background: var(--card);
  font-size: 0.8438rem; font-weight: 700;
  transition: border-color .15s ease, background-color .15s ease;
}
.naver-banner:hover { border-color: var(--naver); background: #f2fdf7; }
.naver-mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--naver); color: #fff; font-size: 0.75rem; font-weight: 800; }
.naver-arrow { font-size: 0.9375rem; color: var(--faint); }
.naver-banner:hover .naver-arrow { color: var(--naver); }

/* 사용 방법: 접이식(기본 닫힘) */
.editorial-guide {
  margin-bottom: 20px;
  border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--card);
}
.guide-summary {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; cursor: pointer; list-style: none;
  color: var(--ink); font-size: 0.875rem; font-weight: 700;
}
.guide-summary::-webkit-details-marker { display: none; }
.guide-icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: var(--violet-deep); background: var(--violet-tint); font-size: 0.75rem; font-weight: 800; }
.guide-chevron { margin-left: auto; color: var(--faint); font-size: 0.875rem; transition: transform .18s ease; }
.editorial-guide[open] .guide-chevron { transform: rotate(180deg); }
.guide-copy { padding: 0 20px 16px 52px; }
.guide-copy p { margin: 0 0 6px; color: var(--muted); font-size: 0.8125rem; line-height: 1.6; }
.guide-copy p:last-child { margin-bottom: 0; }
.guide-copy b { color: var(--violet-deep); font-weight: 700; }

/* 두 에디터: 원문(참고) / 연습(무대) 비대칭 위계 */
.equal-editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: stretch; }
.editor-card {
  display: flex; flex-direction: column; min-width: 0;
  border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--card); box-shadow: var(--shadow-card);
  overflow: hidden;
}
/* 연습 카드가 무대: 보라 상단 액센트로 시선을 잡는다 */
.typing-card { border-color: #c4b7f8; box-shadow: 0 12px 32px rgba(91, 61, 240, .12); }
.typing-card::before { content: ''; display: block; height: 3px; background: var(--violet); }
.typing-card .card-top { border-bottom-color: #ece8fd; background: var(--violet-wash); }
/* 원문 카드는 참고: 배경을 살짝 낮춰 뒤로 물린다 */
.source-card .textarea-frame textarea { background: var(--wash); }

.card-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.card-title { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-size: 0.9375rem; font-weight: 800; letter-spacing: -0.02em; }
.title-icon { display: inline-flex; font-size: 1.125rem; color: var(--violet); }
.count-badge {
  display: inline-flex; align-items: center;
  min-height: 24px; padding: 2px 10px; border-radius: 999px;
  color: var(--muted); background: var(--wash); border: 1px solid var(--line);
  font-size: 0.6875rem; font-weight: 600; font-variant-numeric: tabular-nums;
}

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--wash); }
.typing-toolbar { justify-content: space-between; }
.tip-label { color: var(--muted); font-size: 0.75rem; }
.tip-label b { color: var(--violet-deep); font-weight: 700; }
.typing-actions { display: flex; gap: 8px; }
.tts-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tts-rate-label { color: var(--muted); font-size: 0.75rem; font-weight: 600; }
#voiceSelect {
  height: 34px; padding: 0 30px 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  color: var(--text); background: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23767b92' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  font-size: 0.7812rem; font-weight: 600; cursor: pointer; appearance: none;
}
#ttsRate { width: 90px; accent-color: var(--violet); }
.info-dot { display: inline-grid; place-items: center; width: 16px; height: 16px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--faint); font-size: 0.5625rem; font-weight: 700; cursor: help; position: relative; }
.info-dot:hover::after, .info-dot:focus::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  z-index: 20; width: 210px; padding: 9px 11px; border-radius: 8px;
  color: #fff; background: var(--ink); font-size: 0.6875rem; font-weight: 500; line-height: 1.5; text-align: left;
  box-shadow: var(--shadow-pop);
}

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); color: var(--text); background: var(--card); font-size: 0.7812rem; font-weight: 600; transition: border-color .14s ease, background-color .14s ease, color .14s ease; }
.btn:hover { border-color: var(--faint); background: var(--wash); }
.btn-ico { display: inline-flex; font-size: 0.9375rem; }
.btn-clean:hover, .btn-tts:hover { border-color: var(--violet); color: var(--violet); }
.btn-tts { border-color: #c9befb; color: var(--violet-deep); font-weight: 700; }
.btn-tts:hover { background: var(--violet-wash); }
.btn-reset:hover { border-color: var(--faint); color: var(--text); }
/* 정확도 확인 = 이 화면의 유일한 채움 CTA */
.btn-grade { border-color: transparent; color: #fff; background: var(--violet); font-weight: 700; }
.btn-grade:hover { border-color: transparent; background: var(--violet-deep); }

/* 텍스트 영역 */
.textarea-frame { position: relative; flex: 1; display: flex; }
.textarea-frame textarea {
  flex: 1; width: 100%; resize: none;
  min-height: clamp(468px, 62vh, 728px);
  padding: 18px 18px 34px;
  border: 0; outline: 0;
  color: var(--ink); background: var(--card);
  font-size: 0.9375rem; line-height: 1.9;
}
.textarea-frame textarea::placeholder { color: var(--faint); }
.textarea-counter { position: absolute; right: 14px; bottom: 10px; color: var(--faint); font-size: 0.6875rem; font-variant-numeric: tabular-nums; }

/* 채점 모달 */
.modal-overlay { display: none; position: fixed; z-index: 1000; inset: 0; overflow: auto; padding: 28px 16px; background: rgba(18, 19, 36, .45); }
.modal-content { position: relative; width: min(700px, 100%); margin: 4vh auto; padding: 30px; border-radius: var(--r-card); color: var(--text); background: var(--card); box-shadow: var(--shadow-pop); }
.close-btn { position: absolute; top: 16px; right: 18px; color: var(--faint); font-size: 1.5rem; line-height: 1; cursor: pointer; transition: color .15s ease; }
.close-btn:hover { color: var(--ink); }
.score-circle { display: grid; width: 132px; height: 132px; margin: 18px auto; place-content: center; place-items: center; border: 7px solid var(--violet-tint); border-radius: 50%; color: var(--violet); text-align: center; }
.score-number { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 2.6rem; font-weight: 700; line-height: 1; }
.score-label { font-size: 0.85rem; font-weight: 600; margin-top: 5px; color: var(--faint); }
.score-detail { text-align: center; color: var(--muted); margin-bottom: 22px; font-weight: 600; font-size: 0.8125rem; }
.diff-view { max-height: min(330px, 42vh); overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-ctl); color: var(--text); background: var(--wash); line-height: 1.9; white-space: pre-wrap; word-break: break-all; }
.d-missing { background: var(--red); color: #fff; padding: 2px 4px; border-radius: 4px; font-weight: 700; text-decoration: underline; }
.d-added { color: var(--green); font-weight: 700; text-decoration: underline; }
.d-wrong { border-bottom: 2px solid var(--violet); color: var(--violet-deep); font-weight: 700; margin: 0 2px; }

/* 로그인 / 스피너 (기존 동작 유지) */
#login-wrapper { display: flex; height: 100vh; width: 100vw; background: #fff; position: fixed; top: 0; left: 0; z-index: 3000; }
.login-art { flex: 1.5; background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); display: flex; align-items: center; justify-content: center; flex-direction: column; }
.login-form-container { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 60px; max-width: 500px; }
.inp-box { width: 100%; padding: 18px; border-radius: var(--r-ctl); background: var(--wash); border: 1px solid var(--line-strong); margin-bottom: 14px; outline: none; }
.inp-box:focus { background: #fff; border-color: var(--violet); }
.btn-login { width: 100%; padding: 18px; border-radius: var(--r-ctl); border: none; background: var(--violet); color: #fff; font-size: 1.05rem; font-weight: 700; cursor: pointer; margin-top: 18px; }
.btn-login:hover { background: var(--violet-deep); }
#loading-overlay { display: none; position: fixed; inset: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.8); z-index: 3500; align-items: center; justify-content: center; backdrop-filter: blur(5px); }
.spinner { width: 40px; height: 40px; border: 4px solid var(--line); border-top: 4px solid var(--violet); border-radius: 50%; animation: spin 0.8s infinite linear; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* 반응형 */
@media (max-width: 1100px) {
  .editorial-hero { flex-direction: column; align-items: stretch; gap: 16px; }
  .header-actions { justify-content: space-between; }
  .equal-editor-grid { grid-template-columns: minmax(0, 1fr); }
  .textarea-frame textarea { min-height: 416px; }
}
@media (max-width: 980px) {
  .main-content { width: 100%; padding: 76px clamp(14px, 3vw, 24px) 32px; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-pop); }
  .sidebar.active { transform: translateX(0); }
  .sidebar-close-btn { display: grid; place-items: center; width: 32px; height: 32px; font-size: 1.25rem; color: var(--muted); }
  .sidebar-overlay { position: fixed; z-index: 40; inset: 0; display: block; visibility: hidden; background: rgba(18, 19, 36, .35); opacity: 0; transition: opacity .2s ease, visibility .2s ease; }
  .sidebar-overlay.active { visibility: visible; opacity: 1; }
  .mobile-menu-btn { position: fixed; z-index: 35; top: 14px; left: 14px; display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; color: var(--violet); background: var(--card); box-shadow: var(--shadow-card); font-size: 1.1875rem; }
}
@media (max-width: 640px) {
  .header-actions { flex-direction: column; align-items: stretch; }
  .naver-banner { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
