* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #1e1e1e;
    color: #e0e0e0;
    display: flex;
    min-height: 100vh;
}

.app-container {
    display: flex;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* Control Panel */
.control-panel {
    width: 350px;
    background-color: #2a2a2a;
    padding: 30px;
    border-right: 1px solid #444;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-panel h1 {
    font-size: 24px;
    color: #fff;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 10px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.row-group {
    display: flex;
    gap: 10px;
}

.sub-group {
    flex: 1;
}

.sub-group label {
    font-size: 0.9em;
}

.checkbox-group {
    display: flex;
    gap: 15px;
    align-items: center;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.input-group input[type="text"], 
.input-group textarea,
.input-group select {
    width: 100%;
    background-color: #1e1e1e;
    border: 1px solid #555;
    color: #fff;
    padding: 12px;
    border-radius: 6px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

textarea:focus, input:focus {
    outline: none;
    border-color: #3b82f6;
}

button {
    background-color: #3b82f6;
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

button:hover {
    background-color: #2563eb;
}

button:active {
    transform: scale(0.98);
}

button.secondary {
    background-color: #4b5563;
}

button.secondary:hover {
    background-color: #374151;
}

.custom-dict-details {
    background-color: #333;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 8px 12px;
}

.custom-dict-details summary {
    cursor: pointer;
    font-weight: bold;
    color: #e5e7eb;
    user-select: none;
    font-size: 14px;
}

.custom-dict-content {
    margin-top: 10px;
}

.custom-dict-content .help-text {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 8px;
    line-height: 1.4;
}

#custom-dict-input {
    width: 100%;
    font-family: monospace;
    font-size: 13px;
    padding: 8px;
    background-color: #2a2a2a;
    color: #e5e7eb;
    border: 1px solid #444;
    border-radius: 4px;
    box-sizing: border-box;
    resize: vertical;
}

.footer-info {
    margin-top: auto;
    font-size: 12px;
    color: #888;
    text-align: center;
}

/* Telegram Paper Area */
.paper-container {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px;
    overflow-y: auto;
    background-color: #121212;
}

/* The Paper */
.telegram-paper {
    background-color: #e5d9c5; /* Vintage yellow/brown paper */
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="noiseFilter"><feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%25" height="100%25" filter="url(%23noiseFilter)" opacity="0.05"/></svg>');
    background-size: cover;
    background-position: center;
    width: 210mm;
    height: 198mm;
    padding: 40px 50px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    color: #1a1a1a;
    font-family: 'Noto Serif SC', serif;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.telegram-paper * {
    z-index: 2;
    position: relative;
}

/* Stamps */
.stamp {
    position: absolute;
    z-index: 1;
    font-family: 'Noto Serif SC', serif;
    font-weight: 900;
    pointer-events: none;
    opacity: 0.6;
    mix-blend-mode: multiply;
}

.red-stamp {
    color: #c92a2a;
    border: 6px solid #c92a2a;
    border-radius: 50%;
    width: 150px;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 24px;
    line-height: 1.2;
    padding: 20px;
    transform: rotate(-15deg);
}

.center-stamp {
    top: 50px;
    left: 50%;
    margin-left: -75px;
}

.purple-stamp {
    color: #6741d9;
    border: 4px solid #6741d9;
    font-size: 32px;
    padding: 10px 20px;
    transform: rotate(20deg);
}

.right-stamp {
    top: 150px;
    right: 100px;
}

/* Handwriting */
.handwriting {
    font-family: 'Zhi Mang Xing', 'Ma Shan Zheng', cursive;
    color: #111; /* black ink for filled content */
    font-size: 18px;
}


.box {
    border: 1px solid #1a1a1a;
    height: 100%;
}

.box-title {
    border-bottom: 1px solid #1a1a1a;
    padding: 4px 8px;
    font-size: 14px;
    text-align: center;
}

.box-content {
    padding: 8px;
    text-align: center;
    line-height: 1.2;
}

.header-left, .header-right {
    width: 120px;
}

.header-center {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.main-title {
    font-size: 42px;
    font-weight: 900;
    letter-spacing: 20px;
    font-family: 'CooperZhengKai', "Noto Serif SC", serif;
    color: #1e3a5f; /* ink blue */
    margin: 0;
    line-height: 1;
}

.main-title span {
    display: inline-block;
    width: 60px; /* space between 鐢?and 鎶?*/
}

.sub-title {
    font-size: 16px;
    margin-top: 5px;
    letter-spacing: 5px;
    font-family: 'CooperZhengKai', "Noto Serif SC", serif;
    color: #1e3a5f; /* ink blue */
}

/* Routing Table */
.routing-table {
    width: 100%;
    border-collapse: collapse;
    border: 2px solid #1e3a5f;
    margin-bottom: 0;
    margin-top: 10px;
    mix-blend-mode: multiply;
}

.routing-table th, .routing-table td {
    border: 1px solid #1e3a5f;
    padding: 10px;
    text-align: center;
    font-family: 'CooperZhengKai', "Noto Serif SC", serif;
}

.routing-table td.empty-ao-cell {
    border: none;
    background: transparent;
    vertical-align: middle;
}

.routing-table th {
    font-size: 14px;
    font-weight: normal;
    height: 24px;
    padding: 2px 10px;
    color: #1e3a5f;
    text-align: justify;
    text-align-last: justify;
    white-space: nowrap;
}

.routing-table td.handwriting {
    font-size: 16px;
    height: 50px;
    vertical-align: middle;
    letter-spacing: -1px; /* Reduce spacing for typewriter font */
}

.uppercase {
    text-transform: uppercase;
}

.memo-row {
    display: flex;
    border-left: 2px solid #1e3a5f;
    border-right: 2px solid #1e3a5f;
    border-bottom: 2px solid #1e3a5f;
    margin-bottom: 10px; /* Reduced gap */
    box-sizing: border-box;
    mix-blend-mode: multiply;
}

.memo-title {
    width: 40px;
    border-right: 1px solid #1e3a5f;
    text-align: center;
    padding: 10px 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e3a5f;
}

.memo-content {
    flex: 1;
    padding: 10px;
    font-size: 18px;
    display: flex;
    align-items: center;
}

/* Body Section */
.paper-body {
    margin-top: 0; /* Reduced gap */
    flex: 1;
    display: flex;
    flex-direction: column;
    border-bottom: 6px solid #1e3a5f; /* thick bottom line */
    mix-blend-mode: multiply;
}

.code-grid {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    /* perfectly uniform 1px horizontal lines spaced 45px apart */
    background-image: linear-gradient(to bottom, transparent 44px, #1e3a5f 44px, #1e3a5f 45px);
    background-size: 100% 45px;
    background-position: top left;
    flex: 1;
}

.code-item {
    width: 45px;
    height: 45px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    box-sizing: border-box;
    padding-bottom: 2px;
}

.code-number {
    font-size: 14px;
    font-weight: bold;
    font-family: "Noto Serif SC", serif;
    margin-bottom: 5px;
    color: #111;
}

.code-number:empty {
    display: none;
}

.code-char {
    font-family: 'Zhi Mang Xing', cursive;
    font-size: 20px;
    color: #111;
}

.typewriter-font-active .code-char {
    font-size: 16px;
}

/* Template 2 Specific Styles */
.huiwen-font {
    font-family: 'Huiwen-Fangsong', "Noto Serif SC", serif;
}

.t2-title-image {
    height: 70px;
    width: auto;
    object-fit: contain;
    margin: 0 auto 10px auto;
    mix-blend-mode: multiply;
}

.t1-title-image {
    height: 70px;
    width: auto;
    object-fit: contain;
    margin: 0 auto 2px auto;
    mix-blend-mode: multiply;
    filter: saturate(0.6);
}

.t1-tall-cell {
    height: 80px !important;
}

.t2-edge-date {
    position: absolute;
    right: 20px;
    top: 50px;
    writing-mode: vertical-rl;
    font-size: 16px;
    color: #111;
    mix-blend-mode: multiply;
    font-family: 'CooperZhengKai', "Noto Serif SC", serif;
}

.t2-routing-table {
    margin-top: 30px; /* Space for edge date */
}

.t2-center-cell {
    width: 60%; /* Ensure title has enough space */
}

.t2-memo-title {
    width: 60px;
}

.t2-memo-row {
    border-bottom: 2px solid #1e3a5f;
}

/* Template 2 Footer */
.t2-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 10px;
    mix-blend-mode: multiply;
    color: #1e3a5f;
    font-family: 'CooperZhengKai', "Noto Serif SC", serif;
}

.t2-footer-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.t2-inquiry-text {
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.2;
}

.inquiry-cn {
    font-size: 11px;
}

.inquiry-en {
    font-family: "Times New Roman", "Palatino Linotype", "Book Antiqua", serif;
    font-size: 11px;
}

.t2-form-number {
    font-size: 12px;
}

.t2-footer-right {
    text-align: center;
}

.t2-incoming-label {
    font-size: 14px;
    margin-bottom: 5px;
    text-align: justify;
    text-align-last: justify;
}

.t2-incoming-value {
    font-size: 20px;
    font-weight: bold;
    color: #111;
}

/* Template 2 overrides for colors and dashed lines */
.t2-mode .routing-table {
    border-color: #357e91;
}
.t2-mode .routing-table th, .t2-mode .routing-table td {
    border-color: #357e91;
}
.t2-mode .routing-table th {
    color: #357e91;
}
.t2-mode .memo-row {
    border-color: #357e91;
    border-bottom: none;
    margin-bottom: 0;
}
.t2-mode .memo-title {
    border-color: #357e91;
    color: #357e91;
}
.t2-mode .t2-footer {
    color: #357e91;
}
.t2-mode .t2-edge-date {
    color: #111;
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', Courier, monospace;
    letter-spacing: -1px;
}
.t2-mode .sub-title {
    color: #357e91;
}
.t2-mode .paper-body {
    border-bottom: none;
}
.t2-mode .code-grid {
    background-image: url('data:image/svg+xml;utf8,<svg width="10" height="45" xmlns="http://www.w3.org/2000/svg"><line x1="0" y1="44" x2="10" y2="44" stroke="%23357e91" stroke-width="0.5" stroke-dasharray="2,3" /></svg>');
    background-size: 10px 45px;
    background-position: top left;
    border: 2px solid #357e91;
    margin-top: 0;
}
.t2-mode .code-item {
    border-bottom: none;
}

.t2-typewriter-time {
    font-family: 'Courier New', Courier, 'ZhaohuaTypeWriter Light', monospace;
    color: #111;
    font-size: 16px;
    vertical-align: middle;
    letter-spacing: -1px;
}
/* Template 3 Styles */
/* Template 3 Styles */
.telegram-paper.t3-mode {
    width: 148mm;
    min-height: 210mm;
    padding: 10mm;
}

.t3-mode {
    color: #488b64;
    font-family: 'CooperZhengKai', "Noto Serif SC", serif;
}

#template-3-wrapper {
    color: #488b64;
}

.t3-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.t3-header-left {
    width: 110px;
    font-size: 14px;
    font-weight: bold;
    text-align: left;
    margin-top: -5px;
    margin-left: -5px;
}

.t3-receiving-form {
    line-height: 1.2;
}

.t3-header-center {
    flex: 1;
    text-align: center;
    position: relative;
    padding: 0 10px;
}

.t3-bureau-title-svg {
    width: 140%;
    margin-left: -20%;
    height: auto;
    display: block;
}

.t3-main-title {
    font-family: 'ZhaohuaMinA', '朝華標題A', serif;
    font-size: 22px;
    letter-spacing: 6px;
    margin-top: -15px;
    margin-left: 6px;
    white-space: nowrap;
}

.t3-en-title {
    font-size: 22px;
    font-family: Arial, sans-serif;
    letter-spacing: 4px;
    display: inline-block;
    border-bottom: 1px solid currentColor;
    margin-bottom: 5px;
}

.t3-header-right {
    width: 110px;
    text-align: right;
    font-size: 20px;
}

.t3-meta-rows {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    gap: 30px;
}

.t3-meta-col {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 10px;
}

.t3-meta-item {
    display: flex;
    align-items: flex-end;
    margin-bottom: 5px;
}

.t3-remarks-row {
    display: flex;
    align-items: flex-end;
    margin-top: 10px;
    margin-bottom: 25px; /* distance between remarks and the grid */
    width: 100%;
}

.t3-remarks-value {
    flex-grow: 1;
    border-bottom: 1px dotted #488b64;
    margin-left: 10px;
    min-height: 20px;
    line-height: 1.2;
    padding-bottom: 2px;
}

.t3-meta-label {
    display: block;
    font-size: 9px;
    line-height: 1.2;
    margin-right: 5px;
    white-space: nowrap;
}

.t3-meta-label::first-line {
    font-size: 11px;
}

.t3-meta-value {
    flex: 1;
    border-bottom: 1px dotted #488b64;
    height: 24px;
    text-align: center;
    color: #111;
    font-size: 15px; /* Reduced from 18px */
}

.t3-separator {
    display: flex;
    align-items: center;
    margin: 15px 0;
}

.t3-separator::before,
.t3-separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #488b64;
}

.t3-separator-number {
    font-family: 'Zhi Mang Xing', cursive;
    font-size: 26px;
    color: #1e3a5f; 
    padding: 0 15px;
    line-height: 1;
}

.t3-grid-header {
    display: flex;
    border: 2px solid #488b64;
    border-bottom: none;
}

.t3-grid-header-col {
    flex: 1;
    padding: 5px 10px;
    display: flex;
    flex-direction: row;
    align-items: center;
}

.t3-address-col {
    border-right: 2px solid #488b64;
}

/* T3 Code Grid Layout */
.t3-mode .paper-body {
    border-bottom: none;
}

.t3-mode .code-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr) 30px;
    background-image: none;
    border: 2px solid #488b64;
    border-right: 1px solid #488b64; /* to compensate for item right border */
    border-bottom: 1px solid #488b64; /* to compensate for item bottom border */
    margin: 0;
    gap: 0;
}

.t3-mode .code-item {
    width: 100%;
    border-right: 1px solid #488b64;
    border-bottom: 3px double #488b64;
    height: 40px;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: flex-start;
}

.t3-mode .code-number {
    flex: 5.5;
    font-size: 14px;
    font-family: Arial, sans-serif;
    border-right: 1px solid #488b64;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.t3-mode .code-number:empty {
    display: flex;
}

.t3-mode .code-char {
    flex: 4.5;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.t3-row-number {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-family: Arial, sans-serif;
    color: #488b64;
    border-right: 1px solid #488b64;
    border-bottom: 3px double #488b64;
}

/* T3 Footer */
.t3-footer {
    position: relative;
    margin-top: 5px; /* Reduced to bring it closer */
    color: #488b64;
    padding-bottom: 10px;
}

.t3-footer-left-edge {
    display: none;
}

.t3-footer-bottom {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
}

.t3-footer-from, .t3-footer-to {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 5px 40px; /* Reduced row gap */
}

.t3-footer-item {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    text-align: left;
}

.t3-footer-item .t3-meta-label {
    text-align: left;
    margin-bottom: 0;
    margin-right: 10px;
}

.t3-footer-item .t3-meta-value {
    flex-grow: 1;
    margin-left: 5px;
}

.t3-footer-number {
    position: absolute;
    left: 0;
    bottom: 0;
    font-size: 16px;
    font-family: Arial, sans-serif;
}

/* =========================================
   Template 4 (1951 横线本) Styles
   ========================================= */

.t4-mode.telegram-paper {
    padding-top: 15px;
}

/* Header */
.t4-header {
    position: relative;
    text-align: center;
    margin-bottom: 20px;
    color: #1e3a5f;
}

.t4-top-tag {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 14px;
    font-family: 'Special Elite', 'Courier New', Courier, monospace, 'Noto Serif SC', serif;
}

.t4-title-area {
    padding-top: 10px;
}

.t4-main-title {
    font-size: 60px;
    font-family: 'ZhaohuaMinA', '朝華標題A', serif;
    font-weight: bold;
    letter-spacing: 15px;
}

.t4-sub-title {
    font-size: 20px;
    font-family: 'ZhaohuaMinA', '朝華標題A', serif;
    letter-spacing: 5px;
    margin-top: 5px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.t4-bureau-fill {
    display: inline-block;
    min-width: 100px;
    border-bottom: 2px dotted #1e3a5f;
    margin: 0 10px;
    text-align: center;
    line-height: 1;
    padding-bottom: 2px;
    font-size: 22px;
    letter-spacing: normal;
}

/* Meta Table */
.t4-routing-table {
    margin-bottom: 0;
    border: 3px solid #1e3a5f;
    border-bottom: 1px solid #1e3a5f;
}

.t4-routing-table th {
    font-size: 14px;
    padding: 8px 4px;
    border: 1px solid #1e3a5f;
    font-weight: bold;
    color: #1e3a5f;
    font-family: 'Noto Serif SC', serif;
}

.t4-routing-table td {
    padding: 8px 4px;
    border: 1px solid #1e3a5f;
    height: 30px;
    text-align: center;
}

.t4-remarks-row {
    display: flex;
    border: 3px solid #1e3a5f;
    border-top: none;
    align-items: center;
}

.t4-remarks-label {
    padding: 8px 15px;
    font-size: 14px;
    font-weight: bold;
    color: #1e3a5f;
    border-right: 1px solid #1e3a5f;
    white-space: nowrap;
}

.t4-remarks-content {
    flex: 1;
    padding: 8px 10px;
    min-height: 35px;
}

/* Grid Override (Ruled Lines) */
.t4-mode .paper-body {
    border: 3px solid #1e3a5f;
    border-top: none;
    padding: 0;
    min-height: 384px;
    height: 384px;
}

.t4-mode .code-grid {
    display: block;
    border: none;
    background: repeating-linear-gradient(
        transparent,
        transparent 31px,
        #1e3a5f 31px,
        #1e3a5f 32px
    );
    line-height: 32px;
    padding: 0 10px;
    font-size: 0;
}

.t4-mode .code-item.empty-item {
    display: none;
}

.t4-mode .code-item {
    display: inline-flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: flex-start;
    border: none;
    width: auto;
    height: 32px;
    padding: 0 8px;
    vertical-align: top;
}

.t4-mode .code-number {
    font-size: 16px;
    margin: 0;
    margin-right: 5px;
    display: inline-block;
    border: none;
    flex: none;
    color: #1e3a5f; /* Make numbers match the blue ink theme if we want, or keep it */
}

.t4-mode .code-char {
    font-size: 22px;
    margin: 0;
    display: inline-block;
    flex: none;
}

.t4-mode.typewriter-font-active .code-char {
    font-size: 18px;
}

/* Footer */
.t4-footer {
    position: relative;
    margin-top: 10px;
    color: #1e3a5f;
    padding-bottom: 20px;
}

.t4-footer-bottom {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border: none;
}

.t4-footer-item {
    flex: 1;
    display: flex;
    align-items: flex-end;
    padding: 0 15px;
}

.t4-meta-label {
    font-size: 16px;
    font-weight: bold;
    white-space: nowrap;
}

.t4-footer-item .t4-meta-value {
    flex: 1;
    border-bottom: 1px solid #1e3a5f;
    min-height: 24px;
    margin-left: 5px;
    padding-bottom: 2px;
}

.t4-bottom-tag {
    font-size: 12px;
    margin-top: 5px;
    padding-left: 5px;
    font-family: 'Special Elite', 'Courier New', Courier, monospace, 'Noto Serif SC', serif;
}

/* Template 5 (真蹟电报 - 竖排) */
.telegram-paper.t5-mode {
    display: block;
    position: relative;
    width: 680px;
    height: 960px;
    min-height: 960px;
    padding: 0;
    color: #201817;
}

.telegram-paper.t5-mode #template-5-wrapper {
    position: static !important;
}

.telegram-paper.t5-mode .stamp-layer,
.telegram-paper.t5-mode .paper-body {
    display: none !important;
}

.telegram-paper.t5-mode .t5-frame {
    position: absolute;
    z-index: 1;
    top: 31px;
    right: 29px;
    bottom: 31px;
    left: 91px;
    border: 1.5px solid #3c302b;
    pointer-events: none;
}

.telegram-paper.t5-mode .t5-sidebar {
    position: absolute;
    z-index: 3;
    top: 31px;
    right: 29px;
    bottom: 31px;
    width: 112px;
    border-left: 1px solid #3c302b;
}

.telegram-paper.t5-mode .t5-title {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 438px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 8px;
    border-bottom: 1px solid #3c302b;
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-family: 'Noto Serif SC', serif;
    font-size: 23px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 5px;
}

.telegram-paper.t5-mode .t5-meta {
    position: absolute;
    top: 438px;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-rows: 156px minmax(0, 1fr);
}

/* 原来号数、流水号数：四行单列横线表格。 */
.telegram-paper.t5-mode .t5-number-table {
    position: static;
    display: grid;
    grid-template-rows: repeat(4, 1fr);
    border-bottom: 1px solid #3c302b;
}

.telegram-paper.t5-mode .t5-number-label,
.telegram-paper.t5-mode .t5-number-value {
    position: static;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    margin: 0;
    padding: 3px;
    border-bottom: 1px solid #3c302b;
    text-align: center;
}

.telegram-paper.t5-mode .t5-number-label {
    font-family: 'Noto Serif SC', serif;
    font-size: 12px;
    letter-spacing: 1px;
}

.telegram-paper.t5-mode .t5-number-value {
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
}

.telegram-paper.t5-mode .t5-number-table > :last-child {
    border-bottom: 0;
}

/* 发报日期、发报局名：两行两列；仅显示列间竖线。 */
.telegram-paper.t5-mode .t5-detail-table {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: 70px minmax(0, 1fr);
}

.telegram-paper.t5-mode .t5-detail-label,
.telegram-paper.t5-mode .t5-detail-value {
    position: static;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 5px 3px;
    text-align: center;
}

.telegram-paper.t5-mode .t5-detail-label {
    align-items: center;
    justify-content: flex-start;
    padding-top: 8px;
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-family: 'Noto Serif SC', serif;
    font-size: 13px;
    line-height: 1.2;
    letter-spacing: 2px;
}

.telegram-paper.t5-mode .t5-detail-value {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    padding-top: 5px;
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 20px;
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: 1px;
}

.telegram-paper.t5-mode .t5-detail-value > span {
    position: static;
    writing-mode: vertical-rl;
    text-orientation: upright;
}

.telegram-paper.t5-mode .t5-detail-table > :nth-child(2),
.telegram-paper.t5-mode .t5-detail-table > :nth-child(4) {
    border-left: 1px solid #3c302b;
}

/* 表头与填写项之间不显示横向间隔线。 */
.telegram-paper.t5-mode .t5-detail-label,
.telegram-paper.t5-mode .t5-detail-value {
    border-top: 0;
    border-bottom: 0;
}
.telegram-paper.t5-mode .t5-left-note {
    position: absolute;
    z-index: 3;
    top: 72px;
    bottom: 105px;
    left: 23px;
    display: flex;
    flex-direction: row-reverse;
    color: #62554e;
    font-family: 'Noto Serif SC', serif;
}

.telegram-paper.t5-mode .t5-note-col {
    position: static;
    display: flex;
    align-items: center;
    margin-left: 10px;
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 12px;
    letter-spacing: 1px;
}

.telegram-paper.t5-mode .t5-note-col .note-title,
.telegram-paper.t5-mode .t5-note-col .note-items {
    position: static;
}

.telegram-paper.t5-mode .t5-note-col .note-title {
    margin-bottom: 10px;
    font-size: 14px;
    letter-spacing: 3px;
}

.telegram-paper.t5-mode .t5-note-col .note-items {
    font-size: 10px;
    line-height: 1.55;
}

.telegram-paper.t5-mode .t5-note-col.note-date-col {
    margin-left: 17px;
}

.telegram-paper.t5-mode .t5-note-col.t5-address {
    margin-left: 0;
}

.telegram-paper.t5-mode .t5-text {
    position: absolute;
    z-index: 2;
    top: 49px;
    right: 157px;
    bottom: 52px;
    left: 156px;
    overflow: hidden;
    writing-mode: vertical-rl;
    text-orientation: upright;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 25px;
    line-height: 1.55;
    letter-spacing: 2px;
    color: #201817;
    mix-blend-mode: multiply;
}

.telegram-paper.t5-mode.typewriter-font-active .t5-text {
    font-size: 22px;
}

.telegram-paper.t5-mode .t5-signature {
    position: absolute;
    z-index: 3;
    bottom: 112px;
    left: 112px;
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 38px;
    line-height: 1.05;
    letter-spacing: 3px;
    color: #1c1513;
}

@media (max-width: 820px) {
    .telegram-paper.t5-mode {
        transform-origin: top left;
    }
}
/* Template 5 printed headings use Cooper Zheng Kai. */
.telegram-paper.t5-mode .t5-title,
.telegram-paper.t5-mode .t5-number-label,
.telegram-paper.t5-mode .t5-detail-label {
    font-family: 'CooperZhengKai', 'Noto Serif SC', serif;
}

.telegram-paper.t5-mode .t5-detail-label {
    white-space: nowrap;
}

.telegram-paper.t5-mode .t5-date-fill {
    display: block;
    padding-top: 5px;
    white-space: nowrap;
    writing-mode: vertical-rl;
    text-orientation: upright;
}

.telegram-paper.t5-mode .t5-date-fill > span {
    position: static;
    display: inline;
    writing-mode: vertical-rl;
    text-orientation: upright;
}

.telegram-paper.t5-mode .t5-date-fill > .t5-unit {
    font-family: 'CooperZhengKai', 'Noto Serif SC', serif;
}
/* Template 5 compact sidebar refinement. */
.telegram-paper.t5-mode .t5-title {
    height: 400px;
    padding: 12px 6px;
    font-size: 28px;
    letter-spacing: 4px;
}

.telegram-paper.t5-mode .t5-meta {
    top: 400px;
    grid-template-rows: 128px minmax(0, 1fr);
}

.telegram-paper.t5-mode .t5-number-label,
.telegram-paper.t5-mode .t5-number-value {
    padding: 1px 2px;
}

.telegram-paper.t5-mode .t5-number-label,
.telegram-paper.t5-mode .t5-detail-label {
    font-size: 16px;
    line-height: 1;
    letter-spacing: 0;
}

.telegram-paper.t5-mode .t5-detail-table {
    grid-template-rows: 78px minmax(0, 1fr);
}

.telegram-paper.t5-mode .t5-date-fill {
    display: block;
    padding-top: 2px;
    white-space: nowrap;
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 18px;
    line-height: 1;
    letter-spacing: 0;
}

.telegram-paper.t5-mode .t5-date-fill > span {
    margin: 0;
}

.telegram-paper.t5-mode .t5-date-fill > span:not(.t5-unit) {
    display: inline-block;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    text-combine-upright: all;
    letter-spacing: 0;
}
/* Template 5 date column centering. */
.telegram-paper.t5-mode .t5-date-fill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    writing-mode: horizontal-tb;
}

.telegram-paper.t5-mode .t5-date-fill > span,
.telegram-paper.t5-mode .t5-date-fill > span:not(.t5-unit) {
    display: block;
    margin: 0;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    text-align: center;
}
/* Template 5 denser right-side structure. */
.telegram-paper.t5-mode .t5-title {
    height: 380px;
}

.telegram-paper.t5-mode .t5-meta {
    top: 380px;
    bottom: auto;
    height: 500px;
    grid-template-rows: 112px 388px;
}

.telegram-paper.t5-mode .t5-number-label,
.telegram-paper.t5-mode .t5-detail-label {
    font-size: 18px;
    font-weight: 700;
}
/* Keep enlarged vertical headings inside their cells. */
.telegram-paper.t5-mode .t5-detail-label {
    padding: 2px 3px;
}
/* Template 5 larger page margins: shrink the complete telegram structure. */
.telegram-paper.t5-mode .t5-frame,
.telegram-paper.t5-mode .t5-sidebar {
    top: 48px;
    bottom: 48px;
}

.telegram-paper.t5-mode .t5-title {
    height: 400px;
}

.telegram-paper.t5-mode .t5-meta {
    top: 400px;
    bottom: 0;
    height: auto;
    grid-template-rows: 112px minmax(0, 1fr);
}

.telegram-paper.t5-mode .t5-text {
    top: 66px;
    bottom: 69px;
}

.telegram-paper.t5-mode .t5-left-note {
    top: 89px;
    bottom: 122px;
}

.telegram-paper.t5-mode .t5-signature {
    bottom: 129px;
}
/* Template 5 roomier detail cells. */
.telegram-paper.t5-mode .t5-detail-table {
    grid-template-rows: 88px minmax(0, 1fr);
}

.telegram-paper.t5-mode .t5-detail-label {
    padding: 6px;
}

.telegram-paper.t5-mode .t5-detail-value,
.telegram-paper.t5-mode .t5-date-fill {
    padding: 10px 6px;
}
/* Template 5 outer frame and replacement side notes. */
.telegram-paper.t5-mode .t5-frame {
    border-width: 2.5px;
}

.telegram-paper.t5-mode .t5-left-note {
    top: 48px;
    bottom: 48px;
    left: 12px;
    width: 68px;
    display: flex;
    flex-direction: row-reverse;
    align-items: stretch;
    justify-content: center;
    gap: 3px;
    color: #3c302b;
    font-family: 'CooperZhengKai', 'Noto Serif SC', serif;
    font-size: 11px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: 0;
}

.telegram-paper.t5-mode .t5-note-title,
.telegram-paper.t5-mode .t5-note-item {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    writing-mode: vertical-rl;
    text-orientation: upright;
    white-space: nowrap;
    font: inherit;
}
/* Template 5 notes: title above four top-aligned vertical columns. */
.telegram-paper.t5-mode .t5-left-note {
    top: 62px;
    bottom: auto;
    left: 10px;
    width: 72px;
    height: 190px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 20px 1fr;
    column-gap: 2px;
    row-gap: 6px;
    align-items: start;
}

.telegram-paper.t5-mode .t5-note-title {
    grid-column: 1 / -1;
    grid-row: 1;
    display: block;
    justify-self: center;
    writing-mode: horizontal-tb;
    text-align: center;
}

.telegram-paper.t5-mode .t5-note-item {
    grid-row: 2;
    display: block;
    align-self: start;
    justify-self: center;
    writing-mode: vertical-rl;
}

.telegram-paper.t5-mode .t5-note-item:nth-child(2) { grid-column: 4; }
.telegram-paper.t5-mode .t5-note-item:nth-child(3) { grid-column: 3; }
.telegram-paper.t5-mode .t5-note-item:nth-child(4) { grid-column: 2; }
.telegram-paper.t5-mode .t5-note-item:nth-child(5) { grid-column: 1; }
/* Template 5 restored issue-date stamp. */
.telegram-paper.t5-mode .t5-date-stamp {
    position: absolute;
    z-index: 4;
    right: auto;
    bottom: 64px;
    left: 36px;
    writing-mode: vertical-rl;
    text-orientation: upright;
    white-space: nowrap;
    font-family: 'ZhaohuaMinA', '朝華標題A', serif;
    font-size: 19px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: 2px;
    color: #6c2f78;
    opacity: 0.76;
    mix-blend-mode: multiply;
    transform: rotate(-1.4deg);
    filter: contrast(1.18) saturate(0.9);
    text-shadow: 0.5px 0 rgba(82, 27, 92, 0.42), -0.35px 0.45px rgba(111, 48, 126, 0.3);
    pointer-events: none;
}

.telegram-paper.t5-mode .t5-date-stamp::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    writing-mode: vertical-rl;
    text-orientation: upright;
    color: #7b4387;
    opacity: 0.22;
    transform: translate(0.7px, -0.6px);
    text-shadow: 0 0 0.7px rgba(64, 17, 75, 0.65);
}
/* Template 5 isolated control-panel layout. */
.control-panel.t5-control-mode .shared-routing-inputs,
.control-panel.t5-control-mode .checkbox-group,
.control-panel.t5-control-mode .custom-dict-group,
.control-panel.t5-control-mode .memo-input-group {
    display: none !important;
}

