/**
 * Personal Webmail — UIkit theme overrides
 * Font: Montserrat
 */

:root {
    --mail-sidebar-width: 300px;
    --mail-messages-width: 340px;
    --mail-folder-bg: #d1d5db;
    --mail-folder-header-bg: #c4c9d0;
    --mail-messages-bg: #eef0f3;
    --mail-messages-header-bg: #e4e7ec;
    --mail-selection-bg: #dbeafe;
    --mail-selection-bg-strong: #bfdbfe;
    --mail-selection-border: #3b82f6;
    --mail-selection-text: #1e3a8a;
    --mail-panel-header-height: 48px;
}

iconify-icon.app-icon {
    width: 1em;
    height: 1em;
    font-size: 16px;
    vertical-align: -0.15em;
    flex-shrink: 0;
}

.mail-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1;
    min-height: 32px;
}

.mail-logout-btn iconify-icon.app-icon {
    vertical-align: 0;
}

.mail-navbar-brand {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.mail-compose-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mail-compose-notice {
    font-size: 13px;
    font-weight: 700;
    color: #15803d;
    white-space: nowrap;
}

.mail-compose-notice.is-error {
    color: #b91c1c;
}

.mail-compose-notice[hidden] {
    display: none !important;
}

.mail-compose-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 22px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1;
    box-shadow: 0 8px 20px rgba(30, 135, 240, 0.28);
}

.mail-compose-btn:hover,
.mail-compose-btn:focus {
    box-shadow: 0 10px 24px rgba(30, 135, 240, 0.34);
}

.mail-compose-btn iconify-icon.app-icon {
    font-size: 20px;
    vertical-align: 0;
}

.mail-install-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1;
    min-height: 32px;
    font-weight: 700;
}

.mail-install-btn[hidden] {
    display: none !important;
}

.mail-notifications-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1;
    min-height: 32px;
    font-weight: 700;
}

.mail-notifications-btn-active {
    color: #fff;
    background: #1e87f0;
    border-color: #1e87f0;
}

.mail-notifications-btn-active:hover,
.mail-notifications-btn-active:focus {
    color: #fff;
    background: #0f7ae5;
    border-color: #0f7ae5;
}

html,
body,
.uk-body,
.uk-button,
.uk-input,
.uk-select,
.uk-textarea,
.uk-navbar,
.uk-card,
.uk-label {
    font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    background-color: #f5f7fb;
    color: #1f2937;
    height: 100%;
    overflow: hidden;
}

.uk-card-title,
.uk-heading-small,
.uk-logo {
    font-weight: 700;
}

.uk-form-label {
    font-weight: 600;
}

/* Поштовий клієнт */

.mail-app {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    background-color: #f5f7fb;
}

.mail-layout {
    flex: 1 1 auto;
    min-height: 0;
    height: 0;
    overflow: hidden;
    align-items: stretch;
}

/* UIkit grid-match розтягує дочірні блоки — не даємо цьому зачіпати заголовки */
.mail-layout.uk-grid-match > * > .mail-panel-header {
    flex: 0 0 auto;
}

.mail-layout > * {
    min-height: 0;
}

.mail-sidebar,
.mail-messages,
.mail-preview {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.mail-sidebar {
    max-width: var(--mail-sidebar-width);
}

.mail-messages {
    max-width: var(--mail-messages-width);
}

/* Блок "Папка" — сірий */
.mail-sidebar-panel {
    background-color: var(--mail-folder-bg);
}

.mail-panel-header-sidebar {
    background-color: var(--mail-folder-header-bg);
    border-bottom-color: #b8bec7;
}

/* Блок "Листи" — світло-сірий */
.mail-messages-panel {
    background-color: var(--mail-messages-bg);
    min-height: 0;
    overflow: hidden;
}

.mail-panel-header-messages {
    background-color: var(--mail-messages-header-bg);
    border-bottom-color: #d5d9e0;
}

.mail-panel-header {
    display: flex;
    align-items: center;
    min-height: var(--mail-panel-header-height);
    box-sizing: border-box;
    padding: 0 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafbfc;
    flex: 0 0 auto;
}

.mail-panel-header .uk-h5 {
    margin: 0;
    font-size: 13px;
    line-height: 1.25;
    font-weight: 700;
}

.mail-panel-header-messages .uk-h5 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-panel-header-with-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: var(--mail-panel-header-height);
}

