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

/* ===== TOKENS ===== */
:root {
  --bg: #FAFAFA;
  --bg-card: #FFFFFF;
  --bg-preview: #F3F4F6;
  --text: #111827;
  --text-muted: #6B7280;
  --text-light: #9CA3AF;
  --accent: #0D9488;
  --accent-hover: #0F766E;
  --accent-light: #CCFBF1;
  --accent-subtle: #F0FDFA;
  --border: #E5E7EB;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover: 0 10px 25px rgba(0,0,0,0.08);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --max-w: 960px;
  --radius: 12px;
}

[data-theme="dark"] {
  --bg: #0F0F0F;
  --bg-card: #1A1A1A;
  --bg-preview: #222;
  --text: #E5E7EB;
  --text-muted: #9CA3AF;
  --text-light: #6B7280;
  --accent-light: rgba(13,148,136,0.15);
  --accent-subtle: rgba(13,148,136,0.06);
  --border: #2A2A2A;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-hover: 0 10px 25px rgba(0,0,0,0.4);
}

/* ===== BASE ===== */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }

/* ===== NAV ===== */
.nav {
  background: rgba(250,250,250,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
[data-theme="dark"] .nav { background: rgba(15,15,15,0.85); }
.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--accent);
}
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--accent); }

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.2s, border-color 0.2s;
  width: 32px;
  height: 32px;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ===== HERO ===== */
.hero {
  text-align: center;
  padding: 64px 24px 48px;
}
.hero-inner { max-width: 580px; margin: 0 auto; }
.hero h1 {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.15;
  margin-bottom: 12px;
}
.hero h1 span { color: var(--accent); }
.hero p {
  font-size: 17px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== CATEGORY PILLS ===== */
.categories {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: var(--max-w);
  margin: 0 auto 32px;
  padding: 0 24px;
}
.cat-pill {
  font-size: 13px;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.cat-pill:hover, .cat-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ===== TEMPLATE GRID ===== */
.grid {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 64px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: all 0.25s;
  display: flex;
  flex-direction: column;
}
a.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

/* ===== CARD PREVIEW ===== */
.card-preview {
  background: var(--bg-preview);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4/3;
  position: relative;
  overflow: hidden;
}
.card-preview .preview-doc {
  width: 70%;
  max-width: 140px;
  aspect-ratio: 8.5/11;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  padding: 12%;
  display: flex;
  flex-direction: column;
  gap: 8%;
}
[data-theme="dark"] .card-preview .preview-doc {
  background: #2A2A2A;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.preview-line {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.3;
}
.preview-line:first-child { width: 60%; opacity: 0.6; height: 6px; }
.preview-line:nth-child(2) { width: 100%; }
.preview-line:nth-child(3) { width: 85%; }
.preview-line:nth-child(4) { width: 70%; }
.preview-line:nth-child(5) { width: 90%; }

/* ===== CARD BODY ===== */
.card-body { padding: 18px 20px 20px; flex: 1; display: flex; flex-direction: column; }
.card-body h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}
.card-body p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}
.card-meta {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 99px;
  background: var(--accent-light);
  color: var(--accent);
}
.badge.format {
  background: var(--bg-preview);
  color: var(--text-light);
}

/* ===== TEMPLATE DETAIL PAGE ===== */
.template-header {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px 24px 0;
}
.breadcrumb {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 20px;
}
.breadcrumb a { color: var(--text-muted); transition: color 0.2s; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { margin: 0 6px; }

.template-detail {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 64px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 40px;
  align-items: start;
}
.template-preview-large {
  background: var(--bg-preview);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4/3;
}
.template-preview-large .preview-doc {
  width: 60%;
  max-width: 280px;
  aspect-ratio: 8.5/11;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  padding: 10%;
  display: flex;
  flex-direction: column;
  gap: 6%;
}
[data-theme="dark"] .template-preview-large .preview-doc {
  background: #2A2A2A;
}
.template-preview-large .preview-line {
  height: 6px;
  border-radius: 3px;
}
.template-preview-large .preview-line:first-child { height: 10px; }

.template-info h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  line-height: 1.2;
}
.template-info .desc {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 20px;
}
.template-info .format-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}
.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  width: 100%;
  justify-content: center;
}
.download-btn:hover { background: var(--accent-hover); }
.download-btn svg { width: 18px; height: 18px; }

/* ===== TEMPLATE CONTENT ===== */
.template-content {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 64px;
}
.template-content h2 {
  font-size: 22px;
  font-weight: 700;
  margin-top: 32px;
  margin-bottom: 12px;
}
.template-content h3 {
  font-size: 17px;
  font-weight: 700;
  margin-top: 24px;
  margin-bottom: 8px;
}
.template-content p {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 14px;
}
.template-content ul, .template-content ol {
  padding-left: 20px;
  margin-bottom: 14px;
}
.template-content li {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 4px;
}

/* ===== RELATED TEMPLATES ===== */
.related {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 64px;
}
.related h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ===== FAQ ===== */
.faq {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 64px;
}
.faq h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
}
.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}
.faq-item h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}
.faq-item p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== SUGGEST ===== */
.suggest {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 64px;
}
.suggest-inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
}
.suggest-inner h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}
.suggest-inner > p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.suggest-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 480px;
  margin: 0 auto;
}
.suggest-form textarea,
.suggest-form input {
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}
.suggest-form textarea:focus,
.suggest-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.suggest-btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}
.suggest-btn:hover { background: var(--accent-hover); }
.suggest-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.suggest-status {
  font-size: 13px;
  margin-top: 10px;
  min-height: 20px;
}
.suggest-status.success { color: var(--accent); }
.suggest-status.error { color: #EF4444; }

/* ===== FOOTER ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
  margin-top: auto;
}
.footer-inner { max-width: var(--max-w); margin: 0 auto; }
.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 10px;
}
.footer-links a { color: var(--text-muted); font-weight: 500; transition: color 0.2s; }
.footer-links a:hover { color: var(--accent); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .template-detail { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 32px; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
  .categories { justify-content: flex-start; }
}