.control-panel .t5-section-heading {
    align-items: center;
    color: #d8c9a8;
    font-family: 'CooperZhengKai', 'Noto Serif SC', serif;
    font-size: 17px;
    letter-spacing: 1px;
}

.control-panel.t5-control-mode .t5-only {
    padding: 10px 12px;
    border: 1px solid #4b4741;
    border-radius: 7px;
    background: #302f2d;
}

.control-panel.t5-control-mode .t5-section-heading {
    justify-content: center;
    padding: 8px 12px;
    border-color: #655d50;
    background: #393630;
}

.control-panel.t5-control-mode .t5-stamp-date-control {
    display: flex;
}
/* Template 5 vertical side-note heading. */
.telegram-paper.t5-mode .t5-left-note {
    grid-template-rows: 28px 1fr;
}

.telegram-paper.t5-mode .t5-note-title {
    writing-mode: vertical-rl;
    text-orientation: upright;
    line-height: 1;
}
/* Numbered paper backgrounds with orientation-aware rotation. */
.telegram-paper.custom-paper-bg {
    isolation: isolate;
    overflow: hidden;
}

.telegram-paper.custom-paper-bg::before {
    content: '';
    position: absolute;
    z-index: 0;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background-image: var(--paper-bg-image);
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.telegram-paper.custom-paper-bg.paper-bg-rotated::before {
    width: var(--paper-bg-layer-width);
    height: var(--paper-bg-layer-height);
    transform: translate(-50%, -50%) rotate(90deg);
}
/* Template 6 (Western Union - English/Chinese plain-text telegram) */
.telegram-paper.t6-mode {
    position: relative;
    display: block;
    width: 1000px;
    height: 714px;
    min-height: 714px;
    padding: 0;
    overflow: hidden;
    color: #10182b;
}

.telegram-paper.t6-mode #template-6-wrapper {
    position: absolute !important;
    z-index: 2;
    inset: 0;
}

