/* Magnus Aspirants PM — Mobile-First CSS */
:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #222636;
  --border: #2a2e3d;
  --text: #e4e4e7;
  --text-dim: #71717a;
  --text-muted: #52525b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --blue: #3b82f6;
  --magenta: #a855f7;
  --cyan: #06b6d4;
  --orange: #f97316;
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Layout ── */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 80px;
}

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

header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

header nav {
  display: flex;
  gap: 4px;
}

header nav a {
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: all 0.15s;
}

header nav a:hover,
header nav a.active {
  color: var(--text);
  background: var(--bg-hover);
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ── Progress Bar ── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.progress-text {
  font-size: 13px;
  color: var(--text-dim);
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-pending { background: #27272a; color: #a1a1aa; }
.badge-in_progress { background: #1e3a5f; color: #60a5fa; }
.badge-in_review { background: #3b1f63; color: #c084fc; }
.badge-completed { background: #14532d; color: #4ade80; }
.badge-blocked { background: #450a0a; color: #f87171; }
.badge-cancelled { background: #27272a; color: #71717a; }
.badge-active { background: #14532d; color: #4ade80; }
.badge-broken { background: #450a0a; color: #f87171; }
.badge-overflow { background: #422006; color: #fbbf24; }

.badge-critical { background: #450a0a; color: #f87171; }
.badge-high { background: #422006; color: #fbbf24; }
.badge-medium { background: #1e3a5f; color: #60a5fa; }
.badge-low { background: #27272a; color: #a1a1aa; }

.badge-code { background: #1e3a5f; color: #60a5fa; }
.badge-database { background: #14532d; color: #4ade80; }
.badge-infrastructure { background: #422006; color: #fbbf24; }
.badge-content { background: #3b1f63; color: #c084fc; }
.badge-design { background: #134e4a; color: #5eead4; }
.badge-research { background: #312e81; color: #a5b4fc; }
.badge-bugfix { background: #450a0a; color: #f87171; }

/* ── Review Dots ── */
.review-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.review-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.review-dot.filled { background: var(--green); }
.review-dot.current { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

/* ── Task List ── */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.task-item:hover { border-color: var(--accent); }

.task-id {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 28px;
}

.task-info { flex: 1; min-width: 0; }

.task-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Filters ── */
.filters {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.filter-btn:hover,
.filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

/* ── Session Items ── */
.session-item {
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.session-key {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.session-meta {
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Phase Progress ── */
.phase-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.phase-item:last-child { border-bottom: none; }

.phase-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phase-bar {
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.phase-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
}

.phase-pct {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 36px;
  text-align: right;
}

/* ── Activity Log ── */
.log-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.log-item:last-child { border-bottom: none; }

.log-time {
  font-size: 11px;
  color: var(--text-muted);
}

.log-content { color: var(--text-dim); }

/* ── Task Detail ── */
.detail-header {
  margin-bottom: 16px;
}

.detail-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.3;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.detail-section p,
.detail-section li {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}

.detail-section ul {
  list-style: none;
  padding: 0;
}

.detail-section li {
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}

.detail-section li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--text-dim);
}

.file-list li::before { content: ''; }
.file-list li {
  padding-left: 0;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--cyan);
}

/* ── Pipeline Visual ── */
.pipeline {
  display: flex;
  gap: 2px;
  margin: 12px 0;
}

.pipeline-step {
  flex: 1;
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  border-radius: var(--radius-sm);
  background: var(--border);
  color: var(--text-dim);
}

.pipeline-step.done {
  background: #14532d;
  color: #4ade80;
}

.pipeline-step.current {
  background: #312e81;
  color: #a5b4fc;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

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

.btn-copy {
  background: var(--bg-hover);
}

/* ── Skill Cards ── */
.skill-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.skill-card:hover { border-color: var(--accent); }

.skill-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.skill-meta {
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Login ── */
.login-container {
  max-width: 320px;
  margin: 100px auto;
  padding: 32px;
  text-align: center;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}

.login-input {
  width: 100%;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 18px;
  text-align: center;
  letter-spacing: 8px;
  margin-bottom: 16px;
}

.login-input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 8px;
  display: none;
}

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 10px;
  padding: 4px 12px;
  transition: color 0.15s;
}

.bottom-nav a:hover,
.bottom-nav a.active {
  color: var(--accent);
}

.bottom-nav .nav-icon {
  font-size: 18px;
  line-height: 1;
}

/* ── Back Link ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 12px;
}

.back-link:hover { color: var(--text); }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

.empty-state .icon { font-size: 32px; margin-bottom: 8px; }

/* ── Markdown Content ── */
.markdown-content h1 { font-size: 18px; margin: 16px 0 8px; }
.markdown-content h2 { font-size: 16px; margin: 14px 0 6px; }
.markdown-content h3 { font-size: 14px; margin: 12px 0 4px; }
.markdown-content p { margin: 8px 0; font-size: 14px; }
.markdown-content code {
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.markdown-content pre {
  background: var(--bg-hover);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
}
.markdown-content pre code {
  background: none;
  padding: 0;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--green);
  color: var(--green);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; }

/* ── Loading Indicator ── */
.loading-indicator {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 24px;
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: loadPulse 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ── Search Input ── */
.search-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 8px;
}

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

.search-input::placeholder { color: var(--text-muted); }

/* ── Load More Button ── */
.load-more-btn {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  padding: 10px;
  color: var(--accent);
  border-color: var(--accent);
  background: transparent;
}

.load-more-btn:hover {
  background: rgba(99, 102, 241, 0.1);
}

/* ── Shake Animation ── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.5s ease-in-out;
}

/* ── Tap Refresh ── */
.tap-refresh {
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-dim);
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
}

.tap-refresh:hover { color: var(--accent); border-color: var(--accent); }

/* ── Responsive ── */
@media (min-width: 768px) {
  .container { max-width: 800px; padding: 24px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
