/* ==========================================================================
   PHOSPHOR DESK — 3-Theme Retro-Modern Document Workbench
   Themes: CRT '96 (Default) · OFFICE (Daylight Editorial) · TURBO '96 (DOS Blue)
   ========================================================================== */
:root,
[data-theme="crt"] {
  --bg-main: #060e12;
  --bg-panel: #0b171d;
  --bg-card: #102129;
  --bg-input: #081318;
  --border: #1d3c47;
  --accent: #39ff88;
  --accent-2: #00e5ff;
  --warn: #ffcc4d;
  --danger: #ff5c77;
  --text-main: #e6f4f1;
  --text-muted: #93b5b2;
  --text-dim: #658684;
  --font-ui: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;
}

[data-theme="office"] {
  --bg-main: #f1f5f9;
  --bg-panel: #ffffff;
  --bg-card: #f8fafc;
  --bg-input: #ffffff;
  --border: #cbd5e1;
  --accent: #0f766e;
  --accent-2: #1d4ed8;
  --warn: #b45309;
  --danger: #dc2626;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
}

[data-theme="turbo"] {
  --bg-main: #00007a;
  --bg-panel: #0000a8;
  --bg-card: #00008c;
  --bg-input: #000060;
  --border: #e2e8f0;
  --accent: #ffff55;
  --accent-2: #55ffff;
  --warn: #ffaa00;
  --danger: #ff5555;
  --text-main: #ffffff;
  --text-muted: #cbd5ff;
  --text-dim: #9db2ff;
  --font-ui: 'Consolas', 'Courier New', monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.crt-scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0px,
    rgba(255, 255, 255, 0) 2px,
    rgba(0, 0, 0, 0.14) 3px
  );
  opacity: 0.45;
}
body.no-scanlines .crt-scanlines,
[data-theme="office"] .crt-scanlines { display: none; }

/* TOP BAR */
.topbar {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.brand-cluster { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-weight: 800; font-size: 12px;
  color: var(--bg-main);
  background: var(--accent);
  flex-shrink: 0;
}
.brand-title {
  font-family: var(--font-mono);
  font-weight: 800; font-size: 14px;
  letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 6px;
}
.ver-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--accent);
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.telemetry-cluster { display: flex; align-items: center; gap: 10px; }
.proof-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 999px;
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  cursor: pointer;
}
.proof-pill:hover { border-color: var(--accent); }
.proof-pill.offline-verified {
  border-color: #39ff88 !important;
  background: rgba(57, 255, 136, 0.18) !important;
  color: #39ff88 !important;
  box-shadow: 0 0 14px rgba(57, 255, 136, 0.35);
}
[data-theme="office"] .proof-pill.offline-verified {
  border-color: #059669 !important;
  background: #d1fae5 !important;
  color: #065f46 !important;
}
[data-theme="turbo"] .proof-pill.offline-verified {
  border-color: #ffff55 !important;
  background: #006600 !important;
  color: #ffff55 !important;
}

.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.lcd-strip {
  display: flex; gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
}
.lcd-cell { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.lcd-lbl { font-family: var(--font-mono); font-size: 9px; color: var(--text-dim); }
.lcd-val { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--accent-2); }

.controls-cluster { display: flex; align-items: center; gap: 6px; }
.theme-switch {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.theme-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  cursor: pointer;
}
.theme-btn.active { background: var(--accent); color: var(--bg-main); }
.icon-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
}
.icon-btn.muted { opacity: 0.45; }

/* APP SHELL */
.app-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-lbl {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 2px 6px 6px;
}

