/* ─── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --primary:       #4F46E5;
  --primary-dark:  #3730A3;
  --primary-light: #EEF2FF;
  --gray-50:   #F9FAFB;
  --gray-100:  #F3F4F6;
  --gray-200:  #E5E7EB;
  --gray-300:  #D1D5DB;
  --gray-400:  #9CA3AF;
  --gray-500:  #6B7280;
  --gray-600:  #4B5563;
  --gray-700:  #374151;
  --gray-800:  #1F2937;
  --gray-900:  #111827;
  --white:     #FFFFFF;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;

  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 24px rgba(0,0,0,.12);
  --shadow-xl: 0 20px 40px rgba(0,0,0,.14);

  --ease: cubic-bezier(.4,0,.2,1);
  --dur:  170ms;
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select { font-family: inherit; font-size: inherit; }
a { color: inherit; text-decoration: none; }

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
.container { max-width: 1160px; margin: 0 auto; padding: 0 24px; }

/* ─── Nav ────────────────────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 200;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--gray-200);
}
.nav__inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 58px; gap: 24px;
}
.nav__logo {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 1rem; color: var(--gray-900); white-space: nowrap;
}
.nav__logo-icon {
  flex-shrink: 0;
  display: block;
  transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.nav__logo:hover .nav__logo-icon {
  transform: translateY(-1px) scale(1.06);
  filter: drop-shadow(0 3px 6px rgba(79,70,229,.35));
}
.footer__brand svg { flex-shrink: 0; opacity: .9; }
.nav__links { list-style: none; display: flex; gap: 28px; }
.nav__link {
  font-size: 0.875rem; font-weight: 500; color: var(--gray-500);
  transition: color var(--dur) var(--ease);
}
.nav__link:hover, .nav__link.active { color: var(--primary); }

/* ─── Page header ────────────────────────────────────────────────────────────── */
.page-header {
  background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
  padding: 36px 0 32px;
  border-bottom: 1px solid #C7D2FE;
}
.page-header__title {
  font-size: 1.75rem; font-weight: 800; color: var(--gray-900);
  letter-spacing: -.02em; margin-bottom: 6px;
}
.page-header__sub { font-size: 0.9rem; color: var(--gray-600); max-width: 560px; }

/* ─── Section ────────────────────────────────────────────────────────────────── */
.section { padding: 64px 0; }
.section--generator { padding: 32px 0 48px; }
.section--gray { background: var(--white); }
.section__title {
  font-size: 1.5rem; font-weight: 800; text-align: center;
  color: var(--gray-900); letter-spacing: -.02em; margin-bottom: 8px;
}
.section__subtitle { text-align: center; color: var(--gray-500); font-size: 0.9rem; margin-bottom: 36px; }

/* ═══════════════════════════════════════════════════════════════════════════════
   GENERATOR PANEL
═══════════════════════════════════════════════════════════════════════════════ */
.gen-panel {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  min-height: 600px;
}

/* ── Left sidebar: type list ─────────────────────────────────────────────────── */
.gen-sidebar {
  border-right: 1.5px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  background: var(--gray-50);
  overflow-y: auto;
}
.gen-sidebar__label {
  padding: 16px 16px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--gray-400);
}
.gen-type-list { list-style: none; flex: 1; }
.gen-type-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  outline: none;
}
.gen-type-item:hover { background: var(--gray-100); }
.gen-type-item.active {
  background: var(--primary-light);
  border-left-color: var(--type-color, var(--primary));
}
.gen-type-item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--primary);
}
.gen-type-item__icon { font-size: 1.25rem; line-height: 1; flex-shrink: 0; margin-top: 1px; }
.gen-type-item__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.gen-type-item__name { font-size: 0.85rem; font-weight: 600; color: var(--gray-800); }
.gen-type-item.active .gen-type-item__name { color: var(--primary); }
.gen-type-item__desc { font-size: 0.72rem; color: var(--gray-400); line-height: 1.35; }

