@media (max-width: 1023px) {
  .live-editor-page {
    padding-bottom: calc(108px + env(safe-area-inset-bottom, 0px));
  }

  .live-editor-page #preview-wrapper {
    width: 100%;
    max-width: 100%;
    display: block;
  }

  .live-editor-page #pdf-preview {
    width: 100%;
    min-height: auto;
    overflow: visible;
  }

  .live-editor-page .shadow-paper {
    border-radius: 16px;
  }

  .live-editor-page .live-footer {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .template-mobile-shell {
    width: 100%;
    min-height: 0;
    box-sizing: border-box;
    padding: 16px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
  }

  .template-mobile-accent {
    height: 4px;
    margin: -16px -16px 0;
    background: #0f172a;
    border-radius: 16px 16px 0 0;
  }

  .template-mobile-top {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .template-mobile-brand {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
  }

  .template-mobile-brand-copy {
    min-width: 0;
    flex: 1;
  }

  .template-mobile-logo {
    max-width: 108px;
    max-height: 42px;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .template-mobile-title {
    margin: 0;
    font-size: clamp(2rem, 12vw, 4rem);
    line-height: 0.92;
    letter-spacing: -0.05em;
    text-transform: uppercase;
    font-weight: 900;
    overflow-wrap: anywhere;
  }

  .template-mobile-from-name,
  .template-mobile-to-name {
    font-size: 1.15rem;
    line-height: 1.2;
    font-weight: 800;
    margin-bottom: 4px;
    overflow-wrap: anywhere;
  }

  .template-mobile-subline {
    font-size: 0.96rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .template-mobile-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .template-mobile-meta-card,
  .template-mobile-card {
    border: 1px solid #dbe2ea;
    border-radius: 14px;
    background: #ffffff;
  }

  .template-mobile-meta-card {
    padding: 10px 12px;
    min-width: 0;
  }

  .template-mobile-meta-card span {
    display: block;
    font-size: 0.66rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #64748b;
    margin-bottom: 6px;
  }

  .template-mobile-meta-card strong {
    display: block;
    font-size: clamp(0.95rem, 4.7vw, 1.35rem);
    line-height: 1.2;
    font-weight: 800;
    overflow-wrap: anywhere;
  }

  .template-mobile-card {
    padding: 14px;
  }

  .template-mobile-card-title {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    border-bottom: 2px solid currentColor;
    padding-bottom: 4px;
    margin-bottom: 10px;
  }

  .template-mobile-items-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 10px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid currentColor;
    font-size: 0.66rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.14em;
  }

  .template-mobile-items-head > div:not(:first-child) {
    text-align: right;
  }

  .template-mobile-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .template-mobile-totals-card {
    padding: 14px;
  }

  .template-mobile-total-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid currentColor;
    font-size: 1rem;
    font-weight: 700;
  }

  .template-mobile-total-row span:last-child {
    text-align: right;
    overflow-wrap: anywhere;
  }

  .template-mobile-total-final {
    border-bottom: 0;
    border-top: 2px solid currentColor;
    margin-top: 10px;
    padding-top: 12px;
    font-weight: 900;
  }

  .template-mobile-total-final span:first-child {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  .template-mobile-total-final span:last-child {
    font-size: clamp(2rem, 10vw, 3.25rem);
    line-height: 0.95;
  }

  .template-mobile-notes-body {
    min-height: 0;
  }

  .template-mobile-brandline {
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: inherit;
    opacity: 0.9;
  }

  .preview-mobile .preview-item-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid currentColor;
  }

  .preview-mobile .preview-item-row:last-of-type {
    border-bottom: 0;
  }

  .preview-mobile .preview-item-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
  }

  .preview-mobile .preview-item-desc {
    padding-right: 0;
    font-size: 1rem;
    line-height: 1.35;
  }

  .preview-mobile .preview-item-amt {
    width: auto;
    font-size: 1.15rem;
    line-height: 1.1;
    text-align: right;
    overflow-wrap: anywhere;
  }

  .preview-mobile .preview-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
  }

  .preview-mobile .preview-item-stat {
    display: flex;
    gap: 6px;
    align-items: baseline;
  }

  .preview-mobile .preview-item-stat-label {
    font-size: 0.66rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #64748b;
  }

  .preview-mobile .preview-item-qty,
  .preview-mobile .preview-item-rate {
    width: auto;
    text-align: left;
    font-size: 0.95rem;
  }

  .preview-mobile .live-add-item-row {
    padding-top: 10px;
  }

  .preview-mobile .live-add-item-btn {
    padding: 12px 0;
    border-radius: 10px;
    font-size: 0.78rem;
  }

  .tpl-mobile-minimal,
  .tpl-mobile-agency,
  .tpl-mobile-modern,
  .tpl-mobile-studio {
    color: #0f172a;
  }

  .tpl-mobile-agency .template-mobile-accent,
  .tpl-mobile-studio .template-mobile-accent {
    height: 6px;
    background: #000000;
  }

  .tpl-mobile-modern .template-mobile-meta-card,
  .tpl-mobile-modern .template-mobile-card {
    border-radius: 16px;
  }

  .tpl-mobile-editorial {
    font-family: "Times New Roman", Georgia, serif;
    color: #111827;
  }

  .tpl-mobile-editorial .template-mobile-top,
  .tpl-mobile-editorial .template-mobile-brandline,
  .tpl-mobile-editorial .template-mobile-notes-card {
    text-align: center;
  }

  .tpl-mobile-editorial .template-mobile-title {
    font-size: clamp(2.4rem, 13vw, 4.4rem);
  }

  .tpl-mobile-tech,
  .tpl-mobile-brutalist {
    font-family: "JetBrains Mono", "Courier New", Consolas, monospace;
    color: #0f172a;
  }

  .tpl-mobile-tech .template-mobile-accent {
    height: 8px;
  }

  .tpl-mobile-tech .template-mobile-card,
  .tpl-mobile-tech .template-mobile-meta-card {
    border-radius: 12px;
  }

  .tpl-mobile-midnight {
    background: #05070d;
    color: #ffffff;
  }

  .tpl-mobile-midnight .template-mobile-accent {
    background: #ffffff;
  }

  .tpl-mobile-midnight .template-mobile-meta-card,
  .tpl-mobile-midnight .template-mobile-card {
    background: #0b0d14;
    border-color: #232630;
  }

  .tpl-mobile-midnight .template-mobile-meta-card span,
  .tpl-mobile-midnight .preview-item-stat-label {
    color: #9ca3af;
  }

  .tpl-mobile-midnight .preview-item-row,
  .tpl-mobile-midnight .template-mobile-items-head,
  .tpl-mobile-midnight .template-mobile-total-row {
    border-color: #2a2f3a;
  }

  .tpl-mobile-midnight .live-add-item-btn {
    color: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.16);
  }

  .tpl-mobile-vintage {
    background: #fdfbf7;
    color: #3a3128;
    font-family: "Playfair Display", Georgia, serif;
  }

  .tpl-mobile-vintage .template-mobile-accent {
    background: #855e42;
  }

  .tpl-mobile-vintage .template-mobile-meta-card,
  .tpl-mobile-vintage .template-mobile-card {
    border-color: #d9cdbd;
    background: #fdfbf7;
  }

  .tpl-mobile-vintage .template-mobile-meta-card span,
  .tpl-mobile-vintage .preview-item-stat-label {
    color: #857566;
  }

  .tpl-mobile-vintage .preview-item-row,
  .tpl-mobile-vintage .template-mobile-items-head,
  .tpl-mobile-vintage .template-mobile-total-row {
    border-color: #d0c6b8;
  }

  .tpl-mobile-saas {
    background: #ffffff;
    color: #0f172a;
  }

  .tpl-mobile-saas .template-mobile-accent {
    background: linear-gradient(90deg, #7c3aed, #d946ef);
  }

  .tpl-mobile-saas .template-mobile-meta-card,
  .tpl-mobile-saas .template-mobile-card {
    border-color: #e2e8f0;
    border-radius: 18px;
  }

  .tpl-mobile-saas .template-mobile-total-final span:first-child {
    color: #7c3aed;
  }

  .tpl-mobile-saas .preview-item-row,
  .tpl-mobile-saas .template-mobile-items-head,
  .tpl-mobile-saas .template-mobile-total-row {
    border-color: #e2e8f0;
  }

  .tpl-mobile-brutalist .template-mobile-accent {
    height: 6px;
    background: #000000;
    border-radius: 0;
  }

  .tpl-mobile-brutalist .template-mobile-meta-card,
  .tpl-mobile-brutalist .template-mobile-card {
    border: 2px solid #000000;
    border-radius: 0;
    box-shadow: none;
  }

  .tpl-mobile-brutalist .template-mobile-items-head,
  .tpl-mobile-brutalist .preview-item-row,
  .tpl-mobile-brutalist .template-mobile-total-row {
    border-color: #000000;
    border-width: 2px;
  }

  .tpl-mobile-brutalist .template-mobile-total-final {
    background: #000000;
    color: #ffffff;
    margin: 12px -14px -14px;
    padding: 14px;
    border-top: 0;
  }
}
