/* === DARK THEME (default) === */
:root, [data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-card: #111111;
  --bg-hover: #1a1a1a;
  --accent: #00e676;
  --accent-dim: #00e67622;
  --text: #e8e8e8;
  --text-muted: #666;
  --border: #222;
  --code-bg: #0d1117;
  --font-main: 'JetBrains Mono', 'Fira Code', monospace;
  --font-ui: 'Inter', system-ui, sans-serif;
  --radius: 8px;
  --transition: 0.2s ease;
  --modal-bg: rgba(0,0,0,0.7);
}

/* === LIGHT THEME === */
[data-theme="light"] {
  --bg: #f5f5f5;
  --bg-card: #ffffff;
  --bg-hover: #eaeaea;
  --accent: #00b050;
  --accent-dim: #00b05022;
  --text: #1a1a1a;
  --text-muted: #777;
  --border: #ddd;
  --code-bg: #f0f0f0;
  --modal-bg: rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: #00ff88; }
[data-theme="light"] a:hover { color: #009040; }

.container { max-width: 900px; margin: 0 auto; padding: 2rem 1rem; }

header { text-align: center; margin-bottom: 2.5rem; }
header h1 { font-family: var(--font-main); font-size: 1.75rem; margin: 0 0 0.25rem 0; }
header .tagline { color: var(--text-muted); font-size: 0.95rem; }

/* === Topbar === */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
}
.topbar-inner {
  max-width: 900px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}

/* === Modal === */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--modal-bg);
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem;
  width: 90%; max-width: 400px;
}
.modal-card h2 { margin: 0 0 1rem 0; font-family: var(--font-main); }

/* === Landing hero === */
.hero { text-align: center; margin-bottom: 2.5rem; }
.hero-title { font-size: 2rem; margin: 0 0 0.5rem 0; line-height: 1.2; }
.hero-sub { color: var(--text-muted); font-size: 1.1rem; margin: 0 0 2rem 0; max-width: 560px; margin-left: auto; margin-right: auto; }
.feature-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.feature-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; text-align: center; transition: border-color var(--transition);
}
.feature-card:hover { border-color: var(--accent); }
.feature-icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }
.feature-card h3 { font-size: 1rem; margin: 0 0 0.35rem 0; color: var(--accent); }
.feature-card p { margin: 0; font-size: 0.9rem; color: var(--text-muted); }
.stats-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 2rem; padding: 1rem; color: var(--text-muted); font-size: 0.9rem; }
.form-card-landing { max-width: 480px; margin-left: auto; margin-right: auto; }

/* === Form === */
.form-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; margin-bottom: 2rem; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.4rem; color: var(--text-muted); font-size: 0.9rem; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%; padding: 0.6rem 0.75rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: inherit; font-size: 1rem;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim);
}

.range-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.range-row input[type="range"] { flex: 1; min-width: 120px; accent-color: var(--accent); }
.range-row .value { font-family: var(--font-main); color: var(--accent); min-width: 3ch; }

/* === Day chips === */
.days-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  padding: 0.5rem 1rem; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 0.9rem;
  transition: var(--transition);
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }

/* === Buttons === */
.btn {
  display: inline-block; padding: 0.75rem 1.5rem;
  background: var(--accent); color: var(--bg); border: none; border-radius: var(--radius);
  font-family: var(--font-ui); font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: background var(--transition), transform 0.1s;
}
.btn:hover:not(:disabled) { background: #00ff88; transform: translateY(-1px); }
[data-theme="light"] .btn:hover:not(:disabled) { background: #009040; }
.btn:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); color: var(--text); }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