.tool-nav { display: flex; flex-direction: column; gap: 5px; }
.tool-tab {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--text-main);
  cursor: pointer;
}
.tool-tab:hover { background: var(--bg-card); border-color: var(--border); }
.tool-tab.active {
  background: var(--bg-card);
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.tab-ico { font-size: 18px; flex-shrink: 0; }
.tab-body { display: flex; flex-direction: column; min-width: 0; }
.tab-name { font-weight: 700; font-size: 13px; }
.tab-desc { font-size: 11px; color: var(--text-muted); }

.help-bay { margin-top: auto; }
.feedback-bay, .direct-bay {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}
.bay-header {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  color: var(--accent); margin-bottom: 5px;
}
.bay-tag {
  font-size: 9px; padding: 1px 5px;
  border: 1px solid var(--accent); border-radius: 4px;
}
.bay-copy { margin: 0 0 8px; font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }
.bay-btn {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.bay-btn:hover { border-color: var(--accent); color: var(--accent); }
.sister-links {
  display: flex; flex-wrap: wrap; gap: 5px;
  font-size: 11px; color: var(--text-dim);
}
.sister-links a { color: var(--accent-2); text-decoration: none; }
.sister-links a:hover { text-decoration: underline; }

/* WORKBENCH */
.workbench {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tool-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tool-view[hidden] { display: none !important; }

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 28px;
}

.section-head { margin-bottom: 14px; }
.section-head h2 { margin: 0 0 4px; font-size: 20px; }
.section-head p { margin: 0; font-size: 13px; color: var(--text-muted); }

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* TOOLBAR & BUTTONS */
.view-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.tb-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tb-btn, .cta-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 11px;
  font-size: 12px; font-weight: 700;
  cursor: pointer;
}
.tb-btn:hover, .cta-btn:hover { border-color: var(--accent); color: var(--accent); }
.tb-btn.primary, .cta-btn.primary {
  background: var(--accent);
  color: var(--bg-main);
  border-color: var(--accent);
}
.tb-btn.primary:hover, .cta-btn.primary:hover { filter: brightness(1.08); color: var(--bg-main); }
.tb-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.file-lbl { cursor: pointer; }

.tb-select, .tb-input {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 9px;
  font-size: 12px;
  font-family: var(--font-ui);
}
.tb-input { width: 185px; }

.seg-toggle {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
  gap: 3px;
}
.seg-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 700;
  cursor: pointer;
}
.seg-btn.active { background: var(--accent); color: var(--bg-main); }

/* VIEW 1: WRITER SPLIT */
.writer-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}
.writer-split.focus-mode {
  grid-template-columns: 1fr;
}
.writer-split.focus-mode .preview-pane { display: none; }
.writer-split.focus-mode .md-textarea {
  max-width: 780px;
  margin: 0 auto;
  width: 100%;
  font-size: 16px;
  line-height: 1.75;
}

.writer-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
}
.writer-pane:last-child { border-right: none; }
.pane-hdr {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; flex-wrap: wrap;
  padding: 7px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  color: var(--accent);
}
.pane-hdr-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pane-meta { color: var(--text-muted); font-weight: 400; }

.fmt-toggle-btn {
  background: var(--bg-input);
  color: var(--accent-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 9px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
}
.fmt-toggle-btn:hover,
.fmt-toggle-btn[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.fmt-dropdown {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--accent);
  padding: 10px 14px 12px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}
.fmt-dropdown[hidden] { display: none !important; }
.fmt-drop-hdr {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.05em; color: var(--accent); margin-bottom: 8px;
}
.fmt-close-btn {
  background: transparent; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 13px; padding: 0 4px;
}
.fmt-close-btn:hover { color: var(--accent); }
.fmt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 6px;
}
.fmt-chip {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 8px;
  color: var(--text-main);
  font-size: 11px;
  cursor: pointer;
  text-align: left;
}
.fmt-chip:hover { border-color: var(--accent); background: var(--bg-card); }
.fmt-chip code {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--accent);
  white-space: nowrap;
}
.fmt-chip span { color: var(--text-muted); font-size: 10.5px; white-space: nowrap; }
.fmt-drop-note {
  margin-top: 8px; font-size: 11px; color: var(--text-dim);
}

.local-stat-pill {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 10px;
}

.save-tip-banner {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-2);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.save-tip-banner strong { color: var(--text-main); }

.logo-row {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

.tb-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.md-textarea {
  flex: 1;
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.65;
  padding: 18px 20px;
}

.md-preview {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  line-height: 1.68;
  font-size: 15px;
}
.md-preview h1, .md-preview h2, .md-preview h3 { color: var(--accent); margin-top: 1.2em; margin-bottom: 0.4em; }
.md-preview h1 { margin-top: 0; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.md-preview code {
  font-family: var(--font-mono);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 4px; font-size: 0.9em;
}
.md-preview pre {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 6px; overflow-x: auto;
}
.md-preview pre code { border: none; background: transparent; padding: 0; }
.md-preview blockquote {
  border-left: 3px solid var(--accent-2);
  margin: 12px 0; padding: 6px 14px;
  background: var(--bg-card); color: var(--text-muted);
}
.md-preview a { color: var(--accent-2); }
.md-preview hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.md-preview .md-task-item { list-style: none; margin-left: -18px; }

/* SHARED CARDS & FORMS */
.card-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.form-grid.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-lbl {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11.5px; font-weight: 700; color: var(--text-muted);
}
.text-input, .code-textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 7px 9px;
  font-family: var(--font-ui);
  font-size: 12.5px;
}
.code-textarea { font-family: var(--font-mono); line-height: 1.5; resize: vertical; }
.text-input:focus, .code-textarea:focus { outline: none; border-color: var(--accent); }

.sub-hdr {
  margin: 12px 0 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--accent);
}

/* DOC SPLIT (INVOICE + RESUME) */
.doc-split {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.08fr);
  gap: 16px;
  align-items: start;
}

