:root {
  --primary: #2bc44e;
  --primary-dark: #22a340;
  --nav-bg: #2b3038;
  --bg-page: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --badge-bg: #f1f5f9;
  --badge-text: #334155;
}

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

body {
  font-family: "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Header & Top Navigation
   ========================================================================== */
.header {
  background: var(--nav-bg);
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.brand img {
  width: 34px;
  height: 34px;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.btn-nav-secondary {
  color: #e2e8f0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-nav-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

/* ==========================================================================
   Breadcrumbs
   ========================================================================== */
.breadcrumb-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
}

.breadcrumb-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.breadcrumb-container a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.breadcrumb-container a:hover {
  color: var(--text-main);
}

.breadcrumb-separator {
  color: #cbd5e1;
  font-size: 0.75rem;
}

.breadcrumb-current {
  color: var(--text-main);
  font-weight: 500;
}

/* ==========================================================================
   Index: Hero, Search & Filters
   ========================================================================== */
.hero {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 3.5rem 1.5rem 2.5rem;
  text-align: center;
}

.hero-container {
  max-width: 840px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  background: #eaf8ee;
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.75rem;
  line-height: 1.25;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.hero p:last-of-type {
  margin-bottom: 1.75rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.search-box {
  position: relative;
  width: 100%;
  max-width: 360px;
}

.search-box i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43, 196, 78, 0.15);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.chip {
  background: #f1f5f9;
  border: 1px solid transparent;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.chip:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.chip.active {
  background: var(--nav-bg);
  color: #fff;
}

/* ==========================================================================
   Index: Grid & Cards
   ========================================================================== */
.content {
  max-width: 1200px;
  width: 100%;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  flex: 1;
}

.grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.grid-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.results-count {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: right;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.75rem;
}

.template-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 4px 14px -3px rgba(15, 23, 42, 0.11), 0 2px 6px -2px rgba(15, 23, 42, 0.06);
}

.template-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 18px 34px -10px rgba(15, 23, 42, 0.16), 0 6px 14px -6px rgba(15, 23, 42, 0.08);
  border-color: #cbd5e1;
}

.card-thumb-link {
  display: block;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
}

.card-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 1.25rem;
  transition: transform 0.25s ease;
}

.template-card:hover .card-thumb {
  transform: scale(1.03);
}

.card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.badge-pill {
  font-size: 0.725rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  background: var(--badge-bg);
  color: var(--badge-text);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  line-height: 1.35;
}

.card-title a {
  color: inherit;
  text-decoration: none;
}

.template-card:hover .card-title {
  color: var(--primary-dark);
}

.card-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.25rem;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: auto;
}

.btn-view {
  flex: 1;
  padding: 0.55rem 0.75rem;
  background: #f1f5f9;
  color: var(--text-main);
  border-radius: 6px;
  text-align: center;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s ease;
}

.btn-view:hover {
  background: #e2e8f0;
}

.btn-use {
  flex: 1.2;
  padding: 0.55rem 0.75rem;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  text-align: center;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: background 0.15s ease;
}

.btn-use:hover {
  background: var(--primary-dark);
  color: #fff;
}

.empty-state {
  display: none;
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* ==========================================================================
   Detail: Showcase Layout & Components
   ========================================================================== */
.main-content {
  max-width: 1200px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1.5rem;
  flex: 1;
}

.showcase-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2.5rem;
  align-items: start;
  margin-bottom: 3.5rem;
}

.preview-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 84px;
}

.diagram-img {
  width: 100%;
  height: auto;
  max-height: 500px;
  object-fit: contain;
  display: block;
}

.preview-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(43, 196, 78, 0.1);
  color: var(--primary-dark);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
}

.info-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.curriculum-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.curriculum-badge {
  background: #eaf8ee;
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
}

.experiment-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.experiment-description {
  font-size: 1.05rem;
  line-height: 1.65;
  color: #334155;
}

.experiment-description p {
  margin-bottom: 0.85rem;
}

.experiment-description p:last-child,
.experiment-description ul:last-child,
.experiment-description ol:last-child {
  margin-bottom: 0;
}

.experiment-description ul,
.experiment-description ol {
  margin: 0.5rem 0 0.85rem 1.4rem;
}

.experiment-description li {
  margin-bottom: 0.35rem;
}

.cta-card {
  background: #ffffff;
  border: 1px solid #dcfce7;
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 12px rgba(43, 196, 78, 0.08);
}

.cta-card h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #14532d;
}

.cta-card p {
  font-size: 0.9rem;
  color: #475569;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.btn-cta-large {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: var(--primary);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.85rem 1.75rem;
  border-radius: 8px;
  text-decoration: none;
  width: 100%;
  transition: background 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(43, 196, 78, 0.25);
}

.btn-cta-large:hover {
  background: var(--primary-dark);
  color: #ffffff;
  transform: translateY(-1px);
}

.meta-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  font-size: 0.9rem;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.meta-row:last-child {
  border-bottom: none;
}

.meta-label {
  color: var(--text-muted);
}

.meta-value {
  font-weight: 500;
  color: var(--text-main);
}

/* ==========================================================================
   Detail: Related Templates Section
   ========================================================================== */
.related-section {
  border-top: 1px solid var(--border);
  padding-top: 3rem;
}

.related-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

.related-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}

.related-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -6px rgba(0, 0, 0, 0.08);
  border-color: #cbd5e1;
}

.related-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: contain;
  background: #ffffff;
  padding: 1rem;
}

.related-card-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.related-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  line-height: 1.35;
}

.related-card-curriculum {
  font-size: 0.775rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  background: var(--nav-bg);
  color: #94a3b8;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2.5rem 1.5rem;
  margin-top: 4rem;
  font-size: 0.9rem;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  color: #cbd5e1;
  text-decoration: none;
}

.footer-links a:hover {
  color: #fff;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 860px) {
  .showcase-layout {
    grid-template-columns: 1fr;
  }
  .preview-card {
    position: static;
  }
}

@media (max-width: 640px) {
  .hero h1 {
    font-size: 1.75rem;
  }
  .controls {
    flex-direction: column;
  }
  .search-box {
    max-width: 100%;
  }
  .templates-grid {
    grid-template-columns: 1fr;
  }
}