/* === Loading === */
.loading-box { text-align: center; padding: 2rem; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); }
.loading-box .spinner {
  display: inline-block; width: 32px; height: 32px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Plan overview === */
.plan-header { margin-bottom: 1.5rem; }
.plan-header h1 { font-size: 1.5rem; margin: 0 0 0.5rem 0; }
.badge {
  display: inline-block; padding: 0.2rem 0.6rem;
  background: var(--accent-dim); color: var(--accent);
  border-radius: 4px; font-size: 0.8rem; margin-right: 0.5rem;
}

.progress-bar-wrap { background: var(--bg-card); height: 8px; border-radius: 4px; overflow: hidden; margin: 1rem 0; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width var(--transition); }

.days-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.day-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; transition: border-color var(--transition), background var(--transition);
}
.day-card.available, .day-card.completed { cursor: pointer; }
.day-card.available:hover, .day-card.completed:hover { border-color: var(--accent); background: var(--bg-hover); }
.day-card.completed { border-color: var(--accent); background: var(--accent-dim); }
.day-card.completed .status-icon { color: var(--accent); }
.day-card.available:hover { transform: translateY(-2px); }
.day-card.locked { opacity: 0.5; pointer-events: none; filter: grayscale(0.3); }
.day-card .day-num { font-family: var(--font-main); color: var(--accent); font-size: 0.9rem; margin-bottom: 0.25rem; }
.day-card .topic { font-weight: 500; margin: 0; }
.day-card .status-icon { margin-top: 0.5rem; font-size: 0.85rem; color: var(--text-muted); }

/* === Day detail page === */
.nav-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 0.75rem; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}

.section { margin-bottom: 2rem; }
.section h2 { font-size: 1.1rem; color: var(--accent); margin: 0 0 0.75rem 0; font-family: var(--font-main); }

.theory-block p { margin: 0 0 0.75rem 0; color: var(--text); }

.concepts { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.concept-pill { padding: 0.35rem 0.75rem; background: var(--accent-dim); color: var(--accent); border-radius: 999px; font-size: 0.85rem; }

pre, code { font-family: var(--font-main); background: var(--code-bg); }
pre { padding: 1rem; border-radius: var(--radius); overflow-x: auto; border: 1px solid var(--border); margin: 0.75rem 0; }
pre code { background: none; padding: 0; }
code.inline-code { padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.9em; }

.resource-cards { display: grid; gap: 0.75rem; }
.resource-card {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
  padding: 0.75rem 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
}
.resource-card a { font-weight: 500; }
.report-link { font-size: 0.8rem; color: var(--text-muted); cursor: pointer; }
.report-link:hover { color: var(--accent); }

.expected-output { margin-top: 0.75rem; padding: 0.75rem; background: var(--bg); border-radius: var(--radius); font-family: var(--font-main); font-size: 0.9rem; white-space: pre-wrap; }
.hint-item { margin-top: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.hint-item:last-child { border-bottom: none; }
.hint-trigger { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.9rem; padding: 0.25rem 0; display: block; }
.hint-trigger:hover { text-decoration: underline; }
.hint-content {
  margin-top: 0.25rem; padding: 0.5rem; color: var(--text-muted); font-size: 0.9rem;
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.2s ease;
}
.hint-content.visible { max-height: 500px; opacity: 1; display: block; }

.self-check-box { padding: 1rem; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); }
.answer-reveal {
  margin-top: 0.75rem; padding: 0 0.75rem 0.75rem; max-height: 0; overflow: hidden; opacity: 0;
  background: var(--accent-dim); border-radius: var(--radius);
  transition: max-height 0.35s ease, opacity 0.35s ease, padding 0.2s ease;
}
.answer-reveal.visible { max-height: 300px; opacity: 1; padding: 0.75rem; }

.audio-section { margin: 2rem 0; padding: 1rem; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); }
#audio-player audio { width: 100%; margin-top: 0.5rem; }

.complete-day-btn { width: 100%; padding: 1rem; font-size: 1.1rem; margin-top: 1rem; }

