/* v2.2.3: fewer surfaces, clear primary actions, readable compact forms. */

/* Status messages must remain visible at every width when the app reveals them. */
[hidden] { display: none !important; }
.topbar > .row { min-width: 0; }
#syncStatus:not([hidden]),
#recoveryStatus:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  max-width: none;
  min-height: 32px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
#syncStatus::before, #recoveryStatus::before { flex: none; margin-right: 0; }
body[data-view=record] .shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 320px;
}
body[data-view=record] .topbar {
  flex: 0 0 auto;
  height: auto;
  min-height: 64px;
  padding-top: 10px;
  padding-bottom: 10px;
  gap: 14px;
}
body[data-view=record] main {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  margin: 0 auto;
}
.topbar > .row { flex-wrap: wrap; justify-content: flex-end; }

/* Keep the dialog itself as the one enclosing surface. */
#modal { border-radius: 22px; }
#modal .modal-head { padding-bottom: 16px; }
#modal .modal-head > .icon-button { width: 38px; height: 38px; }
#modal .field { gap: 7px; margin-bottom: 19px; font-size: 12px; }
#modal .field > input,
#modal .field > textarea,
#modal .field > select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  min-height: 44px;
}
#modal .field > :focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
}
#modal .modal-actions {
  position: sticky;
  bottom: 0;
  margin-top: 24px;
  margin-bottom: 0;
  padding-top: 15px;
  padding-bottom: max(15px, env(safe-area-inset-bottom));
  gap: 9px;
  background: var(--surface);
  box-shadow: 0 -8px 12px var(--surface);
}
#modal .modal-actions button { min-height: 42px; font-size: 13px; }
#modal .modal-actions button:not(.primary):not(.danger):not(.icon-button) { color: var(--muted); }
#modal .modal-actions button:not(.primary):hover { color: var(--ink); }
#modal .modal-actions .primary { margin-left: 0; }
#modal :is(details.work-details, details.project-options, details.preflight-details) > summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 11px 0;
  font-size: 12px;
  list-style: none;
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}
#modal :is(details.work-details, details.project-options, details.preflight-details) > summary::-webkit-details-marker { display: none; }
#modal :is(details.work-details, details.project-options, details.preflight-details) > summary::before {
  content: '+';
  width: 12px;
  flex: none;
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  color: var(--muted);
  text-align: center;
}
#modal :is(details.work-details, details.project-options, details.preflight-details)[open] > summary::before { content: '−'; }
#modal :is(details.work-details, details.project-options, details.preflight-details) > summary:hover { color: var(--ink); }
#modal summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* Daily work reads from context to content, followed by optional details. */
.draft-simplified { min-width: 0; padding: 2px 0; }
.draft-simplified + .draft-simplified { border-top: 1px solid var(--line); margin-top: 25px; padding-top: 25px; }
.draft-simplified > .draft-divider { display: none; }
.draft-heading { font-size: 13px; font-weight: 550; margin: 0 0 16px; color: var(--ink); }
.draft-simplified .draft-context { grid-template-columns: minmax(0, 1fr) minmax(0, 165px); gap: 14px; }
#modal .draft-simplified .draft-content { margin-bottom: 16px; }
#modal .draft-content textarea,
#modal textarea.draft-content { min-height: 126px; line-height: 1.85; padding: 12px 14px; }
#modal .draft-simplified .draft-status { max-width: 190px; margin-bottom: 15px; }
#modal .draft-simplified .draft-status select { width: 100%; }
.draft-simplified .work-details { margin-top: 0; padding-top: 0; }
.draft-simplified .work-details summary span { float: none; margin-left: auto; color: var(--muted); font-size: 11px; }
.draft-details-preview { font-size: 12px; line-height: 1.8; color: var(--muted); overflow-wrap: anywhere; margin: 0 0 14px; }
.draft-details-preview p + p { margin-top: 4px; }
.draft-details-preview strong { font-weight: 450; color: var(--ink); }
.work-details[open] + .draft-details-preview { display: none; }
.draft-simplified .draft-template { margin-top: 14px; font-size: 11px; }
.draft-simplified .source-original { margin-top: 9px; padding-top: 9px; border-top: 0; }
.draft-simplified .source-original summary { min-height: 36px; padding: 5px 0; }
.draft-simplified .source-original p { background: transparent; border-left: 2px solid var(--line); border-radius: 0; padding: 2px 0 2px 13px; }
.draft-simplified .inline-note { margin: 12px 0; line-height: 1.8; }
.project-options { border-top: 1px solid var(--line); padding-top: 2px; margin: 2px 0 0; }
.project-options[open] > summary { margin-bottom: 6px; }
#modal .project-options .field:last-child { margin-bottom: 8px; }

