/* OPORD Business Plan Builder — VetsLearn v1.1 (Bone/Ink/Rust), IBM Plex, "field manual" register.
   Local variable NAMES are unchanged from the original dark theme; VALUES now reference the
   shared tokens in sd-tools.css (linked before this file). --accent and --warn are intentionally
   omitted here (same names as the shared tokens) so they inherit the token's values directly. */

:root {
  --bg: var(--bone);
  --bg-panel: var(--panel);
  --bg-input: var(--bone-deep);
  --border: var(--bone-line);
  --text: var(--ink);
  --text-dim: var(--ink-mute);
  --accent-dim: var(--accent-deep);
  --error: var(--bad);
  --font-sans: "IBM Plex Sans", -apple-system, Segoe UI, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --max-width: 860px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  overflow-x: hidden;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--bone);
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
  width: 100%;
}

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0 1.25rem;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0 0 0.35rem;
}
h1 { margin: 0 0 0.4rem; font-size: 1.5rem; font-family: var(--font-display); font-weight: 700; }
.subtitle { margin: 0; color: var(--text-dim); font-size: 0.95rem; max-width: 68ch; }

main { padding: 1.25rem 0 2.5rem; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.panel h2 { margin-top: 0; font-size: 1.05rem; font-family: var(--font-display); font-weight: 600; }
.section-hint { color: var(--text-dim); font-size: 0.85rem; margin-top: -0.5rem; }

/* --- Toolbar --- */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 0.75rem; }
.file-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.localstorage-notice { font-size: 0.82rem; color: var(--text-dim); margin: 0; }
.storage-warning, .import-error { color: var(--error); font-size: 0.85rem; margin: 0.5rem 0 0; }
.import-success { color: var(--accent); font-size: 0.85rem; margin: 0.5rem 0 0; }

/* --- Notices --- */
.opsec-notice {
  font-size: 0.85rem;
  color: var(--warn);
  border-left: 3px solid var(--warn);
  padding: 0.5rem 0.7rem;
  margin: 0;
  background: var(--panel);
}
.placeholder-help {
  font-size: 0.82rem;
  color: var(--text-dim);
  border-left: 3px solid var(--accent-dim);
  padding: 0.4rem 0.6rem;
  margin: 0.5rem 0;
  background: var(--panel);
}

/* --- Paragraph / field editor --- */
.para-block { margin-bottom: 1.75rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.para-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.para-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.6rem; margin: 0 0 1rem; }
.para-opord { font-family: var(--font-mono); font-size: 1.05rem; color: var(--accent); letter-spacing: 0.03em; }
.para-bank { font-size: 0.78rem; color: var(--text-dim); }

.field-editor { margin-bottom: 1.5rem; }
.field-editor:last-child { margin-bottom: 0; }
.field-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; margin-bottom: 0.3rem; }
.label-opord { font-weight: 600; font-size: 0.92rem; }
.label-bank { font-size: 0.76rem; color: var(--text-dim); }
.prompt-text { font-size: 0.86rem; color: var(--text-dim); margin: 0 0 0.5rem; max-width: 68ch; }

.field-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 0.55rem 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}
textarea.field-input { resize: vertical; font-family: var(--font-mono); font-size: 0.88rem; }

.word-counter { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-dim); text-align: right; margin: 0.25rem 0 0; }
.word-counter.over-limit { color: var(--error); }
.field-error { color: var(--error); font-size: 0.83rem; margin: 0.35rem 0 0; }

.examples-block { margin: 0.5rem 0; }
.examples-block summary { cursor: pointer; font-size: 0.83rem; color: var(--accent); }
.examples-list { margin-top: 0.5rem; }
.example-item {
  font-size: 0.85rem;
  color: var(--text-dim);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
  margin: 0 0 0.4rem;
}

/* --- List editor (milestones, startup costs, roles, advisors) --- */
.list-editor { margin-top: 0.5rem; }
.list-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem;
  margin-bottom: 0.6rem;
  background: var(--bg-input);
}
.list-row-col { flex: 1 1 160px; min-width: 0; }
.subfield-label { display: block; font-size: 0.76rem; color: var(--text-dim); margin-bottom: 0.25rem; }
.remove-row-btn, .add-row-btn { flex-shrink: 0; }

