/* Writer (#agent/writer). The Money tokens (--m-*) carry light and dark; the
   page itself stays white paper with dark ink in both, because it is a
   picture of the PDF. */
.wr-navgap { height: 6px; }
.wr-newbtn { width: 100%; justify-content: center; margin-bottom: 2px; }
.wr-navright { margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--m-faint); }
.m-nav.active .wr-navright { color: inherit; }
.wr-gap { margin-top: 12px; }
.wr-warn { color: var(--m-warn, #b7791f); font-weight: 600; }

/* templates */
.wr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.wr-tcard { background: var(--m-surface); border: 1px solid var(--m-line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.wr-tcard:hover { border-color: var(--m-accent); }
.wr-tmain { display: block; padding: 16px 16px 10px; color: inherit; text-decoration: none; flex: 1; }
.wr-thumb { height: 120px; border-radius: 8px; background: #fff; border: 1px solid var(--m-line); padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.wr-thumb i { display: block; height: 6px; border-radius: 3px; background: #dfe3e8; }
.wr-thumb i:first-child { width: 55%; height: 9px; background: #1d2733; margin: 0 auto 4px; }
.wr-thumb i.s { width: 70%; }
.wr-thumb.docx i:first-child { background: #2b579a; }
.wr-tname { font-weight: 600; font-size: 14px; color: var(--m-ink); }
.wr-tsub { font-size: 12px; color: var(--m-muted); margin-top: 3px; }
.wr-tfoot { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--m-line-soft); }
.wr-tfoot .m-btn.primary { margin-right: auto; }

/* new template */
.wr-starts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.wr-start { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 16px; border-radius: 12px; border: 1px solid var(--m-line); background: var(--m-surface); color: var(--m-ink); cursor: pointer; font: inherit; }
.wr-start:hover { border-color: var(--m-accent); background: var(--m-surface-2); }
.wr-start b { font-size: 14px; }
.wr-start span { font-size: 12.5px; color: var(--m-muted); line-height: 1.45; }
.wr-upload { border-style: dashed; }

/* editor */
.wr-wide .m-main { max-width: none; }
.wr-name { font: inherit; font-size: inherit; font-weight: inherit; color: inherit; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 2px 8px; margin-left: -8px; width: min(560px, 60vw); }
.wr-name:hover, .wr-name:focus { border-color: var(--m-line); background: var(--m-surface); outline: none; }
.wr-dirty { font-size: 12px; color: var(--m-muted); margin-right: 4px; }
.wr-editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.wr-paper-col { min-width: 0; }
.wr-tools { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 3px; padding: 7px 8px; background: var(--m-surface); border: 1px solid var(--m-line); border-radius: 12px 12px 0 0; }
.wr-tool { font: inherit; font-size: 12.5px; padding: 5px 9px; border-radius: 7px; border: 0; background: transparent; color: var(--m-ink); cursor: pointer; white-space: nowrap; }
.wr-tool:hover { background: var(--m-surface-2); }
.wr-tool.b { font-weight: 700; } .wr-tool.i { font-style: italic; font-family: Georgia, serif; } .wr-tool.u { text-decoration: underline; }
.wr-tsep { width: 1px; height: 18px; background: var(--m-line); margin: 0 4px; }
.wr-desk { background: var(--m-surface-2); border: 1px solid var(--m-line); border-top: 0; border-radius: 0 0 12px 12px; padding: 22px; overflow-x: auto; }
.wr-desk.preview { border-top: 1px solid var(--m-line); border-radius: 12px; max-height: 72vh; overflow: auto; }
.wr-page { box-sizing: border-box; width: 8.5in; max-width: 100%; min-height: 11in; margin: 0 auto; background: #fff; color: #1a1a1f; box-shadow: 0 1px 3px rgba(16, 24, 40, .12), 0 8px 24px rgba(16, 24, 40, .08); font-family: Helvetica, Arial, sans-serif; line-height: 1.38; outline: none; overflow-wrap: anywhere; }
.wr-page.times { font-family: "Times New Roman", Times, serif; }
.wr-desk.preview .wr-page { min-height: 0; }
.wr-page p { margin: 0 0 .6em; }
.wr-page h1 { font-size: 1.75em; margin: .6em 0 .35em; line-height: 1.25; }
.wr-page h2 { font-size: 1.4em; margin: .6em 0 .35em; line-height: 1.25; }
.wr-page h3 { font-size: 1.17em; margin: .6em 0 .35em; }
.wr-page > :first-child { margin-top: 0; }
.wr-page ul, .wr-page ol { margin: 0 0 .6em; padding-left: 22px; }
.wr-page li { margin-bottom: .25em; }
.wr-page blockquote { margin: 0 0 .6em 24px; }
.wr-page hr { border: 0; border-top: 1px solid #9a9ea8; margin: 8px 0; }
.wr-page table { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 0 0 .8em; }
.wr-page td, .wr-page th { border: 1px solid #9a9ea8; padding: 4px; vertical-align: top; text-align: left; }
.wr-page th { background: #f2f3f6; font-weight: 700; }
.wr-page td p, .wr-page th p { margin: 0; }
.wr-chip { display: inline-block; padding: 0 6px; border-radius: 5px; background: #e8eefb; color: #1f3f8f; border: 1px solid #c4d3f3; font-size: .92em; line-height: 1.35; white-space: nowrap; cursor: default; user-select: all; }
.wr-break { position: relative; height: 0; margin: 18px 0; border-top: 2px dashed #b7bcc6; user-select: none; }
.wr-break::after { content: "Page break"; position: absolute; top: -9px; left: 50%; transform: translateX(-50%); background: #fff; padding: 0 8px; font: 600 10.5px/16px -apple-system, "Segoe UI", sans-serif; color: #8a909b; letter-spacing: .05em; text-transform: uppercase; }

.wr-panel { position: sticky; top: 0; background: var(--m-surface); border: 1px solid var(--m-line); border-radius: 12px; padding: 4px 14px 14px; max-height: calc(100vh - 120px); display: flex; flex-direction: column; }
.wr-fieldq { width: 100%; box-sizing: border-box; margin: 12px 0 8px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--m-line); background: var(--m-surface); color: var(--m-ink); font: inherit; font-size: 13px; }
.wr-fields { overflow: auto; min-height: 120px; flex: 1; margin: 0 -6px; padding: 0 6px; }
.wr-fgroup { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--m-faint); margin: 12px 0 5px; }
.wr-field { display: block; width: 100%; text-align: left; font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 7px; border: 0; background: transparent; color: var(--m-ink); cursor: pointer; }
.wr-field:hover { background: var(--m-accent-soft); }
.wr-tip { margin-top: 10px; line-height: 1.45; }
.wr-settings { margin-top: 12px; }

/* merge */
.wr-mergegrid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.wr-records { max-height: 46vh; overflow: auto; margin: 0 -6px; padding: 0 6px; }
.wr-record { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; padding: 8px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--m-ink); cursor: pointer; }
.wr-record:hover { background: var(--m-surface-2); }
.wr-record.on { border-color: var(--m-accent); background: var(--m-accent-soft); }
.wr-record b { display: block; font-size: 13px; font-weight: 600; }
.wr-record em { display: block; font-style: normal; font-size: 12px; color: var(--m-muted); }
.wr-tick { flex: none; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--m-line); display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.wr-record.on .wr-tick { background: var(--m-accent); border-color: var(--m-accent); }
.wr-tick svg { width: 13px; height: 13px; }
.wr-values { display: grid; gap: 1px; margin-top: 10px; border: 1px solid var(--m-line); border-radius: 10px; overflow: hidden; }
.wr-values div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 12px; background: var(--m-surface); font-size: 13px; }
.wr-values span { color: var(--m-muted); }
.wr-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.wr-tag { display: inline-flex; flex-direction: column; padding: 6px 10px; border-radius: 9px; background: var(--m-surface-2); font-size: 13px; }
.wr-tag em { font-style: normal; font-size: 11px; color: var(--m-faint); font-family: ui-monospace, Menlo, monospace; }
.wr-tag.bad { background: var(--m-warn-soft); }

@media (max-width: 1100px) {
  .wr-editor, .wr-mergegrid { grid-template-columns: 1fr; }
  .wr-panel { position: static; max-height: 50vh; }
}
@media (max-width: 700px) {
  .wr-desk { padding: 8px; }
  .wr-page { padding: 18px !important; min-height: 60vh; }
  .wr-name { width: 100%; }
}

/* the panel is a column: only the field list may shrink */
.wr-panel > .m-tabs, .wr-panel > .wr-fieldq, .wr-panel > .wr-tip { flex: none; }
.wr-page td .wr-chip, .wr-page th .wr-chip { white-space: normal; }
/* a long unbroken template or record name wraps instead of pushing the page sideways */
.wr-main .m-title, .wr-main .pl-sub, .wr-main .m-card-title { overflow-wrap: anywhere; }
