:root {
  --bg: #fafafa;
  --bg-alt: #f0f0f0;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #666666;
  --primary: #101010;

  /* Category specific highlights */
  --sql-color: #3b82f6;
  --sql-bg: rgba(59, 130, 246, 0.08);
  --html-color: #f97316;
  --html-bg: rgba(249, 115, 22, 0.08);
  --java-color: #ec4899;
  --java-bg: rgba(236, 72, 153, 0.08);

  --transition: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --hover-shadow: 0 20px 40px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-alt: #121212;
  --surface: #161616;
  --border: #262626;
  --text: #f0f0f0;
  --text-muted: #a0a0a0;
  --primary: #ffffff;

  --hover-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  --sql-bg: rgba(59, 130, 246, 0.15);
  --html-bg: rgba(249, 115, 22, 0.15);
  --java-bg: rgba(236, 72, 153, 0.15);
}

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

html {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar {
  display: none;
}

body {
  background: var(--bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  line-height: 1.6;
  transition: background-color var(--transition), color var(--transition);
  overflow-x: hidden;
}

/* ──────────── LAYOUT ──────────── */
.container {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ──────────── TOP BAR (GO BACK + THEME) ──────────── */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 2000;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all var(--transition);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.back-link svg {
  width: 18px;
  height: 18px;
}

.back-link:hover {
  color: var(--text);
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.theme-btn-header {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.theme-btn-header:hover {
  color: var(--text);
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.theme-btn-header svg {
  width: 18px;
  height: 18px;
  transition: transform 0.5s var(--ease-out);
}

.theme-btn-header:hover svg {
  transform: rotate(20deg);
}

.icon-sun {
  display: none;
}

.icon-moon {
  display: block;
}

[data-theme="dark"] .icon-sun {
  display: block;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

/* ──────────── HERO SECTION ──────────── */
.hero {
  padding: 120px 0 36px;
  text-align: left;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: block;
}

.hero-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 3rem;
  line-height: 1.15;
  margin-bottom: 14px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 0 32px;
}

.hero:first-of-type .section-label {
  animation: slideUp 0.55s var(--ease-out) 0.05s forwards;
}

.hero:first-of-type .hero-title {
  animation: slideUp 0.6s var(--ease-out) 0.15s forwards;
}

.hero:first-of-type .hero-subtitle {
  animation: slideUp 0.6s var(--ease-out) 0.25s forwards;
}

/* ──────────── SEARCH & FILTER BAR ──────────── */
.controls-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
  flex-wrap: wrap;
  opacity: 0;
  transform: translateY(16px);
  animation: slideUp 0.55s var(--ease-out) 0.35s forwards;
}


.search-box {
  position: relative;
  width: 100%;
  max-width: 220px;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  padding: 9px 16px 9px 38px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
  font-family: inherit;
  transition: all 0.3s var(--ease-out);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.search-input:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .search-input:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 14px;
  height: 14px;
}

.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* Stagger each tab button with nth-child delays */
.tab-btn {
  padding: 8px 20px;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.3s var(--ease-out),
    border-color 0.3s var(--ease-out),
    transform 0.3s var(--ease-out),
    box-shadow 0.3s var(--ease-out),
    background 0.3s var(--ease-out);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
  opacity: 0;
  transform: translateY(14px);
  animation: slideUp 0.5s var(--ease-out) forwards;
}

.tab-btn:nth-child(1) {
  animation-delay: 0.30s;
}

.tab-btn:nth-child(2) {
  animation-delay: 0.38s;
}

.tab-btn:nth-child(3) {
  animation-delay: 0.46s;
}

.tab-btn:nth-child(4) {
  animation-delay: 0.54s;
}

.tab-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
  transform: translateY(-2px) scale(1.03);
}

.tab-btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  transform: scale(1.05);
}



/* ──────────── PRACTICE GRID ──────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* ──────────── TEST CARD ──────────── */
.test-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transform: translateY(0);
  will-change: transform, box-shadow;
}

.test-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .test-card:hover {
  border-color: rgba(255, 255, 255, 0.08);
}

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

.card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
}

.card-category-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent, var(--text-muted));
  background: color-mix(in srgb, var(--accent, currentColor) 12%, transparent);
  padding: 2px 8px;
  border-radius: 20px;
}

