/* ═══════════ CSS Variables ═══════════ */
:root {
  --background: 240 25% 11%;
  --foreground: 220 20% 95%;
  --card: 240 22% 15%;
  --card-foreground: 220 20% 95%;
  --popover: 240 22% 15%;
  --popover-foreground: 220 20% 95%;
  --primary: 255 70% 60%;
  --primary-foreground: 0 0% 100%;
  --secondary: 240 20% 20%;
  --secondary-foreground: 220 20% 90%;
  --muted: 240 18% 22%;
  --muted-foreground: 240 12% 58%;
  --accent: 220 80% 58%;
  --accent-foreground: 0 0% 100%;
  --destructive: 0 75% 55%;
  --destructive-foreground: 0 0% 100%;
  --border: 240 18% 22%;
  --input: 240 18% 22%;
  --ring: 255 70% 60%;
  --radius: 0.75rem;
}

* { border-color: hsl(var(--border)); }

/* ═══════════ Utility classes ═══════════ */
.text-gradient-primary {
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-image: linear-gradient(135deg, hsl(245 80% 62%), hsl(270 70% 58%));
}

.bg-gradient-hero { background: transparent; }

.bg-gradient-card {
  background: linear-gradient(145deg, hsl(240 22% 16%) 0%, hsl(240 22% 13%) 100%);
}

.bg-gradient-primary {
  background: linear-gradient(135deg, hsl(245 80% 58%), hsl(270 70% 55%));
}

.shadow-glow {
  box-shadow: 0 0 40px hsl(255 70% 58% / 0.12), 0 0 80px hsl(255 70% 58% / 0.04);
}

.shadow-glow-sm {
  box-shadow: 0 0 20px hsl(255 70% 58% / 0.08);
}

.border-glow { border-color: hsl(255 70% 58% / 0.25); }

.bg-grid-pattern {
  background-image:
    linear-gradient(hsl(240 18% 24% / 0.4) 1px, transparent 1px),
    linear-gradient(90deg, hsl(240 18% 24% / 0.4) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* ═══════════ Buttons ═══════════ */
.btn-glow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--primary-foreground));
  background: linear-gradient(135deg, hsl(245 80% 58%), hsl(270 70% 55%));
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-glow:hover {
  box-shadow: 0 0 20px hsl(255 70% 58% / 0.3);
  filter: brightness(1.1);
}

.btn-glow-lg {
  padding: 0.75rem 2rem;
  font-size: 1rem;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-ghost:hover { background: hsl(var(--secondary)); }

.btn-outline-glow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  background: transparent;
  border: 1px solid hsl(255 70% 58% / 0.3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-outline-glow:hover {
  border-color: hsl(255 70% 58% / 0.5);
  background: hsl(255 70% 58% / 0.05);
  box-shadow: 0 0 15px hsl(255 70% 58% / 0.1);
}

.btn-outline-glow-lg {
  padding: 0.75rem 2rem;
  font-size: 1rem;
}

/* ═══════════ Animations ═══════════ */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-20px); }
}

@keyframes float-reverse {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(20px); }
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ping {
  75%, 100% { transform: scale(2); opacity: 0; }
}

.animate-float { animation: float 6s ease-in-out infinite; }
.animate-float-delayed { animation: float 6s ease-in-out 2s infinite; }
.animate-float-reverse { animation: float-reverse 5s ease-in-out infinite; }
.animate-pulse-glow { animation: pulse-glow 3s ease-in-out infinite; }
.animate-ping { animation: ping 1s cubic-bezier(0,0,0.2,1) infinite; }

/* Scroll-triggered animations */
.reveal {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  transition: opacity 0.5s ease, transform 0.5s ease;
  will-change: opacity, transform;
  backface-visibility: hidden;
}
.reveal.visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }
.reveal-delay-5 { transition-delay: 0.5s; }

/* Initial page load animation */
.hero-animate {
  animation: fadeInUp 0.6s ease forwards;
  opacity: 0;
}
.hero-animate-delay-1 { animation-delay: 0.1s; }
.hero-animate-delay-2 { animation-delay: 0.2s; }
.hero-animate-delay-3 { animation-delay: 0.3s; }
.hero-animate-delay-4 { animation-delay: 0.4s; }
.hero-animate-delay-5 { animation-delay: 0.5s; }

/* ═══════════ Chat widget ═══════════ */
#chat-btn {
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s ease;
}
#chat-btn.hiding {
  transform: scale(0) !important;
  opacity: 0 !important;
  pointer-events: none;
}

#chat-window {
  transform: translateY(20px) scale(0.92);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s ease;
  display: flex !important;
  visibility: hidden;
}
#chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* Chat internal transitions */
#chat-email-gate {
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#chat-email-gate.fade-out {
  opacity: 0;
  transform: translateY(-10px);
}
#chat-area {
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#chat-area.fade-in {
  animation: fadeInUp 0.3s ease forwards;
}

