:root {
  --wordz-line: #1e4359;
  --wordz-panel: rgba(5, 15, 27, 0.94);
  --wordz-panel-soft: rgba(9, 24, 39, 0.9);
  --wordz-purple: #7c4dff;
  --wordz-green: #36d989;
  --wordz-text: #e9f3fa;
  --wordz-muted: #91a9bb;
}

.wordz-body { min-width: 0; overflow: hidden; }
.wordz-app { height: calc(100vh - 86px); min-height: 620px; display: flex; flex-direction: column; background: rgba(2, 9, 18, 0.34); }
.wordz-titlebar { min-height: 72px; padding: 10px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--wordz-line); background: rgba(4, 13, 24, 0.97); }
.wordz-identity { display: flex; align-items: center; gap: 12px; }
.wordz-identity h1 { margin: 0; font-size: 1.55rem; letter-spacing: 0; }
.wordz-identity .eyebrow { font-size: .68rem; }
.wordz-mark, .wordz-empty-mark { display: grid; place-items: center; border: 1px solid #8c6bff; background: #4f29b6; color: #fff; font-weight: 950; box-shadow: 0 8px 24px rgba(80, 40, 190, .3); }
.wordz-mark { width: 42px; height: 46px; clip-path: polygon(0 0, 72% 0, 100% 25%, 100% 100%, 0 100%); font-size: 1.3rem; }
.wordz-title-actions { display: flex; align-items: center; gap: 8px; }
.wordz-save-state { min-width: 90px; color: var(--wordz-muted); text-align: right; font-weight: 750; }
.wordz-save-state.saved { color: var(--wordz-green); }
.wordz-save-state.error { color: #ff7777; }
.wordz-mobile-panel { display: none; }

.wordz-workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 270px minmax(0, 1fr) 300px; }
.wordz-library, .wordz-inspector { min-height: 0; padding: 14px; overflow: auto; background: var(--wordz-panel); }
.wordz-library { border-right: 1px solid var(--wordz-line); }
.wordz-inspector { border-left: 1px solid var(--wordz-line); }
.wordz-panel-head, .wordz-section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wordz-panel-head { min-height: 42px; margin-bottom: 10px; color: #dceaf4; font-size: 1.05rem; }
.wordz-panel-close { display: none; }
.wordz-library-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 9px; }
.wordz-template-button { grid-column: 1 / -1; }
.wordz-import-button { position: relative; cursor: pointer; text-align: center; }
.wordz-library > .search, .wordz-library > .select { width: 100%; min-height: 43px; margin-bottom: 8px; }
.wordz-check { display: flex; align-items: center; gap: 9px; min-height: 40px; color: var(--wordz-muted); cursor: pointer; }
.wordz-check input { width: 18px; height: 18px; }
.wordz-document-list { display: grid; gap: 6px; margin-top: 8px; }
.wordz-document-row { width: 100%; padding: 11px; border: 1px solid #17384a; border-left: 3px solid transparent; border-radius: 5px; background: #071522; color: var(--wordz-text); text-align: left; cursor: pointer; }
.wordz-document-row:hover { border-color: #2e6e89; background: #0a2030; }
.wordz-document-row.active { border-color: #7356d7; border-left-color: #9b7cff; background: #151d35; }
.wordz-document-row.archived { opacity: .62; }
.wordz-document-row strong, .wordz-document-row span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wordz-document-row span { margin-top: 4px; color: #7f99ac; font-size: .78rem; }

.wordz-editor-column { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #101923; }
.wordz-empty { flex: 1; display: grid; place-items: center; align-content: center; gap: 11px; padding: 30px; text-align: center; color: var(--wordz-muted); }
.wordz-empty h2, .wordz-empty p { margin: 0; letter-spacing: 0; }
.wordz-empty-mark { width: 68px; height: 75px; font-size: 2rem; }
.wordz-editor-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wordz-document-meta { padding: 10px 14px; border-bottom: 1px solid #253a49; background: #0b1520; }
.wordz-title-input { width: 100%; border: 0; padding: 0; background: transparent; color: #f2f7fb; font-size: 1.25rem; font-weight: 850; outline: 0; }
.wordz-document-byline { min-height: 18px; margin-top: 4px; color: #738b9c; font-size: .78rem; }
.wordz-toolbar { display: flex; align-items: center; gap: 3px; min-height: 50px; padding: 5px 8px; overflow-x: auto; border-bottom: 1px solid #263d4e; background: #08121d; scrollbar-width: thin; }
.wordz-toolbar button, .wordz-toolbar select, .wordz-file-tool, .wordz-color-button { flex: 0 0 auto; min-width: 36px; height: 36px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: #c9d7e1; display: grid; place-items: center; cursor: pointer; }
.wordz-toolbar button:hover, .wordz-file-tool:hover, .wordz-color-button:hover { border-color: #31546b; background: #142534; color: #fff; }
.wordz-toolbar select { min-width: 86px; padding: 0 8px; background: #0b1723; }
.wordz-toolbar select[data-block-format] { min-width: 118px; }
.wordz-select-all span { position: relative; display: grid; width: 20px; height: 20px; place-items: center; border: 1px dashed #6f8798; border-radius: 2px; font-size: .78rem; font-weight: 900; }
.wordz-toolbar-divider { width: 1px; height: 25px; margin: 0 3px; background: #294053; flex: 0 0 auto; }
.wordz-color-button { position: relative; font-weight: 900; border-bottom: 3px solid #111827; }
.wordz-highlight-button { background: linear-gradient(transparent 52%, #fff3a3 52%); color: #111827; }
.wordz-color-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.wordz-orbit-button { min-width: 62px !important; border-color: #6949ce !important; color: #cbbcff !important; }
.wordz-canvas-wrap { flex: 1; min-height: 0; overflow: auto; padding: 30px max(20px, calc((100% - 850px) / 2)); background: #1b2731; }
.wordz-page { --wordz-margin-top: .78in; --wordz-margin-right: .82in; --wordz-margin-bottom: .82in; --wordz-margin-left: .82in; width: 100%; min-height: 1100px; padding: var(--wordz-margin-top) var(--wordz-margin-right) var(--wordz-margin-bottom) var(--wordz-margin-left); outline: 0; border: 1px solid #b8c0c8; border-radius: 2px; background: #fff; color: #111827; box-shadow: 0 14px 38px rgba(0, 0, 0, .28); font: 16px/1.55 Arial, sans-serif; overflow-wrap: anywhere; }
.wordz-page h1, .wordz-page h2, .wordz-page h3, .wordz-page h4 { color: #101827; letter-spacing: 0; }
.wordz-page h1 { font-size: 2.15rem; }
.wordz-page h2 { margin-top: 1.4em; font-size: 1.55rem; }
.wordz-page h3 { font-size: 1.2rem; }
.wordz-page p { min-height: 1.3em; }
.wordz-page img { display: block; max-width: 100%; height: auto; margin: 14px auto; }
.wordz-page table { width: 100%; border-collapse: collapse; }
.wordz-page th, .wordz-page td { min-width: 70px; padding: 7px; border: 1px solid #66727d; }
.wordz-page blockquote { margin-left: 0; padding-left: 16px; border-left: 4px solid #7c4dff; color: #425466; }

.wordz-inspector label { display: grid; gap: 6px; margin-bottom: 12px; color: #a7bed0; font-weight: 750; }
.wordz-inspector input, .wordz-inspector select { width: 100%; min-height: 42px; }
.wordz-sharing-note { margin: -4px 0 12px; color: #819bad; font-size: .8rem; line-height: 1.45; }
.wordz-inspector-section { padding: 14px 0; border-top: 1px solid #17384a; }
.wordz-inspector-section > strong, .wordz-section-title strong { display: block; margin-bottom: 9px; color: #dbe9f2; }
.wordz-section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wordz-section-title strong { margin-bottom: 0; }
.wordz-section-title [data-reset-page-margins] { min-height: 32px; padding: 5px 9px; }
.wordz-margin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wordz-margin-grid label { min-width: 0; margin: 0; font-size: .8rem; }
.wordz-margin-grid input { min-height: 38px; }
.wordz-margin-note { margin: 9px 0 0; }
.wordz-orbit-grid, .wordz-export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.wordz-inspector-section > .btn { width: 100%; margin-top: 6px; }
.wordz-version-list { display: grid; gap: 6px; }
.wordz-version-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px; border: 1px solid #18384a; border-radius: 4px; background: #071521; }
.wordz-version-row span, .wordz-version-row small { display: block; }
.wordz-version-row small { margin-top: 2px; color: #7f99ab; }
.wordz-version-row .btn { min-height: 34px; padding: 6px 8px; }
.wordz-danger-zone { margin-top: 10px; }
.wordz-status { position: fixed; left: 50%; bottom: 14px; z-index: 1300; min-width: 260px; max-width: calc(100% - 28px); margin: 0; padding: 9px 13px; border: 1px solid transparent; border-radius: 5px; background: rgba(2, 11, 20, .95); color: #9fc4d7; text-align: center; transform: translateX(-50%); pointer-events: none; opacity: 0; transition: opacity .18s ease; }
.wordz-status.show { border-color: #28647c; opacity: 1; }
.wordz-status.error { border-color: #9f3343; color: #ffc2ca; }

.wordz-dialog { width: min(760px, calc(100% - 24px)); max-height: calc(100vh - 28px); padding: 0; border: 1px solid #31536a; border-radius: 7px; background: #071522; color: var(--wordz-text); box-shadow: 0 24px 80px rgba(0, 0, 0, .62); }
.wordz-dialog::backdrop { background: rgba(0, 5, 12, .82); }
.wordz-dialog-body { padding: 20px; }
.wordz-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.wordz-dialog-head h2 { margin: 2px 0 0; letter-spacing: 0; }
.wordz-dialog-body > label { display: grid; gap: 5px; margin-top: 11px; color: #a7bdcc; font-weight: 750; }
.wordz-dialog-body input, .wordz-dialog-body select, .wordz-dialog-body textarea { width: 100%; }
.wordz-dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 7px; margin-top: 17px; }
.wordz-template-dialog { width: min(1120px, calc(100% - 24px)); }
.wordz-template-dialog .wordz-dialog-body { max-height: calc(100vh - 30px); overflow: auto; }
.wordz-template-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 14px; min-height: 570px; }
.wordz-template-library, .wordz-template-editor { min-width: 0; }
.wordz-template-library { padding-right: 14px; border-right: 1px solid #1e4359; }
.wordz-template-library-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; margin-bottom: 9px; }
.wordz-template-list { display: grid; align-content: start; gap: 6px; max-height: 510px; overflow: auto; }
.wordz-template-row { width: 100%; padding: 10px; border: 1px solid #17384a; border-left: 3px solid transparent; border-radius: 5px; background: #071522; color: #e9f3fa; text-align: left; cursor: pointer; }
.wordz-template-row:hover { border-color: #2e6e89; background: #0a2030; }
.wordz-template-row.active { border-color: #7356d7; border-left-color: #9b7cff; background: #151d35; }
.wordz-template-row strong, .wordz-template-row span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wordz-template-row span { margin-top: 4px; color: #7f99ac; font-size: .78rem; }
.wordz-template-empty { display: grid; min-height: 420px; place-items: center; color: #91a9bb; text-align: center; }
.wordz-template-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .55fr); gap: 10px; }
.wordz-template-fields label { display: grid; gap: 5px; color: #a7bdcc; font-weight: 750; }
.wordz-template-kind { min-height: 20px; margin: 6px 0 9px; color: #8ca6b8; font-size: .8rem; }
.wordz-template-toolbar { display: flex; align-items: center; gap: 4px; min-height: 42px; padding: 4px 6px; overflow-x: auto; border: 1px solid #29465a; border-bottom: 0; border-radius: 4px 4px 0 0; background: #08131f; }
.wordz-template-toolbar select, .wordz-template-toolbar button { flex: 0 0 auto; min-width: 34px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: #d6e3eb; cursor: pointer; }
.wordz-template-toolbar select { min-width: 118px; border-color: #29465a; background: #0b1926; }
.wordz-template-toolbar button:hover { border-color: #3a647d; background: #132737; color: #fff; }
.wordz-template-page { min-height: 420px; max-height: 58vh; padding: 42px 50px; overflow: auto; outline: 0; border: 1px solid #b8c0c8; border-radius: 0 0 2px 2px; background: #fff; color: #111827; font: 16px/1.55 Arial, sans-serif; letter-spacing: 0; overflow-wrap: anywhere; }
.wordz-template-page[contenteditable="true"]:focus { border-color: #8c6bff; box-shadow: 0 0 0 2px rgba(140, 107, 255, .2); }
.wordz-template-page h1, .wordz-template-page h2, .wordz-template-page h3, .wordz-template-page h4 { color: #101827; letter-spacing: 0; }
.wordz-template-page h1 { margin: 0 0 .75em; font-size: 2.15rem; line-height: 1.2; }
.wordz-template-page h2 { margin: 1.35em 0 .65em; font-size: 1.55rem; line-height: 1.25; }
.wordz-template-page h3 { margin: 1.15em 0 .55em; font-size: 1.2rem; line-height: 1.3; }
.wordz-template-page h4 { margin: 1em 0 .5em; font-size: 1.05rem; line-height: 1.35; }
.wordz-template-page p, .wordz-template-page div { min-height: 1.35em; margin: 0 0 .8em; font-size: 1rem; line-height: 1.55; }
.wordz-template-page ul, .wordz-template-page ol { margin: 0 0 .9em; padding-left: 1.65em; }
.wordz-template-page li { margin: .2em 0; }
.wordz-template-actions { justify-content: flex-start; }
.wordz-template-actions [data-save-template] { margin-left: auto; }
.wordz-source-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.wordz-source-tabs .active { border-color: #8567ec; background: #2a2050; }
.wordz-source-list { display: grid; gap: 7px; max-height: 58vh; overflow: auto; }
.wordz-source-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 11px; border: 1px solid #1c4054; border-radius: 5px; background: #0a1b29; }
.wordz-source-row strong, .wordz-source-row p { display: block; margin: 0; }
.wordz-source-row p { margin-top: 5px; color: #9bb2c2; white-space: pre-wrap; }
.wordz-orbit-dialog { width: min(860px, calc(100% - 24px)); }
.wordz-orbit-prompt { display: grid; grid-template-columns: minmax(190px, 1fr) minmax(130px, .65fr) auto; gap: 8px; margin-bottom: 10px; }
.wordz-orbit-dialog textarea { min-height: 300px; resize: vertical; }
.wordz-backdrop { position: fixed; inset: 0; z-index: 1190; background: rgba(0, 5, 12, .72); }

@media (max-width: 1100px) {
  .wordz-workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .wordz-inspector { position: fixed; z-index: 1200; top: 0; right: 0; bottom: 0; width: min(330px, 92vw); border-left: 1px solid var(--wordz-line); transform: translateX(105%); transition: transform .18s ease; }
  .wordz-inspector.open { transform: translateX(0); }
  .wordz-mobile-panel[data-open-inspector] { display: grid; }
  .wordz-panel-close { display: grid; }
}

@media (max-width: 760px) {
  .wordz-body { overflow: auto; }
  .wordz-app { height: calc(100dvh - 70px); min-height: 560px; }
  .wordz-titlebar { min-height: 62px; padding: 8px 10px; }
  .wordz-title-actions > .btn:not(.wordz-mobile-panel):not([data-save-document]) { display: none; }
  .wordz-save-state { min-width: 62px; font-size: .78rem; }
  .wordz-identity h1 { font-size: 1.25rem; }
  .wordz-mark { width: 34px; height: 38px; }
  .wordz-workspace { display: block; }
  .wordz-library { position: fixed; z-index: 1200; top: 0; left: 0; bottom: 0; width: min(310px, 92vw); border-right: 1px solid var(--wordz-line); transform: translateX(-105%); transition: transform .18s ease; }
  .wordz-library.open { transform: translateX(0); }
  .wordz-mobile-panel[data-open-library] { display: grid; }
  .wordz-document-meta { padding: 8px 10px; }
  .wordz-toolbar { min-height: 46px; }
  .wordz-canvas-wrap { padding: 12px 7px 34px; }
  .wordz-page { min-height: 850px; padding: 35px 24px; font-size: 15px; }
  .wordz-orbit-prompt { grid-template-columns: 1fr; }
  .wordz-dialog-actions .btn { flex: 1; }
  .wordz-template-layout { grid-template-columns: 1fr; min-height: 0; }
  .wordz-template-library { padding: 0 0 12px; border-right: 0; border-bottom: 1px solid #1e4359; }
  .wordz-template-list { max-height: 200px; }
  .wordz-template-fields { grid-template-columns: 1fr; }
  .wordz-template-page { min-height: 360px; padding: 28px 22px; }
  .wordz-template-actions [data-save-template] { margin-left: 0; }
}

@page {
  size: letter portrait;
  margin: .78in .82in .82in;

  @bottom-center {
    content: "Page " counter(page) " of " counter(pages);
    color: #56636e;
    font: 9pt Arial, sans-serif;
  }
}

@media print {
  html, body { width: auto !important; margin: 0 !important; padding: 0 !important; background: #fff !important; }
  .topbar, .wordz-titlebar, .wordz-library, .wordz-inspector, .wordz-document-meta, .wordz-toolbar, .wordz-status { display: none !important; }
  .wordz-app, .wordz-workspace, .wordz-editor-column, .wordz-editor-shell, .wordz-canvas-wrap { display: block !important; height: auto !important; overflow: visible !important; padding: 0 !important; background: #fff !important; }
  .wordz-page { box-sizing: border-box; width: 100% !important; max-width: none !important; min-height: 0; margin: 0 auto !important; padding: 0 !important; border: 0; box-shadow: none; }
  .wordz-page figure, .wordz-page img, .wordz-page table, .wordz-page blockquote { break-inside: avoid; page-break-inside: avoid; }
}