.telegram-paper.t6-mode .stamp-layer,
.telegram-paper.t6-mode .paper-body {
    display: none !important;
}

.telegram-paper.t6-mode .t6-header {
    height: 190px;
    display: grid;
    grid-template-columns: 182px minmax(0, 1fr) 182px;
    gap: 28px;
    padding: 22px 38px 5px;
    align-items: start;
}

.telegram-paper.t6-mode .t6-info-box {
    height: 138px;
    border: 3px solid #111a2e;
    color: #111a2e;
    background: rgba(232, 226, 202, 0.12);
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 700;
    text-align: center;
}

.telegram-paper.t6-mode .t6-info-box h3 {
    padding: 7px 4px 5px;
    border-bottom: 2px solid #111a2e;
    font-size: 15px;
    line-height: 1;
}

.telegram-paper.t6-mode .t6-service-box p {
    padding: 10px 11px;
    font-size: 13px;
    line-height: 1.08;
}

.telegram-paper.t6-mode .t6-symbols-box {
    display: grid;
    grid-template-rows: 31px repeat(5, 1fr);
}

.telegram-paper.t6-mode .t6-symbols-box > div {
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #111a2e;
    font-size: 12px;
    line-height: 1;
}

.telegram-paper.t6-mode .t6-symbols-box > div:last-child {
    border-bottom: 0;
}

.telegram-paper.t6-mode .t6-brand {
    position: relative;
    height: 163px;
    text-align: center;
    color: #0b1327;
    font-family: Georgia, 'Times New Roman', serif;
}

.telegram-paper.t6-mode .t6-brand-name {
    font-size: 72px;
    font-weight: 500;
    line-height: 0.77;
    letter-spacing: 5px;
    transform: scaleX(1.08);
    transform-origin: top center;
}

.telegram-paper.t6-mode .t6-president {
    margin-top: 7px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: 1px;
}

.telegram-paper.t6-mode .t6-president span {
    font-size: 10px;
}

.telegram-paper.t6-mode .t6-form-number {
    position: absolute;
    top: 11px;
    right: -7px;
    font-size: 12px;
    font-weight: 700;
}

.telegram-paper.t6-mode .t6-time-notice {
    height: 28px;
    margin: 0 37px;
    padding: 5px 3px 3px;
    border-top: 4px double #111a2e;
    border-bottom: 1px solid #111a2e;
    overflow: hidden;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}

.telegram-paper.t6-mode .t6-routing-area {
    height: 137px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 24px;
    padding: 15px 46px 10px;
    border-bottom: 1px solid rgba(34, 37, 45, 0.42);
}

.telegram-paper.t6-mode .t6-routing-main {
    min-width: 0;
}

.telegram-paper.t6-mode .t6-tape {
    width: max-content;
    max-width: 100%;
    min-height: 27px;
    margin-bottom: 8px;
    padding: 2px 9px 1px;
    overflow: hidden;
    background: rgba(226, 224, 214, 0.68);
    border: 1px solid rgba(91, 84, 96, 0.18);
    box-shadow: 1px 2px 2px rgba(48, 40, 34, 0.18);
    color: rgba(75, 56, 119, 0.72);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 21px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: 1px;
    white-space: nowrap;
    text-overflow: clip;
    mix-blend-mode: multiply;
}

.telegram-paper.t6-mode .t6-recipient-line {
    transform: translateX(8px) rotate(-0.25deg);
}

.telegram-paper.t6-mode .t6-address-line {
    margin-left: 115px;
    transform: rotate(0.18deg);
}

.telegram-paper.t6-mode .t6-received-line {
    align-self: center;
    margin-top: 34px;
    font-size: 20px;
    transform: rotate(0.3deg);
}

.telegram-paper.t6-mode .t6-message-area {
    position: absolute;
    top: 367px;
    right: 42px;
    bottom: 62px;
    left: 42px;
    overflow: hidden;
    color: rgba(74, 56, 119, 0.68);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 24px;
    font-weight: 400;
    line-height: 1.68;
    letter-spacing: 1.2px;
    text-align: left;
    mix-blend-mode: multiply;
}

.telegram-paper.t6-mode .t6-message-copy {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.telegram-paper.t6-mode .t6-message-strips .t6-message-copy {
    padding: 3px 8px 2px;
    background: rgba(226, 224, 214, 0.68);
    border-top: 1px solid rgba(91, 84, 96, 0.13);
    border-bottom: 1px solid rgba(91, 84, 96, 0.13);
    box-shadow: 2px 2px 2px rgba(48, 40, 34, 0.14);
}

.telegram-paper.t6-mode .t6-footer {
    position: absolute;
    right: 0;
    bottom: 18px;
    left: 0;
    color: #10182b;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.8px;
    text-align: center;
}

/* Template 6 isolated control panel. */
.control-panel.t6-control-mode .shared-routing-inputs,
.control-panel.t6-control-mode .checkbox-group,
.control-panel.t6-control-mode .custom-dict-group,
.control-panel.t6-control-mode .memo-input-group,
.control-panel.t6-control-mode .font-input-group {
    display: none !important;
}

.control-panel .t6-section-heading {
    align-items: center;
    justify-content: center;
    color: #d8c9a8;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.control-panel.t6-control-mode .t6-only {
    padding: 10px 12px;
    border: 1px solid #4b4741;
    border-radius: 7px;
    background: #302f2d;
}

.control-panel.t6-control-mode .t6-section-heading {
    padding: 8px 12px;
    border-color: #655d50;
    background: #393630;
}

.control-panel.t6-control-mode .t6-strip-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 500;
    cursor: pointer;
}

.control-panel.t6-control-mode .t6-strip-toggle input {
    width: auto;
}
/* Template 6 chamfered upper corners on both header boxes. */
.telegram-paper.t6-mode .t6-info-box {
    position: relative;
    border: 0;
    padding: 3px;
    overflow: hidden;
    background: #111a2e;
    clip-path: polygon(
        11px 0,
        calc(100% - 11px) 0,
        100% 11px,
        100% 100%,
        0 100%,
        0 11px
    );
}

.telegram-paper.t6-mode .t6-info-box::before {
    content: '';
    position: absolute;
    z-index: 0;
    inset: 3px;
    background: rgba(229, 217, 197, 0.9);
    clip-path: polygon(
        8px 0,
        calc(100% - 8px) 0,
        100% 8px,
        100% 100%,
        0 100%,
        0 8px
    );
    pointer-events: none;
}
/* Template 6 transparent chamfered boxes. */
.telegram-paper.t6-mode .t6-info-box {
    background: transparent;
}

.telegram-paper.t6-mode .t6-info-box::before {
    inset: 0;
    padding: 3px;
    background: #111a2e;
    clip-path: polygon(
        11px 0,
        calc(100% - 11px) 0,
        100% 11px,
        100% 100%,
        0 100%,
        0 11px
    );
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}
/* Template 6 supplied PNG title and frame artwork. */
.telegram-paper.t6-mode .t6-header {
    height: 215px;
}

.telegram-paper.t6-mode .t6-brand {
    height: 188px;
}

.telegram-paper.t6-mode .t6-brand-image {
    display: block;
    width: 100%;
    height: auto;
    margin: -4px auto 0;
}

.telegram-paper.t6-mode .t6-president {
    position: absolute;
    top: 176px;
    right: 0;
    left: 0;
    margin-top: 0;
}

.telegram-paper.t6-mode .t6-message-area {
    top: 392px;
}

.telegram-paper.t6-mode .t6-info-box {
    padding: 3px;
    overflow: visible;
    background-color: transparent;
    background-image: url('2x/frame3.png');
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    clip-path: none;
}

.telegram-paper.t6-mode .t6-info-box::before {
    display: none;
}
/* Template 6 smaller supplied title. */
.telegram-paper.t6-mode .t6-brand-image {
    width: 90%;
}
/* Template 6 title and president position refinement. */
.telegram-paper.t6-mode .t6-brand-image {
    width: 82%;
}