/* ── Right: form + output ────────────────────────────────────────────────────── */
.gen-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gen-form-area {
  padding: 28px 32px 0;
}

.gen-form-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.gen-type-tag {
  display: inline-flex;
  align-items: center;
  background: var(--tag-color, var(--primary));
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 999px;
}
.gen-form-hint {
  font-size: 0.82rem;
  color: var(--gray-400);
}

/* ── Form grid ───────────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group--full { grid-column: 1 / -1; }
.form-group label { font-size: 0.8rem; font-weight: 600; color: var(--gray-700); }
.form-group input, .form-group select {
  padding: 9px 13px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--gray-900);
  background: white;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  width: 100%;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-group input::placeholder { color: var(--gray-400); }
.checkbox-label {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 0.875rem; color: var(--gray-700); padding: 4px 0;
}
.checkbox-label input[type="checkbox"] {
  width: 17px; height: 17px; flex-shrink: 0;
  accent-color: var(--primary); cursor: pointer;
}
.req { color: var(--primary); font-weight: 700; }
.opt { font-weight: 400; color: var(--gray-400); font-size: 0.76rem; }
.form-divider { height: 1px; background: var(--gray-100); margin: 14px 0 2px; }

.gen-submit-row {
  padding: 20px 0 24px;
}
.btn--generate {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  justify-content: center;
}

/* ── Output ──────────────────────────────────────────────────────────────────── */
.gen-output {
  border-top: 1.5px solid var(--gray-200);
  padding: 24px 32px 28px;
  background: var(--gray-50);
}
.gen-output__divider {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.gen-output__divider span {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--gray-400); white-space: nowrap;
}
.gen-output__divider::before, .gen-output__divider::after {
  content: ''; flex: 1; height: 1px; background: var(--gray-200);
}
.gen-output__toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.output-type-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--badge-color, var(--primary));
  color: white; font-size: 0.76rem; font-weight: 700;
  padding: 4px 13px; border-radius: 999px;
}
.output-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.gen-output__box {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  background: white;
}
.gen-output__content {
  padding: 22px 26px;
  font-size: 0.86rem;
  line-height: 1.85;
  white-space: pre-wrap;
  color: var(--gray-800);
  min-height: 200px;
  max-height: 500px;
  overflow-y: auto;
  outline: none;
  font-family: 'Georgia', 'Times New Roman', serif;
}
.gen-output__content.editing {
  background: #FFFDE7;
  box-shadow: inset 0 0 0 2px var(--primary);
}
.gen-output__footer {
  margin-top: 10px;
  text-align: right;
}
.output-note { font-size: 0.76rem; color: var(--gray-400); }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 5px; padding: 9px 18px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.875rem; line-height: 1;
  transition: all var(--dur) var(--ease); white-space: nowrap; cursor: pointer;
}
.btn--primary {
  background: var(--primary); color: white; border: 1.5px solid var(--primary);
}
.btn--primary:hover {
  background: var(--primary-dark); border-color: var(--primary-dark);
  transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,70,229,.3);
}
.btn--primary:active { transform: translateY(0); box-shadow: none; }
.btn--secondary {
  background: var(--gray-100); color: var(--gray-800); border: 1.5px solid var(--gray-200);
}
.btn--secondary:hover { background: var(--gray-200); }
.btn--outline {
  background: transparent; color: var(--gray-600); border: 1.5px solid var(--gray-300);
}
.btn--outline:hover { background: var(--gray-100); color: var(--gray-900); }
.btn--sm { padding: 6px 12px; font-size: 0.78rem; border-radius: 6px; }