/* The report is one readable document; sources are available when needed. */
.report-layout { max-width: 900px; }
.report-layout .page-heading { margin-bottom: 24px; }
.report-layout .report-toolbar { gap: 12px; margin-bottom: 15px; }
.report-primary-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.report-primary-actions .primary { min-height: 40px; white-space: nowrap; font-size: 13px; }
.report-primary-actions > .text-button { min-height: 40px; white-space: nowrap; }
.report-primary-actions > .icon-button { width: 36px; height: 40px; color: var(--muted); }
.report-primary-actions > .icon-button:hover { color: var(--ink); }
.report-source-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 9px; margin: 0 0 13px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.report-source-summary button { min-height: 32px; font-size: 12px; padding: 4px 5px; color: var(--muted); }
.report-source-summary button:hover { color: var(--ink); }
.report-source-summary svg { width: 13px; height: 13px; }
body .report-shell.report-shell-simple { display: block; grid-template-columns: minmax(0, 1fr); }
.report-shell-simple .report-paper { padding: 32px 36px; box-shadow: none; }
.report-shell-simple .report-paper textarea { line-height: 2; }
.report-shell-simple .report-chat { box-shadow: none; margin-top: 15px; border-radius: 12px; }
.report-shell-simple .report-chat input { min-height: 34px; font-size: 13px; }
.report-shell-simple .report-dialogue:empty { display: none; }
.report-layout .report-notice { background: transparent; border-left: 2px solid #c8ac70; border-radius: 0; padding: 7px 11px; line-height: 1.8; }
.preflight-summary { margin: 0 0 16px; padding: 1px 0 16px; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.9; color: var(--muted); }
.preflight-summary strong { display: block; font-size: 21px; font-weight: 550; color: var(--ink); margin: 6px 0; }
.preflight-summary p + p { margin-top: 5px; }
.preflight-alerts { margin: 12px 0 17px; font-size: 12px; line-height: 1.85; color: var(--muted); }
.preflight-alerts .review-note { margin: 8px 0; padding: 6px 11px; border-left-width: 2px; background: transparent; }
.preflight-alerts:empty { display: none; }
.preflight-details { border-top: 1px solid var(--line); margin-top: 12px; }
.preflight-details .preflight-list { max-height: 30dvh; margin: 0 0 12px; padding-right: 5px; scrollbar-width: thin; overscroll-behavior: contain; }
.preflight-details .list-row { align-items: flex-start; padding: 12px 0; }
.preflight-details .status { margin-top: 3px; }
.range-presets { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 19px; }
.range-presets button { min-height: 40px; padding: 8px 14px; font-size: 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; }
.range-presets button:hover { background: var(--soft); }
.range-presets button.active,
.range-presets button[aria-pressed=true] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

body[data-theme=apple] .report-shell-simple .report-paper { padding: 36px 40px; box-shadow: var(--shadow); }
body[data-theme=office] .report-shell-simple .report-paper { padding: 28px 32px; }
body[data-theme=paper] .report-shell-simple .report-paper { padding: 28px 8px; border: 0; border-top: 1px solid var(--line); }
body[data-theme=office] #modal,
body[data-theme=paper] #modal { border-radius: 16px; }

@media (max-width: 760px) {
  body[data-view=record] .topbar { min-height: 56px; padding-top: 8px; padding-bottom: 8px; gap: 9px; }
  .topbar > .row { gap: 3px; }
  .topbar .breadcrumb { flex: none; }
  #syncStatus:not([hidden]), #recoveryStatus:not([hidden]) { max-width: 180px; padding: 4px 6px; font-size: 11px; }
  #modal .modal-head { padding: 18px 20px 13px; }
  #modalBody { padding-top: 4px; }
  #modal .field { margin-bottom: 17px; }
  #modal .field > input,
  #modal .field > textarea,
  #modal .field > select,
  .report-shell-simple .report-paper textarea,
  .report-shell-simple .report-chat input { font-size: 16px; }
  #modal .modal-actions { padding-top: 12px; margin-top: 20px; flex-wrap: wrap; }
  #modal .modal-actions button { min-height: 44px; padding: 9px 14px; }
  .draft-simplified .draft-context { grid-template-columns: minmax(0, 1fr) minmax(0, 145px); gap: 11px; }
  #modal .draft-content textarea,
  #modal textarea.draft-content { min-height: 138px; padding: 11px 12px; }
  .report-layout .page-heading { margin-bottom: 19px; }
  .report-layout .report-toolbar { gap: 10px; margin-bottom: 10px; }
  .report-generate-controls { gap: 8px; }
  .report-primary-actions { gap: 4px; }
  .report-primary-actions .primary { padding: 9px 13px; margin-left: 0; min-height: 42px; }
  .report-primary-actions > .icon-button { width: 30px; height: 42px; }
  .report-source-summary { gap: 3px 7px; font-size: 11px; margin-bottom: 10px; }
  .report-shell-simple .report-paper,
  body[data-theme=apple] .report-shell-simple .report-paper,
  body[data-theme=office] .report-shell-simple .report-paper { padding: 20px; }
  body[data-theme=paper] .report-shell-simple .report-paper { padding: 20px 0; }
  .report-shell-simple .report-paper textarea { line-height: 1.9; }
  .report-shell-simple .report-chat { padding: 8px 10px; }
  .report-shell-simple .report-chat input { width: 100%; }
  .preflight-summary { font-size: 13px; }
  .preflight-details .preflight-list { max-height: 28dvh; }
  .range-presets button { flex: 1; min-width: 80px; }
}

@media (max-width: 420px) {
  .draft-simplified .draft-context { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .report-shell-simple .report-paper,
  body[data-theme=apple] .report-shell-simple .report-paper,
  body[data-theme=office] .report-shell-simple .report-paper { padding: 17px; }
  body[data-theme=paper] .report-shell-simple .report-paper { padding: 18px 0; }
}

@media print {
  .report-source-summary, .report-primary-actions { display: none !important; }
  .report-shell-simple .report-paper { border: 0; padding: 0; box-shadow: none; }
}