.items-editor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.inv-item-row {
  display: grid;
  grid-template-columns: 1fr 64px 86px 32px;
  gap: 6px;
  align-items: center;
}
.del-row-btn {
  height: 32px; width: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 5px; cursor: pointer;
}
.del-row-btn:hover { border-color: var(--danger); color: var(--danger); }

.stack-editor { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.sub-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}

/* CRISP PAPER PREVIEW STAGE (ALWAYS EDITORIAL WHITE PAPER!) */
.preview-col {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.preview-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--accent);
}
.paper-stage {
  padding: 16px;
  background: rgba(0, 0, 0, 0.22);
  overflow-x: auto;
}
[data-theme="office"] .paper-stage { background: #e2e8f0; }

.paper-sheet {
  position: relative;
  z-index: 110;
  background: #ffffff;
  color: #111827;
  padding: 32px 36px;
  border-radius: 4px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  min-height: 460px;
}

/* INVOICE PAPER STYLES */
.inv-top { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.inv-logo-img { max-height: 48px; max-width: 170px; object-fit: contain; display: block; margin-bottom: 8px; }
.inv-sender-name { font-size: 18px; font-weight: 800; color: #0f172a; margin-bottom: 4px; }
.inv-meta-lines { color: #475569; font-size: 12px; }
.inv-title-col { text-align: right; flex-shrink: 0; }
.inv-word { font-size: 26px; font-weight: 900; letter-spacing: 0.08em; color: #0f766e; margin-bottom: 8px; }
.inv-meta-tbl { margin-left: auto; border-collapse: collapse; font-size: 12px; }
.inv-meta-tbl td { padding: 2px 6px; color: #334155; white-space: nowrap; }
.inv-bill-to { margin-bottom: 20px; padding: 10px 14px; background: #f8fafc; border-left: 3px solid #0f766e; }
.inv-lbl { font-size: 10px; font-weight: 800; letter-spacing: 0.08em; color: #64748b; margin-bottom: 3px; }
.inv-client-name { font-size: 15px; font-weight: 700; color: #0f172a; }
.inv-items-tbl { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.inv-items-tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: #475569; border-bottom: 2px solid #0f172a; padding: 7px 6px;
}
.inv-items-tbl td { padding: 9px 6px; border-bottom: 1px solid #e2e8f0; }
.inv-items-tbl .num, .inv-totals-tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-items-tbl .empty-row { text-align: center; color: #94a3b8; padding: 18px; }
.inv-totals-wrap { display: flex; justify-content: flex-end; margin-bottom: 20px; }
.inv-totals-tbl { min-width: 240px; border-collapse: collapse; font-size: 13px; }
.inv-totals-tbl td { padding: 5px 8px; }
.inv-totals-tbl .grand-total td {
  border-top: 2px solid #0f172a;
  font-size: 15px; font-weight: 800; color: #0f172a; padding-top: 8px;
}
.inv-notes { border-top: 1px solid #e2e8f0; padding-top: 12px; font-size: 12px; color: #475569; }

/* RESUME PAPER STYLES */
.resume-sheet.res-serif { font-family: Georgia, 'Times New Roman', serif; }
.resume-sheet.res-sans { font-family: 'Segoe UI', Arial, sans-serif; }
.res-header { text-align: center; border-bottom: 2px solid #0f172a; padding-bottom: 10px; margin-bottom: 14px; }
.res-header h1 { margin: 0 0 3px; font-size: 24px; letter-spacing: 0.03em; color: #0f172a; }
.res-headline { font-size: 13.5px; font-weight: 600; color: #0f766e; margin-bottom: 4px; }
.res-contact { font-size: 11.5px; color: #475569; }
.res-sec { margin-bottom: 14px; }
.res-sec h2 {
  font-size: 11.5px; letter-spacing: 0.1em; color: #0f172a;
  border-bottom: 1px solid #cbd5e1; padding-bottom: 3px; margin: 0 0 8px;
}
.res-sec p { margin: 0; font-size: 12.5px; color: #1f2937; }
.res-item { margin-bottom: 10px; }
.res-item.compact { margin-bottom: 6px; }
.res-item-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: #0f172a; }
.res-dates { font-size: 11.5px; color: #475569; white-space: nowrap; }
.res-item-sub { font-size: 12px; font-style: italic; color: #475569; margin-bottom: 4px; }
.res-bullets { margin: 0; padding-left: 18px; font-size: 12.5px; color: #1f2937; }
.res-bullets li { margin-bottom: 3px; }
.res-skills-line { line-height: 1.6; }

/* DIFF & CLEANROOM */
.pane-lbl { font-family: var(--font-mono); font-size: 11px; color: var(--accent); letter-spacing: 0.05em; }
.diff-stats { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.diff-output {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  max-height: 360px;
  overflow-y: auto;
}
.diff-row {
  display: grid;
  grid-template-columns: 40px 40px 22px 1fr;
  padding: 2px 8px;
  white-space: pre-wrap;
  word-break: break-word;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.diff-row.add { background: rgba(57, 255, 136, 0.14); color: var(--text-main); }
.diff-row.del { background: rgba(255, 92, 119, 0.16); color: var(--text-main); }
[data-theme="office"] .diff-row.add { background: #dcfce7; }
[data-theme="office"] .diff-row.del { background: #fee2e2; }
.diff-ln { color: var(--text-dim); user-select: none; font-size: 11px; }
.diff-sig { font-weight: 800; user-select: none; }
.diff-row.add .diff-sig { color: var(--accent); }
.diff-row.del .diff-sig { color: var(--danger); }

.clean-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

/* STATUSBAR */
.statusbar {
  height: 30px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11px; color: var(--text-muted);
}
.status-left { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status-led { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.tiny-note { font-size: 11.5px; color: var(--text-dim); }

/* MODALS */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0, 0, 0, 0.68);
  display: grid; place-items: center;
  padding: 16px;
}
.modal-backdrop[hidden] { display: none !important; }
.modal-window {
  width: 100%; max-width: 540px; max-height: 90vh;
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}
.modal-window.wide { max-width: 720px; }
.modal-titlebar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--accent);
}
.modal-close {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer;
}
.modal-body { padding: 16px 18px; overflow-y: auto; font-size: 13px; line-height: 1.55; }
.modal-body a { color: var(--accent-2); }
.modal-foot { display: flex; justify-content: flex-end; margin-top: 14px; }

.audit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.audit-tile {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 11px;
}
.audit-tile.offline-ok { border-color: var(--accent); }
.audit-lbl { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }
.audit-val { font-family: var(--font-mono); font-size: 13px; font-weight: 700; }
.audit-val.ok { color: var(--accent); }
.audit-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.help-section { margin-bottom: 12px; }
.help-section h3 { margin: 0 0 4px; font-size: 14px; color: var(--accent); }
.help-section p { margin: 0; color: var(--text-muted); }

.toast {
  position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%);
  z-index: 500;
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

/* PRINT-ONLY DEDICATED PAPER OUTPUT */
.desk-print-mount { display: none; }

@media print {
  body.printing-desk > *:not(#deskPrintMount) { display: none !important; }
  body.printing-desk {
    background: #ffffff !important;
    color: #111827 !important;
    overflow: visible !important;
    height: auto !important;
  }
  body.printing-desk #deskPrintMount {
    display: block !important;
    background: #ffffff;
    color: #111827;
  }
  body.printing-desk .paper-sheet {
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    min-height: 0 !important;
  }
  body.printing-desk .print-md-doc {
    font-family: Georgia, 'Segoe UI', serif;
    font-size: 11pt;
    line-height: 1.6;
    color: #111827;
  }
  body.printing-desk .print-md-doc h1,
  body.printing-desk .print-md-doc h2,
  body.printing-desk .print-md-doc h3 {
    font-family: 'Segoe UI', Arial, sans-serif;
    color: #000000;
  }
  body.printing-desk .print-md-doc pre {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    padding: 10px 12px;
    font-family: Consolas, monospace;
    font-size: 9.5pt;
    white-space: pre-wrap;
  }
  body.printing-desk .print-md-doc blockquote {
    border-left: 3px solid #334155;
    padding-left: 12px;
    color: #334155;
  }
}

/* RESPONSIVE */
@media (max-width: 1180px) {
  .brand-sub, .lcd-strip { display: none; }
  .doc-split { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  body { overflow: auto; }
  .topbar { height: auto; padding: 8px 10px; flex-wrap: wrap; }
  .proof-pill { display: none; }
  .app-shell { flex-direction: column; overflow: visible; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 6px 8px;
  }
  .nav-section-lbl {
    grid-column: 1 / -1;
    padding: 0 4px 2px;
  }
  .tool-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }
  .tool-tab { padding: 7px 8px; gap: 7px; }
  .tool-tab:last-child { grid-column: 1 / -1; justify-content: center; }
  .tab-desc { display: none; }
  .help-bay, .feedback-bay, .direct-bay { display: none; }
  .writer-split { grid-template-columns: 1fr; min-height: 520px; }
  .md-textarea { min-height: 260px; }
  .two-col, .form-grid.two-col, .audit-grid { grid-template-columns: 1fr; }
  .inv-top { flex-direction: column; gap: 12px; }
  .inv-title-col { text-align: left; }
  .inv-meta-tbl { margin-left: 0; }
  .inv-item-row { grid-template-columns: 1fr 56px 76px 32px; }
  .paper-sheet { padding: 18px 16px; }
  .statusbar { display: none; }
}
