.letter-page-card { padding: clamp(1.1rem, 3vw, 2.75rem); }
.letter-intro { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; margin-bottom: 1.5rem; }
.letter-intro-copy { flex: 1; min-width: 0; }
.letter-din-promo { display: flex; align-items: center; gap: .45rem; margin-top: .55rem; color: #526b7e; font-size: .83rem; font-weight: 600; }
.letter-din-promo i { color: #31668e; font-size: .95rem; }
.letter-actions, .letter-file-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.letter-actions { justify-content: space-between; }
.letter-actions .btn { display: inline-flex; gap: .5rem; align-items: center; font-size: .84rem; min-height: 42px; }
.letter-actions .btn-outline-secondary { border-color: #d4dde3; color: #4c606f; }
.letter-actions .btn-outline-secondary:hover { color: white; }
.letter-status { font-size: .81rem; line-height: 1.4; margin: .8rem 0 1.1rem; min-height: 1.1em; color: #527365; }
.letter-status.is-error { color: #a03b33; }
.letter-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.6rem; align-items: start; }
.letter-compose { border: 1px solid #dce3e8; background: #fff; min-width: 0; }
.letter-tabs { display: flex; border-bottom: 1px solid #dce3e8; background: #f7f9fa; }
.letter-tabs button { flex: 1; min-height: 50px; padding: .8rem .5rem; border: 0; border-bottom: 2px solid transparent; background: none; color: #657582; font-size: .88rem; font-weight: 600; white-space: nowrap; }
.letter-tabs button i { margin-right: .3rem; }
.letter-tabs button[aria-selected="true"] { color: var(--tool-blue); border-bottom-color: var(--tool-blue); background: #fff; }
.letter-panel { padding: 1.25rem; }
.letter-panel[hidden], .letter-stage [hidden] { display: none !important; }
.letter-field { margin-bottom: 1rem; min-width: 0; }
.letter-field label, .letter-editor-label { display: block; font-size: .8rem; font-weight: 600; color: #536575; margin-bottom: .4rem; }
.letter-field .form-control { border-color: #dbe2e7; border-radius: 2px; font-size: .9rem; padding: .6rem .7rem; }
.letter-field .form-control::placeholder { color: #929da7; font-weight: 400; }
.letter-field textarea { resize: vertical; min-height: 110px; }
#letter-subject { min-height: 5.6rem; }
#letter-delivery { min-height: 5rem; }
#letter-recipient { min-height: 170px; }
.letter-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 1rem; }
.letter-form-grid fieldset { min-width: 0; }
.letter-form-grid legend { font-size: .95rem; font-weight: 650; padding-bottom: .75rem; }
.letter-toolbar.ql-toolbar.ql-snow { border-color: #dbe2e7; background: #f8fafb; padding: 6px; }
.letter-toolbar.ql-snow .ql-formats { margin-right: 5px; }
.letter-toolbar.ql-snow button { width: 30px; height: 32px; padding: 6px; }
.letter-toolbar.ql-snow button i { display: block; font-size: 17px; line-height: 20px; }
.letter-toolbar button:focus-visible { outline: 2px solid #31668e; outline-offset: 1px; }
#letter-editor.ql-container { font: 15px/1.6 'Segoe UI', Arial, sans-serif; border-color: #dbe2e7; }
#letter-editor .ql-editor { min-height: 335px; max-height: 620px; padding: 18px; }
#letter-editor .ql-editor.ql-blank::before { color: #98a1aa; font-style: normal; left: 18px; right: 18px; }
#letter-editor .ql-editor p { margin-bottom: .8em; }
#letter-editor .ql-page-break { border-top: 1px dashed #9baebc; color: #7b8d9a; margin: 1rem 0; padding-top: .4rem; font-size: 12px; user-select: none; }
#letter-editor .ql-page-break::after { content: attr(data-label); }
.letter-editor-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem; margin: .45rem 0 1.25rem; font-size: .7rem; color: #82909a; }
.letter-more { margin-top: .6rem; border-top: 1px solid #e4e9ed; }
.letter-more summary { padding: .8rem 0; color: #476077; font-size: .85rem; font-weight: 600; cursor: pointer; }
.letter-design-options { display: grid; gap: .75rem; margin-bottom: 1.5rem; }
.letter-design-choice { display: flex; align-items: center; gap: .7rem; padding: 1rem; border: 1px solid #dce3e8; cursor: pointer; }
.letter-design-choice:has(input:checked) { border-color: #31668e; background: #f5f9fc; }
.letter-design-choice small { display: block; margin-top: .3rem; font-size: .78rem; color: #788692; }
.letter-design-choice strong { font-size: .9rem; color: #314a60; }
.letter-design-sample { font-size: 1.7rem; margin-left: auto; color: #31668e; }
.letter-design-sample.serif { font-family: Georgia, serif; color: #30363b; }
.letter-check { display: flex; align-items: flex-start; gap: .6rem; font-size: .83rem; color: #455c6f; cursor: pointer; }
.letter-check input { margin-top: .2em; flex-shrink: 0; }
.letter-stage input[type=checkbox], .letter-stage input[type=radio] { accent-color: #31668e; width: 1.05em; height: 1.05em; }
.letter-storage { background: #f8fafb; padding: 1rem 1.25rem; border-top: 1px solid #dce3e8; }
.letter-storage p { color: #7a8894; font-size: .73rem; line-height: 1.5; margin: .5rem 0 0 1.5rem; }
.letter-text-button { background: none; border: 0; color: #31668e; padding: .6rem 0 0 1.5rem; font-size: .76rem; text-decoration: underline; }
.letter-preview { min-width: 0; background: #eaf0f4; border: 1px solid #dce3e8; padding: 1rem; position: static; }
.letter-preview-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.letter-preview-heading h2 { font-size: .83rem; color: #455c6f; font-weight: 650; margin: 0; }
.letter-preview-heading > span { font-size: .68rem; color: #7b8c99; }
.letter-preview-viewport { width: 100%; max-height: 760px; overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable; scrollbar-width: thin; }
@supports not (scrollbar-gutter: stable) { .letter-preview-viewport { overflow-y: scroll; } }
#letter-preview-scaled { position: relative; width: 210mm; max-width: 100%; margin-inline: auto; }
#letter-preview-scaled > .letter-page { transform-origin: top left; position: absolute; top: 0; left: 0; box-shadow: 0 3px 14px #243e5512; }
.letter-preview-note { font-size: .71rem; line-height: 1.6; color: #677d8e; margin: .85rem 0 0; }
.letter-preview-note i { margin-right: .45rem; }
#letter-print-root { display: none; }
@media (max-width: 1199.98px) { .letter-intro { display: block; } .letter-intro .privacy-tag { margin-top: 1rem; } .letter-workspace { gap: 1rem; } .letter-panel { padding: 1rem; } }
@media (max-width: 991.98px) { .letter-preview-viewport { max-height: 720px; } }
@media (max-width: 575.98px) { .letter-actions > #letter-print { width: 100%; justify-content: center; } .letter-file-actions { width: 100%; } .letter-file-actions #letter-export { flex: 1; } .letter-file-actions .btn { font-size: .75rem; } .letter-form-grid { grid-template-columns: 1fr; } .letter-tabs button { font-size: .8rem; } .letter-tabs button i { display: none; } .letter-preview { padding: .7rem; } }

/* Quote block: mirrors the legacy letter4.php [alert=quote] treatment. */
#letter-editor .ql-editor blockquote {
  margin: 0 0 .8em;
  border-left: 4px solid #12284c;
  padding: 15px;
  color: #222;
}
#letter-editor .ql-editor blockquote + blockquote { margin-top: -.8em; }
.letter-owner-option { margin-bottom: .8rem; }

.letter-design-choice-fixed { cursor: default; }
.letter-owner-settings { margin: 0 0 1rem; padding: .9rem 1rem; border: 1px solid #dce3e8; background: #f8fafb; }
.letter-owner-badge { display: inline-flex; align-items: center; gap: .45rem; margin-bottom: .8rem; color: #31668e; font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.letter-public-print-note { display: flex; align-items: flex-start; gap: .45rem; margin: -.35rem 0 .8rem; color: #748593; font-size: .76rem; line-height: 1.5; }
.letter-public-print-note i { margin-top: .05rem; color: #52718a; }

.letter-private-access { display: inline-flex; align-items: center; gap: .45rem; margin: 0 0 .8rem; padding: 0; border: 0; background: transparent; color: #31668e; font-size: .78rem; font-weight: 600; line-height: 1.4; text-decoration: none; cursor: pointer; }
.letter-private-access:hover, .letter-private-access:focus-visible { color: #244d6c; text-decoration: underline; }
.letter-private-access-muted { color: #748593; font-weight: 500; }

/* Owner-only saved-letter library. Public visitors never receive the corresponding controls. */
.letter-action-divider { width: 1px; height: 28px; margin: 0 .15rem; background: #dce3e8; }
.letter-database-strip { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .65rem; margin: -.35rem 0 1rem; padding: .65rem .8rem; border: 1px solid #dce3e8; background: #f8fafb; }
.letter-database-state { display: inline-flex; align-items: center; gap: .45rem; font-size: .76rem; color: #6a7b88; font-weight: 600; }
.letter-database-state i { color: #57758c; }
.letter-database-state.is-saved { color: #3f7157; }
.letter-database-state.is-saved i { color: #3f7157; }
.letter-database-state.is-dirty { color: #966c18; }
.letter-database-state.is-dirty i { color: #966c18; }
.letter-public-link { display: inline-flex; align-items: center; gap: .35rem; color: #31668e; font-size: .75rem; font-weight: 600; text-decoration: none; }
.letter-public-link:hover { text-decoration: underline; }
.letter-library-dialog { width: calc(100vw - 2rem); height: calc(100vh - 2rem); max-width: none; max-height: none; padding: 0; border: 0; border-radius: 4px; box-shadow: 0 24px 70px #18364b38; color: #273d50; }
.letter-library-dialog::backdrop { background: rgb(18 36 50 / .52); backdrop-filter: blur(2px); }
.letter-library-shell { display: flex; flex-direction: column; height: 100%; min-height: 0; background: #fff; }
.letter-library-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.35rem 1.4rem 1rem; border-bottom: 1px solid #e0e6ea; }
.letter-library-head .btn-close { flex: 0 0 auto; margin-top: .15rem; }
.letter-library-search { padding: 1rem 1.4rem .7rem; }
.letter-library-search .input-group-text { background: #f7f9fa; color: #71818d; border-color: #dbe2e7; }
.letter-library-search .form-control, .letter-library-search .btn { border-color: #dbe2e7; }
.letter-library-summary { min-height: 1.2em; padding: 0 1.4rem .7rem; }
.letter-library-results { flex: 1 1 auto; min-height: 0; overflow: auto; border-top: 1px solid #eef1f3; }
.letter-library-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 1rem 1.25rem; padding: 1rem 1.4rem; border-left: 0; border-right: 0; }
.letter-library-item-main { min-width: 0; }
.letter-library-subject { color: #2c465c; font-weight: 700; font-size: .95rem; line-height: 1.35; }
.letter-library-meta { display: flex; flex-wrap: wrap; gap: .35rem .75rem; margin-top: .28rem; color: #7a8994; font-size: .72rem; }
.letter-library-details { display: grid; grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(135px, .7fr)); gap: .55rem 1rem; margin-top: .8rem; }
.letter-library-detail { min-width: 0; }
.letter-library-detail-label { display: block; margin-bottom: .12rem; color: #85929b; font-size: .65rem; font-weight: 700; letter-spacing: .035em; text-transform: uppercase; }
.letter-library-detail-value { display: block; overflow-wrap: anywhere; color: #40566a; font-size: .76rem; line-height: 1.35; }
.letter-library-detail-address { grid-row: span 2; }
.letter-library-detail-address .letter-library-detail-value { white-space: pre-line; }
.letter-library-detail-url { grid-column: span 2; }
.letter-library-item-actions { display: flex; align-items: center; gap: .35rem; flex: 0 0 auto; position: sticky; top: .5rem; }
.letter-library-item-actions .btn { display: inline-flex; align-items: center; gap: .3rem; min-height: 32px; }
.letter-library-empty { border-top: 1px solid #eef1f3; }
@media (max-width: 1199.98px) {
  .letter-library-details { grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(135px, .8fr)); }
  .letter-library-detail-url { grid-column: auto; }
}
@media (max-width: 767.98px) {
  .letter-action-divider { display: none; }
  .letter-database-strip { align-items: flex-start; flex-direction: column; }
  .letter-library-dialog { width: calc(100vw - 1rem); height: calc(100vh - 1rem); }
  .letter-library-item { grid-template-columns: 1fr; }
  .letter-library-details { grid-template-columns: 1fr 1fr; }
  .letter-library-detail-address { grid-column: 1 / -1; grid-row: auto; }
  .letter-library-detail-url { grid-column: 1 / -1; }
  .letter-library-item-actions { width: 100%; position: static; }
  .letter-library-item-actions .btn:first-child { flex: 1; justify-content: center; }
}

/* Owner-only per-letter access controls. */
.letter-visibility-settings { margin: -.35rem 0 1.15rem; padding: 1rem 1.1rem; background: #f8fafb; border: 1px solid #dce3e8; }
.letter-visibility-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.letter-visibility-row h2 { margin: 0 0 .2rem; color: #314a60; font-size: .89rem; font-weight: 700; }
.letter-visibility-row p, .letter-visibility-reason p { margin: 0; color: #738491; font-size: .75rem; line-height: 1.5; }
.letter-visibility-switch { display: flex; align-items: center; gap: .5rem; cursor: pointer; flex-shrink: 0; }
.letter-visibility-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.letter-visibility-switch-track { width: 45px; height: 25px; border-radius: 20px; background: #a6b3bd; position: relative; transition: background .15s; }
.letter-visibility-switch-track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #1e334155; transition: transform .15s; }
.letter-visibility-switch input:checked + .letter-visibility-switch-track { background: #31668e; }
.letter-visibility-switch input:checked + .letter-visibility-switch-track::after { transform: translateX(20px); }
.letter-visibility-switch input:focus-visible + .letter-visibility-switch-track { outline: 3px solid #75a7d6; outline-offset: 3px; }
.letter-visibility-switch input:disabled + .letter-visibility-switch-track { opacity: .5; }
.letter-visibility-switch-label { font-size: .78rem; min-width: 2.4rem; color: #455c6f; font-weight: 650; }
.letter-visibility-reason { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid #e1e7eb; }
.letter-visibility-reason[hidden] { display: none; }
.letter-visibility-reason label { display: block; font-size: .8rem; font-weight: 650; margin: 0 0 .4rem; color: #455c6f; }
.letter-visibility-reason textarea { resize: vertical; font-size: .85rem; }
.letter-visibility-reason p { margin-top: .4rem; }
.letter-library-access { font-weight: 700; }
.letter-library-access.is-private { color: #986a20; }
.letter-library-access.is-public { color: #36704d; }
@media (max-width: 575.98px) { .letter-visibility-settings { padding: .85rem; } .letter-visibility-row { gap: .6rem; } }