/* Chat messages animation */
#chat-messages > div {
  animation: chatMsgIn 0.3s ease forwards;
}
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════ Dialog / Modal ═══════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  visibility: hidden;
  transition: background 0.3s ease, backdrop-filter 0.3s ease, visibility 0s 0.3s;
}
.modal-overlay.open {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  visibility: visible;
  transition: background 0.3s ease, backdrop-filter 0.3s ease, visibility 0s 0s;
}
.modal-content {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 32rem;
  width: calc(100% - 2rem);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s ease;
}
.modal-overlay.open .modal-content {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* ═══════════ Form inputs ═══════════ */
.form-input {
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--border) / 0.6);
  background: hsl(var(--secondary) / 0.5);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}
.form-input::placeholder { color: hsl(var(--muted-foreground)); }

textarea.form-input { resize: vertical; min-height: 80px; }

/* ═══════════ Feature list active state ═══════════ */
.feature-btn {
  transition: all 0.3s;
  border: 1px solid transparent;
}
.feature-btn:hover { background: hsl(var(--secondary) / 0.5); border-color: hsl(var(--border) / 0.3); }
.feature-btn.active {
  background: hsl(var(--primary) / 0.1);
  border-color: hsl(var(--primary) / 0.25);
  box-shadow: 0 0 20px hsl(255 70% 58% / 0.08);
}

/* ═══════════ Tabs ═══════════ */
.tab-btn {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.75rem;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  cursor: pointer;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  position: relative;
}
.tab-btn:hover { color: hsl(var(--foreground)); background: hsl(var(--secondary) / 0.5); }
.tab-btn.active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: 0 4px 12px hsl(var(--primary) / 0.2);
  transform: scale(1.02);
}

/* Tab panel transitions */
[data-jd-panel] {
  animation: tabFadeIn 0.35s ease forwards;
}
@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════ Smooth page transitions ═══════════ */
.page-enter {
  animation: fadeInUp 0.4s ease forwards;
}

/* ═══════════ Accordion transitions ═══════════ */
[data-accordion-content] {
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease, padding 0.3s ease;
}
[data-accordion-content].collapsing {
  max-height: 0 !important;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}
.accordion-arrow {
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1) !important;
}

/* ═══════════ Mobile menu ═══════════ */
#mobile-menu {
  transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1), opacity 0.25s ease;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}
#mobile-menu.menu-open {
  max-height: 2000px;
  opacity: 1;
  overflow-y: auto;
}

/* ═══════════ Feature panel transition ═══════════ */
#feature-detail-panel {
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.4,0,0.2,1);
}

/* ═══════════ Feature tools tabs (Narzędzia SEO) ═══════════ */
.feature-tools-nav-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.feature-tools-pill {
  border: 1px solid hsl(var(--border) / 0.45);
  background: hsl(var(--secondary) / 0.35);
  color: hsl(var(--muted-foreground));
  border-radius: 9999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.77rem;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
  transition: all 0.2s ease;
}
.feature-tools-pill:hover {
  border-color: hsl(var(--primary) / 0.35);
  color: hsl(var(--foreground));
  background: hsl(var(--primary) / 0.08);
}
.feature-tools-pill.active {
  border-color: hsl(var(--primary) / 0.42);
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.14);
  box-shadow: 0 4px 16px hsl(var(--primary) / 0.16);
}
.feature-tools-nav-mobile .feature-tools-pill {
  font-size: 0.72rem;
  padding: 0.4rem 0.8rem;
}

/* ═══════════ Tutorial sidebar item ═══════════ */
[data-tutorial-id] {
  transition: all 0.2s ease;
}

/* ═══════════ Button hover micro-animations ═══════════ */
.btn-glow, .btn-outline-glow {
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}
.btn-glow:active, .btn-outline-glow:active {
  transform: scale(0.97);
}

/* ═══════════ Card hover ═══════════ */
.reveal a, .reveal [onclick] {
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* ═══════════ Scrollbar ═══════════ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: hsl(var(--background)); }
::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground) / 0.5); }

/* ═══════════ Modal animation ═══════════ */
.animate-in {
  animation: modalIn 0.25s cubic-bezier(0.4,0,0.2,1) forwards;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════ Pricing toggle ═══════════ */
.pricing-type-btn {
  color: hsl(var(--muted-foreground));
  background: transparent;
  border: none;
  cursor: pointer;
}
.pricing-type-btn:hover {
  color: hsl(var(--foreground));
}
.pricing-type-btn.active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: 0 2px 8px hsl(var(--primary) / 0.3);
}

/* ═══════════ Mobile fixes ═══════════ */
html { overflow-x: hidden; }

