﻿@media (max-width: 1024px) {
  .landing-hero,
  .hero-preview-card,
  .preview-content,
  .auth-shell,
  .account-history-grid,
  .template-detail-grid,
  .two-col-grid,
  .three-col-grid,
  .template-showcase-grid,
  .benefits-grid,
  .stats-strip,
  .footer-columns,
  .site-footer {
    grid-template-columns: 1fr;
  }

  .cta-inline,
  .cta-banner,
  .showcase-header,
  .payment-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .site-footer {
    padding: 1.4rem;
  }

  .download-group__grid,
  .template-download-grid,
  .template-method-grid {
    grid-template-columns: 1fr;
  }

  .template-catalog-grid,
  .template-entity-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .template-detail-hero {
    grid-template-columns: minmax(0, 1fr) 240px;
  }

  .template-overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.7rem;
    width: 100%;
    padding: 0.75rem 0.85rem;
    overflow: visible;
  }

  .brand-link {
    min-width: 0;
  }

  .brand-logo {
    width: min(180px, 100%);
  }

  .account-stats {
    grid-template-columns: 1fr;
  }

  .site-nav-toggle {
    display: inline-flex;
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    justify-self: end;
  }

  .main-nav {
    grid-column: 1 / -1;
    display: none;
    width: 100%;
    margin-left: 0;
    padding: 0.75rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    border-radius: 1rem;
    background: rgba(4, 18, 56, 0.5);
  }

  .main-nav.is-open {
    display: flex;
  }

  .main-nav a {
    width: 100%;
    padding: 0.78rem 0.9rem;
  }

  .page-shell {
    width: 100%;
    min-width: 0;
    padding: 1rem 0.85rem 2rem;
  }

  .page-shell > *,
  .page-hero,
  .page-section,
  .faq-layout,
  .faq-layout > *,
  .faq-sidebar,
  .faq-accordion,
  .experience-panel,
  .section-heading-inline,
  .stat-pills {
    min-width: 0;
    max-width: 100%;
  }

  .page-hero h1,
  .page-hero p,
  .section-heading-inline h2,
  .stat-pills span,
  .faq-question,
  .faq-answer {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .hero-card,
  .content-card,
  .page-header,
  .support-form,
  .page-hero,
  .auth-card,
  .info-card {
    border-radius: 18px;
  }

  .header-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto minmax(0, 0.9fr) minmax(0, 1.15fr);
    gap: 0.45rem;
    width: 100%;
    margin-left: 0;
    align-items: stretch;
  }

  .header-actions .button,
  .header-actions .ghost-button,
  .header-actions .account-button {
    min-width: 0;
    min-height: 2.65rem;
    padding: 0.55rem 0.4rem;
    font-size: 0.76rem;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .site-language-switcher {
    order: -1;
    min-width: 0;
  }

  .hero-actions.stacked-actions {
    grid-template-columns: 1fr;
  }

  .hero-mini-gallery,
  .template-detail-facts {
    grid-template-columns: 1fr;
  }

  .template-catalog-hero,
  .template-detail-hero,
  .template-catalog-toolbar,
  .template-catalog-grid,
  .template-entity-map,
  .template-relations-layout,
  .template-overview-grid {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .template-catalog-hero > *,
  .template-detail-hero > *,
  .template-catalog-grid > *,
  .template-entity-map > *,
  .template-relations-layout > *,
  .template-overview-grid > * {
    min-width: 0;
  }

  .template-hero-visual,
  .template-detail-visual {
    display: none;
  }

  .template-catalog-toolbar {
    align-items: stretch;
  }

  .template-result-count {
    min-width: 0;
  }

  .template-card-actions {
    grid-template-columns: 1fr;
  }

  .template-detail-copy h1 {
    font-size: 2rem;
    overflow-wrap: anywhere;
  }

  .template-section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .template-file-card {
    grid-template-columns: auto 1fr;
  }

  .template-file-card .button {
    grid-column: 1 / -1;
    width: 100%;
    text-align: center;
  }

  .template-data-dialog {
    padding: 0;
    place-items: end center;
  }

  .template-data-dialog__panel {
    width: 100%;
    max-height: 94dvh;
    padding: 1rem;
    border-radius: 1.25rem 1.25rem 0 0;
  }

  .template-data-dialog__header p {
    font-size: 0.86rem;
  }

  .template-data-toolbar,
  .template-data-dialog__footer {
    align-items: stretch;
    flex-direction: column;
  }

  .template-data-search {
    flex-basis: auto;
  }

  .template-data-counter {
    white-space: normal;
  }

  .template-data-dialog__footer .button {
    width: 100%;
  }

  .template-data-table th,
  .template-data-table td {
    max-width: 230px;
  }

  .template-card-heading h2,
  .template-card-description,
  .template-card-context span,
  .template-section-heading p,
  .template-file-card h3 {
    overflow-wrap: anywhere;
  }
}

@media (max-width: 520px) {
  .header-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-language-switcher {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .header-actions .button,
  .header-actions .ghost-button,
  .header-actions .account-button {
    width: 100%;
  }

  .page-hero h1 {
    font-size: clamp(1.8rem, 10vw, 2.35rem);
  }
}

@media (max-width: 390px) {
  .brand-logo {
    width: 165px;
  }

  .site-language-button {
    min-width: 1.9rem;
    padding-inline: 0.3rem;
  }

  .header-actions .button {
    font-size: 0.72rem;
  }

  .template-detail-hero,
  .template-catalog-hero,
  .content-card--template {
    padding: 1rem;
  }
}


/* SmartEDT mobile header: single fixed line with language switcher. */
@media (max-width: 720px) {
  .site-header {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.45rem;
  }

  .brand-logo {
    width: min(138px, 100%);
  }

  .header-actions {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    width: auto;
    margin-left: 0;
    gap: 0;
    align-items: center;
    justify-content: center;
  }

  .header-actions .button,
  .header-actions .ghost-button,
  .header-actions .account-button,
  .header-actions .user-chip {
    display: none;
  }

  .site-language-switcher {
    order: 0;
    grid-column: auto;
    justify-self: auto;
    min-width: auto;
    padding: 0.16rem;
  }

  .site-language-button {
    min-width: 1.82rem;
    min-height: 2rem;
    padding: 0.2rem 0.28rem;
    font-size: 0.66rem;
  }

  .site-nav-toggle {
    grid-column: 3;
    grid-row: 1;
    width: 2.35rem;
    height: 2.35rem;
  }

  .main-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    max-height: calc(100vh - var(--site-header-offset, 74px) - 0.8rem);
    overflow-y: auto;
  }
}

@media (max-width: 520px) {
  .header-actions {
    grid-template-columns: none;
  }

  .site-language-switcher {
    grid-column: auto;
  }
}

@media (max-width: 390px) {
  .brand-logo {
    width: 122px;
  }
}