/* === Code editor === */
#code-editor { height: 300px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.editor-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }
.run-output {
  margin-top: 0.75rem; padding: 1rem; background: var(--code-bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: var(--font-main); font-size: 0.9rem; white-space: pre-wrap; min-height: 60px;
}
.run-output-stdout { color: #00e676; }
[data-theme="light"] .run-output-stdout { color: #00803e; }
.run-output-stderr { color: #f44336; }
.run-output-time { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.25rem; }

.stdin-input {
  width: 100%; padding: 0.5rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font-main); font-size: 0.9rem; resize: vertical;
}
.selfcheck-input {
  width: 100%; padding: 0.5rem 0.75rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 1rem;
}
.selfcheck-feedback { margin-top: 0.5rem; padding: 0.5rem; border-radius: var(--radius); }
.selfcheck-feedback.correct { background: var(--accent-dim); color: var(--accent); }
.selfcheck-feedback.incorrect { background: rgba(255,193,7,0.15); color: #ffc107; }

.ai-feedback-card { margin-top: 1rem; padding: 1rem; border-radius: var(--radius); border: 1px solid var(--border); }
.ai-feedback-card.passed { background: var(--accent-dim); border-color: var(--accent); }
.ai-feedback-card.failed { background: rgba(255,193,7,0.1); border-color: #ffc107; }
#ai-feedback-improvements { margin: 0.5rem 0 0 1rem; padding-left: 1rem; }

.streak-badge { margin-top: 0.5rem; font-size: 0.95rem; }
.streak-badge.streak-gold { color: #ffc107; }
.streak-badge.streak-lost { color: var(--text-muted); }

/* === Task cards === */
.task-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin-bottom: 0.75rem; transition: var(--transition);
}
.task-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim); }
.task-card:hover { background: var(--bg-hover); }
.task-card.solved { border-color: var(--accent); background: var(--accent-dim); }
.task-header {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.5rem;
}
.task-header h3 { margin: 0; font-size: 1rem; font-family: var(--font-ui); }
.difficulty-easy { background: #1b5e20; color: #69f0ae; }
.difficulty-medium { background: #e65100; color: #ffcc80; }
.difficulty-hard { background: #b71c1c; color: #ef9a9a; }
.expected-output-wrap { margin-top: 0.5rem; }
.task-select-btn { margin-top: 0.75rem; }
.solved-badge { background: var(--accent); color: var(--bg); font-weight: 600; }

.task-description { font-size: 0.95rem; line-height: 1.6; }
.task-description p { margin: 0 0 0.5rem 0; }

/* === Day timer === */
.day-timer {
  font-family: var(--font-main); font-size: 0.9rem; color: var(--accent);
  padding: 0.3rem 0.75rem; background: var(--accent-dim); border-radius: var(--radius);
}

/* === Profile Banner === */
.profile-banner {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--accent-dim) 100%);
  border-bottom: 1px solid var(--border);
  padding: 2rem 1rem 1.5rem;
}
.profile-banner-inner {
  max-width: 900px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.profile-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--accent); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.25rem; font-weight: 700; font-family: var(--font-main);
  flex-shrink: 0; border: 3px solid var(--bg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.profile-info { flex: 1; min-width: 150px; }
.profile-info h1 { margin: 0; font-size: 1.5rem; font-family: var(--font-main); }
.profile-member-since { margin: 0.25rem 0 0; color: var(--text-muted); font-size: 0.85rem; }
.profile-quick-stats {
  display: flex; gap: 1.25rem; flex-wrap: wrap;
}
.pqs-item { text-align: center; min-width: 60px; }
.pqs-num { display: block; font-family: var(--font-main); font-size: 1.5rem; font-weight: 600; color: var(--text); }
.pqs-label { display: block; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.pqs-accent .pqs-num { color: var(--accent); }

.profile-container { padding-top: 0; }

/* === Profile Tabs === */
.profile-tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem;
}
.profile-tab {
  padding: 0.75rem 1.5rem; background: none; border: none;
  color: var(--text-muted); font-size: 0.95rem; font-weight: 500;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: var(--transition);
  font-family: var(--font-ui);
}
.profile-tab:hover { color: var(--text); }
.profile-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.section-title {
  font-family: var(--font-main); color: var(--accent); font-size: 1rem;
  margin: 0 0 1rem 0; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border);
}
.muted-title { color: var(--text-muted); }
.empty-msg { color: var(--text-muted); font-size: 0.9rem; }

/* === Plan Cards v2 (Profile) === */
.plans-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); margin-bottom: 2rem; }
.plan-card-v2 {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.25rem; cursor: pointer; transition: all 0.25s ease;
  position: relative; overflow: hidden;
}
.plan-card-v2::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent); opacity: 0; transition: opacity 0.25s ease;
}
.plan-card-v2:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.15); }
.plan-card-v2:hover::before { opacity: 1; }

