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

:root {
  --bg: #f5f6f8;
  --fg: #1a1a2e;
  --accent: #c2185b;
  --accent-dark: #a0144d;
  --accent-light: #fce4ec;
  --accent-glow: rgba(194,24,91,0.08);
  --border: #e0e0e0;
  --border-light: #eee;
  --card: #fff;
  --muted: #6b7280;
  --muted-light: #9ca3af;
  --radius: 10px;
  --radius-lg: 14px;
  --max-w: 1100px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
}

/* ── Dark theme ── */
[data-theme="dark"] {
  --bg: #0d1117;
  --fg: #e6edf3;
  --accent: #f06292;
  --accent-dark: #f48fb1;
  --accent-light: rgba(240,98,146,0.1);
  --accent-glow: rgba(240,98,146,0.15);
  --border: #30363d;
  --border-light: #21262d;
  --card: #161b22;
  --muted: #8b949e;
  --muted-light: #6e7681;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Header ── */
header {
  background: var(--card);
  border-bottom: 3px solid var(--accent);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max-w);
  margin: 0 auto;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
header h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
header h1 a { color: var(--fg); }
header h1 a:hover { color: var(--fg); text-decoration: none; }
header h1 span { color: var(--accent); }
header nav { display: flex; gap: 6px; align-items: center; }
header nav a, header nav span, header nav .nav-logout {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 99px;
  transition: all var(--transition);
}
.nav-logout {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
header nav a:hover, header nav .nav-logout:hover { background: var(--accent-light); text-decoration: none; }
header nav .nav-user {
  color: var(--muted);
  font-weight: 500;
}

/* ── Main ── */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 20px;
  min-height: calc(100vh - 200px);
}

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, var(--accent) 0%, #8e1450 100%);
  color: #fff;
  padding: 40px 32px;
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 300px;
  height: 300px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}
.hero h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
.hero p {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 20px;
  max-width: 500px;
  line-height: 1.5;
}
.hero .btn { background: #fff; color: var(--accent-dark); font-weight: 700; }
.hero .btn:hover { background: #f0f0f0; text-decoration: none; }
[data-theme="dark"] .hero .btn { background: rgba(255,255,255,0.95); }
[data-theme="dark"] .hero .btn:hover { background: rgba(255,255,255,0.85); }

/* ── Stats bar ── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stat-card .stat-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  display: block;
  letter-spacing: -1px;
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Section headers ── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.section-header a {
  font-size: 13px;
  font-weight: 600;
}

/* ── Search & filter bar ── */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-bar .search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  background: var(--card);
  color: var(--fg);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-bar .search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.filter-bar select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  min-width: 160px;
  transition: border-color var(--transition);
}
.filter-bar select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Category pills ── */
.category-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.category-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  text-decoration: none;
}
.category-pill.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.category-pill.active:hover {
  background: var(--accent-dark);
  color: #fff;
}

/* ── Card grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  height: 100%;
}
a.card-link { display: flex; color: inherit; }
a.card-link:hover { text-decoration: none; }
a.card-link:hover .card {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card .cat-badge { align-self: flex-start; margin-bottom: 8px; }
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.2px; line-height: 1.35; }
.card p { font-size: 13px; color: var(--muted); margin-bottom: 10px; line-height: 1.5; flex: 1; }
.card-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--muted-light);
  font-weight: 500;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}

/* ── Progress bar ── */
.progress-wrap {
  margin-top: 10px;
}
.progress-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #e91e63);
  border-radius: 99px;
  transition: width 0.5s ease;
  min-width: 2px;
}
.progress-bar-fill.complete {
  background: linear-gradient(90deg, #43a047, #66bb6a);
}
.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted-light);
  font-weight: 600;
}
.progress-info .goal-reached {
  color: #43a047;
  font-weight: 700;
}

/* Big progress bar for detail page */
.progress-wrap.progress-lg .progress-bar {
  height: 10px;
}
.progress-wrap.progress-lg .progress-info {
  font-size: 13px;
  margin-top: 6px;
}