/* ─── Filter tabs ────────────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 28px; justify-content: center;
}
.filter-tab {
  padding: 6px 15px; border-radius: 999px; font-size: 0.82rem; font-weight: 500;
  border: 1.5px solid var(--gray-200); color: var(--gray-600); background: white;
  transition: all var(--dur) var(--ease);
}
.filter-tab:hover { border-color: var(--primary); color: var(--primary); }
.filter-tab.active {
  background: var(--primary); color: white; border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(79,70,229,.25);
}

/* ─── Template grid ──────────────────────────────────────────────────────────── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.template-card {
  background: white; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  display: flex; flex-direction: column;
}
.template-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.template-card__header {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px;
  background: var(--type-color, var(--primary));
}
.template-card__icon { font-size: 1.3rem; line-height: 1; }
.template-card__badge {
  font-size: 0.7rem; font-weight: 700; color: rgba(255,255,255,.9);
  text-transform: uppercase; letter-spacing: .06em;
}
.template-card__body { padding: 18px; flex: 1; }
.template-card__title { font-size: 0.925rem; font-weight: 700; color: var(--gray-900); margin-bottom: 5px; }
.template-card__desc { font-size: 0.78rem; color: var(--gray-500); margin-bottom: 12px; }
.template-card__preview {
  font-size: 0.75rem; color: var(--gray-400); line-height: 1.6;
  border-top: 1px solid var(--gray-100); padding-top: 10px;
}
.template-card__footer {
  padding: 12px 18px; border-top: 1px solid var(--gray-100);
  display: flex; gap: 8px; background: var(--gray-50);
}
.no-results {
  grid-column: 1/-1; text-align: center; color: var(--gray-400);
  padding: 48px 0; font-size: 0.875rem;
}

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal__overlay {
  position: absolute; inset: 0;
  background: rgba(17,24,39,.5); backdrop-filter: blur(4px);
}
.modal__box {
  position: relative; z-index: 1; background: white;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  width: 100%; max-width: 760px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: modalIn .18s var(--ease) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.97) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal__header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--gray-200); gap: 14px;
}
.modal__meta { flex: 1; min-width: 0; }
.modal__type-badge {
  display: inline-block; background: var(--badge-color, var(--primary));
  color: white; font-size: 0.68rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; margin-bottom: 5px;
}
.modal__title { font-size: 1rem; font-weight: 700; color: var(--gray-900); }
.modal__close {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px; font-size: 0.9rem;
  color: var(--gray-500); transition: background var(--dur); flex-shrink: 0;
}
.modal__close:hover { background: var(--gray-100); color: var(--gray-900); }
.modal__actions {
  display: flex; gap: 8px; padding: 12px 22px;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50); flex-wrap: wrap; flex-shrink: 0;
}
.modal__content {
  padding: 24px 28px; font-size: 0.855rem; line-height: 1.85;
  white-space: pre-wrap; overflow-y: auto; flex: 1; outline: none;
  color: var(--gray-800); font-family: 'Georgia', 'Times New Roman', serif;
}
.modal__content.editing { background: #FFFDE7; }
.modal-open { overflow: hidden; }

/* ─── Screen-reader only ─────────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

/* ─── Guide lists (inside FAQ-style accordions) ──────────────────────────────── */
.guide-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding-left: 0;
}
.guide-list li {
  padding-left: 18px;
  position: relative;
  font-size: 0.875rem;
  color: var(--gray-600);
  line-height: 1.7;
}
.guide-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}
.guide-list--ordered { counter-reset: guide-counter; }
.guide-list--ordered li { counter-increment: guide-counter; }
.guide-list--ordered li::before {
  content: counter(guide-counter) '.';
  font-size: 0.8rem;
  font-weight: 700;
  top: 1px;
}
.guide-list code {
  background: var(--gray-100);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: 'Menlo', 'Consolas', monospace;
  color: var(--primary);
}

