:root {
  --bg: #F7F5F2;
  --surface: #FFFFFF;
  --surface-2: #F1EFEA;
  --border: #E2DDD5;
  --text: #18181B;
  --muted: #52525B;
  --brand: #991B1B;
  --brand-hover: #7F1D1D;
  --brand-soft: rgba(153, 27, 27, 0.09);
  --gold: #B45309;
  --ok: #047857;
  --ok-soft: rgba(4, 120, 87, 0.1);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0; gap: 16px;
}
.brand-link {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text); font-weight: 800; font-size: 18px;
}
.brand-link img { width: 32px; height: 32px; }
.offline-badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--ok-soft); color: var(--ok); border: 1px solid rgba(4,120,87,0.25);
}
.header-actions { display: flex; align-items: center; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font-weight: 700; font-size: 13.5px; cursor: pointer; text-decoration: none;
  font-family: inherit; transition: all 0.14s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-pro { background: #18181B; color: #FDE68A; border-color: #27272A; }
.btn-pro:hover { background: #27272A; }
.btn-pro.active { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Hero */
.hero { padding: 34px 0 22px; text-align: center; }
.hero h1 {
  font-size: clamp(26px, 3.8vw, 40px); font-weight: 800; line-height: 1.15;
  letter-spacing: -0.8px; max-width: 860px; margin: 0 auto 10px;
}
.hero h1 span { color: var(--brand); }
.hero p { font-size: 15.5px; color: var(--muted); max-width: 700px; margin: 0 auto; }

/* Workspace Grid */
.workspace {
  display: grid; grid-template-columns: 340px 1fr; gap: 18px;
  align-items: start; margin-bottom: 48px;
}
@media (max-width: 920px) {
  .workspace { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.panel-title {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--muted);
}

/* Dropzone */
.dropzone {
  border: 2px dashed #C7BFB2; border-radius: 10px; padding: 20px 14px;
  text-align: center; background: #FAF8F5; cursor: pointer; transition: all 0.15s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand); background: var(--brand-soft);
}
.dropzone strong { display: block; font-size: 14px; margin-bottom: 4px; }
.dropzone small { display: block; font-size: 11.5px; color: var(--muted); }
.sample-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.mini-btn {
  padding: 6px 8px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 11.5px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.mini-btn:hover { background: #E7E3DC; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between;
}
.pro-chip {
  font-size: 9.5px; font-weight: 800; padding: 1px 6px; border-radius: 4px;
  background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A;
}
.input, .select {
  width: 100%; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 13px; font-family: inherit; outline: none;
}
.input:focus, .select:focus { border-color: var(--brand); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.check-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; font-size: 12.5px; cursor: pointer;
}
.check-item-left { display: flex; align-items: center; gap: 7px; }
.check-item input { accent-color: var(--brand); width: 15px; height: 15px; }

.divider { border: none; border-top: 1px solid var(--border); }

/* Right Preview Pane */
.preview-shell {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
}
.preview-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: #FAF8F5;
}
.stats-pill { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stats-pill strong { color: var(--text); }
.export-btns { display: flex; flex-wrap: wrap; gap: 8px; }

.cap-banner {
  background: #FEF3C7; border-bottom: 1px solid #FDE68A; color: #78350F;
  padding: 10px 16px; font-size: 13px; display: none; align-items: center;
  justify-content: space-between; gap: 10px;
}
.cap-banner.show { display: flex; }

.sha-strip {
  padding: 7px 16px; background: #F1EFEA; border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.doc-canvas {
  padding: 26px 28px; min-height: 520px; max-height: 760px; overflow-y: auto;
  background: #FFFFFF; color: #111827;
}
.empty-preview {
  text-align: center; padding: 90px 24px; color: var(--muted);
}
.empty-preview h3 { font-size: 18px; color: var(--text); margin-bottom: 6px; }

/* Printable Document Styles */
.doc-header {
  border: 1.5px solid #18181B; padding: 16px 18px; margin-bottom: 18px; background: #FAF9F7;
}
.doc-header-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.doc-exhibit {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 0.8px;
  padding: 2px 8px; background: #991B1B; color: #fff; margin-bottom: 6px; text-transform: uppercase;
}
.doc-title { font-size: 19px; font-weight: 800; color: #111827; }
.doc-sub { font-size: 12px; color: #52525B; margin-top: 2px; }
.doc-meta-right { font-size: 12px; color: #27272A; text-align: right; line-height: 1.55; }
.doc-participants { font-size: 12px; border-top: 1px solid #D4D4D8; padding-top: 8px; color: #27272A; }

.court-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.court-table th {
  text-align: left; padding: 8px 10px; background: #18181B; color: #fff;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
}
.court-table td { padding: 8px 10px; border-bottom: 1px solid #E4E4E7; vertical-align: top; }
.court-table tr { break-inside: avoid; }
.court-table tr.row-sys td { background: #F4F4F5; color: #52525B; font-style: italic; }
.col-num { width: 64px; font-family: ui-monospace, monospace; font-size: 11px; color: #52525B; }
.bates-tag { font-size: 9.5px; font-weight: 700; color: #991B1B; margin-top: 2px; }
.col-time { width: 104px; font-family: ui-monospace, monospace; font-size: 11px; white-space: nowrap; }
.t-clock { color: #71717A; font-size: 10.5px; }
.col-sender { width: 155px; font-weight: 700; color: #18181B; }
.col-msg { word-break: break-word; }
.msg-flag {
  display: inline-block; font-size: 9.5px; font-weight: 700; padding: 1px 5px;
  border-radius: 3px; background: #FEF3C7; color: #92400E; margin-left: 6px;
}
.msg-attach { font-size: 11px; color: #1D4ED8; margin-top: 4px; font-weight: 600; }

/* Bubbles Layout */
.bubbles-wrap { display: flex; flex-direction: column; gap: 8px; }
.day-divider { text-align: center; margin: 10px 0 4px; }
.day-divider span {
  font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 999px;
  background: #F4F4F5; color: #52525B; border: 1px solid #E4E4E7;
}
.bubble-sys { text-align: center; font-size: 11.5px; color: #71717A; font-style: italic; padding: 4px; }
.bubble-row { display: flex; break-inside: avoid; }
.bubble-row.right { justify-content: flex-end; }
.bubble {
  max-width: 78%; padding: 9px 13px; border-radius: 10px;
  border: 1px solid #E4E4E7; background: #F9FAFB; font-size: 13px;
}
.bubble-row.right .bubble { background: #FEF2F2; border-color: #FECACA; }
.bubble-head { display: flex; justify-content: space-between; gap: 14px; font-size: 11px; margin-bottom: 4px; color: #52525B; }
.bubble-head strong { color: #18181B; }

/* Compact Layout */
.compact-wrap { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; line-height: 1.55; }
.compact-line { padding: 3px 0; border-bottom: 1px dotted #E4E4E7; break-inside: avoid; }
.c-idx { color: #71717A; }
.c-ts { color: #991B1B; margin: 0 5px; }
.c-att { color: #1D4ED8; }

/* Certificate of Integrity */
.cert-box {
  margin-top: 24px; padding: 16px 18px; border: 1.5px solid #18181B;
  background: #FAF9F7; break-inside: avoid;
}
.cert-title { font-size: 12px; font-weight: 800; letter-spacing: 0.7px; color: #991B1B; margin-bottom: 6px; }
.cert-note { font-size: 11.5px; color: #3F3F46; margin-bottom: 10px; }
.cert-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.cert-table th, .cert-table td { padding: 5px 8px; border: 1px solid #D4D4D8; text-align: left; }
.cert-table th { width: 185px; background: #F4F4F5; font-weight: 700; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; font-size: 10.5px; }

/* SEO Content & FAQ */
.seo-section { padding: 20px 0 56px; }
.seo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 36px; }
.seo-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.seo-card h3 { font-size: 16px; margin-bottom: 6px; }
.seo-card p { font-size: 13.5px; color: var(--muted); }
.faq-list { display: flex; flex-direction: column; gap: 12px; max-width: 820px; margin: 0 auto 36px; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.faq-item h4 { font-size: 15px; margin-bottom: 5px; }
.faq-item p { font-size: 13.5px; color: var(--muted); }

/* Footer */
.site-footer {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 28px 0 36px; font-size: 13px; color: var(--muted);
}
.footer-links { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-bottom: 14px; }
.footer-links a { color: var(--muted); text-decoration: none; font-weight: 500; }
.footer-links a:hover { color: var(--brand); }
.footer-bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* Pro Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.65);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 16px; max-width: 470px; width: 100%;
  padding: 24px; box-shadow: 0 24px 60px rgba(0,0,0,0.28);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal-price { font-size: 32px; font-weight: 800; color: var(--brand); margin: 6px 0; }
.modal-price small { font-size: 14px; color: var(--muted); font-weight: 600; }
.modal-list { list-style: none; margin: 12px 0 16px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.key-row { display: flex; gap: 8px; margin-top: 10px; }
.status-msg { font-size: 12.5px; margin-top: 6px; min-height: 18px; }
.status-msg.ok { color: var(--ok); font-weight: 600; }
.status-msg.err { color: #DC2626; font-weight: 600; }

/* =========================================================================
   COURT-GRADE PRINT / SAVE AS PDF STYLESHEET
   Strips all web chrome; outputs clean, searchable, paginated legal PDF!
   ========================================================================= */
@page {
  margin: 14mm 12mm;
}
@media print {
  body { background: #fff !important; color: #000 !important; }
  .site-header, .hero, .panel, .preview-bar, .cap-banner, .sha-strip,
  .seo-section, .site-footer, .modal-backdrop {
    display: none !important;
  }
  .wrap { max-width: 100% !important; padding: 0 !important; margin: 0 !important; }
  .workspace { display: block !important; margin: 0 !important; }
  .preview-shell { border: none !important; border-radius: 0 !important; overflow: visible !important; }
  .doc-canvas {
    padding: 0 !important; max-height: none !important; overflow: visible !important;
    min-height: auto !important;
  }
  .court-table thead { display: table-header-group; }
  .court-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-exhibit, .doc-header, .cert-box, .bubble {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