/* Prevent auth-menu flicker between page loads.
   State is set early in <head> via html.auth-state-user/auth-state-guest. */
html.auth-state-pending #auth-buttons-desktop,
html.auth-state-pending #auth-user-desktop,
html.auth-state-pending #auth-buttons-mobile,
html.auth-state-pending #auth-user-mobile { display: none !important; }
html:not(.auth-state-user):not(.auth-state-guest) #auth-buttons-desktop,
html:not(.auth-state-user):not(.auth-state-guest) #auth-user-desktop,
html:not(.auth-state-user):not(.auth-state-guest) #auth-buttons-mobile,
html:not(.auth-state-user):not(.auth-state-guest) #auth-user-mobile { display: none !important; }
@media (min-width: 1024px) {
  html.auth-state-user #auth-buttons-desktop { display: none !important; }
  html.auth-state-user #auth-user-desktop { display: flex !important; }
  html.auth-state-guest #auth-buttons-desktop { display: flex !important; }
  html.auth-state-guest #auth-user-desktop { display: none !important; }
}
html.auth-state-user #auth-buttons-mobile { display: none !important; }
html.auth-state-user #auth-user-mobile { display: flex !important; }
html.auth-state-guest #auth-buttons-mobile { display: flex !important; }
html.auth-state-guest #auth-user-mobile { display: none !important; }

/* Force-hide desktop auth elements below lg breakpoint.
   JS sets inline display:flex which overrides Tailwind hidden class. */
@media (max-width: 1023px) {
  #auth-buttons-desktop,
  #auth-user-desktop { display: none !important; }
}

/* Chat widget: full-screen on mobile */
@media (max-width: 639px) {
  #chat-window {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    display: flex !important;
    flex-direction: column !important;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    /* Disable scale transform — causes layout issues on full-screen */
    transform: translateY(100%) !important;
    transition: transform 0.3s ease, opacity 0.25s ease, visibility 0s 0.3s !important;
  }
  #chat-window.open {
    transform: translateY(0) !important;
    transition: transform 0.3s ease, opacity 0.25s ease, visibility 0s 0s !important;
  }
  #chat-window #chat-area {
    flex: 1 1 0% !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  #chat-window #chat-messages {
    flex: 1 1 0% !important;
    overflow-y: auto !important;
    min-height: 0 !important;
  }
  #chat-window #chat-send-form {
    flex-shrink: 0 !important;
  }
  #chat-btn {
    bottom: 1rem !important;
    right: 1rem !important;
    height: 3rem !important;
    width: 3rem !important;
  }
  #chat-btn svg { height: 1.25rem; width: 1.25rem; }
}

@media (max-width: 767px) {
  .container { padding-left: 1rem; padding-right: 1rem; }
  nav .container { padding-left: 0.75rem; padding-right: 0.75rem; }

  /* Pricing cards: single column, no scale transform */
  #cennik .grid { grid-template-columns: 1fr !important; }
  #cennik .grid > div { transform: none !important; }

  /* CTA pills wrap nicely */
  .flex-wrap { gap: 0.5rem; }

  /* Feature section: stack on mobile */
  .lg\:w-2\/5, .lg\:w-3\/5 { width: 100%; }

  /* Reduce large headings on very small screens */
  h1 { font-size: 2rem !important; line-height: 1.2 !important; }
  h2 { font-size: 1.75rem !important; }
}

@media (max-width: 767px) {
  /* Faster, less jarring reveal animations on mobile */
  .reveal {
    transform: translate3d(0, 14px, 0);
    transition: opacity 0.36s ease-out, transform 0.42s cubic-bezier(.22,1,.36,1);
  }
  .reveal-delay-1 { transition-delay: 0.05s; }
  .reveal-delay-2 { transition-delay: 0.1s; }
  .reveal-delay-3 { transition-delay: 0.15s; }
  .reveal-delay-4 { transition-delay: 0.2s; }
  .reveal-delay-5 { transition-delay: 0.25s; }

  /* Faster FAQ accordion on mobile */
  .faq-content {
    transition: max-height 0.25s cubic-bezier(.4,0,.2,1), opacity 0.2s !important;
  }
}

@media (max-width: 479px) {
  h1 { font-size: 1.75rem !important; }
  h2 { font-size: 1.5rem !important; }
  .btn-glow-lg, .btn-outline-glow-lg { padding: 0.625rem 1.5rem; font-size: 0.9rem; }
}

/* ═══════════ Sticky footer layout ═══════════ */
#page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
#page-wrapper > main,
#page-wrapper > .main-content-area {
  flex: 1 0 auto;
}
#page-wrapper > footer {
  flex-shrink: 0;
}

