/**
 * Developed by Mohammad Rameez Imdad (Rameez Scripts)
 * WhatsApp: https://wa.me/923435347417 (For Custom Projects)
 * YouTube: https://www.youtube.com/@rameezimdad (Subscribe for more!)
 */
:root { --navy: #001f3f; --accent: #0074D9; --ink: #1f2937; --muted: #64748b; --line: #dbe3ee; --bg: #eef2f7; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, sans-serif; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.bar-name { font-weight: 700; color: var(--navy); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-name i { color: var(--accent); margin-right: 6px; }
.bar-acts { display: flex; gap: 8px; }
.bar button { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 4px; font: 600 14px Inter, sans-serif; cursor: pointer; touch-action: manipulation; }
.bar button:hover { background: #f4f7fb; }
.bar button.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.bar button.primary:hover { background: #00305f; }
.bar button.on { background: #e8f1fb; border-color: var(--accent); }

.stage { padding: 24px 12px 48px; display: flex; justify-content: center; align-items: flex-start; overflow: hidden; }
.sheet { width: 210mm; flex: 0 0 210mm; min-height: 297mm; background: #fff; box-shadow: 0 6px 24px rgba(0, 31, 63, .12); padding: 16mm 18mm 14mm; display: flex; flex-direction: column; transform-origin: top center; }

.lh-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.lh-brand { display: flex; align-items: center; gap: 14px; flex: none; }
.lh-logo { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.lh-name { white-space: nowrap; font-size: 26px; font-weight: 800; letter-spacing: 4px; color: var(--navy); line-height: 1.1; }
.lh-tag { margin-top: 4px; font-size: 12px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); }
.lh-contact { list-style: none; margin: 0; padding: 0; text-align: right; font-size: 11.5px; line-height: 1.75; color: var(--ink); }
.lh-contact i { width: 16px; text-align: center; margin-right: 6px; color: var(--accent); }
.lh-contact li { white-space: nowrap; }
.lh-rule { border: 0; height: 2px; background: var(--navy); margin: 12px 0 0; }

.lh-letter { flex: 1; display: flex; flex-direction: column; padding-top: 10mm; font-size: 13px; line-height: 1.7; }
.lh-meta { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8mm; }
.lh-to { white-space: pre-wrap; margin-bottom: 6mm; min-height: 1.7em; }
.lh-subj { margin-bottom: 6mm; }
.lh-body { white-space: pre-wrap; flex: 1; min-height: 200mm; }
.lh-sign { margin-top: 14mm; width: 60mm; }
.lh-sign-line { border-bottom: 1px solid var(--ink); height: 14mm; }
.lh-sign-name { margin-top: 4px; font-weight: 700; color: var(--navy); }
.lh-sign-role { font-size: 12px; color: var(--muted); }
[contenteditable] { outline: none; border-radius: 2px; }
[contenteditable]:focus { background: #f2f7fd; }
[contenteditable]:empty::before { content: attr(data-ph); color: #a0aec0; white-space: pre-wrap; }

.lh-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 10mm; padding-top: 8px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--muted); }

body.blank .lh-letter { visibility: hidden; }

@media (max-width: 768px) {
  .bar { padding: 8px 12px; }
  .bar button { min-height: 44px; padding: 0 12px; }
  .bar button span { display: none; }
  .stage { padding: 12px 0 32px; }
}
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff; }
  .bar { display: none; }
  .stage { padding: 0; display: block; }
  .sheet { box-shadow: none; transform: none !important; margin: 0; height: 297mm; min-height: 0; }
  [contenteditable]:empty::before { content: ''; }
  [contenteditable]:focus { background: none; }
}
a, a:hover, a:focus, u { text-decoration: none; }