.mail-panel-header-with-actions .uk-h5 {
    flex: 1;
    min-width: 0;
}

.mail-header-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
    flex-shrink: 0;
    min-height: 32px;
}

.mail-header-action-btn iconify-icon.app-icon {
    vertical-align: 0;
}

.mail-messages-search {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-bottom: 1px solid #d5d9e0;
    background-color: var(--mail-messages-header-bg);
}

.mail-messages-search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0 10px;
    min-height: 36px;
    border: 1px solid #c5cad3;
    border-radius: 8px;
    background: #ffffff;
}

.mail-messages-search-icon {
    flex-shrink: 0;
    color: #6b7280;
    font-size: 18px;
}

.mail-messages-search-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 6px 0;
    font-size: 13px;
    line-height: 1.3;
    color: #111827;
    outline: none;
}

.mail-messages-search-input::-webkit-search-cancel-button,
.mail-messages-search-input::-webkit-search-decoration {
    display: none;
}

.mail-messages-search-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: #eef0f3;
    color: #4b5563;
    cursor: pointer;
}

.mail-messages-search-clear:hover {
    background: #e2e5ea;
}

.search-highlight,
mark.search-highlight {
    background-color: #fff176;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

.mail-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    height: 0;
    padding: 12px;
}

.mail-panel-body-scroll,
.mail-messages-scroll {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.mail-messages-scroll {
    flex: 1 1 auto;
    min-height: 0;
    height: 0;
}

.uk-border-right {
    border-right: 1px solid #e5e7eb;
}

/* Дерево акаунтів і папок */

.account-tree-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.account-tree .uk-card {
    border: 1px solid #b8bec7;
    background-color: #ffffff;
}

.account-tree-header {
    padding-bottom: 2px;
}

.account-tree-header .account-item-label {
    display: block;
    font-weight: 700;
    font-size: 14px;
    color: #111827;
}

.account-tree-header .account-item-email {
    display: block;
    font-size: 11px;
    color: #6b7280;
    word-break: break-all;
}

.folder-nav {
    list-style: none;
    margin: 0;
    padding: 0;
}

.folder-nav .folder-item {
    margin: 0 0 4px;
}

.folder-nav .folder-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 8px;
    color: #374151;
    text-decoration: none;
    box-sizing: border-box;
    border: 1px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.folder-nav .folder-link:hover {
    background: rgba(255, 255, 255, 0.55);
    color: #111827;
}

.folder-nav .folder-item.is-active .folder-link {
    background: var(--mail-selection-bg-strong);
    border-color: var(--mail-selection-border);
    color: var(--mail-selection-text);
    font-weight: 700;
    box-shadow: inset 4px 0 0 var(--mail-selection-border);
}

.folder-item-name {
    flex: 1;
    min-width: 0;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-item-count {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #4b5563;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.folder-item-count-unread {
    background: #2563eb;
    color: #ffffff;
}

.folder-nav .folder-item.is-active .folder-item-count {
    background: #1d4ed8;
    color: #ffffff;
}

.folder-nav .folder-item.is-active .folder-item-count-unread {
    background: #1d4ed8;
    color: #ffffff;
}

/* Список листів */

.message-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.message-list-item {
    list-style: none;
    margin: 0 0 8px;
}

.message-list-sentinel {
    list-style: none;
    min-height: 24px;
}

.message-list-sentinel[hidden] {
    display: none !important;
}

.message-day-divider {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 10px;
    padding: 0 4px;
    cursor: pointer;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: left;
}

.message-day-divider:hover .message-day-label,
.message-day-divider:focus-visible .message-day-label {
    color: #374151;
}

.message-day-divider:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
    border-radius: 4px;
}

.message-day-divider:first-child {
    margin-top: 4px;
}

.message-day-divider::before,
.message-day-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: #c8ced8;
}

.message-day-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #6b7280;
    text-transform: capitalize;
    white-space: nowrap;
    pointer-events: none;
}

.message-calendar-view {
    padding: 4px 2px 12px;
}