.lang-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  transition: transform var(--transition);
}

.test-card:hover .lang-logo {
  transform: scale(1.1);
}

.test-card[data-category="sql"] {
  --accent: var(--sql-color);
}

.test-card[data-category="html"] {
  --accent: var(--html-color);
}

.test-card[data-category="java"] {
  --accent: var(--java-color);
}

.test-number {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.test-title {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.35;
  color: var(--text);
}

.test-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: auto;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: auto;
  padding-top: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: gap 0.3s var(--ease-out), color 0.3s var(--ease-out);
}

.test-card:hover .card-footer {
  gap: 8px;
  color: var(--text);
}

.card-footer svg {
  width: 11px;
  height: 11px;
  transition: transform 0.3s var(--ease-out);
}

.test-card:hover .card-footer svg {
  transform: translateX(3px);
}

/* ──────────── EMPTY STATE ──────────── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ──────────── SCROLL REVEAL ANIMATIONS ──────────── */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.55s var(--ease-out), transform 0.55s var(--ease-out);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ──────────── FOOTER ──────────── */
.footer {
  margin-top: 96px;
  border-top: 1px solid var(--border);
  padding: 24px 0;
}

/* ──────────── AI SQL EXAM STYLES ──────────── */
.ai-test-section {
  padding: 40px 0;
}

#ai-exams-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.ai-test-card {
  padding: 28px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
}

.ai-test-card .test-title {
  font-size: 1rem;
  margin-top: 8px;
  margin-bottom: 12px;
}

.ai-test-card .test-desc {
  line-height: 1.6;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border: none;
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.hidden {
  display: none !important;
}

.ai-test-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.ai-test-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.ai-test-header h3 {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.ai-test-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.question-item {
  margin-bottom: 24px;
}

.question-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.question-input {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: monospace;
  font-size: 0.9rem;
  min-height: 80px;
  resize: vertical;
  transition: border-color var(--transition);
}

.question-input:focus {
  outline: none;
  border-color: var(--text);
}

.form-actions {
  margin-top: 32px;
  text-align: right;
}

#ai-loading-state {
  text-align: center;
  padding: 40px 0;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#ai-results-container {
  margin-top: 32px;
}

#ai-results-container h3 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  font-family: 'Playfair Display', Georgia, serif;
}

.result-item {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.result-header h4 {
  font-size: 1.1rem;
  margin: 0;
  line-height: 1.4;
}

.status-text {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.status-text.status-correct {
  color: #16a34a;
}

.status-text.status-partial {
  color: #ca8a04;
}

.status-text.status-wrong {
  color: #dc2626;
}

[data-theme="dark"] .status-text.status-correct {
  color: #4ade80;
}

[data-theme="dark"] .status-text.status-partial {
  color: #facc15;
}

[data-theme="dark"] .status-text.status-wrong {
  color: #f87171;
}

.result-item .user-answer,
.result-item .correct-answer,
.result-item .feedback {
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.result-item strong {
  color: var(--text);
  font-weight: 600;
}

.result-item pre {
  background: var(--surface);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow-x: auto;
  margin-top: 4px;
}

.footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ──────────── SCHEMA VISUALIZER STYLES ──────────── */
.schema-visualizer {
  margin-top: 24px;
  padding: 20px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.schema-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.schema-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  align-items: start;
}

.schema-column,
.schema-column-stacked {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.schema-table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--hover-shadow);
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  min-width: 0;
}

.schema-table-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 10px;
  font-family: monospace;
  border-bottom: 2px solid var(--border);
  padding-bottom: 4px;
}

.schema-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.75rem;
}

.schema-table th,
.schema-table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}

.schema-table th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}

.col-name {
  font-family: monospace;
  font-weight: 500;
  color: var(--text);
}

.col-name.pk {
  color: var(--html-color);
  font-weight: 600;
}

.col-name.fk {
  color: var(--sql-color);
  font-weight: 600;
}

.schema-table td:last-child {
  color: var(--text-muted);
}

/* ──────────── RESPONSIVE ──────────── */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2.3rem;
  }

  .container {
    padding: 0 20px;
  }

  .top-bar {
    padding: 12px 16px;
  }

  .controls-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .search-box {
    max-width: 100%;
    width: 100%;
  }

  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  #ai-exams-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .schema-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .schema-visualizer {
    padding: 12px;
  }

  .schema-table-card {
    padding: 10px;
  }

  .footer .container {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
  }
}

/* PLAYGROUND SPECIFIC STYLES */
.pg-graph-container {
  width: 100%;
  height: 280px;
  margin-top: 24px;
  clip-path: inset(0 100% 0 0);
  animation: sweepReveal 2.5s cubic-bezier(0.19, 1, 0.22, 1) forwards;
  animation-delay: 0.2s;
}

@keyframes sweepReveal {
  to {
    clip-path: inset(0 0 0 0);
  }
}

.card-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 12px;
}

.card-desc:last-child {
  margin-bottom: 0;
}

.tag-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid var(--border);
}

.tag:hover {
  background: var(--border);
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.resource-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.resource-card:hover {
  border-color: var(--text-muted);
}

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

.res-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.res-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: contain;
  display: inline-block;
}

.res-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  flex-grow: 1;
}

.res-tags {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.res-tag {
  font-size: 0.75rem;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-weight: 500;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* HEATMAP STYLES */
.heatmap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.heatmap-title {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.heatmap-title span {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
}

.heatmap-stats {
  display: flex;
  gap: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.heatmap-stats strong {
  color: var(--text);
  font-weight: 600;
}

.heatmap-scroll-container {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 12px;
}

.heatmap-scroll-container::-webkit-scrollbar {
  height: 6px;
}

.heatmap-scroll-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.heatmap-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: max-content;
}

.heatmap-months-labels {
  display: flex;
  justify-content: space-between;
  padding-left: 4px;
}

.heatmap-label {
  font-size: 0.8rem;
  color: var(--text);
}

.heatmap-grid {
  display: flex;
  gap: 4.5px;
}

.heatmap-week {
  display: flex;
  flex-direction: column;
  gap: 4.5px;
}

.heatmap-day {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--border);
  transition: opacity 0.2s, transform 0.1s;
  cursor: crosshair;
  opacity: 0;
  animation: heatPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes heatPop {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.heatmap-day:hover {
  opacity: 0.8;
  transform: scale(1.2);
}

.heatmap-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
}

.heatmap-legend span {
  margin: 0 4px;
}

/* LeetCode/GitHub Light Colors */
.heatmap-day.level-0 {
  background: rgba(0, 0, 0, 0.05);
}

.heatmap-day.level-1 {
  background: #9be9a8;
}

.heatmap-day.level-2 {
  background: #40c463;
}

.heatmap-day.level-3 {
  background: #30a14e;
}

.heatmap-day.level-4 {
  background: #216e39;
}

/* LeetCode/GitHub Dark Colors */
[data-theme="dark"] .heatmap-day.level-0 {
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .heatmap-day.level-1 {
  background: #0e4429;
}

[data-theme="dark"] .heatmap-day.level-2 {
  background: #006d32;
}

[data-theme="dark"] .heatmap-day.level-3 {
  background: #26a641;
}

[data-theme="dark"] .heatmap-day.level-4 {
  background: #39d353;
}

/* ──────────── IDEATION / THINKING CARDS ──────────── */
.masonry-grid {
  column-count: 2;
  column-gap: 20px;
  margin-top: 24px;
}

@media (max-width: 768px) {
  .masonry-grid {
    column-count: 1;
  }
}

.idea-card {
  break-inside: avoid;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}

.idea-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
  border-color: var(--text-muted);
}

[data-theme="dark"] .idea-card:hover {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.2);
}

.idea-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 12px;
}

.idea-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.3;
}

