/* Editor chrome — screen only.
 *
 * Everything here is app UI, never part of the printed document. The print
 * block at the bottom is load-bearing: it hides the chrome AND unwinds the
 * scrolling layout, because an ancestor of <doc-page> with overflow:auto or a
 * fixed height makes Chrome print only the first page.
 */

:root {
  --ui-bg: #ffffff;
  --ui-panel: #faf9f7;
  --ui-line: #e4e1dc;
  --ui-line-soft: #eeebe6;
  --ui-text: #23282b;
  --ui-muted: #6f7276;
  --ui-accent: #0f5c5c;
  --ui-accent-soft: #e7efee;
  --ui-danger: #8c2f2f;
}

/* Scoped to the chrome on purpose — NOT a universal reset. The document's
 * rules and boxes are content-box (a .tbl-row is height:34px PLUS its 1px
 * border, exactly as in the reference), and a global border-box would quietly
 * shave a pixel off every rule, checkbox and table row. */
.toolbar, .toolbar *,
.editor, .editor *,
.modal-scrim, .modal-scrim * { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  /* plan.css sets the document font/color on body; the chrome overrides its
     own pieces below rather than fighting it here. */
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ── Toolbar ────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  padding: 0 14px;
  height: 52px;
  background: var(--ui-bg);
  border-bottom: 1px solid var(--ui-line);
  font-size: 13px;
}

.toolbar-brand {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--ui-accent);
  letter-spacing: -0.01em;
}

.toolbar-field { display: flex; }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--ui-line);
  margin: 0 4px;
}

.toolbar-status {
  min-width: 6ch;
  font-size: 12px;
  color: var(--ui-muted);
}

/* ── Controls ───────────────────────────────────────────────────────────── */
button,
select,
input[type='text'],
input[type='number'],
textarea {
  font: inherit;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ui-text);
  background: var(--ui-bg);
  border: 1px solid var(--ui-line);
  border-radius: 4px;
  padding: 5px 9px;
}

button { cursor: pointer; }
button:hover { background: var(--ui-panel); border-color: #d6d2cb; }

button.primary {
  background: var(--ui-accent);
  border-color: var(--ui-accent);
  color: #fff;
  font-weight: 500;
}
button.primary:hover { background: #0a4a4a; border-color: #0a4a4a; }

button.danger { color: var(--ui-danger); }

/* Small inline buttons inside the editor rows */
button.icon {
  padding: 2px 7px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ui-muted);
}
button.icon:hover { color: var(--ui-text); }

textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.5;
  min-height: 60px;
}

input[type='text'], input[type='number'] { width: 100%; }

:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 1px;
}

/* ── Workspace split ────────────────────────────────────────────────────── */
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

.editor {
  flex: none;
  width: 380px;
  overflow-y: auto;
  background: var(--ui-panel);
  border-right: 1px solid var(--ui-line);
  padding: 14px;
}

.preview {
  flex: 1;
  overflow: auto;
  min-width: 0;
}

/* ── Editor sections ────────────────────────────────────────────────────── */
.sec {
  background: var(--ui-bg);
  border: 1px solid var(--ui-line);
  border-radius: 5px;
  margin-bottom: 10px;
}

.sec > summary {
  cursor: pointer;
  padding: 9px 11px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ui-muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::before {
  content: '▸';
  font-size: 10px;
  color: var(--ui-accent);
}
.sec[open] > summary::before { content: '▾'; }
.sec[open] > summary { border-bottom: 1px solid var(--ui-line-soft); }

.sec-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12.5px;
  color: var(--ui-text);
}

.sec-body { padding: 11px; }

.field { margin-bottom: 11px; }
.field:last-child { margin-bottom: 0; }

.field > label,
.field-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ui-muted);
  margin-bottom: 4px;
}

/* Repeating rows: bullets, columns, check-in rows, prompts */
.row {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-bottom: 5px;
}

.row textarea { min-height: 44px; }

.row-controls {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: none;
}

.col-row { display: flex; gap: 5px; align-items: center; margin-bottom: 5px; }
.col-row .col-label { flex: 1; min-width: 0; }
.col-row .col-width { flex: none; width: 72px; }

.inline-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}

.hint {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ui-muted);
  margin: 0 0 8px;
}

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper input { width: 64px; }

.obj-actions {
  display: flex;
  gap: 5px;
  margin-left: auto;
  flex: none;
}

/* ── First-run modal ────────────────────────────────────────────────────── */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(28, 30, 30, 0.42);
}

.modal {
  width: 100%;
  max-width: 470px;
  background: var(--ui-bg);
  border-radius: 8px;
  border: 1px solid var(--ui-line);
  box-shadow: 0 10px 40px rgba(20, 20, 19, 0.22);
  padding: 26px 26px 20px;
}

.modal-title {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ui-accent);
  margin: 0 0 8px;
}

.modal-desc {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ui-muted);
  margin: 0 0 18px;
}

.modal-choices { display: grid; gap: 10px; }

/* Each choice is a button, so it is reachable and pressable by keyboard
   without any extra wiring. */
.choice {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 15px;
  border: 1px solid var(--ui-line);
  border-radius: 6px;
  background: var(--ui-bg);
}

.choice:hover {
  border-color: var(--ui-accent);
  background: var(--ui-accent-soft);
}

.choice-title {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--ui-text);
  margin-bottom: 3px;
}

.choice-desc {
  display: block;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ui-muted);
}

.modal-foot {
  font-size: 12px;
  color: var(--ui-muted);
  margin: 16px 0 0;
  text-align: center;
}

/* ── Print ──────────────────────────────────────────────────────────────── *
 * Hide the chrome and put <doc-page> back into plain document flow. The
 * scroll container is the important part: leave .preview as an overflow:auto
 * flex child and Chrome truncates the PDF to a single page.               */
@media print {
  html, body { height: auto; overflow: visible; }

  .toolbar, .editor, .modal-scrim { display: none !important; }

  .app,
  .workspace,
  .preview {
    display: block !important;
    overflow: visible !important;
    height: auto !important;
    min-height: 0 !important;
    flex: none !important;
  }
}
