* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5e6ea;
  color: #1a1a2e;
  min-height: 100vh;
}

/* iOS Safari 대응: fixed 배경을 별도 레이어로 처리 */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('/static/images/hero-bg.png');
  background-size: cover;
  background-position: center center;
  z-index: -2;
}

@media (min-width: 768px) {
  body::after {
    background-image: url('/static/images/hero-bg-desktop.png');
  }
}

/* 전체 배경 어둡게 오버레이 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 30, 0.35);
  z-index: 0;
  pointer-events: none;
}

header {
  background: transparent;
  color: white;
  text-align: center;
  padding: 24px 16px;
  position: relative;
  z-index: 1;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 6px rgba(0,0,0,0.4);
}

header p {
  margin-top: 6px;
  opacity: 0.95;
  font-size: 0.95rem;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.header-icon {
  width: 32px;
  height: 32px;
  vertical-align: middle;
  margin-right: 4px;
  position: relative;
  top: -2px;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.3));
}

.header-auth {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 0.88rem;
  position: relative;
  z-index: 1;
}

.header-auth a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 4px 12px;
  border-radius: 20px;
  transition: background 0.2s;
}

.header-auth a:hover {
  background: rgba(255,255,255,0.15);
}

.header-auth span {
  opacity: 0.85;
  padding: 4px 0;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px;
  padding-bottom: var(--app-bottom-content-space, calc(96px + env(safe-area-inset-bottom)));
  position: relative;
  z-index: 1;
}

/* 섹션 전환 */
.section { display: none; }
.section.active { display: block; }

/* 주제 선택 */
.topic-card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.topic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.topic-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.random-btn {
  padding: 6px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 20px;
  background: white;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}

