@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');

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

:root {
  --bg: #0a0a0a;
  --card: #1a1a1e;
  --text: #f5f5f5;
  --subtext: #888;
  --accent: #6c5ce7;
  --accent-hover: #5a4bd1;
  --border: #2a2a2e;
  --max-width: 720px;
  --radius: 12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── 헤더 ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

.header__logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.3px;
}

.header__logo span {
  color: var(--accent);
}

/* ── 탭 ── */
.tab-bar {
  display: flex;
  gap: 4px;
  padding: 16px 24px 0;
  max-width: calc(var(--max-width) + 48px);
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--subtext);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── 탭 패널 ── */
.tab-panel {
  display: none;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 28px 24px;
}

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

/* ── 카드 ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ── 업로드 영역 ── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--card);
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.05);
}

.upload-area__icon {
  font-size: 36px;
  margin-bottom: 10px;
  display: block;
}

.upload-area__text {
  color: var(--subtext);
  font-size: 14px;
}

.upload-area__text strong {
  color: var(--accent);
}

.upload-area__preview {
  margin-top: 14px;
}

.upload-area__preview img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  object-fit: contain;
}

/* ── 라디오 그룹 ── */
.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-group input[type="radio"] {
  display: none;
}

.radio-group label {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  color: var(--subtext);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  user-select: none;
}

.radio-group input[type="radio"]:checked + label {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(108, 92, 231, 0.1);
}

/* ── 버튼 ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: transparent;
  color: var(--subtext);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-ghost:hover {
  border-color: var(--text);
  color: var(--text);
}

/* ── 스피너 ── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

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

/* ── 섹션 라벨 ── */
.section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--subtext);
  margin-bottom: 8px;
}

/* ── 폼 ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

/* ── 에러 메시지 ── */
.error-msg {
  background: rgba(220, 53, 69, 0.12);
  border: 1px solid rgba(220, 53, 69, 0.3);
  color: #ff6b6b;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  margin-top: 16px;
}

/* ── 결과 영역 ── */
.result-section {
  margin-top: 28px;
}

.result-section__title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ── 원본 문제 카드 ── */
.original-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.original-card__badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  background: rgba(108, 92, 231, 0.12);
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
}

.original-card__content {
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.7;
}

/* ── 유사 문제 카드 ── */
.problem-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.problem-card__header {
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.problem-card__number {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
  padding-top: 2px;
}

.problem-card__text {
  flex: 1;
  font-size: 14px;
  white-space: pre-wrap;
  line-height: 1.7;
}

.problem-card__toggle {
  flex-shrink: 0;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--subtext);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.problem-card__toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── 풀이 패널 ── */
.solution-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  border-top: 0 solid var(--border);
}

.solution-panel.open {
  max-height: 800px;
  border-top-width: 1px;
}

.solution-panel__inner {
  padding: 16px 20px;
  background: rgba(108, 92, 231, 0.04);
}

.solution-panel__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}

.solution-panel__content {
  font-size: 14px;
  white-space: pre-wrap;
  line-height: 1.7;
  color: var(--text);
}

/* ── 오답노트 ── */
.notebook-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.notebook-counter {
  font-size: 13px;
  color: var(--subtext);
  margin-right: auto;
}

.notebook-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notebook-empty {
  text-align: center;
  color: var(--subtext);
  font-size: 14px;
  padding: 40px 0;
}

.notebook-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.notebook-item input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.notebook-item__body {
  flex: 1;
  min-width: 0;
}

.notebook-item__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.subject-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.subject-badge--math {
  background: rgba(108, 92, 231, 0.15);
  color: #a29bfe;
}

.subject-badge--korean {
  background: rgba(0, 184, 148, 0.15);
  color: #55efc4;
}

.subject-badge--english {
  background: rgba(253, 203, 110, 0.15);
  color: #fdcb6e;
}

.notebook-item__timestamp {
  font-size: 11px;
  color: var(--subtext);
}

