:root {
  --bg-color: #f8fafc;
  --bg-surface: #ffffff;
  --bg-secondary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --wa-green: #25d366;
  --wa-green-hover: #1ebe5d;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.3);
}

html.dark {
  --bg-color: #0b1120;
  --bg-surface: #1e293b;
  --bg-secondary: #0f172a;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --accent-primary: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-glow: rgba(96, 165, 250, 0.5);
  --border-color: #334155;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
  --glass-bg: rgba(15, 23, 42, 0.8);
  --glass-border: rgba(255, 255, 255, 0.05);
}

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

html, body { width: 100%; overflow-x: clip; scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg-color);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
  line-height: 1.6;
}

/* HEADER */
header {
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 50;
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
  transition: all 0.4s ease;
}

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

.brand {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.brand span { color: var(--accent-primary); }

.nav-actions { display: flex; align-items: center; gap: 1.5rem; }

nav { display: flex; gap: 1.5rem; align-items: center; }

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  transition: color 0.3s ease;
}

nav a:hover { color: var(--accent-primary); }

.theme-toggle {
  background: var(--bg-secondary);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.theme-toggle:hover { background: var(--border-color); transform: scale(1.05); }

html.dark .icon-sun { display: block; }
html.dark .icon-moon { display: none; }
html:not(.dark) .icon-sun { display: none; }
html:not(.dark) .icon-moon { display: block; }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-primary);
  cursor: pointer;
}

@media(max-width:768px) {
  #nav-menu {
    position: absolute;
    top: 70px;
    right: 1.5rem;
    background: var(--bg-surface);
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    display: none;
    min-width: 200px;
    text-align: right;
  }
  #nav-menu.show { display: flex; animation: slideDown 0.3s ease forwards; }
  .menu-toggle { display: block; }
}

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

/* MAIN */
main { max-width: 900px; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }

@media(max-width:768px) { main { padding: 1.5rem 1rem 6rem; } }
@media(max-width:480px) { main { padding: 1.25rem 0.75rem 6rem; } }

/* BREADCRUMB */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  overflow: hidden;
  white-space: nowrap;
}

.breadcrumb a { color: var(--text-muted); text-decoration: none; transition: color 0.2s; flex-shrink: 0; }
.breadcrumb a:hover { color: var(--accent-primary); }
.breadcrumb .sep { flex-shrink: 0; }
.breadcrumb .bc-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

@media(max-width:480px) {
  .breadcrumb { font-size: 0.72rem; margin-bottom: 1rem; }
  .breadcrumb .bc-mid { display: none; }
  .breadcrumb .sep-mid { display: none; }
}

/* PAGE HERO */
.page-hero { text-align: center; margin-bottom: 2rem; }

.page-hero h1 {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: 0.65rem;
}

.page-hero h1 .hl {
  background: linear-gradient(135deg, var(--accent-primary), #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline;
}

.page-hero p { font-size: 0.9rem; color: var(--text-secondary); max-width: 560px; margin: 0 auto; line-height: 1.6; }

@media(max-width:480px) {
  .page-hero { margin-bottom: 1.25rem; }
  .page-hero p { font-size: 0.85rem; }
}

/* TOOL CARD */
.tool-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.tool-card-inner { padding: 2rem; }

@media(max-width:768px) {
  .tool-card { border-radius: 16px; }
  .tool-card-inner { padding: 1.25rem; }
}

@media(max-width:480px) {
  .tool-card { border-left: none; border-right: none; border-radius: 0; box-shadow: none; margin: 0 -0.75rem; }
  .tool-card-inner { padding: 1.25rem 1rem; }
}

/* SECTION LABEL */
.section-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media(max-width:480px) { .section-label { font-size: 0.72rem; } }

/* CATEGORY PILLS */
.category-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  padding-top: 0.1rem;
  scrollbar-width: none;
  margin-bottom: 1.25rem;
  -webkit-overflow-scrolling: touch;
}

.category-scroll::-webkit-scrollbar { display: none; }

.pill {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1.5px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.25s ease;
  min-height: 38px;
}

.pill:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.pill.active { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); box-shadow: 0 4px 12px var(--accent-glow); }

@media(max-width:480px) { .pill { padding: 0.45rem 0.85rem; font-size: 0.78rem; min-height: 36px; } }

/* TEMPLATE GRID */
.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.25rem; }

@media(min-width:768px) { .template-grid { gap: 1rem; } }
@media(max-width:480px) { .template-grid { grid-template-columns: 1fr; gap: 0.6rem; } }

.template-item {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  padding: 0.875rem;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.template-item:hover { border-color: var(--accent-primary); background: var(--bg-surface); }
.template-item.selected { border-color: var(--accent-primary); background: var(--bg-surface); box-shadow: 0 0 0 3px var(--accent-glow); }

.template-item .t-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-right: 1.5rem;
}

.template-item .t-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.template-item .check {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-primary);
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.template-item.selected .check { display: flex; }

@media(max-width:480px) {
  .template-item { padding: 0.75rem; }
  .template-item .t-name { font-size: 0.8rem; }
  .template-item .t-preview { font-size: 0.72rem; }
}

/* DIVIDER */
.divider { height: 1px; background: var(--border-color); margin: 1.5rem 0; }

/* FORM */
.form-group { margin-bottom: 1rem; }

.form-group label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 0.35rem; }

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: all 0.25s ease;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent-primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group textarea { resize: vertical; min-height: 110px; line-height: 1.6; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.875rem; }

@media(max-width:600px) { .form-row { grid-template-columns: 1fr; gap: 0; } }

@media(max-width:480px) {
  .form-group input,
  .form-group textarea { font-size: 16px; padding: 0.65rem 0.875rem; }
}