.idea-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ──────────── MONTH SELECTOR ──────────── */
.month-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 14px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.month-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.month-btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ──────────── ENGINEERING PRINCIPLES ──────────── */
.principle-item {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}

.principle-item .arrow {
  color: var(--text-muted);
  font-family: monospace;
  margin: 0 4px;
}

/* ──────────── JOURNAL ENTRIES (LINEAR STYLE) ──────────── */
.journal-list {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.journal-entry {
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.journal-entry:last-child {
  border-bottom: none;
}

.journal-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
}

.journal-title {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0;
}

.journal-meta {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.journal-desc {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  opacity: 0.85;
}

.journal-callout {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 16px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text);
  margin: 8px 0;
}

.journal-callout strong {
  font-weight: 600;
  color: var(--primary);
  margin-right: 8px;
}

.journal-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  transition: opacity var(--transition);
}

.journal-link:hover {
  opacity: 0.6;
}

/* ──────────── ENGINEERING THINKING REDESIGN ──────────── */

/* Section Dividers & General Structure */
.section-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 60px 0;
}

.thinking-section {
  margin-bottom: 100px;
}

.section-heading {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 8px;
}

.section-sub {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 40px;
}

/* 1. INFINITE THINKING FLOW */
.thinking-infinite-flow {
  width: 100%;
  overflow: hidden;
  position: relative;
  margin-bottom: 80px;
  mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.flow-track {
  display: flex;
  align-items: center;
  width: max-content;
}

.track-1 {
  animation: scrollFlowLeft 35s linear infinite;
}

.track-2 {
  animation: scrollFlowRight 40s linear infinite;
}

.track-3 {
  animation: scrollFlowLeft 30s linear infinite;
}

@keyframes scrollFlowLeft {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(-50%);
  }
}

@keyframes scrollFlowRight {
  0% {
    transform: translateX(-50%);
  }

  100% {
    transform: translateX(0);
  }
}

.flow-step {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 20px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.flow-connector {
  width: 32px;
  height: 1px;
  background: var(--border);
  margin: 0 12px;
  opacity: 0.6;
}

/* Track 1: System Design (Blue) */
.track-1 .flow-step {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.25);
  color: #3b82f6;
}

.track-1 .flow-connector {
  background: linear-gradient(90deg, transparent 0%, rgba(59, 130, 246, 0.5) 50%, transparent 100%);
}

/* Track 2: Backend (Emerald Green) */
.track-2 .flow-step {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
  color: #10b981;
}

.track-2 .flow-connector {
  background: linear-gradient(90deg, transparent 0%, rgba(16, 185, 129, 0.5) 50%, transparent 100%);
}

/* Track 3: AI Engineering (Amber) */
.track-3 .flow-step {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
  color: #f59e0b;
}

.track-3 .flow-connector {
  background: linear-gradient(90deg, transparent 0%, rgba(245, 158, 11, 0.5) 50%, transparent 100%);
}

