/* ============================================================
   하루전기 (Haru Elec) - Design System & Modern Responsive Styles
   ============================================================ */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #121829;
  --bg-card: rgba(20, 27, 45, 0.85);
  --bg-card-hover: rgba(28, 38, 64, 0.95);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: #38bdf8;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --accent-elec: #fbbf24;
  --accent-elec-hover: #f59e0b;
  --accent-cyan: #38bdf8;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-purple: #818cf8;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 20px rgba(251, 191, 36, 0.25);
  
  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(56, 189, 248, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(251, 191, 36, 0.06) 0%, transparent 45%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

.container {
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Glassmorphism */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.6));
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--accent-elec);
  font-weight: 600;
  display: block;
  margin-top: -3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-elec);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-elec), #f59e0b);
  color: #0f172a;
  padding: 12px 22px;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 12px 22px;
  font-size: 0.95rem;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-green), #059669);
  color: white;
  padding: 12px 22px;
  font-size: 0.95rem;
}

.btn-outline-sm {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  font-size: 0.82rem;
}

.btn-outline-sm:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-muted);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.3rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: all 0.2s;
}

.btn-icon:hover {
  color: var(--accent-elec);
  background: rgba(255, 255, 255, 0.06);
}

.btn-icon.active {
  color: var(--accent-elec);
}

/* Main Content */
.main-content {
  padding-top: 20px;
  padding-bottom: 60px;
}

/* Summary Card */
.summary-card {
  padding: 20px 24px;
  margin-bottom: 20px;
  border-left: 4px solid var(--accent-elec);
}

.today-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.summary-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.summary-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: rgba(10, 14, 26, 0.5);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.qstat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.qstat-num {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-elec);
}

.qstat-lbl {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Mode Tabs */
.mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.mode-tabs::-webkit-scrollbar {
  display: none;
}

.mode-tab {
  flex: 1;
  min-width: 120px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
  white-space: nowrap;
}

.mode-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.mode-tab.active {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.badge {
  background: var(--accent-red);
  color: white;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
}

/* Subject Filter Bar */
.subject-filter-bar {
  padding: 12px 16px;
  margin-bottom: 20px;
}

.filter-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn.active, .filter-btn:hover {
  background: rgba(251, 191, 36, 0.15);
  border-color: var(--accent-elec);
  color: var(--accent-elec);
}

/* Quiz Container */
.quiz-header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.quiz-progress-wrap {
  flex: 1;
  margin-right: 16px;
}

.quiz-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.subject-tag {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
}

.question-progress {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-elec));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* Question Card */
.question-card {
  padding: 24px;
  margin-bottom: 20px;
}

.question-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.year-badge {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-dim);
}

.question-body {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.7;
  margin-bottom: 24px;
  word-break: keep-all;
}

/* Math formula styling inside question and explanation */
.katex-display {
  margin: 10px 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  color: var(--text-main);
  user-select: none;
}

.option-item:hover:not(.locked) {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateX(3px);
}

.option-num {
  font-weight: 700;
  color: var(--accent-cyan);
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.1);
  font-size: 0.85rem;
}

.option-text {
  flex: 1;
  word-break: keep-all;
}

/* Feedback states */
.option-item.correct {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: var(--accent-green) !important;
  color: #6ee7b7;
}

.option-item.correct .option-num {
  background: var(--accent-green);
  color: #064e3b;
}

.option-item.wrong {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: var(--accent-red) !important;
  color: #fca5a5;
}

.option-item.wrong .option-num {
  background: var(--accent-red);
  color: white;
}

/* Explanation Card */
.explanation-box {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-top: 20px;
  animation: fadeIn 0.3s ease;
}

.exp-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--accent-elec);
}

.exp-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
}

.exp-content {
  font-size: 0.9rem;
  color: #cbd5e1;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: keep-all;
}

/* Quiz Footer Controls */
.quiz-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* Result Section */
.result-container {
  padding: 36px 24px;
  text-align: center;
}

.result-stamp {
  font-size: 3.5rem;
  margin-bottom: 12px;
  display: inline-block;
  animation: stampPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-header h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.result-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.score-circle {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.score-num {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--accent-elec);
  font-family: var(--font-mono);
}

.score-total {
  font-size: 1.1rem;
  color: var(--text-dim);
}

.pass-tag {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--accent-green);
  color: var(--accent-green);
  padding: 4px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 8px;
}

.result-breakdown {
  margin-bottom: 30px;
  text-align: left;
}

.result-breakdown h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-muted);
}

.subject-results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.sub-res-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* Stats Section */
.stats-container {
  padding: 24px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 20px;
}

.stats-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent-elec);
  font-family: var(--font-mono);
}

.subject-mastery-list h3 {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.mastery-row {
  margin-bottom: 12px;
}

.mastery-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.mastery-bar-bg {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.mastery-bar-fill {
  height: 100%;
  background: var(--accent-cyan);
  border-radius: var(--radius-full);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

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

.btn-block {
  width: 100%;
  margin-top: 10px;
}

.auth-toggle {
  text-align: center;
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-weight: 700;
  cursor: pointer;
  margin-left: 6px;
}

.form-msg {
  font-size: 0.8rem;
  margin-top: 8px;
  min-height: 18px;
}

.form-msg.error {
  color: var(--accent-red);
}

.form-msg.success {
  color: var(--accent-green);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-cyan);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 300;
  animation: slideUp 0.3s ease;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes stampPop {
  0% { transform: scale(0.2) rotate(-20deg); opacity: 0; }
  70% { transform: scale(1.2) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Responsive */
@media (max-width: 600px) {
  .header-inner {
    height: 56px;
  }
  .brand-text h1 {
    font-size: 1.1rem;
  }
  .question-card {
    padding: 18px 16px;
  }
  .question-body {
    font-size: 0.98rem;
  }
  .option-item {
    padding: 12px 14px;
    font-size: 0.9rem;
  }
  .quiz-footer {
    flex-direction: column;
  }
  .quiz-footer .btn {
    width: 100%;
  }
}

/* Source Badge & KEC Badge */
.source-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.kec-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.76rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #f59e0b);
  border: 1px solid rgba(251, 191, 36, 0.4);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
  animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 16px rgba(245, 158, 11, 0.7); }
}

/* KEC Diff Comparison Card */
.kec-diff-card {
  margin: 14px 0 16px 0;
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.kec-diff-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent-elec);
  margin-bottom: 12px;
}

.kec-diff-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.diff-box {
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
}

.diff-before {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.diff-after {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.diff-lbl {
  font-size: 0.76rem;
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.diff-before .diff-lbl {
  color: var(--accent-red);
}

.diff-after .diff-lbl {
  color: var(--accent-green);
}

.diff-val {
  color: var(--text-main);
  font-weight: 600;
}

.diff-arrow {
  color: var(--accent-elec);
  font-size: 1.3rem;
  font-weight: 800;
}

@media (max-width: 600px) {
  .kec-diff-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .diff-arrow {
    text-align: center;
    transform: rotate(90deg);
  }
}

/* Search Bar */
.search-bar-wrap {
  margin-bottom: 20px;
  padding: 16px 20px;
}

.search-input-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-icon {
  font-size: 1.2rem;
  color: var(--text-muted);
}

.search-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

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

.search-info-text {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