.pcv2-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.pcv2-dir-icon {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--accent-dim); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700; font-family: var(--font-main);
  flex-shrink: 0;
}
.pcv2-title-wrap { flex: 1; min-width: 0; }
.pcv2-title-wrap h3 { margin: 0; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcv2-badges { margin-top: 0.25rem; }

.pcv2-progress { margin-bottom: 0.5rem; }
.pcv2-progress-bar {
  height: 6px; border-radius: 3px; background: var(--border); overflow: hidden;
}
.pcv2-progress-fill {
  height: 100%; border-radius: 3px; background: var(--accent);
  transition: width 0.5s ease;
}
.pcv2-progress-info {
  display: flex; justify-content: space-between; margin-top: 0.35rem;
  font-size: 0.8rem; color: var(--text-muted);
}
.pcv2-pct { color: var(--accent); font-weight: 600; }

.pcv2-footer {
  display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem;
}
.pcv2-streak { color: #ff9800; font-weight: 500; }
.pcv2-actions { margin-left: auto; display: flex; gap: 0.25rem; }

.btn-icon {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 0.3rem 0.5rem; cursor: pointer; font-size: 0.85rem;
  transition: var(--transition); color: var(--text);
}
.btn-icon:hover { border-color: var(--accent); background: var(--accent-dim); }
.btn-icon-danger:hover { border-color: #f44336; background: rgba(244,67,54,0.1); }

/* === Achievements v2 (Profile) === */
.achievements-overview {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem;
  padding: 1rem; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border);
}
.ach-progress-bar-outer {
  flex: 1; height: 10px; border-radius: 5px; background: var(--border); overflow: hidden;
}
.ach-progress-bar-fill {
  height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), #00ff88);
  transition: width 0.6s ease;
}
.ach-progress-text { font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }

.ach-category { margin-bottom: 2rem; }
.ach-cat-header {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--border);
}
.ach-cat-icon { font-size: 1.25rem; }
.ach-cat-header h3 { margin: 0; font-size: 1rem; font-family: var(--font-main); color: var(--text); flex: 1; }
.ach-cat-count { font-size: 0.8rem; color: var(--text-muted); }

.ach-cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.75rem;
}
.ach-item {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem; text-align: center; cursor: pointer; transition: all 0.25s ease;
}
.ach-item:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.ach-item.earned { border-color: var(--accent); background: var(--accent-dim); }
.ach-item.earned:hover { box-shadow: 0 4px 16px rgba(0,230,118,0.2); }
.ach-item.locked { opacity: 0.5; filter: grayscale(0.4); }
.ach-item.locked:hover { opacity: 0.7; filter: grayscale(0.2); }
.ach-item-icon { font-size: 2rem; display: block; margin-bottom: 0.35rem; }
.ach-item-title { font-size: 0.75rem; color: var(--text); font-weight: 500; }
.ach-item.locked .ach-item-title { color: var(--text-muted); }

/* Achievement Popup */
.ach-popup-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: var(--modal-bg);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.ach-popup-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  padding: 2rem; width: 90%; max-width: 360px; text-align: center;
  position: relative; animation: popIn 0.25s ease;
}
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.ach-popup-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: none; border: none; color: var(--text-muted); font-size: 1.5rem;
  cursor: pointer; line-height: 1;
}
.ach-popup-close:hover { color: var(--text); }

.ach-popup-icon { font-size: 4rem; margin-bottom: 0.5rem; }
.ach-popup-card h3 { margin: 0 0 0.5rem; font-size: 1.2rem; font-family: var(--font-main); }
.ach-popup-desc { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 0.75rem; }
.ach-popup-rarity {
  display: inline-block; padding: 0.2rem 0.75rem; border: 1px solid;
  border-radius: 999px; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.75rem;
}
.ach-popup-hint {
  background: var(--bg); border-radius: var(--radius); padding: 0.75rem;
  font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem;
}
.ach-popup-date { font-size: 0.8rem; color: var(--accent); }