.telegram-paper.t6-mode .t6-president {
    top: 150px;
}
/* Template 6 tighter spacing below the president line. */
.telegram-paper.t6-mode .t6-header {
    height: 195px;
}

.telegram-paper.t6-mode .t6-brand {
    height: 168px;
}

.telegram-paper.t6-mode .t6-message-area {
    top: 372px;
}
/* Template 6 optically centered president spacing. */
.telegram-paper.t6-mode .t6-president {
    top: 148px;
}
/* Template 6 lower header boxes and lighter inner copy. */
.telegram-paper.t6-mode .t6-info-box {
    transform: translateY(7px);
}

.telegram-paper.t6-mode .t6-service-box p {
    font-size: 11px;
    font-weight: 400;
    font-stretch: normal;
    letter-spacing: 0;
    transform: none;
}

.telegram-paper.t6-mode .t6-symbols-box > div {
    font-size: 10.5px;
    font-weight: 400;
    font-stretch: normal;
    letter-spacing: 0;
    transform: none;
}
/* Template 6 service copy and complete time notice. */
.telegram-paper.t6-mode .t6-service-box p {
    line-height: 1.4;
}

.telegram-paper.t6-mode .t6-time-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 1px 1px;
    font-size: 9.5px;
    line-height: 1;
    letter-spacing: -0.1px;
}
/* Template 7 (Post Office Telegram) */
.telegram-paper.t7-mode {
    position: relative;
    display: block;
    width: 1000px;
    height: 675px;
    min-height: 675px;
    padding: 0;
    overflow: hidden;
    background-color: #ead9aa;
    color: #25241f;
}

.telegram-paper.t7-mode:not(.custom-paper-bg) {
    background-image: linear-gradient(98deg, rgba(255,255,255,.11), transparent 38%, rgba(129,94,40,.05) 72%, transparent);
}

.telegram-paper.t7-mode #template-7-wrapper {
    position: absolute !important;
    z-index: 2;
    inset: 0;
    overflow: hidden;
    font-family: Arial, Helvetica, sans-serif;
}

.telegram-paper.t7-mode .stamp-layer,
.telegram-paper.t7-mode .paper-body {
    display: none !important;
}

.telegram-paper.t7-mode .t7-corner-mark {
    position: absolute;
    top: 23px;
    width: 61px;
    height: 3px;
    background: #282820;
}

.telegram-paper.t7-mode .t7-corner-left { left: 18px; }
.telegram-paper.t7-mode .t7-corner-right { right: 18px; }

.telegram-paper.t7-mode .t7-header {
    position: absolute;
    top: 28px;
    right: 18px;
    left: 18px;
    height: 207px;
    border-bottom: 4px solid #292920;
}

.telegram-paper.t7-mode .t7-top-left {
    position: absolute;
    top: 20px;
    left: 15px;
    width: 195px;
    height: 110px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 12px;
}

.telegram-paper.t7-mode .t7-no-line {
    display: grid;
    grid-template-columns: 38px 1fr;
    min-height: 30px;
}

.telegram-paper.t7-mode .t7-no-line strong {
    color: rgba(61, 67, 65, .85);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', monospace;
    font-size: 22px;
    font-weight: 400;
    letter-spacing: 2px;
}

.telegram-paper.t7-mode .t7-office-stamp-label {
    margin-top: 6px;
    font-weight: 700;
}

.telegram-paper.t7-mode .t7-brand-block {
    position: absolute;
    top: 11px;
    left: 50%;
    width: 390px;
    transform: translateX(-50%);
    text-align: center;
}

.telegram-paper.t7-mode .t7-brand-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 25px;
    height: 55px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 23px;
    font-weight: 900;
    letter-spacing: 1px;
}

.telegram-paper.t7-mode .t7-crown {
    display: block;
    width: 48px;
    height: 44px;
    object-fit: contain;
}

.telegram-paper.t7-mode .t7-title {
    margin-top: -3px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 25px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 6px;
}

.telegram-paper.t7-mode .t7-top-right {
    position: absolute;
    top: 0;
    right: 16px;
    width: 170px;
    height: 189px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 12px;
}

.telegram-paper.t7-mode .t7-top-right > div:not(.t7-money-row):not(.t7-charges-label) {
    display: grid;
    grid-template-columns: 39px 1fr;
    min-height: 28px;
    align-items: center;
}

.telegram-paper.t7-mode .t7-top-right strong {
    min-height: 18px;
    color: rgba(61, 67, 65, .88);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', monospace;
    font-size: 15px;
    font-weight: 400;
}

.telegram-paper.t7-mode .t7-money-row {
    display: flex;
    justify-content: flex-end;
    gap: 45px;
    padding: 2px 12px 0 0;
    font-size: 10px;
}

.telegram-paper.t7-mode .t7-money-row em {
    font-style: normal;
}

.telegram-paper.t7-mode .t7-charges-label {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: end;
    gap: 8px;
    min-height: 25px;
    font-weight: 700;
}

.telegram-paper.t7-mode .t7-inquiry-copy {
    position: absolute;
    top: 97px;
    left: 200px;
    width: 510px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 11px;
    line-height: 1.2;
    text-align: left;
}

.telegram-paper.t7-mode .t7-origin-note {
    position: absolute;
    top: 151px;
    left: 201px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 9px;
    line-height: 1.05;
}

.telegram-paper.t7-mode .t7-office-stamp {
    position: absolute;
    z-index: 4;
    top: 72px;
    left: 31px;
    width: 151px;
    height: 151px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 5px double rgba(93, 63, 100, .36);
    border-radius: 50%;
    color: rgba(92, 62, 99, .38);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 15px;
    line-height: 1.4;
    text-align: center;
    transform: rotate(-21deg);
    mix-blend-mode: multiply;
    pointer-events: none;
}

.telegram-paper.t7-mode .t7-office-stamp::before,
.telegram-paper.t7-mode .t7-office-stamp::after {
    content: '';
    position: absolute;
    right: 10px;
    left: 10px;
    height: 2px;
    background: currentColor;
}

.telegram-paper.t7-mode .t7-office-stamp::before { top: 45px; }
.telegram-paper.t7-mode .t7-office-stamp::after { bottom: 44px; }

.telegram-paper.t7-mode .t7-office-stamp strong {
    font-size: 17px;
    font-weight: 500;
    letter-spacing: 1px;
}

.telegram-paper.t7-mode .t7-office-stamp small {
    font-size: 10px;
    letter-spacing: 1px;
}

.telegram-paper.t7-mode .t7-message-area {
    position: absolute;
    top: 235px;
    right: 18px;
    left: 58px;
    height: 264px;
    overflow: hidden;
    border-left: 2px solid rgba(43, 43, 35, .72);
    border-bottom: 3px solid #292920;
}

.telegram-paper.t7-mode .t7-message-lines {
    position: absolute;
    z-index: 0;
    inset: 0;
    display: grid;
    grid-template-rows: repeat(6, 41px);
}

.telegram-paper.t7-mode .t7-message-lines i {
    display: block;
    border-bottom: 1px solid rgba(74, 69, 51, .13);
}

.telegram-paper.t7-mode .t7-message-copy {
    position: absolute;
    z-index: 1;
    top: 7px;
    right: 23px;
    left: 25px;
    max-height: 246px;
    overflow: hidden;
    color: rgba(61, 67, 65, .9);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 22px;
    font-weight: 400;
    line-height: 41px;
    letter-spacing: 2.2px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    text-transform: uppercase;
    mix-blend-mode: multiply;
}

.telegram-paper.t7-mode .t7-message-copy.t7-copy-long {
    font-size: 18px;
    letter-spacing: 1.4px;
}

.telegram-paper.t7-mode .t7-message-copy.t7-copy-dense {
    font-size: 15px;
    letter-spacing: .8px;
}

.telegram-paper.t7-mode .t7-bottom-form {
    position: absolute;
    top: 499px;
    right: 18px;
    left: 58px;
    height: 126px;
    display: grid;
    grid-template-columns: 8% 8% 12% 43% 8% 21%;
    border-left: 2px solid #292920;
    border-bottom: 2px solid #292920;
    color: #292920;
}

.telegram-paper.t7-mode .t7-bottom-cell {
    position: relative;
    min-width: 0;
    padding: 9px 7px;
    border-right: 2px solid #292920;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 9px;
}

.telegram-paper.t7-mode .t7-bottom-cell > span {
    display: block;
    line-height: 1.12;
}

.telegram-paper.t7-mode .t7-bottom-cell > strong,
.telegram-paper.t7-mode .t7-bottom-cell div > strong {
    color: rgba(61, 67, 65, .88);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 17px;
    font-weight: 400;
    letter-spacing: 1px;
}

.telegram-paper.t7-mode .t7-prefix-cell,
.telegram-paper.t7-mode .t7-code-cell,
.telegram-paper.t7-mode .t7-handed-cell {
    text-align: center;
}

.telegram-paper.t7-mode .t7-prefix-cell > strong,
.telegram-paper.t7-mode .t7-code-cell > strong,
.telegram-paper.t7-mode .t7-handed-cell > strong {
    display: block;
    margin-top: 23px;
}

.telegram-paper.t7-mode .t7-origin-cell > strong {
    display: block;
    margin: 17px 0 7px;
    font-size: 20px;
}

.telegram-paper.t7-mode .t7-origin-cell small {
    display: block;
    font-size: 8px;
    line-height: 1.05;
}

.telegram-paper.t7-mode .t7-words-cell {
    text-align: center;
}

.telegram-paper.t7-mode .t7-words-cell > strong {
    display: block;
    margin-top: 15px;
    font-size: 24px;
}

.telegram-paper.t7-mode .t7-words-cell > div {
    position: absolute;
    right: 6px;
    bottom: 8px;
    left: 6px;
    display: flex;
    justify-content: space-around;
}

.telegram-paper.t7-mode .t7-words-cell em {
    font-size: 8px;
    font-style: normal;
}

.telegram-paper.t7-mode .t7-received-cell {
    padding: 7px 8px;
}

.telegram-paper.t7-mode .t7-received-cell > span {
    margin-bottom: 4px;
}

.telegram-paper.t7-mode .t7-received-cell > div {
    display: grid;
    grid-template-columns: 33px 1fr;
    align-items: baseline;
    min-height: 25px;
}

.telegram-paper.t7-mode .t7-received-cell label {
    font-size: 9px;
}

.telegram-paper.t7-mode .t7-received-cell div > strong {
    font-size: 16px;
}

.telegram-paper.t7-mode .t7-received-at {
    position: absolute;
    top: 35px;
    right: 7px;
    max-width: 58px;
    font-size: 12px !important;
    text-align: right;
}

.telegram-paper.t7-mode .t7-footer-code,
.telegram-paper.t7-mode .t7-footer-mark {
    position: absolute;
    bottom: 18px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 7px;
    font-weight: 700;
}

.telegram-paper.t7-mode .t7-footer-code { left: 60px; }
.telegram-paper.t7-mode .t7-footer-mark { right: 25px; }

/* Template 7 isolated control panel. */
.control-panel.t7-control-mode .shared-routing-inputs,
.control-panel.t7-control-mode .checkbox-group,
.control-panel.t7-control-mode .custom-dict-group,
.control-panel.t7-control-mode .memo-input-group,
.control-panel.t7-control-mode .font-input-group {
    display: none !important;
}

.control-panel .t7-section-heading {
    align-items: center;
    justify-content: center;
    color: #d7c9a7;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 16px;
    font-weight: 700;
}

.control-panel.t7-control-mode .t7-only {
    padding: 10px 12px;
    border: 1px solid #4f4b40;
    border-radius: 7px;
    background: #302f2b;
}

.control-panel.t7-control-mode .t7-section-heading {
    padding: 8px 12px;
    border-color: #68604e;
    background: #39362f;
}

.control-panel.t7-control-mode .t7-stamp-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 500;
    cursor: pointer;
}

.control-panel.t7-control-mode .t7-stamp-toggle input {
    width: auto;
}
/* Template 8 (Official Use Telegram) */
.telegram-paper.t8-mode {
    position: relative;
    display: block;
    width: 760px;
    height: 740px;
    min-height: 740px;
    padding: 0;
    overflow: hidden;
    border: 7px solid #25251f;
    background-color: #e8d5a9;
    color: #292820;
}

.telegram-paper.t8-mode:not(.custom-paper-bg) {
    background-image: linear-gradient(93deg, rgba(255,255,255,.1), transparent 42%, rgba(110,82,39,.05) 70%, transparent);
}

.telegram-paper.t8-mode #template-8-wrapper {
    position: absolute !important;
    z-index: 2;
    inset: 0;
    overflow: hidden;
    font-family: Georgia, 'Times New Roman', serif;
}

.telegram-paper.t8-mode .stamp-layer,
.telegram-paper.t8-mode .paper-body {
    display: none !important;
}

.telegram-paper.t8-mode .t8-side-rail {
    position: absolute;
    top: 26px;
    bottom: 22px;
    left: 15px;
    width: 76px;
    border-right: 2px solid #3d3b30;
    text-align: center;
}

.telegram-paper.t8-mode .t8-side-rail > strong {
    display: block;
    margin-top: 8px;
    font-size: 29px;
    font-weight: 500;
}

.telegram-paper.t8-mode .t8-official-use {
    position: absolute;
    top: 66px;
    right: 0;
    left: 0;
    font-size: 9px;
    font-weight: 700;
    line-height: 3.5;
}

.telegram-paper.t8-mode .t8-block-letters {
    position: absolute;
    top: 330px;
    left: 25px;
    width: 17px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.32;
    letter-spacing: 1px;
    writing-mode: vertical-rl;
    text-orientation: upright;
}

.telegram-paper.t8-mode .t8-header {
    position: absolute;
    top: 24px;
    right: 22px;
    left: 89px;
    height: 88px;
}

.telegram-paper.t8-mode .t8-agency {
    position: absolute;
    top: 2px;
    right: 152px;
    left: 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .4px;
    text-align: center;
}

.telegram-paper.t8-mode .t8-title {
    position: absolute;
    top: 25px;
    right: 154px;
    left: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 3px;
    text-align: center;
}