.message-calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.message-calendar-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #c5cad3;
    border-radius: 8px;
    background: #ffffff;
    color: #374151;
    cursor: pointer;
}

.message-calendar-nav:hover {
    background: #f3f4f6;
}

.message-calendar-title {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    text-transform: capitalize;
}

.message-calendar-weekdays,
.message-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}

.message-calendar-weekday {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    padding: 4px 0;
}

.message-calendar-day {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: #ffffff;
    color: #111827;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.message-calendar-day.is-empty {
    background: transparent;
    cursor: default;
    pointer-events: none;
}

.message-calendar-day:not(.is-empty):hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.message-calendar-day.is-today {
    border-color: #93c5fd;
}

.message-calendar-day.is-focused {
    box-shadow: inset 0 0 0 2px #3b82f6;
}

.message-calendar-day.has-messages::after {
    content: "";
    position: absolute;
    bottom: 4px;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: #3b82f6;
}

.message-calendar-day {
    position: relative;
}

.message-calendar-day.has-messages {
    font-weight: 700;
}

.message-calendar-footer {
    margin-top: 12px;
    display: flex;
    justify-content: center;
}

.message-calendar-back-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid #c5cad3;
    border-radius: 8px;
    background: #ffffff;
    color: #374151;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.message-calendar-back-all:hover {
    background: #f3f4f6;
}

.message-day-filter-bar {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 12px;
    padding: 8px 10px;
    border: 1px solid #d5d9e0;
    border-radius: 10px;
    background: #ffffff;
}

.message-day-filter-label {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    text-transform: capitalize;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-day-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 0;
    border-radius: 6px;
    background: #eef0f3;
    color: #374151;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.message-day-filter-btn:hover {
    background: #e2e5ea;
}

.message-card {
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    background-color: #ffffff;
    border: 1px solid transparent;
}

.message-card:hover {
    background-color: #f8fafc;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.message-list .message-card.uk-active {
    background-color: var(--mail-selection-bg);
    border-color: var(--mail-selection-border);
    box-shadow:
        inset 4px 0 0 var(--mail-selection-border),
        0 0 0 1px rgba(59, 130, 246, 0.2);
}

.message-card.uk-active .message-subject {
    color: var(--mail-selection-text);
}

.message-card.uk-active .message-meta {
    color: #1d4ed8;
}

.message-card.unread .message-subject {
    font-weight: 700;
}

.message-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.message-card-top .message-subject {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.message-thread-count {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.message-list .message-card.uk-active .message-thread-count {
    background: #2563eb;
    color: #ffffff;
}

.message-subject {
    margin: 0 0 4px;
    font-size: 14px;
    color: #111827;
}

.message-meta {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
}

/* Контекстне меню списку листів */

.mail-context-menu {
    position: fixed;
    z-index: 1100;
    min-width: 220px;
    padding: 6px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

.mail-context-menu[hidden] {
    display: none !important;
}

.mail-context-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mail-context-menu-item button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 36px;
    padding: 8px 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #374151;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.mail-context-menu-item button:hover,
.mail-context-menu-item button:focus-visible {
    background: #f3f4f6;
    outline: none;
}

.mail-context-menu-item-danger button {
    color: #dc2626;
}

.mail-context-menu-item-danger button:hover,
.mail-context-menu-item-danger button:focus-visible {
    background: #fef2f2;
    color: #b91c1c;
}

.mail-context-menu-divider {
    height: 1px;
    margin: 4px 8px;
    background: #e5e7eb;
    list-style: none;
}

.rules-modal-dialog {
    width: min(720px, calc(100vw - 32px));
}

.rules-modal-description {
    margin-top: -6px;
    margin-bottom: 18px;
}

.rules-section-title {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
}

.rules-list-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.rules-list-toolbar .uk-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.rules-list-wrap {
    margin-bottom: 0;
}

.rules-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: min(420px, calc(100vh - 240px));
    overflow-y: auto;
    padding-right: 4px;
}

.rules-list-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fafbfc;
}

.rules-list-item.is-disabled {
    opacity: 0.65;
}

.rules-list-item-main {
    min-width: 0;
}

.rules-list-item-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 600;
    color: #111827;
}