/* ── Category badge ── */
.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

/* ── Tag ── */
.tag {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; color: #fff; }
.btn-outline { border: 2px solid var(--accent); color: var(--accent); background: transparent; }
.btn-outline:hover { background: var(--accent-light); text-decoration: none; }
.btn-small { padding: 6px 14px; font-size: 13px; }
.btn[disabled] { opacity: 0.4; cursor: default; }
.btn-success { background: #43a047; color: #fff; }
.btn-success:hover { background: #388e3c; }
.btn-ghost { color: var(--muted); background: transparent; }
.btn-ghost:hover { color: var(--accent); background: var(--accent-light); }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--fg);
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--card);
  color: var(--fg);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group textarea { resize: vertical; }
.form-group small { color: var(--muted); font-size: 12px; margin-top: 4px; display: block; }
.form-group .char-count { float: right; font-variant-numeric: tabular-nums; }

/* ── Flash messages ── */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
}
.flash-ok { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.flash-err { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
[data-theme="dark"] .flash-ok { background: rgba(46,125,50,0.15); color: #81c784; border-color: rgba(46,125,50,0.3); }
[data-theme="dark"] .flash-err { background: rgba(198,40,40,0.15); color: #ef9a9a; border-color: rgba(198,40,40,0.3); }

/* ── Username check ── */
.username-check { font-size: 12px; margin-top: 4px; font-weight: 600; }
.username-ok { color: #2e7d32; }
.username-taken { color: #c62828; }

/* ── Count accent ── */
.count { font-weight: 800; color: var(--accent); }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 15px;
}
.empty-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--muted-light);
}

/* ── Detail page ── */
.detail-card { padding: 24px; }
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}
.detail-header h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  flex: 1;
}
.detail-body {
  font-size: 15px;
  color: var(--fg);
  white-space: pre-wrap;
  line-height: 1.7;
  margin: 16px 0;
}
.detail-remarks {
  margin-top: 16px;
  border-top: 1px solid var(--border-light);
  padding-top: 16px;
}
.detail-remarks summary {
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  transition: color var(--transition);
}
.detail-remarks summary:hover { color: var(--accent); }
.detail-remarks p {
  margin-top: 8px;
  font-size: 14px;
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--fg);
}

/* ── Profile page ── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}
.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #e91e63);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}
.profile-info h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 2px;
}
.profile-info p {
  font-size: 13px;
  color: var(--muted);
}
.profile-stats {
  display: flex;
  gap: 24px;
  margin-top: 6px;
}
.profile-stats span {
  font-size: 13px;
  color: var(--muted);
}
.profile-stats strong {
  color: var(--fg);
  font-weight: 800;
}

/* ── About page ── */
.about-content h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 24px 0 8px;
  color: var(--fg);
}
.about-content h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 20px 0 6px;
  color: var(--fg);
}
.about-content p {
  font-size: 15px;
  line-height: 1.7;
  color: var(--muted);
  margin-bottom: 12px;
}
.about-content ul {
  padding-left: 20px;
  margin-bottom: 12px;
}
.about-content li {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 4px;
  line-height: 1.6;
}
.phase-list {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}
.phase-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.phase-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}
.phase-item h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}
.phase-item p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* ── FAQ ── */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
.faq-item summary {
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  background: var(--card);
  transition: background var(--transition);
}
.faq-item summary:hover { background: var(--bg); }
.faq-item p {
  padding: 0 18px 14px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

/* Deleted comment */
.comment-deleted-msg {
  font-size: 13px;
  color: var(--muted-light);
  font-style: italic;
  padding: 4px 0;
}

/* Delete button */
.comment-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-light);
  padding: 2px 0;
  transition: color var(--transition);
}
.comment-delete-btn:hover {
  color: #c62828;
}

/* ── Comments section ── */
.comments-section {
  margin-top: 24px;
}
.comments-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}
.comments-header h3 {
  font-size: 16px;
  font-weight: 700;
}