/* --- Cash-flow / table editor --- */
.table-scroll { overflow-x: auto; }
.cashflow-table, .plan-cashflow-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.cashflow-table th, .cashflow-table td,
.plan-cashflow-table th, .plan-cashflow-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  text-align: left;
}
.cashflow-table thead th, .plan-cashflow-table thead th { color: var(--accent); font-weight: 600; }
.row-label { white-space: nowrap; font-family: var(--font-mono); color: var(--text-dim); }
.cell-input { min-width: 90px; padding: 0.3rem 0.4rem; }

/* --- Buttons --- */
button {
  background: var(--accent);
  color: var(--bone);
  border: none;
  border-radius: 4px;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
button:disabled { background: var(--accent-dim); color: var(--bone); opacity: 0.6; cursor: not-allowed; }
button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}
button.secondary.danger { color: var(--error); border-color: var(--error); }

/* --- AI polish --- */
.polish-block { margin-top: 0.6rem; }
.status-note {
  font-size: 0.85rem;
  padding: 0.5rem 0.65rem;
  border-radius: 4px;
  background: var(--panel);
  color: var(--warn);
  margin: 0.5rem 0 0;
}
.polish-result { margin-top: 0.6rem; }
.critique-block, .rewrite-block {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.6rem;
  font-size: 0.88rem;
}
.critique-block h4, .rewrite-block h4 { margin: 0 0 0.5rem; font-size: 0.85rem; color: var(--accent); }
.rewrite-text { white-space: pre-wrap; }

/* --- Preview / plan document --- */
.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.tab-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px 4px 0 0;
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
}
.tab-btn.active { color: var(--accent); border-color: var(--accent-dim); background: var(--bg-input); }
.print-btn { margin-left: auto; }

.plan-view { }
.plan-doc { background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 1.25rem; }
.plan-section { margin-bottom: 1.5rem; }
.plan-section:last-child { margin-bottom: 0; }
.plan-section-heading {
  font-family: var(--font-mono);
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
  margin: 0 0 0.75rem;
}
.plan-field { margin-bottom: 0.9rem; }
.plan-field-heading { font-size: 0.88rem; margin: 0 0 0.3rem; }
.plan-field-text { margin: 0; white-space: pre-wrap; font-size: 0.92rem; }
.plan-field-empty { margin: 0; color: var(--text-dim); font-style: italic; font-size: 0.88rem; }
.plan-derived {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}
.derived-note { font-size: 0.8rem; color: var(--warn); margin: 0 0 0.4rem; }

/* --- Footer --- */
.site-footer { border-top: 1px solid var(--border); padding: 1.25rem 0 2rem; }
.site-footer p { font-size: 0.75rem; color: var(--text-dim); margin: 0 0 0.6rem; }

.loading-note, .error-msg { color: var(--text-dim); font-size: 0.9rem; }
.error-msg { color: var(--error); }

/* --- Mobile: usable at 375px, no horizontal scroll --- */
@media (max-width: 480px) {
  h1 { font-size: 1.25rem; }
  .panel { padding: 0.9rem; }
  .tabs { flex-direction: column; align-items: stretch; }
  .print-btn { margin-left: 0; }
  .list-row { flex-direction: column; align-items: stretch; }
}

/* --- Print (spec 13 R5): clean Letter-format document, no nav/toolbar,
   page-break-safe headings. Only the currently visible tab panel prints —
   the inactive one carries the `hidden` attribute (display:none), which is
   already excluded from print by default; .no-print covers everything
   else (header, toolbar, footer, tabs). --- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .panel, .plan-doc { background: #fff; border: none; padding: 0; }
  #form-section, #opsec-panel, #toolbar-panel { display: none !important; }
  #preview-section { margin: 0; padding: 0; }
  .plan-section { break-inside: avoid; page-break-inside: avoid; }
  .plan-section-heading { break-after: avoid; page-break-after: avoid; color: #000; }
  .plan-field-heading { break-after: avoid; page-break-after: avoid; }
  .plan-field-text, .plan-field-empty { color: #000; }
  .cashflow-table, .plan-cashflow-table th, .plan-cashflow-table td { border-color: #999; }
  a { color: #000; text-decoration: underline; }
  @page { size: letter; margin: 0.75in; }
}