/* 2. ARCHITECTURE WORKSPACE (DOCUMENT PLATFORM) */
.architecture-workspace {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.arch-left {
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.arch-left h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: var(--text);
}

.arch-left p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.arch-flow {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
}

.arch-node {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  flex: 0 1 auto;
}

.arch-node:hover,
.arch-node.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.arch-arrow {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.arch-right {
  border-left: 1px solid var(--border);
  padding-left: 20px;
}

.arch-details-content {
  animation: fadeIn 0.3s ease;
}

.arch-details-content strong {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  margin-bottom: 4px;
  margin-top: 12px;
}

.arch-details-content strong:first-child {
  margin-top: 0;
}

.arch-details-content span {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.4;
  display: block;
}

/* 3. TRADE-OFFS */
.tradeoff-workspace {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}

.tradeoff-controls {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}

.tradeoff-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
}

.tradeoff-btn.active,
.tradeoff-btn:hover {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.tradeoff-visuals {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tradeoff-bar-group {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 24px;
}

.tradeoff-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.tradeoff-track {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.tradeoff-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tradeoff-summary {
  margin-top: 32px;
  padding: 16px;
  background: color-mix(in srgb, var(--primary) 5%, transparent);
  border-left: 2px solid var(--primary);
  color: var(--text);
  font-size: 0.95rem;
}

/* 4. PRINCIPLES SCROLL */
.principles-scroll-container {
  display: flex;
  flex-direction: column;
  gap: 60px;
}

.principle-block {
  opacity: 0.2;
  transform: scale(0.95);
  transition: all 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding: 40px 0;
}

.principle-block.active {
  opacity: 1;
  transform: scale(1);
}

.p-num {
  font-size: 1.2rem;
  font-family: monospace;
  color: var(--primary);
  margin-bottom: 16px;
}

.p-title {
  font-size: 3rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 16px;
}

.p-sub {
  font-size: 1.25rem;
  color: var(--text-muted);
}

/* 5. DECISION LAB */
.decision-lab {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.dl-tabs {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.dl-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all var(--transition);
}

.dl-btn.active,
.dl-btn:hover {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.dl-architecture {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.dl-node {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  animation: fadeUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
}

.dl-node:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.dl-node.core {
  border-color: var(--primary);
}

.dl-node.advanced {
  border-style: dashed;
}

/* 6. THINKING DOMAINS (DIRECTORY LIST) */
.domain-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--border);
}

.domain-list-item {
  display: grid;
  grid-template-columns: 250px 1fr;
  align-items: center;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
  transition: all 0.3s ease;
  cursor: default;
}

.domain-list-item:hover {
  background: color-mix(in srgb, var(--text) 2%, transparent);
  padding-left: 16px;
  padding-right: 16px;
  margin-left: -16px;
  margin-right: -16px;
  border-radius: 8px;
  border-bottom-color: transparent;
}

.domain-list-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.domain-list-num {
  font-family: 'Playfair Display', serif;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.domain-list-title {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
}

.domain-list-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.domain-list-tags span {
  font-size: 0.8rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 20px;
  transition: all 0.3s ease;
}

.domain-list-item:hover .domain-list-tags span {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

/* Responsive Overrides */
@media (max-width: 1024px) {
  .architecture-workspace {
    grid-template-columns: 1fr;
  }

  .arch-right {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 24px;
  }

  .p-title {
    font-size: 2rem;
  }
}

/* Scratch Highlight Effect */
.scratch-wrapper {
  position: relative;
  display: inline-block;
  white-space: nowrap;
  z-index: 1;
}

.scratch-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  overflow: visible;
}

.scratch-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.visible .scratch-path {
  animation: draw-scratch 0.8s ease-in-out forwards;
}

.scratch-1 .scratch-path {
  stroke: #c80080; /* Darker vibrant pink */
  stroke-width: 3px;
  animation-delay: 1.2s;
  opacity: 0.9;
}

.scratch-2 .scratch-path {
  stroke: #0088cc; /* Darker vibrant blue/cyan */
  stroke-width: 3px;
  animation-delay: 1.8s;
  opacity: 0.9;
}

[data-theme="dark"] .scratch-1 .scratch-path {
  stroke: #ff00ff; /* Neon Magenta */
}

[data-theme="dark"] .scratch-2 .scratch-path {
  stroke: #00ffff; /* Neon Cyan */
}

@keyframes draw-scratch {
  to {
    stroke-dashoffset: 0;
  }
}