.random-btn:hover { background: #f5f3ff; border-color: #e8849a; }

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

.topic-btn {
  padding: 6px 14px;
  border: 2px solid #e5e5e5;
  border-radius: 20px;
  background: white;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  color: #555;
}

.topic-btn:hover { border-color: #e8849a; color: #e8849a; }

.topic-btn.selected {
  background: #e8849a;
  border-color: #e8849a;
  color: white;
}

/* 문제 카드 */
.question-card {
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 14px;
  border-left: 4px solid #e8849a;
}

.question-loading {
  text-align: center;
  color: #888;
  font-size: 0.9rem;
  padding: 8px 0;
}

.question-en {
  font-size: 1.05rem;
  font-weight: 600;
  color: #2d2d2d;
  line-height: 1.5;
  margin-bottom: 8px;
}

.question-ko {
  font-size: 0.88rem;
  color: #666;
  margin-bottom: 12px;
}

.question-tips {
  font-size: 0.82rem;
  color: #888;
  background: rgba(255,255,255,0.6);
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.6;
}

/* 입력 섹션 */
.input-card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 32px 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  text-align: center;
}

.input-card h2 {
  font-size: 1.1rem;
  color: #555;
  margin-bottom: 28px;
}

/* 녹음 버튼 */
.record-btn {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #e8849a, #d4607a);
  color: white;
  font-size: 2rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(232,132,154,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.record-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(232,132,154,0.5);
}

.record-btn.recording {
  background: linear-gradient(135deg, #ff4757, #ff6b81);
  animation: pulse 1.2s infinite;
  box-shadow: 0 4px 20px rgba(255,71,87,0.5);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.record-label {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 8px;
}

.record-timer {
  font-size: 1.1rem;
  font-weight: 600;
  color: #ff4757;
  height: 24px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0;
  color: #bbb;
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e5e5;
}

/* 파일 업로드 */
.upload-area {
  border: 2px dashed #d0d0d0;
  border-radius: 12px;
  padding: 28px 16px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: #e8849a;
  background: #f5f3ff;
}

.upload-area .icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.upload-area p {
  color: #888;
  font-size: 0.9rem;
}

.upload-area .hint {
  font-size: 0.78rem;
  color: #bbb;
  margin-top: 6px;
}

.file-selected {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  background: #f0f2f5;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  color: #444;
}

.file-selected.visible { display: flex; }

.analyze-btn {
  display: none;
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #e8849a, #d4607a);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.analyze-btn:hover { opacity: 0.9; }
.analyze-btn.visible { display: block; }

/* 로딩 섹션 */
.loading-card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 48px 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  text-align: center;
}

.spinner {
  width: 56px;
  height: 56px;
  border: 4px solid #e8e8e8;
  border-top-color: #e8849a;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-card h2 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.loading-status {
  color: #888;
  font-size: 0.9rem;
}

/* 결과 섹션 */
.result-header {
  text-align: center;
  margin-bottom: 20px;
}

.result-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.result-header p {
  color: #888;
  font-size: 0.88rem;
  margin-top: 4px;
}

.card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-body {
  font-size: 0.92rem;
  line-height: 1.7;
  color: #333;
  white-space: pre-wrap;
}

/* TTS 플레이어 */
.tts-card {
  background: linear-gradient(135deg, #e8849a, #d4607a);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 14px;
  color: white;
}

.tts-card .card-title {
  color: white;
}

.tts-card audio {
  width: 100%;
  margin-top: 8px;
  border-radius: 8px;
}

/* 시험 결과 입력 */
.score-card {
  border: 2px solid #e8e4ff;
}

.score-desc {
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 14px;
}

.score-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.score-btn {
  padding: 8px 16px;
  border: 2px solid #d0d0d0;
  border-radius: 20px;
  background: white;
  color: #555;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.score-btn:hover {
  border-color: #e8849a;
  color: #e8849a;
}

.score-btn.selected {
  background: #e8849a;
  border-color: #e8849a;
  color: white;
}

.score-submit-btn {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: #f0eeff;
  color: #e8849a;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.score-submit-btn:hover {
  background: #e0d9ff;
}

.exam-score-btn {
  padding: 8px 16px;
  border: 2px solid #d0d0d0;
  border-radius: 20px;
  background: white;
  color: #555;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.exam-score-btn:hover {
  border-color: #e8849a;
  color: #e8849a;
}
.exam-score-btn.selected {
  background: #e8849a;
  border-color: #e8849a;
  color: white;
}

/* 다시 시도 버튼 */
.retry-btn {
  width: 100%;
  padding: 14px;
  border: 2px solid #e8849a;
  border-radius: 10px;
  background: white;
  color: #e8849a;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  margin-top: 4px;
}

.retry-btn:hover {
  background: #e8849a;
  color: white;
}

/* 에러 메시지 */
.error-msg {
  background: #fff0f0;
  border: 1px solid #ffcccc;
  border-radius: 10px;
  padding: 14px 16px;
  color: #cc3333;
  font-size: 0.9rem;
  margin-bottom: 14px;
  display: none;
}

.error-msg.visible { display: block; }

/* ===== 하단 네비게이션 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,0.4);
  display: flex;
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 16px rgba(0,0,0,0.12);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  text-decoration: none;
  color: #aaa;
  transition: color 0.15s;
  gap: 3px;
}

.bottom-nav-item.active {
  color: #e8849a;
}

.bottom-nav-item:hover {
  color: #e8849a;
}

.bottom-nav-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.bottom-nav-svg {
  width: 28px;
  height: 28px;
  transition: filter 0.2s;
}

.bottom-nav-item.active .bottom-nav-svg {
  filter: brightness(1.1) drop-shadow(0 0 3px rgba(232,132,154,0.4));
}

.bottom-nav-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: -0.3px;
}

/* ===== 모의고사 준비중 ===== */
.coming-soon-card {
  background: white;
  border-radius: 16px;
  padding: 60px 24px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  margin-top: 20px;
}

.coming-soon-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.coming-soon-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.coming-soon-card p {
  color: #888;
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ===== 프로필 탭 레거시 UI ===== */
.mypage-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: white;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.mypage-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
  color: #aaa;
  cursor: pointer;
  transition: all 0.2s;
}

.mypage-tab.active {
  background: #e8849a;
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===== 모의고사 ===== */
.exam-intro {
  margin-bottom: 4px;
}

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

.structure-item {
  background: rgba(232,132,154,0.1);
  color: #e8849a;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
}

.exam-set-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 14px;
  padding: 18px 16px;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}

.exam-set-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
}

.exam-set-card.locked {
  opacity: 0.55;
  cursor: pointer;
}

.exam-set-card.locked:hover {
  transform: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.exam-set-number {
  font-size: 1rem;
  font-weight: 700;
  color: #e8849a;
  min-width: 40px;
}
.recommend-badge {
  display: inline-block;
  background: linear-gradient(135deg, #e8849a, #d4607a);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 8px;
  vertical-align: middle;
  margin-left: 4px;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 4px rgba(212,96,122,0.4);
}

.exam-set-info {
  flex: 1;
}

.exam-set-topics {
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 3px;
}

.dolbal-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #e8849a;
  background: rgba(232, 132, 154, 0.12);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 2px;
  white-space: nowrap;
}

.exam-set-meta {
  font-size: 0.78rem;
  color: #999;
}

.exam-set-arrow {
  font-size: 1.5rem;
  color: #ccc;
  font-weight: 300;
}

/* ===== 설문조사 ===== */
.survey-mode-card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.13);
}

.survey-mode-label {
  font-size: 0.88rem;
  color: #777;
  text-align: center;
  margin-bottom: 12px;
}

.survey-mode-btns {
  display: flex;
  gap: 10px;
}

.survey-mode-btn {
  flex: 1;
  padding: 14px 10px;
  border: 2px solid #e5e5e5;
  border-radius: 12px;
  background: white;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #888;
}

.survey-mode-btn.active {
  border-color: #e8849a;
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  color: #e8849a;
}

.survey-mode-desc {
  font-size: 0.75rem;
  font-weight: 400;
  color: #aaa;
  line-height: 1.4;
  text-align: center;
}

.survey-mode-btn.active .survey-mode-desc {
  color: #8b7dd8;
}

.survey-part-card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.13);
}

.survey-part-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.survey-part-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, #e8849a, #d4607a);
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

.survey-count-badge {
  font-size: 0.82rem;
  font-weight: 700;
  color: #999;
  background: #f0f0f5;
  padding: 4px 10px;
  border-radius: 20px;
  transition: all 0.2s;
}

.survey-count-badge.over {
  color: white;
  background: linear-gradient(135deg, #43e97b, #38f9d7);
}

.survey-question {
  font-size: 0.97rem;
  font-weight: 700;
  color: #2d2d2d;
  margin-bottom: 14px;
  line-height: 1.5;
}

.survey-sub-question {
  border-top: 1px solid #f0f0f5;
  padding-top: 4px;
  margin-top: 4px;
}

.survey-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.survey-radio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid #ebebeb;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.9rem;
  color: #444;
}

.survey-radio-item:has(input:checked) {
  border-color: #e8849a;
  background: #f5f3ff;
  color: #e8849a;
  font-weight: 600;
}

.survey-radio-item input[type=radio] {
  display: none;
}

.survey-radio-custom {
  width: 18px;
  height: 18px;
  border: 2px solid #d0d0d0;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.15s;
  position: relative;
}

.survey-radio-item:has(input:checked) .survey-radio-custom {
  border-color: #e8849a;
  background: #e8849a;
}

.survey-radio-item:has(input:checked) .survey-radio-custom::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
}

.survey-sub-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #555;
  margin-bottom: 10px;
}

.survey-min-hint {
  font-weight: 400;
  color: #aaa;
  font-size: 0.82rem;
}

.survey-check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.survey-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1.5px solid #ebebeb;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.82rem;
  color: #555;
  line-height: 1.3;
}

.survey-check-item:has(input:checked) {
  border-color: #e8849a;
  background: #f5f3ff;
  color: #e8849a;
  font-weight: 600;
}

.survey-check-item input[type=checkbox] {
  display: none;
}

.survey-check-custom {
  width: 16px;
  height: 16px;
  border: 2px solid #d0d0d0;
  border-radius: 4px;
  flex-shrink: 0;
  transition: all 0.15s;
  position: relative;
}

.survey-check-item:has(input:checked) .survey-check-custom {
  border-color: #e8849a;
  background: #e8849a;
}

.survey-check-item:has(input:checked) .survey-check-custom::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 10px;
  line-height: 1;
}

.survey-error {
  background: #fff0f0;
  color: #e53e3e;
  border: 1px solid #fed7d7;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.survey-submit-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #e8849a, #d4607a);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.survey-submit-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}