/* === History Timeline === */
.history-timeline { }
.history-group { margin-bottom: 1.5rem; }
.history-date {
  font-family: var(--font-main); font-size: 0.85rem; color: var(--text-muted);
  margin-bottom: 0.5rem; padding-bottom: 0.25rem; border-bottom: 1px solid var(--border);
}
.history-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 0.5rem;
  text-decoration: none; color: var(--text); transition: var(--transition);
}
.history-item:hover { border-color: var(--accent); background: var(--bg-hover); color: var(--text); }
.history-check { font-size: 1.1rem; flex-shrink: 0; }
.history-item-info { flex: 1; min-width: 0; }
.history-topic { display: block; font-weight: 500; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-plan-name { display: block; font-size: 0.75rem; color: var(--text-muted); }
.history-day-num { font-size: 0.8rem; color: var(--accent); font-family: var(--font-main); white-space: nowrap; }

/* === AI Floating Chat === */
.mentor-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 500;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: none;
}
.mentor-fab:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(0,0,0,0.4); }

.mentor-float {
  position: fixed; bottom: 90px; right: 24px; z-index: 501;
  width: 380px; max-width: calc(100vw - 32px); max-height: 500px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.mentor-float-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem; background: var(--accent); color: var(--bg);
  font-weight: 600; font-size: 0.9rem; cursor: grab; user-select: none;
}
.mentor-float-header:active { cursor: grabbing; }
.mentor-float-btns { display: flex; gap: 0.5rem; }
.mentor-float-btn {
  background: none; border: none; color: var(--bg); font-size: 1.1rem;
  cursor: pointer; opacity: 0.8; line-height: 1; padding: 0 0.25rem;
}
.mentor-float-btn:hover { opacity: 1; }

.mentor-float .chat-messages {
  flex: 1; max-height: 320px; overflow-y: auto; padding: 1rem;
}
.mentor-float .chat-input-row {
  display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--border);
}
.mentor-float .chat-input-row input { flex: 1; }

.chat-messages { max-height: 300px; overflow-y: auto; padding: 1rem; }
.chat-msg { margin-bottom: 0.75rem; font-size: 0.9rem; line-height: 1.5; }
.chat-msg.user { color: var(--accent); }
.chat-msg.ai { color: var(--text); }
.chat-input-row {
  display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--border);
}
.chat-input-row input { flex: 1; }

