/* The document page and its editor chrome. Colours inside .document-page, the theme thumbnails
   and the colour swatches are document content (the same palette the exports use), so they are
   defined here and not in the token-checked workspace stylesheet. */
/* Document studio (owner direction 8 Nov 2026): the page you edit is the preview. Sizes follow
   the exported file (A4, 1pt = 1.33px) so what is on screen is what is exported. */
.document-studio {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.document-themes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 12px;
}
.document-themes h3 {
  margin: 0 0 2px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.theme-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}
.theme-card[aria-pressed="true"] {
  border-color: var(--action);
  box-shadow: 0 0 0 2px var(--action);
}
.theme-thumb {
  display: block;
  height: 52px;
  padding: 7px 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.theme-thumb i,
.theme-thumb b,
.theme-thumb u {
  display: block;
  height: 3px;
  margin-bottom: 4px;
  background: var(--t-name);
  text-decoration: none;
}
.theme-thumb i {
  width: 55%;
  height: 5px;
  margin-left: var(--t-thumb-left, 0);
}
.theme-thumb b {
  width: 70%;
  height: 2px;
  background: var(--t-section);
  border-bottom: 1px solid var(--t-rule);
  margin-left: var(--t-thumb-sec, 0);
}
.theme-thumb u {
  width: 100%;
  height: 2px;
  background: #dedbd0;
}
.document-editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--sidebar);
}
.document-editor:focus-within {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}
.document-editor-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px 8px 0 0;
  position: sticky;
  top: 0;
  z-index: 5;
}
.doc-tool,
.doc-menu > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 32px;
  min-height: 32px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: var(--text-sm);
  cursor: pointer;
  list-style: none;
}
.doc-menu > summary::-webkit-details-marker {
  display: none;
}
.doc-tool:hover:not(:disabled),
.doc-menu > summary:hover {
  background: var(--sidebar);
}
.doc-tool.is-active {
  background: var(--brand-tint);
  border-color: var(--action);
  color: var(--action);
}
.doc-tool:disabled {
  opacity: 0.4;
  cursor: default;
}
.doc-sep {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--border);
}
.doc-select {
  min-height: 32px;
  padding: 0 6px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
}
.doc-select-size {
  width: 64px;
}
.doc-menu {
  position: relative;
}
.doc-menu-popover,
.doc-menu > .package-options-popover {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  margin-top: 4px;
  padding: 8px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}