.telegram-paper.t8-mode .t8-sent-line {
    position: absolute;
    right: 153px;
    bottom: 0;
    left: 5px;
    display: grid;
    grid-template-columns: 38px 1fr 25px 1fr 25px 1fr;
    align-items: center;
    min-height: 24px;
    font-size: 10px;
}

.telegram-paper.t8-mode .t8-sent-line em {
    font-style: normal;
    text-align: center;
}

.telegram-paper.t8-mode .t8-sent-line strong,
.telegram-paper.t8-mode .t8-charge strong {
    min-height: 18px;
    color: rgba(57, 62, 59, .9);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', monospace;
    font-size: 14px;
    font-weight: 400;
}

.telegram-paper.t8-mode .t8-charge {
    position: absolute;
    top: 0;
    right: 0;
    width: 135px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
}

.telegram-paper.t8-mode .t8-routing-form {
    position: absolute;
    top: 112px;
    left: 91px;
    width: 508px;
    height: 137px;
    border-top: 2px solid #3d3b30;
    border-bottom: 2px solid #3d3b30;
    border-left: 0;
}

.telegram-paper.t8-mode .t8-routing-top,
.telegram-paper.t8-mode .t8-routing-bottom {
    display: grid;
    height: 50%;
}

.telegram-paper.t8-mode .t8-routing-top {
    grid-template-columns: 20% 20% 40% 20%;
    border-bottom: 2px solid #3d3b30;
}

.telegram-paper.t8-mode .t8-routing-bottom {
    grid-template-columns: 20% 30% 50%;
}

.telegram-paper.t8-mode .t8-routing-top > div,
.telegram-paper.t8-mode .t8-routing-bottom > div {
    min-width: 0;
    padding: 7px 5px;
    border-right: 2px solid #3d3b30;
    text-align: center;
}

.telegram-paper.t8-mode .t8-routing-form span {
    display: block;
    font-size: 8.5px;
    line-height: 1.12;
}

.telegram-paper.t8-mode .t8-routing-form strong {
    display: block;
    margin-top: 14px;
    overflow: hidden;
    color: rgba(57, 62, 59, .9);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 14px;
    font-weight: 400;
    line-height: 1;
    white-space: nowrap;
}

.telegram-paper.t8-mode .t8-officer-area {
    position: absolute;
    top: 112px;
    right: 22px;
    width: 135px;
    height: 137px;
    border-top: 2px solid #3d3b30;
    border-bottom: 2px solid #3d3b30;
    text-align: center;
}

.telegram-paper.t8-mode .t8-seal {
    width: 101px;
    height: 101px;
    margin: 8px auto 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(54, 52, 43, .55);
    border-radius: 50%;
}

.telegram-paper.t8-mode .t8-seal strong {
    max-width: 76px;
    opacity: 0;
    color: rgba(82, 59, 91, .55);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.15;
    overflow-wrap: anywhere;
    transform: rotate(-10deg);
}

.telegram-paper.t8-mode .t8-seal.t8-seal-visible strong {
    opacity: 1;
}

.telegram-paper.t8-mode .t8-officer-area > span {
    font-size: 9px;
}

.telegram-paper.t8-mode .t8-reply-note {
    position: absolute;
    top: 255px;
    right: 25px;
    left: 100px;
    font-size: 8.5px;
    line-height: 1;
}

.telegram-paper.t8-mode .t8-message-area {
    position: absolute;
    top: 271px;
    right: 22px;
    left: 91px;
    height: 354px;
    overflow: hidden;
}

.telegram-paper.t8-mode .t8-to-line {
    position: absolute;
    z-index: 2;
    top: 0;
    right: 0;
    left: 0;
    height: 37px;
    display: flex;
    align-items: center;
    gap: 15px;
    padding-left: 10px;
    border-bottom: 1px dotted rgba(54, 52, 43, .65);
}

.telegram-paper.t8-mode .t8-to-line span {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 20px;
    font-weight: 800;
}

.telegram-paper.t8-mode .t8-to-line strong {
    flex: 1;
    overflow: hidden;
    color: rgba(57, 62, 59, .9);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 18px;
    font-weight: 400;
    white-space: nowrap;
}

.telegram-paper.t8-mode .t8-writing-lines {
    position: absolute;
    z-index: 0;
    top: 37px;
    right: 0;
    left: 0;
    display: grid;
    grid-template-rows: repeat(9, 35px);
}

.telegram-paper.t8-mode .t8-writing-lines i {
    display: block;
    border-bottom: 1px dotted rgba(54, 52, 43, .65);
}

.telegram-paper.t8-mode .t8-message-copy {
    position: absolute;
    z-index: 1;
    top: 42px;
    right: 8px;
    left: 8px;
    max-height: 306px;
    overflow: hidden;
    color: rgba(57, 62, 59, .9);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 18px;
    font-weight: 400;
    line-height: 35px;
    letter-spacing: 1.3px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    text-transform: uppercase;
    mix-blend-mode: multiply;
}

.telegram-paper.t8-mode .t8-message-copy.t8-copy-long {
    font-size: 15px;
    letter-spacing: .8px;
}

.telegram-paper.t8-mode .t8-message-copy.t8-copy-dense {
    font-size: 12px;
    letter-spacing: .35px;
}

.telegram-paper.t8-mode .t8-footer {
    position: absolute;
    top: 629px;
    right: 22px;
    bottom: 18px;
    left: 91px;
}

.telegram-paper.t8-mode .t8-from-line {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 10px;
    min-height: 31px;
    border-top: 2px solid #3d3b30;
    font-size: 10px;
}

.telegram-paper.t8-mode .t8-from-line strong {
    flex: 1;
    color: rgba(57, 62, 59, .9);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 14px;
    font-weight: 400;
}

.telegram-paper.t8-mode .t8-footer-note {
    margin-top: 10px;
    padding-left: 10px;
    font-size: 8.5px;
}

.telegram-paper.t8-mode .t8-form-number {
    position: absolute;
    right: 0;
    bottom: 0;
    font-size: 10px;
    font-weight: 700;
}

/* Template 8 isolated control panel. */
.control-panel.t8-control-mode .shared-routing-inputs,
.control-panel.t8-control-mode .checkbox-group,
.control-panel.t8-control-mode .custom-dict-group,
.control-panel.t8-control-mode .memo-input-group,
.control-panel.t8-control-mode .font-input-group {
    display: none !important;
}

.control-panel .t8-section-heading {
    align-items: center;
    justify-content: center;
    color: #d8c9a5;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 16px;
    font-weight: 700;
}

.control-panel.t8-control-mode .t8-only {
    padding: 10px 12px;
    border: 1px solid #504b3e;
    border-radius: 7px;
    background: #302f2a;
}

.control-panel.t8-control-mode .t8-section-heading {
    padding: 8px 12px;
    border-color: #68604b;
    background: #39362e;
}

.control-panel.t8-control-mode .t8-seal-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 500;
    cursor: pointer;
}

.control-panel.t8-control-mode .t8-seal-toggle input {
    width: auto;
}
/* Template 9 (Postal Telegraph) */
.telegram-paper.t9-mode {
    position: relative;
    display: block;
    width: 1000px;
    height: 670px;
    min-height: 670px;
    padding: 0;
    overflow: hidden;
    background-color: #dfcf9f;
    color: #27335d;
}

.telegram-paper.t9-mode:not(.custom-paper-bg) {
    background-image: linear-gradient(96deg, rgba(255,255,255,.12), transparent 38%, rgba(111,83,36,.06) 75%, transparent);
}

.telegram-paper.t9-mode #template-9-wrapper {
    position: absolute !important;
    z-index: 2;
    inset: 0;
    overflow: hidden;
    font-family: Georgia, 'Times New Roman', serif;
}

.telegram-paper.t9-mode .stamp-layer,
.telegram-paper.t9-mode .paper-body {
    display: none !important;
}

.telegram-paper.t9-mode .t9-masthead {
    position: absolute;
    top: 17px;
    right: 20px;
    left: 20px;
    height: 171px;
    color: #e5d29d;
}

.telegram-paper.t9-mode .t9-masthead-frame {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 143px;
    overflow: hidden;
    border: 3px solid #1c2848;
    background: #1c2848;
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
}

