/* ══════════════════════════════════════════════════════════
   TMI Practice — Design System
   Aesthetic: Japanese ink wash × modern clarity
   ══════════════════════════════════════════════════════════ */

:root {
  --bg: #F5F0E8;
  --surface: #FDFAF5;
  --surface-2: #EDE8DF;
  --surface-3: #E4DDD2;
  --border: #D6CDBF;
  --border-light: #E8E2D8;
  --text: #1E1A14;
  --text-2: #3D3628;
  --text-muted: #7A7060;
  --text-faint: #A89E8E;
  --accent: #B8712A;
  --accent-hover: #9A5E22;
  --accent-light: #F2E0C8;
  --primary: #2A3E35;
  --primary-hover: #1E2E28;
  --primary-light: #D6E4DF;
  --info: #2E4A7A;
  --info-light: #D4E0F0;
  --warning: #8A6020;
  --warning-light: #F5E8CC;
  --danger: #8A2828;
  --danger-light: #F0D4D4;
  --success: #285A3A;
  --success-light: #D4EAD8;

  /* Stage depth spectrum - pale sand to deep ink */
  --stage-color-1: #D4C8B8;
  --stage-color-2: #C4B4A0;
  --stage-color-3: #B4A090;
  --stage-color-4: #9A8A78;
  --stage-color-5: #847060;
  --stage-color-6: #6E5C4C;
  --stage-color-7: #584838;
  --stage-color-8: #443828;
  --stage-color-9: #342A1E;
  --stage-color-10: #1E1410;

  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 2px 8px rgba(30,26,20,0.08);
  --shadow-md: 0 4px 16px rgba(30,26,20,0.12);
  --shadow-lg: 0 8px 32px rgba(30,26,20,0.15);

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', monospace;

  --sidebar-w: 240px;
  --topbar-h: 56px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { background: var(--bg); color: var(--text); font-family: var(--font-body); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 32px; height: 32px; color: var(--accent); }
.logo-text { font-family: var(--font-display); font-size: 1.1rem; font-weight: 500; color: var(--text); }
.sidebar-close { display: none; color: var(--text-muted); font-size: 1rem; padding: 4px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-section-label {
  font-size: 0.65rem; font-weight: 500; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 12px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  font-size: 0.88rem; color: var(--text-2);
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
.nav-item.sub { padding-left: 34px; font-size: 0.83rem; color: var(--text-muted); }
.nav-item.sub:hover { color: var(--text-2); }
.nav-item.logout { color: var(--text-muted); }
.nav-item.logout:hover { color: var(--danger); background: var(--danger-light); }
.nav-icon { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-light);
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0;
  z-index: 50;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px; padding: 6px; border-radius: 6px;
}
.hamburger:hover { background: var(--surface-2); }
.hamburger span {
  display: block; width: 20px; height: 2px;
  background: var(--text-2); border-radius: 1px;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }
.page-body { padding: 32px 32px 64px; max-width: 1100px; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(30,26,20,0.4);
  z-index: 90;
}

/* ── Flash Messages ── */
.flash {
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 0.85rem; font-weight: 500;
  transition: opacity 0.5s;
}
.flash-success { background: var(--success-light); color: var(--success); }
.flash-error { background: var(--danger-light); color: var(--danger); }
.flash-info { background: var(--info-light); color: var(--info); }

/* ── Typography ── */
.page-title {
  font-family: var(--font-display);
  font-size: 2.2rem; font-weight: 500;
  color: var(--text); line-height: 1.2;
  margin-bottom: 8px;
}
.page-subtitle { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 32px; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; line-height: 1.25; }
h1 { font-size: 2.4rem; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.05rem; }
p { margin-bottom: 12px; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-accent { color: var(--accent); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.font-mono { font-family: var(--font-mono); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card-sm { padding: 16px; border-radius: var(--radius); }
.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem; font-weight: 500;
  margin-bottom: 4px;
}
.card-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 16px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius);
  font-size: 0.88rem; font-weight: 500;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--primary); color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-accent {
  background: var(--accent); color: #fff;
}
.btn-accent:hover { background: var(--accent-hover); }
.btn-outline {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--surface-2); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #701e1e; }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 0.83rem; font-weight: 500;
  color: var(--text-2); margin-bottom: 6px;
}
.form-label small { font-weight: 400; color: var(--text-muted); }
.form-control {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184,113,42,0.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.78rem; color: var(--text-faint); margin-top: 4px; }

.check-group { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill input[type=checkbox] { display: none; }
.check-pill label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.check-pill input:checked + label {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.check-pill label:hover { border-color: var(--accent); }

/* ── Grid helpers ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

/* ── Stage badge ── */
.stage-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 500;
  background: var(--surface-2);
  color: var(--text-2);
}
.stage-badge.current { background: var(--accent-light); color: var(--accent); }

/* ── Stage depth indicator (ink circle) ── */
.stage-depth {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 1.3rem;
  color: #fff; font-weight: 600;
}

/* ── Progress bar ── */
.progress-bar {
  height: 6px; background: var(--surface-2);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  background: var(--accent);
  transition: width 0.4s ease;
}

/* ── Star rating ── */
.star-rating { display: flex; gap: 6px; }
.star-rating input[type=radio] { display: none; }
.star-rating label {
  font-size: 1.5rem; cursor: pointer; color: var(--border);
  transition: color 0.15s;
}
.star-rating input:checked ~ label,
.star-rating label:hover,
.star-rating label:hover ~ label { color: var(--accent); }
.star-rating { flex-direction: row-reverse; }
.stars-display { color: var(--accent); }

/* ── Tags / pills ── */
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 12px;
  font-size: 0.75rem;
  background: var(--surface-2);
  color: var(--text-2);
}
.tag-accent { background: var(--accent-light); color: var(--accent); }
.tag-primary { background: var(--primary-light); color: var(--primary); }

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

/* ── Landing page ── */
.landing { min-height: 100vh; background: var(--bg); }
.landing-hero {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: 40px 24px;
  position: relative;
  overflow: hidden;
}
.landing-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 40%, rgba(184,113,42,0.06), transparent);
}
.hero-orb {
  width: 180px; height: 180px;
  border-radius: 50%;
  border: 1px solid rgba(184,113,42,0.3);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 40px;
  position: relative;
}
.hero-orb::before {
  content: '';
  position: absolute;
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 1px solid rgba(184,113,42,0.2);
}
.hero-orb::after {
  content: '';
  position: absolute;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: rgba(184,113,42,0.1);
}
.hero-content { max-width: 600px; position: relative; }
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 400; line-height: 1.1;
  color: var(--text);
  margin-bottom: 20px;
}
.hero-title em { color: var(--accent); font-style: italic; }
.hero-sub {
  font-size: 1.05rem; color: var(--text-muted);
  max-width: 480px; margin: 0 auto 40px; line-height: 1.7;
}
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.landing-section {
  padding: 80px 24px;
  max-width: 960px; margin: 0 auto;
}
.section-title {
  font-family: var(--font-display);
  font-size: 1.8rem; text-align: center;
  margin-bottom: 48px; color: var(--text);
}
.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.stage-card-mini {
  padding: 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform 0.15s, box-shadow 0.15s;
}
.stage-card-mini:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stage-num { font-family: var(--font-display); font-size: 1.8rem; color: var(--text-faint); }
.stage-name { font-size: 0.82rem; font-weight: 500; color: var(--text-2); margin-top: 6px; }