.doc-bar-end .doc-menu > .package-options-popover {
  left: auto;
  right: 0;
}
.doc-swatches {
  flex-direction: row;
  flex-wrap: wrap;
  width: 148px;
  min-width: 0;
}
.doc-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.25);
  cursor: pointer;
}
.doc-swatch-clear {
  flex-basis: 100%;
  font-size: var(--text-xs);
  min-height: 26px;
}
.doc-link {
  width: 260px;
}
.doc-link div {
  display: flex;
  gap: 6px;
}
.doc-bar-end {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.document-table-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.document-table-bar button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-xs);
}
.document-editor-error {
  margin: 6px 12px 0;
  color: var(--danger);
  font-size: var(--text-sm);
}
.document-canvas {
  padding: 20px 12px 28px;
  overflow: auto;
  max-height: 78vh;
}
.document-page {
  width: 100%;
  max-width: 794px;
  min-height: 1000px;
  margin: 0 auto;
  padding: 58px 64px;
  background: #fff;
  color: #172234;
  border: 1px solid var(--border);
  box-shadow: 0 2px 14px rgba(15, 23, 42, 0.1);
  font-family: Roboto, var(--font-sans);
  font-size: 14px;
  line-height: 1.2;
}
.document-editor-surface {
  outline: none;
  overflow-wrap: anywhere;
}
.document-editor-surface > * + * {
  margin-top: 0;
}
.document-editor-surface p {
  margin: 0 0 5px;
  min-height: 1.2em;
}
.document-page[data-kind="letter"] p,
.document-page[data-kind="email"] p {
  margin-bottom: 13px;
}
.document-editor-surface h1 {
  margin: 0 0 11px;
  font-size: var(--t-name-size);
  line-height: 1.15;
  color: var(--t-name);
  text-align: var(--t-name-align);
}
.document-editor-surface h2 {
  margin: 17px 0 6px;
  font-size: 16px;
  color: var(--t-section);
  text-align: var(--t-section-align);
  border-bottom: 1px solid var(--t-rule);
  padding-bottom: 1px;
}
.document-editor-surface h3 {
  margin: 12px 0 5px;
  font-size: 14.67px;
  color: #111;
}
.document-editor-surface ul,
.document-editor-surface ol {
  margin: 0 0 5px;
  padding-left: 26px;
}
.document-editor-surface li p {
  margin: 0 0 3px;
}
.document-editor-surface blockquote {
  margin: 4px 0 8px 8px;
  padding-left: 10px;
  border-left: 2px solid #9aa4b2;
  color: #4b5563;
}
.document-editor-surface a {
  color: #1d4ed8;
  text-decoration: underline;
}
.document-editor-surface img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 3px 0 8px;
}
.document-editor-surface img.ProseMirror-selectednode {
  outline: 2px solid var(--action);
}
.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 3px 0 10px;
  table-layout: fixed;
}
.doc-table td,
.doc-table th {
  border: 1px solid #c5cdd8;
  padding: 4px 6px;
  vertical-align: top;
  text-align: left;
}
.doc-table th {
  background: #f1f4f8;
  font-weight: 700;
}
.doc-table .selectedCell {
  background: #dbe7ff;
}
.doc-table p {
  margin: 0;
}
.ta-center {
  text-align: center;
}
.ta-right {
  text-align: right;
}
.ta-justify {
  text-align: justify;
}
.document-editor-surface strong {
  font-weight: 700;
}
.fc-111111 {
  color: #111111;
}
.fc-4B5563 {
  color: #4b5563;
}
.fc-DC2626 {
  color: #dc2626;
}
.fc-EA580C {
  color: #ea580c;
}
.fc-CA8A04 {
  color: #ca8a04;
}
.fc-16A34A {
  color: #16a34a;
}
.fc-0F766E {
  color: #0f766e;
}
.fc-1D4ED8 {
  color: #1d4ed8;
}
.fc-7C3AED {
  color: #7c3aed;
}
.fc-DB2777 {
  color: #db2777;
}
.hl-FFF2A8 {
  background: #fff2a8;
}
.hl-BBF7D0 {
  background: #bbf7d0;
}
.hl-BFDBFE {
  background: #bfdbfe;
}
.hl-FBCFE8 {
  background: #fbcfe8;
}
.hl-E5E7EB {
  background: #e5e7eb;
}
.fs-9 {
  font-size: 12px;
}
.fs-10 {
  font-size: 13.33px;
}
.fs-11 {
  font-size: 14.67px;
}
.fs-12 {
  font-size: 16px;
}
.fs-14 {
  font-size: 18.67px;
}
.fs-16 {
  font-size: 21.33px;
}
.fs-18 {
  font-size: 24px;
}
.fs-24 {
  font-size: 32px;
}

/* Theme looks: the same settings the exports use. */
.document-page[data-theme="simple"],
.theme-thumb[data-theme="simple"] {
  --t-name: #111111;
  --t-section: #111111;
  --t-rule: transparent;
  --t-name-align: left;
  --t-section-align: left;
  --t-name-size: 30.7px;
  --t-thumb-left: 0;
  --t-thumb-sec: 0;
}
.document-page[data-theme="compact"],
.theme-thumb[data-theme="compact"] {
  --t-name: #111111;
  --t-section: #111111;
  --t-rule: transparent;
  --t-name-align: left;
  --t-section-align: left;
  --t-name-size: 28px;
  --t-thumb-left: 0;
  --t-thumb-sec: 0;
}
.document-page[data-theme="classic"],
.theme-thumb[data-theme="classic"] {
  --t-name: #111111;
  --t-section: #111111;
  --t-rule: #9aa4b2;
  --t-name-align: center;
  --t-section-align: left;
  --t-name-size: 30.7px;
  --t-thumb-left: 22%;
  --t-thumb-sec: 0;
}
.document-page[data-theme="modern"],
.theme-thumb[data-theme="modern"] {
  --t-name: #1d4ed8;
  --t-section: #1d4ed8;
  --t-rule: #1d4ed8;
  --t-name-align: left;
  --t-section-align: left;
  --t-name-size: 30.7px;
  --t-thumb-left: 0;
  --t-thumb-sec: 0;
}
.document-page[data-theme="executive"],
.theme-thumb[data-theme="executive"] {
  --t-name: #1e3a5f;
  --t-section: #1e3a5f;
  --t-rule: #1e3a5f;
  --t-name-align: left;
  --t-section-align: left;
  --t-name-size: 33.3px;
  --t-thumb-left: 0;
  --t-thumb-sec: 0;
}
.document-page[data-theme="elegant"],
.theme-thumb[data-theme="elegant"] {
  --t-name: #0f766e;
  --t-section: #0f766e;
  --t-rule: #0f766e;
  --t-name-align: center;
  --t-section-align: center;
  --t-name-size: 32px;
  --t-thumb-left: 22%;
  --t-thumb-sec: 15%;
}
.document-page[data-theme="compact"] {
  padding: 48px 54px;
  line-height: 1.08;
}
.document-page[data-theme="compact"] h2 {
  margin-top: 12px;
}
@media (max-width: 900px) {
  .document-studio {
    grid-template-columns: minmax(0, 1fr);
  }
  .document-themes {
    flex-direction: row;
    overflow-x: auto;
    position: static;
  }
  .theme-card {
    min-width: 96px;
  }
  .document-page {
    padding: 28px 22px;
    min-height: 600px;
  }
}