.telegram-paper.t9-mode .t9-masthead-frame::before {
    content: '';
    position: absolute;
    z-index: 0;
    inset: 5px;
    border: 2px solid transparent;
    border-image-source: var(--paper-bg-image, linear-gradient(#dfcf9f, #dfcf9f));
    border-image-slice: 1;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
    pointer-events: none;
}

.telegram-paper.t9-mode .t9-company-name {
    position: absolute;
    top: 8px;
    right: 20px;
    left: 20px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 25px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 2px;
    text-align: center;
}

.telegram-paper.t9-mode .t9-president {
    position: absolute;
    top: 37px;
    right: 275px;
    left: 275px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .7px;
    text-align: center;
}

.telegram-paper.t9-mode .t9-title {
    position: absolute;
    top: 48px;
    right: 272px;
    left: 272px;
    font-family: Arial Black, Impact, sans-serif;
    font-size: 40px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 7px;
    text-align: center;
}

.telegram-paper.t9-mode .t9-received-box,
.telegram-paper.t9-mode .t9-delivery-box {
    position: absolute;
    top: 48px;
    height: 59px;
    padding: 5px 9px;
    border: 2px solid transparent;
    border-image-source: var(--paper-bg-image, linear-gradient(#dfcf9f, #dfcf9f));
    border-image-slice: 1;
    font-family: Arial, Helvetica, sans-serif;
}

.telegram-paper.t9-mode .t9-received-box {
    left: 20px;
    width: 235px;
}

.telegram-paper.t9-mode .t9-delivery-box {
    right: 20px;
    width: 235px;
}

.telegram-paper.t9-mode .t9-received-box span,
.telegram-paper.t9-mode .t9-delivery-box span {
    display: block;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
}

.telegram-paper.t9-mode .t9-received-box strong,
.telegram-paper.t9-mode .t9-delivery-box strong {
    display: block;
    margin-top: 4px;
    overflow: hidden;
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: .7px;
    white-space: normal;
    overflow-wrap: anywhere;
}

.telegram-paper.t9-mode .t9-terms {
    position: absolute;
    right: 18px;
    bottom: 8px;
    left: 18px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 8px;
    font-weight: 600;
    letter-spacing: .15px;
    text-align: center;
}


.telegram-paper.t9-mode .t9-message-sheet {
    position: absolute;
    z-index: 1;
    top: 187px;
    right: 20px;
    bottom: 32px;
    left: 20px;
    overflow: hidden;
    color: rgba(39, 51, 93, .88);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 17px;
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: .8px;
    mix-blend-mode: multiply;
}


.telegram-paper.t9-mode .t9-routing,
.telegram-paper.t9-mode .t9-origin-line,
.telegram-paper.t9-mode .t9-recipient,
.telegram-paper.t9-mode .t9-address-one,
.telegram-paper.t9-mode .t9-address-two,
.telegram-paper.t9-mode .t9-message-copy,
.telegram-paper.t9-mode .t9-signature,
.telegram-paper.t9-mode .t9-bottom-code {
    position: absolute;
    z-index: 1;
}

.telegram-paper.t9-mode .t9-routing {
    top: 34px;
    left: 66px;
}

.telegram-paper.t9-mode .t9-origin-line {
    top: 34px;
    left: 245px;
    display: flex;
    gap: 9px;
}

.telegram-paper.t9-mode .t9-recipient {
    top: 77px;
    left: 66px;
}

.telegram-paper.t9-mode .t9-address-one {
    top: 108px;
    left: 111px;
}

.telegram-paper.t9-mode .t9-address-two {
    top: 139px;
    left: 156px;
}

.telegram-paper.t9-mode .t9-message-copy {
    top: 145px;
    right: 65px;
    left: 66px;
    max-height: 210px;
    overflow: hidden;
    font-size: 20px;
    line-height: 42px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
}

.telegram-paper.t9-mode .t9-message-copy.t9-copy-long {
    font-size: 16px;
    letter-spacing: .5px;
}

.telegram-paper.t9-mode .t9-message-copy.t9-copy-dense {
    font-size: 13px;
    letter-spacing: .2px;
}

.telegram-paper.t9-mode .t9-signature {
    top: 367px;
    left: 360px;
    font-size: 19px;
}

.telegram-paper.t9-mode .t9-bottom-code {
    bottom: 24px;
    left: 66px;
    font-size: 17px;
}

.telegram-paper.t9-mode .t9-reply-line {
    position: absolute;
    z-index: 3;
    right: 52px;
    bottom: 8px;
    color: rgba(39, 51, 93, .82);
    font-family: Impact, 'Arial Narrow', sans-serif;
    font-size: 25px;
    font-weight: 900;
    letter-spacing: 1px;
    transform: scaleX(.8);
    transform-origin: right bottom;
    mix-blend-mode: multiply;
}

/* Template 9 isolated control panel. */
.control-panel.t9-control-mode .shared-routing-inputs,
.control-panel.t9-control-mode .checkbox-group,
.control-panel.t9-control-mode .custom-dict-group,
.control-panel.t9-control-mode .memo-input-group,
.control-panel.t9-control-mode .font-input-group {
    display: none !important;
}

.control-panel .t9-section-heading {
    align-items: center;
    justify-content: center;
    color: #c9d0e2;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 16px;
    font-weight: 700;
}

.control-panel.t9-control-mode .t9-only {
    padding: 10px 12px;
    border: 1px solid #454d66;
    border-radius: 7px;
    background: #292d3a;
}

.control-panel.t9-control-mode .t9-section-heading {
    padding: 8px 12px;
    border-color: #56617f;
    background: #303747;
}

.control-panel.t9-control-mode .t9-option-toggle {
    gap: 10px;
}

.control-panel.t9-control-mode .t9-option-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 500;
    cursor: pointer;
}

.control-panel.t9-control-mode .t9-option-toggle input {
    width: auto;
}
/* Template 9 two-line recipient block and paper-knockout masthead lettering. */
.telegram-paper.t9-mode .t9-address-two {
    display: none;
}

.telegram-paper.t9-mode .t9-company-name,
.telegram-paper.t9-mode .t9-president,
.telegram-paper.t9-mode .t9-title,
.telegram-paper.t9-mode .t9-received-box span,
.telegram-paper.t9-mode .t9-received-box strong,
.telegram-paper.t9-mode .t9-delivery-box span,
.telegram-paper.t9-mode .t9-delivery-box strong,
.telegram-paper.t9-mode .t9-terms {
    color: transparent;
    background-color: #dfcf9f;
    background-image: var(--paper-bg-image, linear-gradient(#dfcf9f, #dfcf9f));
    background-position: center;
    background-repeat: no-repeat;
    background-size: 1000px 670px;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
/* Template 10 (French-form telegram) */
.telegram-paper.t10-mode {
    position: relative;
    display: block;
    width: 1000px;
    height: 660px;
    min-height: 660px;
    padding: 0;
    overflow: hidden;
    background-color: #d9b879;
    color: #242116;
}

.telegram-paper.t10-mode:not(.custom-paper-bg) {
    background-image: linear-gradient(96deg, rgba(255,255,255,.1), transparent 38%, rgba(102,70,24,.06) 75%, transparent);
}

.telegram-paper.t10-mode #template-10-wrapper {
    position: absolute !important;
    z-index: 2;
    inset: 0;
    overflow: hidden;
    font-family: Arial, Helvetica, sans-serif;
}

.telegram-paper.t10-mode .stamp-layer,
.telegram-paper.t10-mode .paper-body {
    display: none !important;
}

.telegram-paper.t10-mode .t10-service-reserve {
    position: absolute;
    top: 48px;
    left: 24px;
    height: 150px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 1px;
    text-align: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.telegram-paper.t10-mode .t10-charge-area {
    position: absolute;
    top: 31px;
    left: 64px;
    width: 292px;
    height: 122px;
    border-right: 2px solid #242116;
}

.telegram-paper.t10-mode .t10-form-number {
    position: absolute;
    top: 0;
    left: 0;
    padding-bottom: 3px;
    border-bottom: 2px solid #242116;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 15px;
    font-weight: 700;
}

.telegram-paper.t10-mode .t10-charge-row {
    position: relative;
    left: 60px;
    width: 225px;
    height: 31px;
    display: grid;
    grid-template-columns: 126px 1fr;
    align-items: center;
    border-bottom: 1px dotted rgba(36,33,22,.65);
    font-size: 10px;
}

.telegram-paper.t10-mode .t10-charge-row:nth-child(2) { margin-top: 14px; }
.telegram-paper.t10-mode .t10-total-row { margin-top: 4px; }

.telegram-paper.t10-mode .t10-charge-row strong {
    min-height: 27px;
    padding: 6px 4px;
    border-left: 1px solid #242116;
    color: rgba(34, 40, 58, .84);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', monospace;
    font-size: 14px;
    font-weight: 400;
}

.telegram-paper.t10-mode .t10-brand {
    position: absolute;
    top: 32px;
    left: 365px;
    width: 388px;
    height: 116px;
    text-align: center;
}

.telegram-paper.t10-mode .t10-agency {
    position: absolute;
    top: 6px;
    right: 0;
    left: 84px;
    overflow: hidden;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0;
    white-space: nowrap;
    transform: scaleX(.9);
    transform-origin: left center;
}

.telegram-paper.t10-mode .t10-title {
    position: absolute;
    right: 0;
    bottom: 4px;
    left: 0;
    font-family: 'Arial Narrow', Arial, sans-serif;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 6px;
}

.telegram-paper.t10-mode .t10-wing-mark {
    position: absolute;
    top: 0;
    left: 4px;
    width: 66px;
    height: 48px;
}

.telegram-paper.t10-mode .t10-wing-mark i {
    position: absolute;
    right: 0;
    height: 9px;
    background: #242116;
    clip-path: polygon(18% 0, 100% 0, 82% 100%, 0 100%);
}

.telegram-paper.t10-mode .t10-wing-mark i:nth-child(1) { top: 4px; width: 43px; }
.telegram-paper.t10-mode .t10-wing-mark i:nth-child(2) { top: 17px; width: 58px; }
.telegram-paper.t10-mode .t10-wing-mark i:nth-child(3) { top: 30px; width: 38px; }

.telegram-paper.t10-mode .t10-right-meta {
    position: absolute;
    top: 25px;
    right: 25px;
    width: 214px;
    height: 194px;
    display: grid;
    grid-template-columns: 98px 116px;
    border-left: 2px solid #242116;
}

.telegram-paper.t10-mode .t10-local-box,
.telegram-paper.t10-mode .t10-transmission-box,
.telegram-paper.t10-mode .t10-phone-box {
    position: relative;
    padding: 8px 6px;
    text-align: center;
}

.telegram-paper.t10-mode .t10-transmission-box {
    grid-column: 2;
    grid-row: 1 / span 2;
    border-left: 2px solid #242116;
}

.telegram-paper.t10-mode .t10-phone-box {
    grid-column: 1;
    grid-row: 2;
    border-top: 2px solid #242116;
}

.telegram-paper.t10-mode .t10-right-meta span {
    display: block;
    font-size: 9px;
    line-height: 1.12;
}

.telegram-paper.t10-mode .t10-right-meta strong {
    display: block;
    margin-top: 12px;
    overflow: hidden;
    color: rgba(34, 40, 58, .84);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 14px;
    font-weight: 400;
    overflow-wrap: anywhere;
}

.telegram-paper.t10-mode .t10-routing-table {
    position: absolute;
    top: 154px;
    right: 239px;
    left: 64px;
    height: 65px;
    display: grid;
    grid-template-columns: 16% 16% 14% 15% 9% 12% 18%;
    border-top: 2px solid #242116;
    border-bottom: 2px solid #242116;
    border-left: 2px solid #242116;
}

.telegram-paper.t10-mode .t10-routing-table > div {
    min-width: 0;
    padding: 6px 3px;
    border-right: 2px solid #242116;
    text-align: center;
}

.telegram-paper.t10-mode .t10-routing-table span {
    display: block;
    font-size: 8.5px;
    line-height: 1.05;
}

.telegram-paper.t10-mode .t10-routing-table strong {
    display: block;
    margin-top: 10px;
    overflow: hidden;
    color: rgba(34, 40, 58, .86);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 15px;
    font-weight: 400;
    line-height: 1;
    white-space: nowrap;
}

.telegram-paper.t10-mode .t10-main-frame {
    position: absolute;
    top: 228px;
    right: 43px;
    bottom: 35px;
    left: 43px;
    border: 3px solid #242116;
}

.telegram-paper.t10-mode .t10-frame-heading {
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 2px solid #242116;
    font-size: 15px;
    letter-spacing: 1px;
}

.telegram-paper.t10-mode .t10-frame-heading strong {
    margin: 0 8px;
    font-weight: 900;
}

.telegram-paper.t10-mode .t10-form-body {
    position: absolute;
    top: 35px;
    right: 0;
    bottom: 66px;
    left: 0;
    display: grid;
    grid-template-columns: 105px 1fr;
}

.telegram-paper.t10-mode .t10-body-labels {
    position: relative;
    border-right: 2px solid #242116;
}

.telegram-paper.t10-mode .t10-address-label,
.telegram-paper.t10-mode .t10-text-label {
    position: absolute;
    right: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.telegram-paper.t10-mode .t10-address-label {
    top: 0;
    height: 109px;
    border-bottom: 2px solid #242116;
}

.telegram-paper.t10-mode .t10-text-label {
    top: 109px;
    bottom: 0;
}

.telegram-paper.t10-mode .t10-body-labels small {
    margin-top: 4px;
    font-size: 9px;
    font-weight: 500;
    line-height: 1.1;
}

.telegram-paper.t10-mode .t10-writing-area {
    min-width: 0;
    overflow: hidden;
}

.telegram-paper.t10-mode .t10-address-zone {
    position: relative;
    height: 109px;
    overflow: hidden;
    border-bottom: 2px solid #242116;
}

.telegram-paper.t10-mode .t10-address-note {
    position: absolute;
    z-index: 2;
    top: 5px;
    right: 8px;
    left: 15px;
    font-size: 8px;
    line-height: 1.12;
}

.telegram-paper.t10-mode .t10-address-lines {
    position: absolute;
    top: 35px;
    right: 0;
    left: 0;
    display: grid;
    grid-template-rows: repeat(2, 35px);
}

.telegram-paper.t10-mode .t10-address-lines i,
.telegram-paper.t10-mode .t10-text-lines i {
    border-bottom: 1px dotted rgba(36,33,22,.55);
}

.telegram-paper.t10-mode .t10-address-copy {
    position: absolute;
    z-index: 1;
    top: 37px;
    right: 8px;
    left: 15px;
    max-height: 70px;
    overflow: hidden;
    color: rgba(24, 31, 70, .9);
    font-size: 23px;
    font-weight: 400;
    line-height: 35px;
    letter-spacing: 1.3px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.telegram-paper.t10-mode .t10-text-zone {
    position: absolute;
    top: 109px;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: hidden;
}

.telegram-paper.t10-mode .t10-text-lines {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: repeat(6, 30px);
}

.telegram-paper.t10-mode .t10-message-copy {
    position: absolute;
    z-index: 1;
    top: 0;
    right: 8px;
    left: 14px;
    max-height: 180px;
    overflow: hidden;
    color: rgba(24, 31, 70, .9);
    font-size: 20px;
    font-weight: 400;
    line-height: 30px;
    letter-spacing: 1.2px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
}

.telegram-paper.t10-mode .t10-message-copy.t10-copy-long {
    font-size: 16px;
    letter-spacing: .7px;
}

.telegram-paper.t10-mode .t10-message-copy.t10-copy-dense {
    font-size: 13px;
    letter-spacing: .25px;
}

.telegram-paper.t10-mode .t10-sender-footer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 66px;
    padding: 9px 16px 4px;
    border-top: 2px solid #242116;
    font-size: 10px;
}

.telegram-paper.t10-mode .t10-sender-footer > span {
    display: inline-block;
    margin-right: 8px;
}

.telegram-paper.t10-mode .t10-sender-footer > strong {
    display: inline-block;
    min-width: 510px;
    padding: 0 5px 3px;
    border-bottom: 1px dotted rgba(36,33,22,.55);
    color: rgba(24, 31, 70, .9);
    font-size: 15px;
    font-weight: 400;
}

.telegram-paper.t10-mode .t10-sender-footer > div {
    margin-top: 11px;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
}

.telegram-paper.t10-mode .t10-print-code {
    position: absolute;
    bottom: 21px;
    left: 45px;
    font-size: 7px;
}

/* Template 10 isolated control panel. */
.control-panel.t10-control-mode .shared-routing-inputs,
.control-panel.t10-control-mode .checkbox-group,
.control-panel.t10-control-mode .custom-dict-group,
.control-panel.t10-control-mode .memo-input-group {
    display: none !important;
}

.control-panel .t10-section-heading {
    align-items: center;
    justify-content: center;
    color: #dac391;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    font-weight: 700;
}

.control-panel.t10-control-mode .t10-only {
    padding: 10px 12px;
    border: 1px solid #5a4c35;
    border-radius: 7px;
    background: #342f27;
}

.control-panel.t10-control-mode .t10-section-heading {
    padding: 8px 12px;
    border-color: #756342;
    background: #40372a;
}

.control-panel.t10-control-mode .t10-option-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 500;
    cursor: pointer;
}

.control-panel.t10-control-mode .t10-option-toggle input {
    width: auto;
}
/* Template 10 header alignment and narrow date/time cells. */
.telegram-paper.t10-mode .t10-routing-table > div:nth-child(5) strong,
.telegram-paper.t10-mode .t10-routing-table > div:nth-child(6) strong {
    margin-top: 8px;
    padding: 0 1px;
    font-size: 13px;
    letter-spacing: 0;
    text-overflow: clip;
}
/* Template 10 shared-edge border fix. */
.telegram-paper.t10-mode .t10-routing-table > div:last-child {
    border-right: 0;
}
/* Template 11 (Cyrillic telegram form) */
.telegram-paper.t11-mode {
    position: relative;
    display: block;
    width: 1000px;
    height: 680px;
    min-height: 680px;
    padding: 0;
    overflow: hidden;
    background-color: #e5d4ad;
    color: #5a5140;
}

.telegram-paper.t11-mode:not(.custom-paper-bg) {
    background-image: linear-gradient(96deg, rgba(255,255,255,.11), transparent 42%, rgba(102,75,34,.05) 76%, transparent);
}

.telegram-paper.t11-mode #template-11-wrapper {
    position: absolute !important;
    z-index: 2;
    inset: 0;
    overflow: hidden;
    font-family: Georgia, 'Times New Roman', serif;
}

.telegram-paper.t11-mode .stamp-layer,
.telegram-paper.t11-mode .paper-body {
    display: none !important;
}

.telegram-paper.t11-mode .t11-stub {
    position: absolute;
    top: 72px;
    bottom: 54px;
    left: 34px;
    width: 184px;
    border-right: 2px solid rgba(73,66,52,.8);
}

.telegram-paper.t11-mode .t11-fee-table {
    position: absolute;
    top: 0;
    left: 0;
    width: 160px;
    height: 84px;
    border-top: 1px solid rgba(73,66,52,.8);
    border-bottom: 1px solid rgba(73,66,52,.8);
}

.telegram-paper.t11-mode .t11-fee-head {
    display: grid;
    grid-template-columns: 45px 1fr;
    height: 27px;
    border-bottom: 1px solid rgba(73,66,52,.8);
    text-align: center;
}

.telegram-paper.t11-mode .t11-fee-head span,
.telegram-paper.t11-mode .t11-fee-sub span {
    padding-top: 6px;
    border-right: 1px solid rgba(73,66,52,.8);
    font-size: 9px;
}

.telegram-paper.t11-mode .t11-fee-sub,
.telegram-paper.t11-mode .t11-fee-values {
    display: grid;
    grid-template-columns: 45px 1fr 1fr;
    height: 27px;
    text-align: center;
}

.telegram-paper.t11-mode .t11-fee-values > * {
    padding-top: 5px;
    border-top: 1px solid rgba(73,66,52,.55);
    border-right: 1px solid rgba(73,66,52,.8);
}

.telegram-paper.t11-mode .t11-fee-sub span:first-child,
.telegram-paper.t11-mode .t11-fee-values i {
    color: rgba(37,45,78,.82);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', monospace;
    font-style: normal;
}

.telegram-paper.t11-mode .t11-fee-values strong {
    color: rgba(37,45,78,.82);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', monospace;
    font-size: 13px;
    font-weight: 400;
}

.telegram-paper.t11-mode .t11-receiver-line {
    position: absolute;
    top: 93px;
    left: 0;
    width: 160px;
    display: flex;
    gap: 8px;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(73,66,52,.7);
    font-size: 10px;
}

.telegram-paper.t11-mode .t11-receiver-line strong {
    flex: 1;
    color: rgba(37,45,78,.82);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 12px;
    font-weight: 400;
}

.telegram-paper.t11-mode .t11-receipt {
    position: absolute;
    right: 8px;
    bottom: 0;
    left: 0;
    height: 245px;
    font-size: 10px;
}

.telegram-paper.t11-mode .t11-receipt h3 {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.15;
    text-align: center;
}

.telegram-paper.t11-mode .t11-receipt > div {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(73,66,52,.6);
}

.telegram-paper.t11-mode .t11-receipt label {
    display: block;
    margin-top: 17px;
}

.telegram-paper.t11-mode .t11-receipt > strong {
    display: block;
    min-height: 30px;
    margin-top: 5px;
    color: rgba(37,45,78,.82);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 13px;
    font-weight: 400;
    overflow-wrap: anywhere;
}

.telegram-paper.t11-mode .t11-receipt p {
    position: absolute;
    right: 7px;
    bottom: 0;
    font-size: 8px;
    line-height: 1.15;
    text-align: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.telegram-paper.t11-mode .t11-main-form {
    position: absolute;
    top: 72px;
    right: 52px;
    bottom: 54px;
    left: 218px;
    border-right: 2px solid rgba(73,66,52,.8);
}

.telegram-paper.t11-mode .t11-header {
    position: absolute;
    top: 0;
    right: 276px;
    left: 0;
    height: 215px;
    border-bottom: 2px solid rgba(73,66,52,.8);
    text-align: center;
}

.telegram-paper.t11-mode .t11-agency {
    position: absolute;
    top: 48px;
    right: 15px;
    left: 15px;
    font-size: 15px;
    letter-spacing: 2px;
}

.telegram-paper.t11-mode .t11-title {
    position: absolute;
    top: 103px;
    right: 0;
    left: 0;
    font-size: 31px;
    font-weight: 500;
    letter-spacing: 10px;
}

.telegram-paper.t11-mode .t11-number-line {
    position: absolute;
    top: 155px;
    left: 130px;
    width: 260px;
    display: grid;
    grid-template-columns: 25px 1fr;
    align-items: end;
}

.telegram-paper.t11-mode .t11-number-line strong,
.telegram-paper.t11-mode .t11-date-line strong {
    min-height: 23px;
    border-bottom: 1px solid rgba(73,66,52,.65);
    color: rgba(37,45,78,.82);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', monospace;
    font-size: 14px;
    font-weight: 400;
}

.telegram-paper.t11-mode .t11-date-line {
    position: absolute;
    top: 184px;
    left: 126px;
    width: 285px;
    display: grid;
    grid-template-columns: 15px 115px 15px 100px 25px;
    gap: 3px;
    align-items: end;
}

.telegram-paper.t11-mode .t11-transfer-box {
    position: absolute;
    top: 0;
    right: 0;
    width: 276px;
    height: 215px;
    display: grid;
    grid-template-rows: 34px repeat(5, 1fr);
    border-bottom: 2px solid rgba(73,66,52,.8);
    border-left: 2px solid rgba(73,66,52,.8);
}

.telegram-paper.t11-mode .t11-transfer-box h3 {
    height: 34px;
    padding-top: 10px;
    border-bottom: 1px solid rgba(73,66,52,.7);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 4px;
    text-align: center;
}

.telegram-paper.t11-mode .t11-transfer-box > div {
    min-height: 0;
    padding: 5px 8px 3px;
    border-bottom: 1px solid rgba(73,66,52,.5);
    font-size: 9px;
}

.telegram-paper.t11-mode .t11-transfer-box > div > span {
    display: inline-block;
    margin-right: 5px;
}

.telegram-paper.t11-mode .t11-transfer-box strong {
    color: rgba(37,45,78,.82);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 12px;
    font-weight: 400;
}

.telegram-paper.t11-mode .t11-transfer-date {
    display: flex;
    align-items: center;
    gap: 5px;
}

.telegram-paper.t11-mode .t11-transfer-date strong {
    min-width: 39px;
    border-bottom: 1px solid rgba(73,66,52,.55);
    text-align: center;
}

.telegram-paper.t11-mode .t11-message-form {
    position: absolute;
    top: 215px;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: hidden;
}

.telegram-paper.t11-mode .t11-category-row,
.telegram-paper.t11-mode .t11-destination-row {
    height: 35px;
    display: grid;
    grid-template-columns: 205px 1fr;
    align-items: center;
    padding: 0 9px;
    border-bottom: 1px solid rgba(73,66,52,.65);
    font-size: 10px;
}

.telegram-paper.t11-mode .t11-category-row strong,
.telegram-paper.t11-mode .t11-destination-row strong {
    overflow: hidden;
    color: rgba(37,45,78,.84);
    font-family: 'ZhaohuaTypeWriter Light', 'Courier New', 'Noto Serif SC', monospace;
    font-size: 14px;
    font-weight: 400;
    white-space: nowrap;
}

.telegram-paper.t11-mode .t11-writing-lines {
    position: absolute;
    top: 70px;
    right: 8px;
    left: 8px;
    display: grid;
    grid-template-rows: repeat(10, 21px);
}

.telegram-paper.t11-mode .t11-writing-lines i {
    border-bottom: 1px solid rgba(73,66,52,.42);
}

.telegram-paper.t11-mode .t11-message-copy {
    position: absolute;
    z-index: 1;
    top: 70px;
    right: 14px;
    left: 14px;
    max-height: 210px;
    overflow: hidden;
    color: rgba(37,45,78,.86);
    font-size: 17px;
    font-weight: 400;
    line-height: 21px;
    letter-spacing: .8px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
}

.telegram-paper.t11-mode .t11-message-copy.t11-copy-long {
    font-size: 14px;
    letter-spacing: .4px;
}

.telegram-paper.t11-mode .t11-message-copy.t11-copy-dense {
    font-size: 11px;
    letter-spacing: .1px;
}

.telegram-paper.t11-mode .t11-sender-footer {
    position: absolute;
    right: 10px;
    bottom: 0;
    left: 10px;
    height: 55px;
    display: grid;
    grid-template-columns: 245px 1fr;
    align-items: end;
    padding-bottom: 3px;
    background: transparent;
    font-size: 9px;
    line-height: 1.1;
}

.telegram-paper.t11-mode .t11-sender-footer strong {
    min-height: 24px;
    border-bottom: 1px solid rgba(73,66,52,.55);
    color: rgba(37,45,78,.84);
    font-size: 14px;
    font-weight: 400;
}

.telegram-paper.t11-mode .t11-form-code {
    position: absolute;
    top: 45px;
    right: 56px;
    font-size: 10px;
    font-weight: 700;
}

.telegram-paper.t11-mode .t11-print-line {
    position: absolute;
    right: 64px;
    bottom: 31px;
    font-size: 8px;
}

/* Template 11 isolated control panel. */
.control-panel.t11-control-mode .shared-routing-inputs,
.control-panel.t11-control-mode .checkbox-group,
.control-panel.t11-control-mode .custom-dict-group,
.control-panel.t11-control-mode .memo-input-group {
    display: none !important;
}

.control-panel .t11-section-heading {
    align-items: center;
    justify-content: center;
    color: #d8ccb2;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 16px;
    font-weight: 700;
}

.control-panel.t11-control-mode .t11-only {
    padding: 10px 12px;
    border: 1px solid #514d43;
    border-radius: 7px;
    background: #302f2c;
}

.control-panel.t11-control-mode .t11-section-heading {
    padding: 8px 12px;
    border-color: #696256;
    background: #393631;
}

.control-panel.t11-control-mode .t11-option-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 500;
    cursor: pointer;
}

.control-panel.t11-control-mode .t11-option-toggle input {
    width: auto;
}
/* Template 11 transfer grid edge alignment. */
.telegram-paper.t11-mode .t11-transfer-box > div:last-child {
    border-bottom: 0;
}

.telegram-paper.t11-mode .t11-transfer-box strong {
    display: inline-block;
    max-width: 150px;
    overflow: hidden;
    vertical-align: bottom;
    white-space: nowrap;
}
/* Editorial application interface */
:root {
    --ui-ink: #171713;
    --ui-muted: #706e66;
    --ui-rule: #c9c5b8;
    --ui-paper: #f3f0e7;
    --ui-field: #fbfaf5;
    --ui-canvas: #d8d6ce;
    --ui-accent: #8e2f25;
}

body {
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    background: var(--ui-canvas);
    color: var(--ui-ink);
    font-family: Arial, Helvetica, 'Noto Sans SC', sans-serif;
}

.app-container {
    width: 100%;
    max-width: none;
    height: 100vh;
    margin: 0;
    background: var(--ui-canvas);
}

.control-panel {
    position: relative;
    z-index: 10;
    width: 390px;
    height: 100vh;
    flex: 0 0 390px;
    gap: 12px;
    padding: 24px 24px 32px;
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 1px solid var(--ui-ink);
    background: var(--ui-paper);
    color: var(--ui-ink);
    scrollbar-width: thin;
    scrollbar-color: var(--ui-ink) transparent;
}

.control-panel::-webkit-scrollbar {
    width: 7px;
}

.control-panel::-webkit-scrollbar-thumb {
    background: var(--ui-ink);
}

.control-panel::-webkit-scrollbar-track {
    background: transparent;
}

.editor-header {
    margin-bottom: 6px;
    padding: 13px 0 17px;
    border-top: 5px solid var(--ui-ink);
    border-bottom: 1px solid var(--ui-ink);
}

.editorial-kicker {
    margin-bottom: 19px;
    color: var(--ui-muted);
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .2em;
}

.control-panel h1 {
    margin: 0;
    color: var(--ui-ink);
    font-family: 'Noto Serif SC', Georgia, serif;
    font-size: 31px;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: .04em;
}

.control-panel .subtitle {
    margin: 10px 0 0;
    color: var(--ui-muted);
    font-family: 'Noto Serif SC', Georgia, serif;
    font-size: 12px;
    line-height: 1.5;
    letter-spacing: .06em;
}

.control-panel > .input-group,
.control-panel > [class$='-section-heading'] {
    margin: 0;
}

.control-panel > .input-group,
.control-panel .t1-only,
.control-panel .t2-only,
.control-panel .t3-only,
.control-panel .t4-only,
.control-panel .t5-only,
.control-panel .t6-only,
.control-panel .t7-only,
.control-panel .t8-only,
.control-panel .t9-only,
.control-panel .t10-only,
.control-panel .t11-only {
    gap: 8px;
    padding: 11px 12px;
    border: 1px solid var(--ui-rule);
    border-radius: 0;
    background: var(--ui-field);
    color: var(--ui-ink);
    box-shadow: none;
}

.control-panel.t1-control-mode .shared-routing-inputs,
.control-panel.t1-control-mode .font-input-group,
.control-panel.t1-control-mode .memo-input-group,
.control-panel.t2-control-mode .shared-routing-inputs,
.control-panel.t2-control-mode .font-input-group,
.control-panel.t2-control-mode .memo-input-group,
.control-panel.t3-control-mode .shared-routing-inputs,
.control-panel.t3-control-mode .font-input-group,
.control-panel.t3-control-mode .memo-input-group,
.control-panel.t4-control-mode .shared-routing-inputs,
.control-panel.t4-control-mode .font-input-group,
.control-panel.t4-control-mode .memo-input-group {
    border-color: var(--ui-rule);
    background: var(--ui-field);
}

.control-panel .t1-section-heading,
.control-panel .t2-section-heading,
.control-panel .t3-section-heading,
.control-panel .t4-section-heading,
.control-panel .t5-section-heading,
.control-panel .t6-section-heading,
.control-panel .t7-section-heading,
.control-panel .t8-section-heading,
.control-panel .t9-section-heading,
.control-panel .t10-section-heading,
.control-panel .t11-section-heading {
    min-height: 38px;
    padding: 9px 12px;
    border: 1px solid var(--ui-ink);
    border-radius: 0;
    background: var(--ui-ink);
    color: var(--ui-paper);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.control-panel label,
.control-panel .sub-group label {
    margin: 0 0 3px;
    color: var(--ui-ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: .08em;
}

.control-panel .sub-group {
    min-width: 0;
}

.control-panel .row-group {
    align-items: flex-start;
    gap: 8px;
}

.control-panel input[type='text'],
.control-panel textarea,
.control-panel select {
    width: 100%;
    min-height: 38px;
    padding: 9px 10px;
    border: 1px solid #aaa69b;
    border-radius: 0;
    outline: 0;
    background: #fffef9;
    color: var(--ui-ink);
    font-family: 'Noto Serif SC', Georgia, serif;
    font-size: 13px;
    line-height: 1.35;
    box-shadow: none;
    transition: border-color .15s ease, background-color .15s ease;
}

.control-panel textarea {
    min-height: 82px;
    resize: vertical;
}

.control-panel #message-input {
    min-height: 116px;
    font-size: 15px;
    line-height: 1.6;
}

.control-panel select {
    appearance: none;
    padding-right: 34px;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--ui-ink) 50%),
        linear-gradient(135deg, var(--ui-ink) 50%, transparent 50%);
    background-position:
        calc(100% - 16px) 16px,
        calc(100% - 11px) 16px;
    background-repeat: no-repeat;
    background-size: 5px 5px, 5px 5px;
}

.control-panel input[type='text']:focus,
.control-panel textarea:focus,
.control-panel select:focus {
    border-color: var(--ui-ink);
    background-color: #fff;
}

.control-panel input[type='checkbox'] {
    appearance: none;
    width: 14px !important;
    min-width: 14px;
    height: 14px;
    min-height: 14px;
    margin: 0;
    border: 1px solid var(--ui-ink);
    border-radius: 0;
    background: transparent;
    cursor: pointer;
}

.control-panel input[type='checkbox']:checked {
    background: var(--ui-ink);
    box-shadow: inset 0 0 0 3px var(--ui-paper);
}

.control-panel .checkbox-group,
.control-panel .t6-strip-toggle,
.control-panel .t7-stamp-toggle,
.control-panel .t8-seal-toggle,
.control-panel .t9-option-toggle,
.control-panel .t10-option-toggle,
.control-panel .t11-option-toggle {
    gap: 10px;
}

.control-panel .checkbox-group label,
.control-panel .t6-strip-toggle label,
.control-panel .t7-stamp-toggle label,
.control-panel .t8-seal-toggle label,
.control-panel .t9-option-toggle label,
.control-panel .t10-option-toggle label,
.control-panel .t11-option-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
}

.control-panel .custom-dict-details {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.control-panel .custom-dict-details summary {
    padding: 2px 0;
    color: var(--ui-ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    list-style-position: inside;
}

.control-panel .custom-dict-content {
    margin-top: 12px;
    padding-top: 11px;
    border-top: 1px solid var(--ui-rule);
}

.control-panel .custom-dict-content .help-text {
    color: var(--ui-muted);
    font-size: 10px;
    line-height: 1.55;
}

.control-panel code {
    padding: 1px 3px;
    background: #e8e4d9;
    color: var(--ui-ink);
    font-family: 'Courier New', monospace;
}

.control-panel button {
    position: relative;
    width: 100%;
    min-height: 45px;
    padding: 12px 16px;
    border: 1px solid var(--ui-ink);
    border-radius: 0;
    background: var(--ui-ink);
    color: var(--ui-paper);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .18em;
    text-transform: uppercase;
    box-shadow: none;
}

.control-panel button:hover {
    background: var(--ui-accent);
    border-color: var(--ui-accent);
}

.control-panel button:active {
    transform: translateY(1px);
}

.control-panel button.secondary {
    background: transparent;
    color: var(--ui-ink);
}

.control-panel button.secondary:hover {
    background: var(--ui-ink);
    color: var(--ui-paper);
}

.control-panel .footer-info {
    margin-top: 7px;
    padding-top: 13px;
    border-top: 1px solid var(--ui-ink);
    color: var(--ui-muted);
    font-family: 'Noto Serif SC', Georgia, serif;
    font-size: 9px;
    line-height: 1.5;
    letter-spacing: .05em;
    text-align: left;
}

.paper-container {
    position: relative;
    min-width: 0;
    height: 100vh;
    align-items: flex-start;
    justify-content: center;
    padding: 66px 48px 48px;
    overflow: auto;
    background-color: var(--ui-canvas);
    background-image:
        linear-gradient(rgba(23,23,19,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23,23,19,.035) 1px, transparent 1px);
    background-size: 24px 24px;
}

.paper-container::before {
    content: 'PREVIEW / OUTPUT';
    position: absolute;
    top: 23px;
    left: 30px;
    color: #5f5d56;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .2em;
}

.paper-container::after {
    content: '';
    position: absolute;
    top: 40px;
    right: 30px;
    left: 30px;
    height: 1px;
    background: rgba(23,23,19,.45);
}

.paper-container .telegram-paper {
    flex: 0 0 auto;
    box-shadow: 0 18px 45px rgba(28,27,23,.2), 0 0 0 1px rgba(23,23,19,.15);
}

@media (max-width: 900px) {
    body {
        height: auto;
        overflow: auto;
    }

    .app-container {
        display: block;
        height: auto;
    }

    .control-panel {
        width: 100%;
        height: auto;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid var(--ui-ink);
    }

    .paper-container {
        min-height: 720px;
        height: auto;
    }
}
/* Editorial template-panel specificity normalization */
.control-panel.t1-control-mode .t1-only,
.control-panel.t2-control-mode .t2-only,
.control-panel.t3-control-mode .t3-only,
.control-panel.t4-control-mode .t4-only,
.control-panel.t5-control-mode .t5-only,
.control-panel.t6-control-mode .t6-only,
.control-panel.t7-control-mode .t7-only,
.control-panel.t8-control-mode .t8-only,
.control-panel.t9-control-mode .t9-only,
.control-panel.t10-control-mode .t10-only,
.control-panel.t11-control-mode .t11-only {
    padding: 11px 12px;
    border: 1px solid var(--ui-rule);
    border-radius: 0;
    background: var(--ui-field);
    color: var(--ui-ink);
    box-shadow: none;
}

.control-panel.t1-control-mode .t1-section-heading,
.control-panel.t2-control-mode .t2-section-heading,
.control-panel.t3-control-mode .t3-section-heading,
.control-panel.t4-control-mode .t4-section-heading,
.control-panel.t5-control-mode .t5-section-heading,
.control-panel.t6-control-mode .t6-section-heading,
.control-panel.t7-control-mode .t7-section-heading,
.control-panel.t8-control-mode .t8-section-heading,
.control-panel.t9-control-mode .t9-section-heading,
.control-panel.t10-control-mode .t10-section-heading,
.control-panel.t11-control-mode .t11-section-heading {
    min-height: 38px;
    padding: 9px 12px;
    border: 1px solid var(--ui-ink);
    border-radius: 0;
    background: var(--ui-ink);
    color: var(--ui-paper);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .16em;
}

.control-panel #custom-dict-input {
    width: 100%;
    min-height: 76px;
    padding: 9px 10px;
    border: 1px solid #aaa69b;
    border-radius: 0;
    background: #fffef9;
    color: var(--ui-ink);
    font-family: 'Courier New', monospace;
    font-size: 12px;
}
/* Editorial control-panel type scale */
.control-panel .t1-section-heading,
.control-panel .t2-section-heading,
.control-panel .t3-section-heading,
.control-panel .t4-section-heading,
.control-panel .t5-section-heading,
.control-panel .t6-section-heading,
.control-panel .t7-section-heading,
.control-panel .t8-section-heading,
.control-panel .t9-section-heading,
.control-panel .t10-section-heading,
.control-panel .t11-section-heading {
    font-size: 11px;
}

.control-panel label,
.control-panel .sub-group label {
    font-size: 14px;
}

.control-panel .font-choice {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-panel .font-input-group {
    gap: 12px;
}

.control-panel input[type='text'],
.control-panel textarea,
.control-panel select {
    min-height: 42px;
    padding: 10px 11px;
    font-size: 15px;
}

.control-panel #message-input {
    font-size: 16px;
}

.control-panel select {
    background-position:
        calc(100% - 16px) 18px,
        calc(100% - 11px) 18px;
}

.control-panel .checkbox-group label,
.control-panel .t6-strip-toggle label,
.control-panel .t7-stamp-toggle label,
.control-panel .t8-seal-toggle label,
.control-panel .t9-option-toggle label,
.control-panel .t10-option-toggle label,
.control-panel .t11-option-toggle label,
.control-panel .custom-dict-details summary {
    font-size: 12px;
}

.control-panel .custom-dict-content .help-text {
    font-size: 11px;
}
/* Cross-template font access and requested frame adjustments */
.control-panel.t6-control-mode .font-input-group,
.control-panel.t7-control-mode .font-input-group,
.control-panel.t8-control-mode .font-input-group,
.control-panel.t9-control-mode .font-input-group {
    display: flex !important;
}

.control-panel.t5-control-mode .code-font-choice,
.control-panel.t6-control-mode .code-font-choice,
.control-panel.t7-control-mode .code-font-choice,
.control-panel.t8-control-mode .code-font-choice,
.control-panel.t9-control-mode .code-font-choice,
.control-panel.t10-control-mode .code-font-choice,
.control-panel.t11-control-mode .code-font-choice {
    display: none !important;
}

.telegram-paper.t1-mode .code-number,
.telegram-paper.t1-mode .code-char {
    position: relative;
    top: 4px;
}

.telegram-paper.t8-mode {
    border: 0;
}
/* Export workspace and fixed-canvas mobile navigation */
.export-settings {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 12px;
    border: 1px solid var(--ui-ink);
    background: #ebe7dc;
}
.export-settings-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--ui-ink);
}
.export-settings-heading h2 {
    margin: 0;
    font-family: 'Noto Serif SC', Georgia, serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}
.export-settings-index {
    color: var(--ui-muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .18em;
}
.export-setting-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.export-status {
    min-height: 17px;
    margin: 0;
    color: var(--ui-muted);
    font-size: 11px;
    line-height: 1.45;
}
.export-status.is-error { color: var(--ui-accent); }
.control-panel #download-btn:disabled {
    cursor: wait;
    opacity: .58;
}
.mobile-dock { display: none; }

@media (max-width: 900px) {
    body {
        display: block;
        width: 100vw;
        height: 100dvh;
        min-height: 0;
        padding-bottom: 64px;
        overflow: hidden;
    }
    .app-container {
        display: flex;
        width: 100vw;
        height: calc(100dvh - 64px);
        min-height: 0;
        overflow: hidden;
    }
    .control-panel {
        width: 100%;
        height: calc(100dvh - 64px);
        max-height: none;
        flex: 1 1 auto;
        padding: 20px 18px 30px;
        overflow-x: hidden;
        overflow-y: auto;
        border-right: 0;
        border-bottom: 0;
    }
    .paper-container {
        width: 100%;
        height: calc(100dvh - 64px);
        min-width: 0;
        min-height: 0;
        flex: 1 1 auto;
        align-items: flex-start;
        justify-content: flex-start;
        padding: 66px 24px 32px;
        overflow: auto;
        overscroll-behavior: contain;
    }
    .paper-container .telegram-paper {
        max-width: none !important;
        max-height: none !important;
        flex: 0 0 auto !important;
        transform: none !important;
        zoom: 1 !important;
    }
    body.mobile-view-edit .control-panel,
    body.mobile-view-export .control-panel { display: flex; }
    body.mobile-view-edit .paper-container,
    body.mobile-view-export .paper-container { display: none !important; }
    body.mobile-view-preview .control-panel { display: none !important; }
    body.mobile-view-preview .paper-container { display: flex; }
    body.mobile-view-export .control-panel > * { display: none !important; }
    body.mobile-view-export .control-panel > .editor-header {
        display: block !important;
    }
    body.mobile-view-export .control-panel > .export-settings,
    body.mobile-view-export .control-panel > #download-btn { display: flex !important; }
    body.mobile-view-export .control-panel > #download-btn {
        justify-content: center;
        align-items: center;
    }
    .mobile-dock {
        position: fixed;
        z-index: 1000;
        right: 0;
        bottom: 0;
        left: 0;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        height: 64px;
        padding: 0;
        border-top: 1px solid var(--ui-ink);
        background: var(--ui-paper);
    }
    .mobile-dock button {
        appearance: none;
        border: 0;
        border-right: 1px solid var(--ui-rule);
        border-radius: 0;
        background: transparent;
        color: var(--ui-muted);
        font-family: Arial, Helvetica, sans-serif;
        font-size: 13px;
        font-weight: 700;
        letter-spacing: .12em;
    }
    .mobile-dock button:last-child { border-right: 0; }
    .mobile-dock button.is-active {
        background: var(--ui-ink);
        color: var(--ui-paper);
    }
}
/* Raster stamp assets and ink blending */
.telegram-paper.t1-mode #bureau-stamp,
.telegram-paper.t2-mode #bureau-stamp {
    top: 50px;
    left: 50%;
    width: 150px;
    height: 150px;
    margin-left: -75px;
    padding: 0;
    border: 0;
    border-radius: 0;
    object-fit: contain;
    opacity: .72;
    filter: contrast(1.08) saturate(.9);
    mix-blend-mode: multiply;
    transform: rotate(-10deg);
}