.notebook-item__preview {
  font-size: 13px;
  color: var(--subtext);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 구분선 ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ── 오답노트 카드 펼침/접힘 ── */
.notebook-item {
  cursor: pointer;
}

.notebook-item__toggle-hint {
  font-size: 11px;
  color: var(--subtext);
  margin-left: auto;
  user-select: none;
  flex-shrink: 0;
}

.notebook-item__full {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.notebook-item--expanded .notebook-item__full {
  max-height: 6000px;
}

.notebook-item--expanded .notebook-item__preview {
  display: none;
}

.notebook-item--expanded {
  border-color: var(--accent);
}

/* ── A4 문제 내용 박스 ── */
.problem-content-full {
  background: #ffffff;
  color: #1a1a1a;
  padding: 32px 40px;
  border-radius: 8px;
  max-width: 100%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  font-size: 16px;
  line-height: 1.8;
  margin-top: 12px;
  font-family: 'Pretendard', system-ui, sans-serif;
}

.problem-content-full p {
  margin-bottom: 6px;
}

.problem-content-full br {
  display: block;
  content: '';
  margin-top: 4px;
}

.problem-content-full h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 16px 0 8px;
  color: #1a1a1a;
}

.problem-content-full strong {
  font-weight: 700;
}

.problem-content-full em {
  font-style: italic;
}

.problem-content-full ul {
  padding-left: 22px;
  margin: 8px 0;
}

.problem-content-full li {
  margin-bottom: 4px;
}

.problem-content-full table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
}

.problem-content-full table th,
.problem-content-full table td {
  border: 1px solid #ccc;
  padding: 8px 12px;
  text-align: left;
}

.problem-content-full table th {
  background: #f0f0f0;
  font-weight: 600;
}

/* ── 모바일 ── */
@media (max-width: 480px) {
  .header {
    padding: 12px 16px;
  }

  .tab-bar {
    padding: 12px 16px 0;
  }

  .tab-panel {
    padding: 20px 16px;
  }

  .tab-btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  .btn-primary {
    width: 100%;
    justify-content: center;
  }

  .notebook-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .notebook-counter {
    margin-right: 0;
  }
}

/* ── 텍스트 입력 필드 ── */
.input-field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.input-field:focus {
  border-color: var(--accent);
}

.input-field::placeholder {
  color: var(--subtext);
}

/* ── 인증 모달 ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}

.modal-logo {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
  color: var(--text);
}

.modal-logo span {
  color: var(--accent);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
}

.modal-btn {
  width: 100%;
  margin-top: 8px;
}

.modal-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--subtext);
}

.modal-switch a {
  color: var(--accent);
  text-decoration: none;
}

.modal-switch a:hover {
  text-decoration: underline;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: box-shadow 0.15s, background 0.15s;
  margin-top: 8px;
}

.btn-google:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px;
  color: var(--subtext);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── 헤더 유저 영역 ── */
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-user__email {
  font-size: 13px;
  color: var(--subtext);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 플랜 뱃지 ── */
.plan-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

.plan-badge--free  { background: #2a2a2e; color: var(--subtext); }
.plan-badge--basic { background: #1a3a5c; color: #4fc3f7; }
.plan-badge--pro   { background: #2d1b4e; color: #ce93d8; }

.header-user__usage {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(255,255,255,0.07);
  color: var(--subtext);
  letter-spacing: 0.2px;
}

/* ── 요금제 카드 ── */
.pricing-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.pricing-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pricing-card--current {
  border-color: var(--accent);
}

.pricing-card--pro {
  background: linear-gradient(135deg, #1a1a1e 0%, #1e1530 100%);
}

.pricing-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pricing-card__name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.pricing-card__badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(108, 92, 231, 0.2);
  color: var(--accent);
  letter-spacing: 0.3px;
}

.pricing-card__discount {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(255, 107, 107, 0.15);
  color: #ff6b6b;
  letter-spacing: 0.3px;
  margin-left: auto;
}

.pricing-card__price {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pricing-card__price-main {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.pricing-card__original {
  font-size: 13px;
  font-weight: 400;
  color: var(--subtext);
  text-decoration: line-through;
}

.pricing-card__features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.pricing-card__features li {
  font-size: 13px;
  color: var(--subtext);
  padding-left: 16px;
  position: relative;
}

.pricing-card__features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 12px;
}

.pricing-card__btn {
  width: 100%;
  justify-content: center;
}

@media (max-width: 480px) {
  .pricing-cards {
    grid-template-columns: 1fr;
  }
}