/* Toolbar fits one line where there is room; controls keep their own size. */
.document-editor-bar .doc-select {
  width: auto;
  min-width: 0;
  height: 32px;
  min-height: 32px;
  padding: 0 8px;
  margin: 0;
}
.document-editor-bar .doc-select-size {
  width: 66px;
}
.document-editor-bar {
  gap: 2px;
}
.document-editor-bar .doc-sep {
  margin: 0 3px;
}
.editor-panel#draft-editor {
  padding: 0;
  border: 0;
  background: transparent;
}
.document-editor:focus-within {
  outline: 0;
  border-color: var(--action);
}
.document-studio {
  grid-template-columns: 124px minmax(0, 1fr);
  gap: 12px;
}
.doc-bar-end .save-state {
  margin: 0 4px 0 0;
  white-space: nowrap;
}
.doc-bar-end .compact-control,
.doc-bar-end > .doc-menu > summary {
  min-height: 32px;
}

.doc-swatch[data-color="111111"] {
  background: #111111;
}
.doc-swatch[data-color="4B5563"] {
  background: #4b5563;
}
.doc-swatch[data-color="DC2626"] {
  background: #dc2626;
}
.doc-swatch[data-color="EA580C"] {
  background: #ea580c;
}
.doc-swatch[data-color="CA8A04"] {
  background: #ca8a04;
}
.doc-swatch[data-color="16A34A"] {
  background: #16a34a;
}
.doc-swatch[data-color="0F766E"] {
  background: #0f766e;
}
.doc-swatch[data-color="1D4ED8"] {
  background: #1d4ed8;
}
.doc-swatch[data-color="7C3AED"] {
  background: #7c3aed;
}
.doc-swatch[data-color="DB2777"] {
  background: #db2777;
}
.doc-swatch[data-color="FFF2A8"] {
  background: #fff2a8;
}
.doc-swatch[data-color="BBF7D0"] {
  background: #bbf7d0;
}
.doc-swatch[data-color="BFDBFE"] {
  background: #bfdbfe;
}
.doc-swatch[data-color="FBCFE8"] {
  background: #fbcfe8;
}
.doc-swatch[data-color="E5E7EB"] {
  background: #e5e7eb;
}

.document-studio,
.editor-panel#draft-editor {
  min-width: 0;
  max-width: 100%;
}
@media (max-width: 900px) {
  .document-themes {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}

.doc-menu-popover,
.doc-menu > .package-options-popover {
  max-width: calc(100vw - 32px);
}
@media (max-width: 900px) {
  .doc-menu {
    position: static;
  }
  .doc-menu-popover,
  .doc-menu > .package-options-popover,
  .doc-bar-end .doc-menu > .package-options-popover {
    left: 8px;
    right: 8px;
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
  }
  .doc-menu-popover > *,
  .doc-menu > .package-options-popover > * {
    min-width: 0;
    max-width: 100%;
  }
}

details.doc-menu:not([open]) > .doc-menu-popover,
details.doc-menu:not([open]) > .package-options-popover {
  display: none;
}

.doc-bar-end {
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}
.document-editor-bar {
  min-width: 0;
}