.telegram-paper.t7-mode .t7-office-stamp {
    top: 79px;
    left: 38px;
    display: block;
    width: 145px;
    height: auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    object-fit: contain;
    opacity: .48;
    filter: contrast(1.02) saturate(.55);
    mix-blend-mode: multiply;
    transform: rotate(-13deg);
}

.telegram-paper.t7-mode .t7-office-stamp::before,
.telegram-paper.t7-mode .t7-office-stamp::after {
    content: none;
}
/* Site filing footer */
:root {
    --site-filing-height: 38px;
}

body {
    padding-bottom: var(--site-filing-height);
}

.app-container,
.control-panel,
.paper-container {
    height: calc(100vh - var(--site-filing-height));
}

.site-filing {
    position: fixed;
    z-index: 950;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    min-height: var(--site-filing-height);
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 7px 16px;
    border-top: 1px solid var(--ui-rule);
    background: var(--ui-paper);
    color: var(--ui-muted);
    font-family: Arial, Helvetica, 'Noto Sans SC', sans-serif;
    font-size: 11px;
    line-height: 1.3;
    text-align: center;
}

.site-filing p {
    margin: 0;
}

.site-filing a {
    color: inherit;
    text-decoration: none;
}

.site-filing a:hover {
    color: var(--ui-accent);
    text-decoration: underline;
}

@media (max-width: 900px) {
    :root {
        --site-filing-height: 46px;
    }

    body {
        padding-bottom: calc(64px + var(--site-filing-height));
    }

    .app-container,
    .control-panel,
    .paper-container {
        height: calc(100dvh - 64px - var(--site-filing-height));
    }

    .site-filing {
        bottom: 64px;
        flex-wrap: wrap;
        align-content: center;
        gap: 2px 14px;
        padding: 5px 8px;
        font-size: 10px;
    }
}