.feature-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 24px; }
.feature-item { text-align: center; padding: 24px; }
.feature-icon { font-size: 2rem; margin-bottom: 12px; }
.feature-title { font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 8px; }
.feature-desc { font-size: 0.88rem; color: var(--text-muted); line-height: 1.6; }

.landing-nav {
  position: fixed; top: 0; left: 0; right: 0;
  padding: 16px 32px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(245,240,232,0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-light);
  z-index: 50;
}
.landing-nav .logo { display: flex; align-items: center; gap: 10px; }
.landing-nav .logo-mark { width: 28px; height: 28px; color: var(--accent); }
.nav-links { display: flex; gap: 8px; }

/* ── Dashboard ── */
.stats-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 2.2rem; font-weight: 400;
  color: var(--text); line-height: 1;
  margin-bottom: 4px;
}
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

.current-stage-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
  display: flex; gap: 24px; align-items: flex-start;
}
.stage-num-large {
  font-family: var(--font-display);
  font-size: 5rem; line-height: 1; font-weight: 400;
  color: var(--text-faint); min-width: 80px;
}

/* ── Theory ── */
.stage-list {
  display: grid; gap: 12px;
}
.stage-list-item {
  display: flex; align-items: center; gap: 20px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  transition: all 0.2s;
  box-shadow: var(--shadow);
}
.stage-list-item:hover {
  transform: translateX(4px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.stage-list-num {
  font-family: var(--font-display);
  font-size: 3rem; font-weight: 400;
  min-width: 60px; color: var(--text-faint);
  line-height: 1;
}
.stage-list-body { flex: 1; }
.stage-list-name { font-family: var(--font-display); font-size: 1.2rem; font-weight: 500; }
.stage-list-subtitle { font-size: 0.82rem; color: var(--text-muted); }
.stage-list-goal { font-size: 0.88rem; color: var(--text-2); margin-top: 4px; }
.stage-group-label {
  font-size: 0.7rem; font-weight: 500; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 20px 0 8px;
}

.stage-detail-header {
  display: flex; align-items: flex-start; gap: 28px;
  margin-bottom: 40px;
}
.stage-detail-num {
  font-family: var(--font-display);
  font-size: 7rem; font-weight: 400;
  line-height: 1; color: var(--text-faint);
  min-width: 120px;
}
.detail-section { margin-bottom: 32px; }
.detail-section-title {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 500;
  color: var(--text); margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.technique-card {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 10px;
}
.technique-name { font-weight: 500; font-size: 0.9rem; margin-bottom: 4px; color: var(--primary); }
.technique-desc { font-size: 0.85rem; color: var(--text-2); line-height: 1.6; }

.problem-item { margin-bottom: 14px; }
.problem-q { font-weight: 500; font-size: 0.88rem; color: var(--text); margin-bottom: 4px; }
.problem-q::before { content: '❧ '; color: var(--accent); }
.problem-a { font-size: 0.85rem; color: var(--text-2); padding-left: 16px; line-height: 1.6; }

.mastery-list { list-style: none; }
.mastery-list li {
  padding: 8px 0 8px 22px;
  position: relative;
  font-size: 0.88rem; color: var(--text-2);
  border-bottom: 1px solid var(--border-light);
}
.mastery-list li::before {
  content: '✓'; position: absolute; left: 0;
  color: var(--success); font-weight: 600;
}
.obstacle-list { list-style: none; }
.obstacle-list li {
  padding: 6px 0 6px 20px; position: relative;
  font-size: 0.88rem; color: var(--text-2);
}
.obstacle-list li::before {
  content: '◦'; position: absolute; left: 0;
  color: var(--accent);
}

.warning-box {
  background: var(--warning-light);
  border: 1px solid rgba(138,96,32,0.2);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 0.88rem; color: var(--warning);
  margin-bottom: 20px;
}
.insight-box {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  padding: 14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.88rem; color: var(--primary);
  font-style: italic; margin-top: 20px;
  line-height: 1.6;
}

.stage-nav {
  display: flex; justify-content: space-between;
  margin-top: 48px; padding-top: 24px;
  border-top: 1px solid var(--border-light);
}

/* ── Concepts ── */
.concept-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.concept-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}
.concept-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.concept-icon { font-size: 1.8rem; margin-bottom: 12px; }
.concept-title { font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 4px; }
.concept-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; }
.concept-preview { font-size: 0.85rem; color: var(--text-2); line-height: 1.6; }

.prose { max-width: 680px; }
.prose h3 { font-family: var(--font-display); font-size: 1.2rem; margin: 24px 0 10px; }
.prose p { font-size: 0.92rem; color: var(--text-2); line-height: 1.75; margin-bottom: 14px; }
.prose strong { color: var(--text); font-weight: 500; }
.prose em { color: var(--accent); font-style: italic; }
.prose ul { padding-left: 20px; margin-bottom: 14px; }
.prose ul li { font-size: 0.9rem; color: var(--text-2); margin-bottom: 6px; }

/* ── Practice / Timer ── */
.practice-layout {
  display: grid; grid-template-columns: 1fr 360px; gap: 28px;
  align-items: start;
}
.timer-wrap {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 20px;
}
.timer-ring-wrap {
  position: relative; width: 240px; height: 240px;
  margin-bottom: 32px;
}
.timer-ring {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.timer-ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 6; }
.timer-ring-progress {
  fill: none; stroke: var(--accent); stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
.timer-display {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.timer-time {
  font-family: var(--font-display);
  font-size: 3rem; font-weight: 400; color: var(--text);
  line-height: 1;
}
.timer-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.timer-controls { display: flex; gap: 12px; margin-bottom: 24px; }
.timer-btn {
  width: 52px; height: 52px;
  border-radius: 50%; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: var(--text-2);
  transition: all 0.15s; background: var(--surface);
}
.timer-btn:hover { border-color: var(--accent); color: var(--accent); }
.timer-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 1.4rem; width: 64px; height: 64px; }
.timer-btn.primary:hover { background: var(--accent-hover); }

.session-instructions {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  max-height: 500px;
  overflow-y: auto;
}
.instruction-step {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.88rem; color: var(--text-2);
  line-height: 1.6;
}
.instruction-step:last-child { border-bottom: none; }
.instruction-step.active { color: var(--primary); font-weight: 500; }
.step-num { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-faint); display: block; }

.bell-control {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.85rem;
}

/* ── Journal ── */
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; }
.entry-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.15s;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.entry-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border); }
.entry-date { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-faint); margin-bottom: 8px; }
.entry-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.entry-preview { font-size: 0.85rem; color: var(--text-2); line-height: 1.5; flex: 1; }
.entry-footer { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; }
.entry-duration { font-family: var(--font-display); font-size: 1.2rem; color: var(--text-muted); }