/* === Quiz === */
.quiz-blocker {
  background: var(--bg-card); border: 2px solid #ffc107; border-radius: var(--radius);
  padding: 1.5rem; margin-bottom: 1.5rem;
}
.quiz-question { margin-bottom: 1.25rem; }
.quiz-question p { margin: 0 0 0.5rem 0; }
.quiz-options { display: flex; flex-direction: column; gap: 0.35rem; }
.quiz-option {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem; border-radius: var(--radius);
  cursor: pointer; transition: var(--transition);
}
.quiz-option:hover { background: var(--bg-hover); }
.quiz-option input { accent-color: var(--accent); }
.quiz-option.correct-answer { background: var(--accent-dim); }
.quiz-option.wrong-answer { background: rgba(244,67,54,0.15); }
.quiz-result { margin-top: 1rem; padding: 1rem; border-radius: var(--radius); }
.quiz-result.passed { background: var(--accent-dim); color: var(--accent); }
.quiz-result.failed { background: rgba(255,193,7,0.15); color: #ffc107; }

/* === Admin Dashboard v2 === */
.topbar-title {
  font-family: var(--font-main); font-size: 0.9rem; color: var(--accent);
}

.admin-dashboard {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
  margin-bottom: 2rem;
}
.admin-stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.25rem; display: flex; align-items: center; gap: 1rem;
  transition: var(--transition);
}
.admin-stat-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.admin-stat-icon { font-size: 2rem; }
.admin-stat-info { display: flex; flex-direction: column; }
.admin-stat-num { font-family: var(--font-main); font-size: 1.75rem; font-weight: 700; color: var(--text); line-height: 1; }
.admin-stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.admin-stat-primary .admin-stat-num { color: #2196f3; }
.admin-stat-secondary .admin-stat-num { color: #9c27b0; }
.admin-stat-accent .admin-stat-num { color: var(--accent); }
.admin-stat-info .admin-stat-num { color: #ff9800; }

/* Admin Tabs */
.admin-tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem;
}
.admin-tab {
  padding: 0.75rem 1.5rem; background: none; border: none;
  color: var(--text-muted); font-size: 0.95rem; font-weight: 500;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: var(--transition); font-family: var(--font-ui);
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; }

.admin-search { margin-bottom: 1rem; }

/* Admin User Cards */
.admin-users-grid { display: grid; gap: 0.75rem; }
.admin-user-card-v2 {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.25rem; transition: var(--transition);
}
.admin-user-card-v2:hover { border-color: var(--accent); }

.admin-user-header-v2 { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.admin-user-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700; font-family: var(--font-main); flex-shrink: 0;
}
.admin-user-info { flex: 1; }
.admin-user-info strong { display: block; font-size: 1rem; }
.admin-user-meta { font-size: 0.8rem; color: var(--text-muted); }

.admin-user-plans { display: grid; gap: 0.5rem; }
.admin-plan-item {
  padding: 0.5rem 0.75rem; background: var(--bg); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.admin-plan-item-top {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem;
}
.admin-plan-goal { font-size: 0.85rem; font-weight: 500; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.admin-plan-progress { display: flex; align-items: center; gap: 0.75rem; }
.admin-plan-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.admin-plan-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.admin-plan-pct { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

.admin-no-plans { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

/* Orphan & Report cards */
.admin-orphan-list { display: grid; gap: 0.5rem; }
.admin-orphan-card {
  padding: 0.75rem 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
}
.admin-orphan-top { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; font-size: 0.9rem; }

.admin-reports-list { display: grid; gap: 0.5rem; }
.admin-report-card {
  padding: 0.75rem 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
}
.admin-report-info { display: flex; justify-content: space-between; margin-bottom: 0.25rem; }
.admin-report-label { font-size: 0.9rem; font-weight: 500; }
.admin-report-date { font-size: 0.8rem; color: var(--text-muted); }
.admin-report-link { font-size: 0.85rem; word-break: break-all; }

/* Admin plan dates */
.admin-plan-dates {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  margin-top: 0.35rem; font-size: 0.75rem; color: var(--text-muted);
}
.admin-plan-dates.stale-warn { color: #ff9800; }
.admin-plan-dates.stale-danger { color: #f44336; }
.badge-completed {
  display: inline-block; padding: 0.1rem 0.5rem;
  background: var(--accent-dim); color: var(--accent);
  border-radius: 4px; font-size: 0.7rem; font-weight: 600;
}

/* Admin orphan actions bar */
.admin-orphan-actions {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem;
  padding: 0.75rem 1rem; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.admin-orphan-hint { font-size: 0.85rem; color: var(--text-muted); }
.admin-orphan-goal { flex: 1; font-weight: 500; }
.admin-orphan-top { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; font-size: 0.9rem; }

/* Tab count badge */
.tab-count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  background: #f44336; color: #fff; border-radius: 10px;
  font-size: 0.7rem; font-weight: 700; margin-left: 0.35rem;
}

/* Admin stat warn color */
.admin-stat-warn .admin-stat-num { color: #ff9800; }

/* === Delete button === */
.btn-danger { background: #b71c1c; color: #fff; border: none; }
.btn-danger:hover:not(:disabled) { background: #d32f2f; }

/* === Plan actions === */
.plan-actions { margin-left: auto; display: flex; gap: 0.25rem; }

/* === Responsive === */
@media (max-width: 768px) {
  .admin-dashboard { grid-template-columns: repeat(2, 1fr); }
  .plans-grid { grid-template-columns: 1fr; }
  .profile-banner-inner { flex-direction: column; text-align: center; }
  .profile-quick-stats { justify-content: center; }
  .mentor-float { width: calc(100vw - 16px); right: 8px; bottom: 80px; }
}
@media (max-width: 600px) {
  .container { padding: 1rem 0.75rem; }
  .days-grid { grid-template-columns: 1fr; }
  .stats-cards { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; }
  .admin-dashboard { grid-template-columns: 1fr; }
  .ach-cat-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
  .profile-tabs { overflow-x: auto; }
  .profile-tab { padding: 0.6rem 1rem; font-size: 0.85rem; white-space: nowrap; }
}