/* Root comment form */
.comment-form-root {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 20px;
}
.comment-form-root textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
  margin-bottom: 8px;
  transition: border-color var(--transition);
  background: var(--bg);
  color: var(--fg);
}
.comment-form-root textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.comment-login-prompt {
  text-align: center;
  padding: 20px;
  font-size: 14px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.comments-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted-light);
  font-size: 14px;
}

/* Individual comment */
.comment {
  position: relative;
  padding-left: 2px;
}
.comment-inner {
  display: flex;
  gap: 8px;
  padding: 8px 0;
}
.comment-thread-line {
  position: absolute;
  left: 15px;
  top: 40px;
  bottom: 0;
  width: 2px;
  background: var(--border-light);
  cursor: pointer;
  transition: background var(--transition);
}
.comment-thread-line:hover {
  background: var(--accent);
}
.comment:last-child > .comment-thread-line {
  display: none;
}
.comment-children {
  padding-left: 24px;
}
.comment-children .comment-thread-line {
  left: 15px;
}

/* Collapse */
.comment-collapse {
  font-size: 11px;
  color: var(--muted-light);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  font-weight: 700;
  line-height: 1;
  padding-top: 2px;
  transition: color var(--transition);
}
.comment-collapse:hover {
  color: var(--accent);
}
.comment.collapsed > .comment-inner > .comment-content > .comment-body,
.comment.collapsed > .comment-inner > .comment-content > .comment-actions,
.comment.collapsed > .comment-inner > .comment-content > .comment-reply-form,
.comment.collapsed > .comment-children,
.comment.collapsed > .comment-thread-line {
  display: none;
}
.comment.collapsed > .comment-inner > .comment-content > .comment-head {
  opacity: 0.5;
}

/* Vote arrows */
.comment-votes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  min-width: 28px;
}
.vote-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: var(--muted-light);
  padding: 2px 4px;
  line-height: 1;
  border-radius: 3px;
  transition: all var(--transition);
}
.vote-btn:hover {
  color: var(--accent);
  background: var(--accent-light);
}
.vote-btn.vote-active.vote-up {
  color: var(--accent);
}
.vote-btn.vote-active.vote-down {
  color: #5c6bc0;
}
.vote-score {
  font-size: 12px;
  font-weight: 800;
  color: var(--fg);
  text-align: center;
  min-width: 20px;
  line-height: 1.2;
}

/* Comment content */
.comment-content {
  flex: 1;
  min-width: 0;
}
.comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 4px;
}
.comment-author {
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
}
a.comment-author:hover {
  color: var(--accent);
}
.comment-time {
  color: var(--muted-light);
  font-size: 12px;
}
.comment-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
}
.comment-actions {
  margin-top: 4px;
  display: flex;
  gap: 12px;
}
.comment-reply-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-light);
  padding: 2px 0;
  transition: color var(--transition);
}
.comment-reply-btn:hover {
  color: var(--accent);
}

/* Reply form (inline) */
.comment-reply-form {
  margin-top: 8px;
}
.comment-reply-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 60px;
  margin-bottom: 6px;
  transition: border-color var(--transition);
  background: var(--bg);
  color: var(--fg);
}
.comment-reply-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.comment-reply-actions {
  display: flex;
  gap: 6px;
}

/* ── Theme toggle ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: var(--muted);
  width: 32px;
  height: 32px;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.theme-toggle svg { width: 16px; height: 16px; }
.theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: flex; }

/* ── Lucide icons ── */
.cat-badge svg, .category-pill svg {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  stroke-width: 2.5;
}
.category-pill svg { width: 15px; height: 15px; }
.stat-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.5;
}
.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--accent-light);
  color: var(--accent);
}
.empty-icon svg {
  width: 48px;
  height: 48px;
  stroke-width: 1.2;
}
.nav-icon { display: inline-flex; vertical-align: -3px; margin-right: 2px; }
.nav-icon svg { width: 15px; height: 15px; stroke-width: 2; }
.nav-text { /* visible by default, hidden on mobile via media query */ }
.btn svg { width: 15px; height: 15px; vertical-align: -2px; stroke-width: 2.5; margin-right: 2px; }