.entry-detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
}
.entry-section { margin-bottom: 24px; }
.entry-section-title {
  font-size: 0.75rem; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-faint);
  margin-bottom: 8px;
}
.entry-content {
  font-size: 0.9rem; color: var(--text-2); line-height: 1.7;
}

/* ── Stats / Charts ── */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
.chart-title { font-family: var(--font-display); font-size: 1.1rem; margin-bottom: 20px; }
.chart-wrap { position: relative; }

/* ── Progress / Tasks ── */
.tasks-stage-section { margin-bottom: 32px; }
.tasks-stage-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}
.stage-progress-mini { flex: 1; }
.stage-progress-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }

.task-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius);
  transition: background 0.15s;
  cursor: pointer;
}
.task-item:hover { background: var(--surface-2); }
.task-item.completed { opacity: 0.55; }
.task-check {
  width: 18px; height: 18px; border-radius: 4px;
  border: 2px solid var(--border); flex-shrink: 0;
  margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; background: var(--surface);
}
.task-item.completed .task-check {
  background: var(--success); border-color: var(--success); color: #fff;
}
.task-text { font-size: 0.87rem; color: var(--text-2); line-height: 1.5; }
.task-item.completed .task-text { text-decoration: line-through; }
.task-category {
  font-size: 0.7rem; color: var(--text-faint);
  font-family: var(--font-mono); margin-top: 2px;
}