/* ═══════════ Cookie consent mobile full-height ═══════════ */
@media (max-width: 639px) {
  #cookie-consent-banner {
    position: fixed !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    border-radius: 1rem 1rem 0 0 !important;
    z-index: 90 !important;
  }
  #cookie-consent-banner #cookie-settings-view {
    max-height: calc(100vh - 2rem) !important;
    overflow-y: auto !important;
  }
  #cookie-consent-banner #cookie-settings-view .flex.flex-col.gap-3 {
    max-height: calc(100vh - 12rem) !important;
  }
  #cookie-consent-icon {
    bottom: 1rem !important;
    left: 1rem !important;
    height: 2.75rem !important;
    width: 2.75rem !important;
  }
}

/* ═══════════ Hero chart mobile — hide Y-axis label via CSS ═══════════ */

/* ═══════════ Feature mobile accordion ═══════════ */
.feature-mobile-content {
  max-height: 0;
  overflow: hidden;
  overflow-anchor: none;
  opacity: 0;
  transition: max-height 0.4s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease;
}
.feature-mobile-content.open {
  opacity: 1;
}

/* ═══════════ Article content (blog) ═══════════ */
.article-content {
  font-size: 1.05rem;
  line-height: 1.9;
  color: hsl(var(--muted-foreground));
}
.article-content h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin: 2.5rem 0 1rem;
  line-height: 1.3;
}
.article-content h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin: 2rem 0 0.75rem;
  line-height: 1.35;
}
.article-content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin: 1.5rem 0 0.5rem;
}
.article-content p {
  margin: 0 0 1.25rem;
}
.article-content a {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-underline-offset: 2px;
}
.article-content a:hover {
  opacity: 0.85;
}
.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1.5rem 0;
  border: 1px solid hsl(var(--border));
}
.article-content ul, .article-content ol {
  padding-left: 1.5rem;
  margin: 0 0 1.25rem;
}
.article-content li {
  margin-bottom: 0.4rem;
}
.article-content blockquote {
  border-left: 3px solid hsl(var(--primary));
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: hsl(var(--primary) / 0.04);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: hsl(var(--muted-foreground));
}
.article-content strong, .article-content b {
  color: hsl(var(--foreground));
  font-weight: 600;
}
.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* =========== Legal documents =========== */
.legal-content {
  font-size: 1rem;
  line-height: 1.8;
  color: hsl(var(--muted-foreground));
}
.legal-content h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin: 2rem 0 0.85rem;
  line-height: 1.35;
}
.legal-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin: 1.5rem 0 0.65rem;
  line-height: 1.4;
}
.legal-content p {
  margin: 0 0 1rem;
}
.legal-content ul,
.legal-content ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}
.legal-content li {
  margin: 0.3rem 0;
}
.legal-content a {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-underline-offset: 2px;
}
.legal-content .legal-note {
  margin: 1.25rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid hsl(var(--border) / 0.6);
  border-radius: 0.75rem;
  background: hsl(var(--secondary) / 0.35);
}
.legal-content .legal-template {
  margin: 1.25rem 0 0;
  padding: 1rem;
  border: 1px dashed hsl(var(--border) / 0.8);
  border-radius: 0.75rem;
  background: hsl(var(--secondary) / 0.25);
  white-space: pre-line;
  color: hsl(var(--foreground));
}

/* Legal docs: numbering resets per legal paragraph section (each §) */
.legal-numbered p {
  position: relative;
  counter-increment: legal-item;
  padding-left: 2.1rem;
  max-width: 78ch;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}
.legal-numbered h2 + p,
.legal-numbered h3 + p {
  counter-reset: legal-item;
}
.legal-numbered p::before {
  content: counter(legal-item);
  position: absolute;
  left: 0.25rem;
  top: 0;
  font-weight: 700;
  color: hsl(var(--foreground));
}
.legal-numbered ul,
.legal-numbered ol {
  list-style: disc;
  max-width: 78ch;
  margin-left: auto;
  margin-right: auto;
  padding-left: 2.1rem;
  text-align: left;
}
.legal-numbered li {
  text-align: left;
}
.legal-numbered ol.legal-toc {
  list-style: none;
  max-width: 78ch;
  margin: 0 auto 1rem;
  padding-left: 0;
}
.legal-numbered ol.legal-toc li {
  position: relative;
  margin-bottom: 0.55rem;
  padding-left: 2.1rem;
  text-align: left;
}
.legal-numbered ol.legal-toc li::before {
  content: counter(list-item);
  position: absolute;
  left: 0.25rem;
  top: 0;
  font-weight: 700;
  color: hsl(var(--foreground));
}
@media (max-width: 767px) {
  .legal-content {
    font-size: 0.95rem;
  }
  .legal-content h2 {
    font-size: 1.2rem;
  }
}

/* ═══════════ Selection ═══════════ */
::selection {
  background: hsl(var(--primary) / 0.3);
  color: hsl(var(--foreground));
}