/* ─── FAQ ────────────────────────────────────────────────────────────────────── */
.faq__container { max-width: 720px; }
.faq-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.faq-item {
  border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  overflow: hidden; background: white;
  transition: border-color var(--dur) var(--ease);
}
.faq-item.open { border-color: var(--primary); }
.faq-q {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 14px 18px; text-align: left;
  font-size: 0.9rem; font-weight: 600; color: var(--gray-900); gap: 14px;
  transition: background var(--dur) var(--ease);
}
.faq-q:hover { background: var(--gray-50); }
.faq-icon { font-size: 1.2rem; color: var(--primary); transition: transform var(--dur) var(--ease); flex-shrink: 0; line-height: 1; }
.faq-a { max-height: 0; overflow: hidden; transition: max-height .28s var(--ease); }
.faq-a p { padding: 0 18px 16px; font-size: 0.875rem; color: var(--gray-600); line-height: 1.75; }
.faq-item.open .faq-a { max-height: 500px; }
.faq-item.open .faq-icon { transform: rotate(45deg); }

/* ─── Examples Section ───────────────────────────────────────────────────────── */
.how-to-box {
  background: var(--primary-light);
  border: 1.5px solid #C7D2FE;
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 48px;
}
.how-to-box h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 10px;
}
.how-to-box > p {
  font-size: 0.875rem;
  color: var(--gray-700);
  margin-bottom: 14px;
  line-height: 1.7;
}
.examples-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.example-group {
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.example-group:hover { border-color: #C7D2FE; box-shadow: var(--shadow); }
.example-group h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}
.example-group > p {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 14px;
  line-height: 1.6;
  flex: 1;
}
.example-snippet {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  position: relative;
}
.example-snippet pre {
  font-family: inherit;
  font-size: 0.775rem;
  color: var(--gray-700);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.65;
  margin: 0;
  padding-right: 76px;
}
.example-snippet__copy {
  position: absolute;
  top: 10px;
  right: 10px;
  flex-shrink: 0;
}
.example-group--wide {
  grid-column: 1 / -1;
}

@media (max-width: 768px) {
  .examples-grid { grid-template-columns: 1fr; }
  .how-to-box { padding: 20px; }
  .example-group--wide { grid-column: unset; }
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.footer { background: var(--gray-900); color: var(--gray-400); padding: 44px 0 28px; }
.footer__inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.footer__brand { display: flex; align-items: center; gap: 9px; color: white; font-weight: 700; font-size: 1rem; }
.footer__note { font-size: 0.78rem; max-width: 540px; line-height: 1.75; }
.footer__copy { font-size: 0.74rem; color: var(--gray-500); }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 22px; right: 22px;
  background: var(--gray-900); color: white;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 0.84rem; font-weight: 500; box-shadow: var(--shadow-lg);
  transform: translateY(10px); opacity: 0; pointer-events: none;
  transition: transform .2s var(--ease), opacity .2s var(--ease);
  z-index: 3000; border-left: 3px solid var(--primary);
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .gen-panel {
    grid-template-columns: 1fr;
  }
  .gen-sidebar {
    border-right: none;
    border-bottom: 1.5px solid var(--gray-200);
  }
  .gen-type-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }
  .gen-type-item {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 8px;
    border-left: none;
    border-bottom: 3px solid transparent;
    gap: 5px;
  }
  .gen-type-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--type-color, var(--primary));
  }
  .gen-type-item__desc { display: none; }
  .gen-sidebar__label { text-align: center; }
}

@media (max-width: 600px) {
  .gen-type-list { grid-template-columns: repeat(4, 1fr); }
  .gen-type-item__name { font-size: 0.7rem; }
  .gen-type-item__icon { font-size: 1.1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .gen-form-area { padding: 20px 18px 0; }
  .gen-output { padding: 20px 18px 22px; }
  .gen-output__toolbar { flex-direction: column; align-items: flex-start; }
  .filter-tabs { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .filter-tabs::-webkit-scrollbar { display: none; }
}

@media (max-width: 480px) {
  .gen-type-list { grid-template-columns: repeat(4, 1fr); }
  .template-grid { grid-template-columns: 1fr; }
  .nav__links { display: none; }
}
