* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f0f0;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Верхняя панель заголовка */
.title-bar {
    background: linear-gradient(to bottom, #2b579a 0%, #1e3f73 100%);
    color: white;
    height: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    -webkit-app-region: drag;
    user-select: none;
}

.title-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.word-icon {
    font-size: 16px;
    color: #4fc3f7;
}

.title-text {
    display: flex;
    gap: 5px;
    font-size: 12px;
}

.app-name {
    font-weight: 600;
}

.title-bar-right {
    display: flex;
    gap: 5px;
    -webkit-app-region: no-drag;
}

.title-btn {
    background: transparent;
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    transition: background 0.2s;
}

.title-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.title-btn.close:hover {
    background: #e81123;
}

/* Панель быстрого доступа */
.quick-access-toolbar {
    background: #f3f3f3;
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 5px;
    border-bottom: 1px solid #d0d0d0;
}

.qat-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    color: #333;
    transition: background 0.2s;
}

.qat-btn:hover {
    background: #e0e0e0;
}

.qat-btn:active {
    background: #d0d0d0;
}

/* Лента инструментов (Ribbon) */
.ribbon {
    background: #f3f3f3;
    border-bottom: 1px solid #d0d0d0;
}

.ribbon-tabs {
    display: flex;
    background: #f3f3f3;
    border-bottom: 1px solid #d0d0d0;
    padding: 0 5px;
}

.ribbon-tab {
    background: transparent;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    color: #333;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.ribbon-tab:hover {
    background: #e8e8e8;
}

.ribbon-tab.active {
    background: white;
    border-bottom-color: #0078d4;
    color: #0078d4;
}

.ribbon-panel {
    display: none;
    padding: 10px;
    background: white;
    min-height: 120px;
}

.ribbon-panel.active {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.ribbon-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 5px;
    border-right: 1px solid #e0e0e0;
    min-width: 120px;
}

.ribbon-group:last-child {
    border-right: none;
}

.group-label {
    font-size: 11px;
    color: #666;
    text-align: center;
    margin-bottom: 5px;
}

.group-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    align-items: center;
}

.ribbon-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 40px;
    transition: all 0.2s;
    color: #333;
    font-size: 11px;
}

.ribbon-btn:hover {
    background: #e8e8e8;
    border-color: #c0c0c0;
}

.ribbon-btn:active {
    background: #d0d0d0;
}

.ribbon-btn.active {
    background: #cce5ff;
    border-color: #0078d4;
}

.ribbon-btn i {
    font-size: 16px;
}

.font-family,
.font-size,
.style-select,
.theme-select {
    padding: 4px 8px;
    border: 1px solid #c0c0c0;
    border-radius: 3px;
    font-size: 12px;
    background: white;
    cursor: pointer;
}

.font-family {
    width: 140px;
}

.font-size {
    width: 60px;
}

.style-select {
    width: 150px;
}

.theme-select {
    width: 120px;
}

.color-picker-wrapper {
    position: relative;
    display: inline-block;
}

.color-picker {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.color-indicator {
    width: 16px;
    height: 3px;
    background: #000;
    margin-top: 2px;
}

.color-indicator.highlight {
    background: #ffff00;
    height: 12px;
    border-radius: 2px;
}

/* Область редактирования */
.editor-container {
    flex: 1;
    overflow: auto;
    background: #e5e5e5;
    display: flex;
    flex-direction: column;
}

.ruler {
    height: 25px;
    background: #f3f3f3;
    border-bottom: 1px solid #d0d0d0;
    position: relative;
}

.ruler-marks {
    height: 100%;
    background: repeating-linear-gradient(
        to right,
        transparent,
        transparent 47px,
        #d0d0d0 47px,
        #d0d0d0 48px
    );
}

.editor-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    overflow-y: auto;
    gap: 20px;
}

.side-image {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: sticky;
    top: 20px;
    height: fit-content;
}

.side-logo {
    max-width: 200px;
    max-height: 400px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.editor {
    background: white;
    width: 816px; /* A4 width at 96 DPI */
    min-height: 1056px; /* A4 height at 96 DPI */
    padding: 96px; /* 1 inch margins */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    outline: none;
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
    font-family: 'Calibri', 'Arial', sans-serif;
}

.editor p {
    margin: 0 0 6px 0;
}

.editor h1 {
    font-size: 24pt;
    font-weight: bold;
    margin: 12px 0;
}

.editor h2 {
    font-size: 18pt;
    font-weight: bold;
    margin: 10px 0;
}

.editor h3 {
    font-size: 14pt;
    font-weight: bold;
    margin: 8px 0;
}

.editor img {
    max-width: 100%;
    height: auto;
}

.editor table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}

.editor table td,
.editor table th {
    border: 1px solid #000;
    padding: 8px;
    text-align: left;
}

.editor a {
    color: #0078d4;
    text-decoration: underline;
}

/* Статусная строка */
.status-bar {
    background: #f3f3f3;
    height: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    border-top: 1px solid #d0d0d0;
    font-size: 11px;
    color: #666;
}

.status-left {
    display: flex;
    gap: 15px;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 5px;
}

.zoom-btn {
    background: transparent;
    border: 1px solid #c0c0c0;
    width: 24px;
    height: 20px;
    cursor: pointer;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #333;
}

.zoom-btn:hover {
    background: #e0e0e0;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 400px;
    max-width: 500px;
    position: relative;
}

.close-modal {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 24px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: #000;
}

.modal-content h2 {
    margin-bottom: 15px;
    font-size: 18px;
    color: #333;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 12px;
    color: #666;
}

.form-input {
    padding: 6px 10px;
    border: 1px solid #c0c0c0;
    border-radius: 3px;
    font-size: 13px;
}

.form-input:focus {
    outline: none;
    border-color: #0078d4;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 10px;
}

.btn-primary {
    background: #0078d4;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
}

.btn-primary:hover {
    background: #106ebe;
}

.btn-secondary {
    background: #f3f3f3;
    color: #333;
    border: 1px solid #c0c0c0;
    padding: 8px 16px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
}

.btn-secondary:hover {
    background: #e8e8e8;
}

/* Таблица в модальном окне */
.table-grid {
    display: grid;
    grid-template-columns: repeat(10, 20px);
    grid-template-rows: repeat(10, 20px);
    gap: 2px;
    margin: 20px 0;
    border: 1px solid #c0c0c0;
    padding: 5px;
    background: white;
}

.table-cell {
    background: #f0f0f0;
    border: 1px solid #d0d0d0;
    cursor: pointer;
    transition: background 0.1s;
}

.table-cell:hover {
    background: #e0e0e0;
}

.table-cell.selected {
    background: #0078d4;
}

.table-size-info {
    text-align: center;
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* Адаптивность */
@media (max-width: 1200px) {
    .editor {
        width: 100%;
        max-width: 816px;
    }
}