.overall-progress {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 32px;
  box-shadow: var(--shadow);
}
.overall-bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.overall-fill {
  height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, var(--primary-light), var(--accent));
  transition: width 0.6s ease;
}

.insight-item {
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 8px;
  display: flex; align-items: flex-start; gap: 12px;
}
.insight-text { font-size: 0.88rem; color: var(--text-2); flex: 1; line-height: 1.6; }
.insight-meta { font-size: 0.72rem; color: var(--text-faint); font-family: var(--font-mono); margin-top: 4px; }

/* ── Auth pages ── */
.auth-page {
  min-height: 100vh; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px;
}
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  text-align: center; margin-bottom: 32px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.auth-logo-mark { width: 48px; height: 48px; color: var(--accent); }
.auth-title {
  font-family: var(--font-display);
  font-size: 1.8rem; text-align: center;
  margin-bottom: 8px; color: var(--text);
}
.auth-sub { text-align: center; font-size: 0.88rem; color: var(--text-muted); margin-bottom: 28px; }
.auth-footer { text-align: center; margin-top: 24px; font-size: 0.85rem; color: var(--text-muted); }
.auth-footer a { color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .sidebar-overlay.active { display: block; }
  .hamburger { display: flex; }
  .main-content { margin-left: 0; }
  .page-body { padding: 24px 16px 48px; }

  .stats-row { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .entry-detail-grid { grid-template-columns: 1fr; }
  .practice-layout { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: 1fr; }
  .concept-grid { grid-template-columns: 1fr; }
  .current-stage-card { flex-direction: column; }
  .stage-detail-header { flex-direction: column; }
}

@media (max-width: 600px) {
  .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stage-list-item { flex-direction: column; gap: 8px; }
  .hero-title { font-size: 2.2rem; }
  .auth-card { padding: 28px 24px; }
}

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.35s ease forwards; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.pulse { animation: pulse 2s ease infinite; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Additional polish ── */

/* Heatmap wrap */
#heatmapWrap { min-height: 100px; }

/* Phase ring in timer */
#phaseRing { transform-origin: 110px 110px; }
.timer-ring { transform: rotate(-90deg); transform-origin: center; }

/* Task item completed state */
.task-item.completed .task-check {
  background: var(--success); border-color: var(--success); color: #fff;
}
.task-item.completed .task-text { text-decoration: line-through; color: var(--text-faint); }

/* Reference page */
@media (max-width: 860px) {
  .ref-stage-block > div:last-child {
    grid-template-columns: 1fr 1fr !important;
  }
}
@media (max-width: 600px) {
  .ref-stage-block > div:last-child {
    grid-template-columns: 1fr !important;
  }
}

/* Better stage list hover */
.stage-list-item {
  position: relative;
}
.stage-list-item::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}
.stage-list-item:hover::after { opacity: 1; }

/* Entry card hover polish */
.entry-card { transition: transform 0.15s, box-shadow 0.15s; }

/* Better check pills on mobile */
@media (max-width: 600px) {
  .check-group { gap: 6px; }
  .check-pill label { font-size: 0.78rem; padding: 5px 10px; }
}

/* Concept card active state */
.concept-card { position: relative; overflow: hidden; }
.concept-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.2s;
  transform-origin: left;
}
.concept-card:hover::before { transform: scaleX(1); }

/* Smoother sidebar on desktop */
@media (min-width: 901px) {
  .sidebar { transform: none !important; }
}

/* Stats section labels */
.stats-section-title {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 24px 0 12px;
}

/* Tag group */
.tag-group { display: flex; flex-wrap: wrap; gap: 6px; }

/* Print styles for reference */
@media print {
  :root { --bg: #fff; --surface: #fff; }
}