.rules-list-item-line {
    display: block;
    word-break: break-word;
}

.rules-list-item-meta {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.45;
}

.rules-list-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.rules-list-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 0;
    line-height: 1;
}

.rules-form-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.rules-form-checks label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.rules-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

#rulesFormAlert[hidden],
#signaturesFormAlert[hidden] {
    display: none !important;
}

.signature-body-input {
    min-height: 180px;
    resize: vertical;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    line-height: 1.5;
}

.signature-list-preview {
    white-space: pre-wrap;
}

.signature-context-menu-empty button[disabled] {
    opacity: 0.72;
    cursor: default;
}

.signature-context-menu {
    min-width: 220px;
    z-index: 10120;
}

/* Preview листа */

.preview-subject {
    margin: 0 0 12px;
    font-size: 22px;
    line-height: 1.3;
    font-weight: 700;
}

.preview-meta {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
    color: #4b5563;
    font-size: 13px;
}

.preview-meta p {
    margin: 0 0 6px;
}

.preview-content {
    line-height: 1.6;
    word-break: break-word;
}

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

.preview-attachments {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #f8fafc;
}

.preview-attachments-title {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.preview-attachments-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preview-attachment-item a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #1d4ed8;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.preview-attachment-item a:hover {
    text-decoration: underline;
}

.preview-attachment-size {
    color: #6b7280;
    font-weight: 500;
}

.inline-mail-gallery {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0 0 16px;
}

.inline-mail-image {
    margin: 0;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #ffffff;
}

.inline-mail-image img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.inline-mail-image figcaption {
    margin-top: 8px;
    font-size: 12px;
    color: #6b7280;
}

.thread-bubble-body .preview-attachments,
.thread-bubble-body .inline-mail-gallery {
    margin-top: 12px;
}

.thread-bubble-files,
.thread-bubble-gallery {
    margin: 0;
    padding: 10px 14px 12px;
    border-bottom: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(255, 255, 255, 0.42);
}

.thread-bubble.is-outgoing .thread-bubble-files,
.thread-bubble.is-outgoing .thread-bubble-gallery {
    background: rgba(255, 255, 255, 0.24);
    border-bottom-color: rgba(37, 99, 235, 0.18);
}

.thread-bubble-file-icon {
    flex-shrink: 0;
    font-size: 14px;
    line-height: 1;
}

.thread-bubble-files-title {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.thread-bubble-files-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.thread-bubble-files .preview-attachment-item a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    color: #1d4ed8;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    word-break: break-word;
}

.thread-bubble-files .preview-attachment-item a:hover {
    text-decoration: underline;
}

.thread-bubble-gallery {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.thread-bubble-gallery .inline-mail-image {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.thread-bubble-gallery .inline-mail-image img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.thread-bubble-body img {
    max-width: 100%;
    height: auto;
}

.preview-content.text-mode {
    white-space: pre-wrap;
    font-family: Consolas, Monaco, monospace;
}

.mail-thread-meta {
    margin: -4px 0 16px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
}

.mail-thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.thread-bubble {
    max-width: min(88%, 720px);
    padding: 0;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    background: #f3f4f6;
    overflow: hidden;
}

.thread-bubble.is-incoming {
    align-self: flex-start;
    border-bottom-left-radius: 6px;
}

.thread-bubble.is-outgoing {
    align-self: flex-end;
    background: var(--mail-selection-bg);
    border-color: #93c5fd;
    border-bottom-right-radius: 6px;
}

.thread-bubble.is-current {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.22);
}

.thread-bubble-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 10px;
    border-bottom: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(255, 255, 255, 0.42);
}

.thread-bubble.is-outgoing .thread-bubble-header {
    background: rgba(255, 255, 255, 0.28);
    border-bottom-color: rgba(37, 99, 235, 0.18);
}

.thread-bubble-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.thread-bubble-avatar.is-incoming {
    background: #dbeafe;
    color: #1d4ed8;
}

.thread-bubble-avatar.is-outgoing {
    background: #1d4ed8;
    color: #ffffff;
}