/* ── Back link ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 16px;
  color: var(--muted);
}
.back-link:hover { color: var(--accent); }

/* ── Footer ── */
footer {
  text-align: center;
  padding: 24px 20px;
  font-size: 12px;
  color: var(--muted-light);
  border-top: 1px solid var(--border);
  margin-top: 40px;
  max-width: var(--max-w);
  margin-left: auto;
  margin-right: auto;
}
footer a { color: var(--muted); }
footer nav {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 10px;
}

/* ══════════════════════════════════════════
   RESPONSIVE — Native app-like mobile UX
   ══════════════════════════════════════════ */

/* ── Touch device optimizations ── */
@media (hover: none) and (pointer: coarse) {
  * { -webkit-tap-highlight-color: transparent; }
  html { touch-action: manipulation; }
  a.card-link:hover .card { transform: none; box-shadow: var(--shadow-sm); }
  .vote-btn { padding: 6px 8px; font-size: 12px; }
  .comment-reply-btn, .comment-delete-btn { padding: 6px 2px; font-size: 13px; }
}

/* ── Tablet ── */
@media (max-width: 900px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

/* ── Mobile ── */
@media (max-width: 640px) {
  /* -- Global mobile feel -- */
  html { scroll-behavior: smooth; overscroll-behavior-y: contain; }
  body { font-size: 15px; }
  main { padding: 16px; min-height: calc(100vh - 120px); }
  main > h2[style] { font-size: 18px !important; margin-bottom: 12px !important; }

  /* -- Header: app-style top bar -- */
  header {
    padding: 0 12px;
    height: 52px;
    border-bottom-width: 2px;
    box-shadow: none;
    position: sticky;
    top: 0;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: color-mix(in srgb, var(--card) 85%, transparent);
  }
  header h1 { font-size: 16px; letter-spacing: -0.3px; }
  header nav { gap: 0; }
  header nav a, header nav span, header nav .nav-logout {
    padding: 0 10px;
    font-size: 0;
    height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    position: relative;
  }
  header nav a:hover { background: transparent; }
  header nav a:active { background: var(--accent-light); }
  /* Icon-only mode */
  .nav-text { display: none; }
  .nav-icon { margin-right: 0; }
  .nav-icon svg { width: 20px; height: 20px; stroke-width: 1.8; }
  /* CTA button stays visible but compact */
  header nav .btn {
    font-size: 0;
    padding: 0 10px;
    height: 52px;
    border-radius: 0;
    background: transparent;
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  header nav .btn:hover { background: transparent; }
  header nav .btn:active { background: var(--accent-light); }
  header nav .btn svg { width: 22px; height: 22px; stroke-width: 1.8; margin-right: 0; }
  /* Theme toggle flush with nav */
  .theme-toggle {
    width: 44px; height: 52px;
    border: none; border-radius: 0;
    padding: 0;
  }
  .theme-toggle:hover { background: transparent; }
  .theme-toggle:active { background: var(--accent-light); }
  .theme-toggle svg { width: 20px; height: 20px; }

  /* -- Hero -- */
  .hero {
    padding: 24px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
  }
  .hero::after { width: 180px; height: 180px; top: -30%; right: -8%; }
  .hero h2 { font-size: 20px; margin-bottom: 6px; }
  .hero p { font-size: 13px; margin-bottom: 16px; line-height: 1.45; }
  .hero .btn { padding: 10px 24px; font-size: 13px; }

  /* -- Stats: compact inline strip -- */
  .stats-bar {
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    margin-bottom: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .stat-card {
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 12px 6px;
    border-right: 1px solid var(--border-light);
  }
  .stat-card:last-child { border-right: none; }
  .stat-icon { width: 28px; height: 28px; border-radius: 6px; margin-bottom: 4px; }
  .stat-icon svg { width: 14px; height: 14px; }
  .stat-card .stat-num { font-size: 20px; letter-spacing: -0.5px; }
  .stat-card .stat-label { font-size: 9px; letter-spacing: 0.8px; }

  /* -- Section headers -- */
  .section-header { margin-bottom: 12px; }
  .section-header h2 { font-size: 16px; }

  /* -- Category pills: edge-to-edge scroll -- */
  .category-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -16px 16px;
    padding: 0 16px 2px;
    gap: 6px;
    scroll-snap-type: x proximity;
  }
  .category-pills::-webkit-scrollbar { display: none; }
  .category-pill {
    flex-shrink: 0;
    padding: 7px 12px;
    font-size: 12px;
    gap: 3px;
    scroll-snap-align: start;
  }
  .category-pill svg { width: 13px; height: 13px; }

  /* -- Filter bar -- */
  .filter-bar {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 16px;
  }
  .filter-bar .search-input {
    min-width: 0;
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 8px;
  }
  .filter-bar select {
    min-width: auto;
    width: auto;
    padding: 10px 8px;
    font-size: 13px;
    flex-shrink: 0;
    border-radius: 8px;
  }
  .filter-bar .btn { display: none; } /* auto-submit via select */

  /* -- Card grid -- */
  .card-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .card {
    padding: 14px;
    border-radius: 8px;
  }
  a.card-link:active .card {
    background: var(--accent-light);
    transition: background 0.05s;
  }
  .card h2 { font-size: 14px; margin-bottom: 4px; }
  .card p { font-size: 12px; margin-bottom: 8px; line-height: 1.45; }
  .card .cat-badge { margin-bottom: 6px; }
  .card-meta { font-size: 10px; gap: 6px; margin-top: 6px; }
  .card-meta svg { width: 10px !important; height: 10px !important; }
  .progress-wrap { margin-top: 8px; }
  .progress-bar { height: 4px; }
  .progress-info { font-size: 10px; margin-top: 3px; }

  /* -- Detail page -- */
  .detail-card { padding: 16px; border-radius: 8px; }
  .detail-header { flex-direction: column; gap: 6px; margin-bottom: 6px; }
  .detail-header h2 { font-size: 18px; line-height: 1.3; }
  .detail-body { font-size: 14px; margin: 12px 0; line-height: 1.6; }
  .detail-remarks { margin-top: 12px; padding-top: 12px; }
  .detail-remarks summary { font-size: 13px; }
  .detail-remarks p { font-size: 13px; }
  .card-meta { font-size: 11px; gap: 8px; }

  /* Action buttons: full-width stacked */
  .btn-group {
    flex-direction: column;
    gap: 8px;
  }
  .btn-group .btn {
    width: 100%;
    text-align: center;
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }
  .btn-group .btn svg { margin-right: 0; }

  /* -- Comments — tight & compact -- */
  .comments-section { margin-top: 20px; }
  .comments-header { margin-bottom: 12px; padding-bottom: 10px; }
  .comments-header h3 { font-size: 15px; }

  .comment-form-root { padding: 12px; border-radius: 8px; }
  .comment-form-root textarea {
    min-height: 64px;
    font-size: 14px;
    padding: 10px;
    border-radius: 8px;
  }
  .comment-form-root .btn { width: 100%; padding: 10px; font-size: 14px; border-radius: 8px; }

  /* Thread nesting: cap indent, reduce aggressively */
  .comment-children { padding-left: 12px; }
  .comment-children .comment-children { padding-left: 10px; }
  .comment-children .comment-children .comment-children { padding-left: 8px; }
  .comment-children .comment-children .comment-children .comment-children { padding-left: 4px; }
  .comment-thread-line { left: 8px; width: 1.5px; }
  .comment-children .comment-thread-line { left: 8px; }

  .comment-inner { gap: 6px; padding: 6px 0; }
  .comment-collapse { width: 16px; font-size: 10px; padding-top: 3px; }
  .comment-votes { min-width: 24px; }
  .vote-btn { padding: 4px 6px; }
  .vote-score { font-size: 11px; min-width: 18px; }
  .comment-author { font-size: 12px; }
  .comment-time { font-size: 11px; }
  .comment-body { font-size: 13px; line-height: 1.5; }
  .comment-head { gap: 6px; margin-bottom: 2px; }
  .comment-actions { gap: 16px; margin-top: 3px; }
  .comment-reply-form textarea {
    min-height: 50px;
    font-size: 13px;
    border-radius: 8px;
  }
  .comment-reply-actions .btn { padding: 8px 14px; font-size: 13px; }
  .comment-login-prompt { padding: 16px; font-size: 13px; }
  .comments-empty { padding: 24px 12px; font-size: 13px; }

  /* -- Forms -- */
  .form-group { margin-bottom: 14px; }
  .form-group label { font-size: 13px; margin-bottom: 5px; }
  .form-group input, .form-group textarea, .form-group select {
    padding: 12px;
    font-size: 16px; /* prevents iOS zoom */
    border-radius: 8px;
  }
  .form-group small { font-size: 11px; }
  .form-group textarea { min-height: 100px; }

  /* -- Profile -- */
  .profile-header { flex-direction: column; text-align: center; gap: 14px; }
  .profile-avatar { width: 56px; height: 56px; font-size: 22px; }
  .profile-info h2 { font-size: 18px; }
  .profile-stats { justify-content: center; gap: 16px; }
  .profile-stats span { font-size: 12px; }

  /* -- About & FAQ -- */
  .about-content h2 { font-size: 17px; margin: 20px 0 6px; }
  .about-content p { font-size: 14px; line-height: 1.6; }
  .about-content li { font-size: 13px; }
  .phase-item { padding: 12px; gap: 10px; }
  .phase-num { width: 28px; height: 28px; font-size: 12px; }
  .phase-item h4 { font-size: 14px; }
  .phase-item p { font-size: 12px; }
  .faq-item summary { padding: 12px 14px; font-size: 14px; }
  .faq-item p { padding: 0 14px 12px; font-size: 13px; }

  /* -- Empty states -- */
  .empty { padding: 36px 16px; font-size: 14px; }
  .empty-icon svg { width: 40px; height: 40px; }

  /* -- Back link: full-width tap target -- */
  .back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px -16px 0;
    padding: 14px;
    font-size: 13px;
    background: var(--card);
    border-top: 1px solid var(--border);
    border-radius: 0;
  }

  /* -- Footer compact -- */
  footer { padding: 20px 16px; margin-top: 24px; font-size: 11px; }
  footer nav { gap: 16px; margin-bottom: 8px; }

  /* -- Buttons — larger touch targets -- */
  .btn { border-radius: 8px; }
  .btn-primary { padding: 12px 20px; font-size: 14px; }

  /* -- Cat badge compact -- */
  .cat-badge { padding: 2px 8px; font-size: 10px; }
  .cat-badge svg { width: 11px; height: 11px; }

  /* -- Progress bar large variant on mobile -- */
  .progress-wrap.progress-lg .progress-bar { height: 8px; }
  .progress-wrap.progress-lg .progress-info { font-size: 12px; margin-top: 4px; }
}

/* ── Tiny phones ── */
@media (max-width: 380px) {
  main { padding: 12px; }
  .hero { padding: 20px 16px; }
  .hero h2 { font-size: 18px; }
  .hero p { font-size: 12px; }
  .stat-card .stat-num { font-size: 18px; }
  .stat-card .stat-label { font-size: 8px; }
  .stat-icon { width: 24px; height: 24px; border-radius: 5px; }
  .stat-icon svg { width: 12px; height: 12px; }
  .card { padding: 12px; }
  .card h2 { font-size: 13px; }
  .detail-card { padding: 12px; }
  .detail-header h2 { font-size: 16px; }
  header nav a, header nav span { padding: 0 8px; }
  .category-pills { margin: 0 -12px 14px; padding: 0 12px 2px; }
  .back-link { margin: 12px -12px 0; }
}

/* ── Safe area insets for notched phones ── */
@supports (padding: env(safe-area-inset-top)) {
  @media (max-width: 640px) {
    header { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
    main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
    footer { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  }
}