/* PREVIEW BOX */
.preview-box {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  border: 1.5px solid #86efac;
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 0.5rem;
  position: relative;
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #86efac transparent;
}

.preview-box::-webkit-scrollbar { width: 4px; }
.preview-box::-webkit-scrollbar-thumb { background: #86efac; border-radius: 4px; }

html.dark .preview-box {
  background: linear-gradient(135deg, rgba(21, 128, 61, 0.18), rgba(22, 101, 52, 0.12));
  border-color: rgba(134, 239, 172, 0.25);
}

.preview-box .preview-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #15803d;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  position: sticky;
  top: 0;
  background: inherit;
}

html.dark .preview-box .preview-label { color: #4ade80; }
.preview-box .preview-label svg { flex-shrink: 0; }

.preview-text {
  font-size: 0.88rem;
  color: #1a2e1a;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

html.dark .preview-text { color: #d1fae5; }

@media(max-width:480px) {
  .preview-text { font-size: 0.83rem; }
  .preview-box { max-height: none; min-height: 180px; }
}

/* CHAR COUNT */
.char-count { font-size: 0.72rem; color: var(--text-muted); text-align: right; margin-top: 0.35rem; margin-bottom: 1rem; }
.char-count.warn { color: #f59e0b; }

/* ACTION BUTTONS */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.btn-copy,
.btn-wa {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.3s ease;
  text-decoration: none;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

.btn-copy { background: var(--bg-secondary); color: var(--text-primary); border: 1.5px solid var(--border-color); }
.btn-copy:hover { background: var(--border-color); transform: translateY(-2px); }
.btn-copy:active { transform: scale(0.97); }
.btn-copy.copied { background: #f0fdf4; color: #15803d; border-color: #86efac; }
html.dark .btn-copy.copied { background: rgba(21, 128, 61, 0.2); color: #4ade80; border-color: rgba(134, 239, 172, 0.3); }

.btn-wa { background: var(--wa-green); color: #fff; box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35); }
.btn-wa:hover { background: var(--wa-green-hover); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(37, 211, 102, 0.45); }
.btn-wa:active { transform: scale(0.97); }

/* STICKY ACTIONS on mobile */
@media(max-width:600px) {
  .actions-wrapper {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: 0.875rem 1rem;
    margin: 0 -1rem -1.25rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    z-index: 10;
  }
  html.dark .actions-wrapper { box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4); }
  .btn-copy, .btn-wa { font-size: 0.85rem; padding: 0.75rem 0.875rem; }
}

/* TIPS */
.tips-box {
  margin-top: 1.75rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.06), rgba(168, 85, 247, 0.06));
  border: 1px solid rgba(59, 130, 246, 0.18);
  border-radius: 14px;
  padding: 1.25rem;
}

.tips-box h3 { font-size: 0.85rem; font-weight: 700; color: var(--accent-primary); margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.4rem; }
.tips-box ul { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.tips-box ul li { font-size: 0.82rem; color: var(--text-secondary); display: flex; align-items: flex-start; gap: 0.5rem; line-height: 1.5; }
.tips-box ul li::before { content: "✓"; color: var(--accent-primary); font-weight: 700; flex-shrink: 0; margin-top: 0.05rem; }

@media(max-width:480px) {
  .tips-box { padding: 1rem; }
  .tips-box ul li { font-size: 0.78rem; }
}

/* FOOTER */
footer { background: var(--bg-surface); border-top: 1px solid var(--border-color); padding: 3rem 1.5rem 2rem; margin-top: 4rem; }

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 2.5rem;
  margin-bottom: 2rem;
}

.footer-about h3 { font-size: 1.25rem; font-weight: 800; margin-bottom: 0.75rem; }
.footer-about p, .footer-contact p { color: var(--text-secondary); line-height: 1.8; font-size: 14px; margin-bottom: 0.5rem; }
.footer-contact h4 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }
.footer-bottom { max-width: 1200px; margin: 0 auto; text-align: center; padding-top: 1.5rem; border-top: 1px solid var(--border-color); color: var(--text-muted); font-size: 14px; }

/* STARS */
#stars-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
  opacity: 0;
  transition: opacity 1s ease;
}

html.dark #stars-container { opacity: 1; }

.meteor {
  position: absolute;
  width: 2px;
  height: 80px;
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,1));
  transform-origin: top;
  filter: drop-shadow(0 0 6px rgba(255,255,255,1));
  border-radius: 50%;
  animation: meteor-fall linear infinite;
  opacity: 0;
}

@keyframes meteor-fall {
  0%   { transform: translateY(-100px) translateX(100px) rotate(45deg); opacity: 1; }
  100% { transform: translateY(100vh) translateX(-100vh) rotate(45deg); opacity: 0; }
}

/* =========================================
   SCROLL TO TOP ROCKET BUTTON
   ========================================= */
.scroll-top-btn {
  position: fixed;
  bottom: 100px;
  right: 32px;
  width: 50px;
  height: 50px;
  background-color: transparent;
  color: var(--accent-primary);
  border: none;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.8rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 999;
  padding: 0;
}

.scroll-top-btn.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-top-btn.launching {
  opacity: 0 !important;
  transform: translateY(-800px) scale(0.8) !important;
  transition: transform 0.6s cubic-bezier(0.55, 0.085, 0.68, 0.53), opacity 0.4s ease-in 0.2s !important;
  pointer-events: none;
}

.scroll-top-btn:hover {
  background-color: transparent;
  transform: translateY(-5px) scale(1.1);
  color: var(--accent-hover);
}

html.dark .scroll-top-btn {
  color: var(--accent-primary);
}

html.dark .scroll-top-btn:hover {
  color: var(--accent-hover);
}