.thread-bubble-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.thread-bubble-meta-top {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.thread-bubble-meta-bottom {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
    font-size: 11px;
    line-height: 1.35;
    color: #6b7280;
}

.thread-bubble-author {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    line-height: 1.25;
    word-break: break-word;
}

.thread-bubble-role {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
}

.thread-bubble-role.is-incoming {
    background: #eff6ff;
    color: #1d4ed8;
}

.thread-bubble-role.is-outgoing {
    background: rgba(255, 255, 255, 0.72);
    color: #1e40af;
}

.thread-bubble-email {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-bubble-date {
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
}

.thread-bubble-meta-bottom .thread-bubble-email + .thread-bubble-date::before {
    content: "·";
    margin-right: 8px;
    color: #9ca3af;
}

.thread-reply-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 0;
    line-height: 1;
    background: rgba(255, 255, 255, 0.88);
}

.thread-bubble.is-outgoing .thread-reply-btn {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(37, 99, 235, 0.25);
}

.thread-bubble-body {
    padding: 12px 14px 14px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
}

.thread-bubble-body.text-mode {
    white-space: pre-wrap;
    font-family: inherit;
}

.reply-modal-dialog {
    width: min(980px, calc(100vw - 24px));
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.reply-from-control {
    position: relative;
    display: flex;
    align-items: stretch;
}

.reply-from-input {
    flex: 1 1 auto;
    min-width: 0;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.reply-from-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 38px;
    min-width: 38px;
    padding: 0;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-left: 0;
}

.reply-from-toggle.is-open {
    background: var(--mail-selection-bg, #eff6ff);
    border-color: #93c5fd;
}

.reply-from-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 10060;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    max-height: 220px;
    overflow-y: auto;
}

.reply-from-dropdown[hidden] {
    display: none !important;
}

.reply-from-list {
    list-style: none;
    margin: 0;
    padding: 4px;
}

.reply-from-item {
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: 6px;
}

.reply-from-item:hover {
    background: #f3f4f6;
}

.reply-from-item-select {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 10px;
    border: 0;
    background: transparent;
    text-align: left;
    font: inherit;
    color: #111827;
    cursor: pointer;
    word-break: break-all;
}

.reply-from-item-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin-right: 4px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
}

.reply-from-item-remove:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.reply-from-empty {
    padding: 10px 12px;
}

.reply-from-empty[hidden] {
    display: none !important;
}

.reply-to-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #e5e5e5;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.reply-to-control:focus-within {
    border-color: #1e87f0;
    box-shadow: 0 0 0 2px rgba(30, 135, 240, 0.12);
}

.reply-to-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.reply-to-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 2px 6px 2px 10px;
    border-radius: 999px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
    font-size: 12px;
    line-height: 1.4;
}

.reply-to-tag-label {
    word-break: break-all;
}

.reply-to-tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #2563eb;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.reply-to-tag-remove:hover {
    background: #dbeafe;
    color: #1d4ed8;
}

.reply-to-input {
    flex: 1 1 140px;
    min-width: 120px;
    border: 0;
    outline: none;
    background: transparent;
    font: inherit;
    color: #111827;
    padding: 2px 0;
}

.reply-form {
    display: flex;
    flex-direction: column;
    min-height: 520px;
}

.reply-editor-field {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.reply-editor-wrap {
    flex: 1 1 auto;
    min-height: 360px;
    display: flex;
    flex-direction: column;
}

.reply-body-input {
    flex: 1 1 auto;
    min-height: 360px;
    resize: vertical;
}

.reply-editor-wrap .tox-tinymce {
    flex: 1 1 auto;
    border-radius: 8px;
    border-color: var(--mail-border, #e5e5e5);
}

.reply-editor-wrap .tox-edit-area__iframe {
    background: #fff;
}

.tox-tinymce-aux {
    z-index: 10050 !important;
}

.reply-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.reply-form-actions .uk-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#replyFormAlert[hidden] {
    display: none !important;
}

.mail-preview-toolbar {
    flex: 0 0 auto;
    padding: 0;
    background: transparent;
}

.mail-preview-toolbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 32px;
}

.mail-preview-toolbar .uk-button[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.mailbox-card {
    min-height: 100%;
}

@media (max-width: 960px) {
    .mail-sidebar,
    .mail-messages {
        max-width: none;
    }

    .mail-layout > div {
        min-height: 280px;
    }
}
