:root {
    --navy: #11264d;
    --line: #dfe3eb;
    --bg: #f3f4f7;
    --text: #1c2637;
    --muted: #687489;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Segoe UI", system-ui, sans-serif; font-size: 14px; }
button, input, select { font: inherit; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 3px solid #8da8d8; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.app-header { background: var(--navy); color: #fff; min-height: 120px; padding: 16px 36px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 20px; }
.brand-logo { width: 88px; height: 88px; object-fit: contain; }
.brand-copy { display: flex; flex-direction: column; gap: 4px; }
.brand-mark { font-size: 24px; font-weight: 750; letter-spacing: 1.5px; }
.brand-text { color: #c4cede; font-size: 14px; }
.session { display: flex; align-items: center; gap: 16px; }
.session-user { color: #c4cede; font-size: 13px; }
.session form { margin: 0; }
.app-main { padding: 30px 32px 64px; max-width: 1760px; margin: 0 auto; }
.page-intro { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 25px; }
.eyebrow { font-size: 10px; font-weight: 750; letter-spacing: 1.8px; color: var(--muted); margin: 0 0 8px; }
.page-title { font-size: clamp(25px, 2.4vw, 34px); line-height: 1.2; letter-spacing: -.9px; margin: 0 0 7px; color: var(--navy); font-weight: 650; }
.page-description { color: var(--muted); margin: 0; line-height: 1.55; font-size: 13px; }
.document-badge { flex-shrink: 0; border: 1px solid var(--line); border-radius: 5px; padding: 7px 12px; color: var(--muted); font-size: 11px; }
.editor-grid { display: grid; grid-template-columns: 245px minmax(0, 1fr); gap: 20px; align-items: start; }
.writing-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; min-width: 0; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 20px; min-width: 0; }
.panel h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .65px; color: var(--muted); margin: 0 0 12px; font-weight: 650; }
.settings-group + .settings-group { padding-top: 21px; margin-top: 21px; border-top: 1px solid #edf0f4; }
.field { display: block; margin-bottom: 10px; }
.field > span:not(.sr-only) { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.input { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 5px; font: inherit; background: #fff; }
.input:focus { outline: 2px solid #d4def0; border-color: #6b82aa; }
select.input { font-size: 12px; }
.inline-checks { display: flex; gap: 14px; font-size: 12px; }
.inline-checks.stack { flex-direction: column; gap: 12px; }
.inline-checks label { display: flex; gap: 8px; align-items: flex-start; line-height: 1.45; cursor: pointer; }
.inline-checks input { accent-color: var(--navy); width: 15px; height: 15px; margin: 1px 0 0; flex-shrink: 0; }
.hint { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 8px 0 0; }
.actions { margin-top: 26px; display: flex; flex-direction: column; gap: 10px; }
.btn { border: 1px solid var(--line); background: #fff; padding: 10px 14px; border-radius: 5px; cursor: pointer; font-size: 13px; font-weight: 550; transition: transform 140ms ease-out, background-color 140ms ease; }
.btn:hover { border-color: #aab7ce; background: #f6f8fc; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { color: #fff; background: #203b66; border-color: #203b66; }
.btn-ghost { color: #dce4f0; background: transparent; border-color: #506180; padding: 7px 14px; }
.btn-ghost:hover { color: #fff; background: #243959; border-color: #8494b2; }
.content-panel, .preview-panel { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 81px; padding: 18px 20px; }
.step-label { display: block; color: #8290a5; font-size: 9px; font-weight: 700; letter-spacing: 1.4px; margin-bottom: 6px; }
.panel-head h2 { font-size: 16px; text-transform: none; letter-spacing: -.3px; color: var(--navy); margin: 0; }
.word-count, .preview-status { color: var(--muted); font-size: 11px; white-space: nowrap; }
.preview-status { display: flex; align-items: center; gap: 5px; }
.preview-status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #7d9b87; }
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 9px 11px; background: #f8f9fb; border-top: 1px solid #edf0f4; border-bottom: 1px solid var(--line); }
.toolbar-group { display: flex; align-items: center; gap: 1px; padding: 0 4px; border-left: 1px solid var(--line); }
.toolbar-select { color: var(--text); border: 1px solid transparent; border-radius: 4px; padding: 7px 5px; background: transparent; font-size: 11px; max-width: 120px; cursor: pointer; }
.toolbar-select:hover { background: #e9eef5; }
.tool-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 32px; padding: 5px; background: transparent; border: 0; border-radius: 4px; color: #44536b; cursor: pointer; font-size: 15px; }
.tool-btn:hover { background: #e8edf5; color: var(--navy); }
.tool-btn[aria-pressed="true"] { background: #dae4f3; color: var(--navy); }
.tool-btn:active { background: #cbd9ee; }
.tool-btn:disabled { opacity: .3; cursor: not-allowed; }
.tool-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn-wide { width: auto; min-width: 67px; padding: 5px 7px; font-size: 10px; white-space: nowrap; }
.clear-format { display: flex; align-items: baseline; font-size: 16px; }
.clear-format > span { font-size: 12px; }
.editor-content { min-height: 580px; max-height: 75vh; overflow-y: auto; background: #fff; }
.tiptap { min-height: 580px; padding: 30px 28px 42px; outline: none; color: #1c2637; font-family: "Carlito", Calibri, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.5; tab-size: 6; overflow-wrap: anywhere; }
@font-face { font-family: "Carlito"; src: url('/fonts/Carlito-Regular.ttf'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Carlito"; src: url('/fonts/Carlito-Bold.ttf'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Carlito"; src: url('/fonts/Carlito-Italic.ttf'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Carlito"; src: url('/fonts/Carlito-BoldItalic.ttf'); font-weight: 700; font-style: italic; font-display: swap; }
.tiptap:focus { box-shadow: inset 0 0 0 2px #e3eaf4; }
.tiptap p { margin: 0 0 10pt; }
.tiptap h2 { color: #1f2d5a; font-size: 16px; line-height: 1.4; margin: 12pt 0 6pt; font-weight: 700; letter-spacing: 0; text-transform: none; }
.tiptap ol, .tiptap ul { margin: 0 0 8pt; padding-left: 25px; }
.tiptap li > p { margin: 0 0 4pt; }
.tiptap ol ol { list-style-type: lower-alpha; }
.tiptap ol ol ol { list-style-type: lower-roman; }
.tiptap p[data-tabbed-line] { white-space: pre-wrap; }
.tiptap:has(> p:only-child > br:only-child)::before { content: attr(data-placeholder); float: left; height: 0; pointer-events: none; color: #929bad; font-family: "Segoe UI", sans-serif; font-size: 13px; max-width: calc(100% - 56px); }
.editor-page-break { border-top: 1px dashed #afbacd; border-bottom: 1px dashed #afbacd; background: #f3f6fa; padding: 8px; margin: 18px 0; text-align: center; font-family: "Segoe UI", sans-serif; font-size: 10px; letter-spacing: 1px; color: var(--muted); user-select: none; }
.editor-page-break.ProseMirror-selectednode { outline: 2px solid #7795c3; }
.editor-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-top: 1px solid #edf0f4; color: var(--muted); font-size: 9px; line-height: 1.5; }
.preview-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 12px; height: 51px; background: #f8f9fb; border-top: 1px solid #edf0f4; border-bottom: 1px solid var(--line); }
.preview-pagination { display: flex; align-items: center; gap: 3px; }
.preview-pagination span { font-size: 11px; min-width: 74px; text-align: center; font-variant-numeric: tabular-nums; }
.preview-pagination .tool-btn { font-size: 25px; }
.pdf-stage { padding: 16px; background: #e7eaf0; min-height: 580px; max-height: 75vh; overflow: auto; }
.pdf-stage canvas { display: block; margin: 0 auto; background: #fff; box-shadow: 0 3px 12px #15274b24; }
.preview-placeholder { color: var(--muted); font-size: 13px; padding: 140px 20px; text-align: center; }
.preview-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 13px 16px; font-size: 10px; color: var(--muted); }
.preview-footer > span { margin-right: auto; }
.text-link, .text-button { color: var(--navy); text-decoration: none; font-size: 10px; font-weight: 650; white-space: nowrap; }
.text-link:hover, .text-button:hover { text-decoration: underline; }
.text-button { border: 0; background: transparent; padding: 0; cursor: pointer; }
.text-button:disabled { opacity: .4; }
.preview-panel .alert { margin: 0 16px 16px; }
.alert { margin-top: 12px; padding: 10px 12px; border-radius: 5px; font-size: 12px; line-height: 1.5; }
.alert.error, .login-error { background: #fdecea; color: #a12d21; border: 1px solid #f5c6c2; }
.alert.ok { background: #eaf6ec; color: #226b32; border: 1px solid #c3e2c9; }
.login-wrap { display: flex; justify-content: center; padding-top: 40px; }
.login-panel { width: 100%; max-width: 380px; }
.login-submit { width: 100%; margin-top: 18px; }
.login-error { border-radius: 6px; padding: 9px 12px; font-size: 13px; margin: 0 0 14px; }
.validation-message { color: #c0392b; font-size: 12px; display: block; margin-top: 4px; }
@media (max-width: 1200px) {
    .editor-grid { grid-template-columns: 215px minmax(0, 1fr); gap: 16px; }
    .writing-workspace { gap: 16px; }
    .document-settings { padding: 16px; }
    .app-main { padding: 26px 24px 48px; }
    .tiptap { padding: 26px 20px 38px; }
}
@media (max-width: 1050px) {
    .editor-grid { grid-template-columns: 1fr; }
    .document-settings { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
    .settings-group + .settings-group { padding: 0; margin: 0; border: 0; }
    .actions { grid-column: 1 / -1; flex-direction: row; margin: 0; }
    .actions .btn { min-width: 160px; }
    .document-settings .alert { grid-column: 1 / -1; margin: 0; }
    .panel-head { padding: 16px; }
}
@media (max-width: 720px) {
    .app-header { min-height: 101px; padding: 14px 18px; gap: 12px; }
    .brand { gap: 12px; }
    .brand-logo { width: 68px; height: 72px; }
    .brand-mark { font-size: 21px; }
    .brand-text { font-size: 11px; }
    .session-user { display: none; }
    .btn-ghost { font-size: 11px; padding: 7px 10px; }
    .app-main { padding: 23px 16px 36px; }
    .page-intro { margin-bottom: 20px; }
    .page-description { font-size: 12px; }
    .document-badge { display: none; }
    .document-settings { grid-template-columns: 1fr 1fr; gap: 16px; }
    .settings-group:nth-child(3) { grid-column: 1 / -1; border-top: 1px solid #edf0f4; padding-top: 16px; }
    .inline-checks.stack { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
    .actions .btn { flex: 1; min-width: 0; }
    .writing-workspace { grid-template-columns: 1fr; }
    .editor-content, .tiptap { min-height: 420px; }
    .editor-content { max-height: 65vh; }
    .tiptap { font-size: 16px; padding: 24px 22px; }
    .input { font-size: 16px; }
    select.input { font-size: 13px; }
    .editor-toolbar { padding: 8px; gap: 5px; }
    .tool-btn { width: 33px; height: 35px; }
    .tool-btn-wide { width: auto; }
    .pdf-stage { min-height: 380px; max-height: 78vh; }
}
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }
