@font-face {
    font-family: "Kanit Cyrillic";
    src: url("../fonts/Kanit Cyrillic.woff") format("woff");
}

:root {
    --bg: #08111a;
    --panel: rgba(26, 30, 38, 0.86);
    --panel-soft: rgba(26, 30, 38, 0.58);
    --border: rgba(110, 193, 228, 0.28);
    --border-strong: rgba(110, 193, 228, 0.48);
    --accent: #6ec1e4;
    --accent-soft: #a8d8ea;
    --text: #e8f1f5;
    --muted: #b1c7d4;
    --danger: #f18c9b;
    --ok: #8de2b2;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Kanit Cyrillic", system-ui, sans-serif;
    color: var(--text);
    background: var(--bg);
}

.welcome-page {
    height: 100vh;
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(8, 17, 26, 0.88), rgba(8, 17, 26, 0.42) 48%, rgba(8, 17, 26, 0.72)),
        linear-gradient(180deg, rgba(8, 17, 26, 0.16), rgba(8, 17, 26, 0.82));
    z-index: 1;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

.parallax-bg {
    position: fixed;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background: url("../images/bg.png") center/cover;
    background-color: #08111a;
    opacity: 0.92;
    filter: brightness(0.5) blur(0.7px) saturate(1.05);
    transform: translate3d(0, 0, 0) scale(1.1);
    transform-origin: center;
    will-change: transform;
    backface-visibility: hidden;
    z-index: 0;
}

.topbar {
    height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(20, 24, 31, 0.7);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar,
.welcome-shell,
.mail-app,
.compose-shell,
.settings-shell,
.setup-shell,
.not-found-shell,
.site-footer,
.flash-wrap {
    position: relative;
    z-index: 2;
}

.brand,
.topnav {
    display: flex;
    align-items: center;
}

.brand {
    gap: 12px;
    color: var(--accent);
    font-weight: 700;
    font-size: 1.2rem;
}

.brand img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.topnav {
    gap: 18px;
    color: var(--muted);
}

.topnav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pill-link,
.primary-action,
.secondary-action,
.compose-button,
.icon-text {
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border-radius: 8px;
    cursor: pointer;
}

.pill-link,
.primary-action,
.compose-button {
    background: var(--accent);
    color: #101821;
    font-weight: 700;
}

.pill-link {
    padding: 10px 16px;
}

.flash-wrap {
    position: fixed;
    top: 84px;
    right: 20px;
    z-index: 20;
    display: grid;
    gap: 10px;
}

.flash {
    width: min(410px, calc(100vw - 32px));
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(17, 25, 34, 0.94);
    box-shadow: var(--shadow);
    transition: 0.25s ease;
}

.flash-danger {
    border-color: rgba(241, 140, 155, 0.5);
}

.flash-success {
    border-color: rgba(141, 226, 178, 0.5);
}

.welcome-shell {
    max-width: 1240px;
    margin: 0 auto;
    height: calc(100vh - 124px);
    padding: 26px 28px 18px;
}

.welcome-hero {
    height: 100%;
    display: grid;
    grid-template-columns: minmax(300px, 0.78fr) minmax(460px, 1.22fr);
    gap: clamp(92px, 10vw, 156px);
    align-items: center;
}

.hero-copy h1 {
    font-family: Ubuntu, sans-serif;
    color: var(--accent);
    font-size: clamp(3.8rem, 7vw, 7.5rem);
    margin: 0 0 16px;
    line-height: 0.94;
}

.hero-text {
    color: var(--muted);
    font-size: 1.16rem;
    line-height: 1.58;
    max-width: 520px;
}

.primary-action,
.secondary-action {
    min-height: 44px;
    padding: 0 18px;
}

.secondary-action {
    background: rgba(110, 193, 228, 0.1);
    border: 1px solid var(--border);
    color: var(--accent-soft);
}

.mail-preview {
    height: min(500px, 61vh);
    min-height: 330px;
    display: grid;
    grid-template-columns: 92px 0.9fr 1.2fr;
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(110, 193, 228, 0.18);
    box-shadow: var(--shadow);
    transform: translateX(42px);
}

.preview-sidebar,
.preview-list,
.preview-message {
    background: rgba(14, 21, 29, 0.88);
    padding: 22px;
}

.preview-sidebar {
    display: grid;
    align-content: start;
    gap: 15px;
}

.preview-sidebar span,
.preview-row,
.preview-search,
.preview-subject,
.preview-line {
    border-radius: 8px;
    background: rgba(110, 193, 228, 0.18);
}

.preview-sidebar span {
    width: 38px;
    height: 38px;
}

.preview-search {
    height: 42px;
    margin-bottom: 18px;
}

.preview-row {
    height: 58px;
    margin-bottom: 12px;
    padding: 13px;
    display: grid;
    align-content: center;
    gap: 8px;
}

.preview-row.strong {
    background: rgba(110, 193, 228, 0.3);
}

.preview-row span,
.preview-row i {
    display: block;
    height: 8px;
    border-radius: 8px;
    background: rgba(232, 241, 245, 0.22);
}

.preview-row i {
    width: 68%;
    background: rgba(177, 199, 212, 0.14);
}

.preview-row.short {
    width: 70%;
}

.site-footer {
    height: 58px;
    background: rgba(20, 24, 31, 0.7);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
}

.footer-content {
    height: 100%;
    margin: 0 auto;
    padding: 0 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    color: var(--muted);
}

.footer-content p {
    margin: 0;
}

.footer-content p a {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.footer-content p a:hover,
.footer-content p a:visited,
.footer-content p a:active {
    color: inherit;
    text-decoration: none;
}

.social-icons {
    display: flex;
    align-items: center;
    gap: 22px;
}

.social-icons a {
    color: var(--muted);
    font-size: 1.18rem;
    transition: color 0.3s ease, transform 0.3s ease;
}

.social-icons a:hover {
    color: var(--accent);
    transform: translateY(-2px);
}

.preview-subject {
    height: 48px;
    margin-bottom: 28px;
}

.preview-line {
    height: 18px;
    margin-bottom: 14px;
}

.preview-line.small {
    width: 58%;
}

.mail-app {
    height: calc(100dvh - 66px);
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    overflow: hidden;
    min-height: 0;
}

.mail-sidebar {
    border-right: 1px solid var(--border);
    background: rgba(16, 23, 31, 0.76);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: 0;
}

.compose-button {
    min-height: 48px;
}

.folder-nav {
    display: grid;
    gap: 5px;
}

.sidebar-section {
    min-height: 0;
    display: grid;
    gap: 10px;
}

.sidebar-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    padding: 0 4px;
    font-size: 0.88rem;
}

.sidebar-section-body.scrollable {
    max-height: 188px;
    overflow: auto;
    padding-right: 4px;
}

.sidebar-inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.hidden,
.sidebar-inline-form.hidden,
.sidebar-modal.hidden,
.action-menu-list.hidden {
    display: none;
}

.sidebar-context-menu.hidden {
    display: none;
}

.sidebar-inline-form input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(8, 17, 26, 0.48);
    color: var(--text);
    padding: 10px 12px;
    outline: 0;
}

.sidebar-mini-button {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(26, 30, 38, 0.6);
    color: var(--accent-soft);
    cursor: pointer;
}

.folder-link {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    border-radius: 8px;
    padding: 0 12px;
}

.folder-link span {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    min-width: 0;
}

.folder-link i {
    width: 20px;
    color: var(--accent-soft);
}

.folder-link.active,
.folder-link:hover {
    color: var(--text);
    background: rgba(110, 193, 228, 0.14);
}

.folder-link strong {
    min-width: 26px;
    text-align: center;
    color: #101821;
    background: var(--accent);
    border-radius: 20px;
    font-size: 0.84rem;
}

.mail-account {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    background: rgba(8, 17, 26, 0.38);
}

.sidebar-bottom {
    margin-top: auto;
    display: grid;
    gap: 12px;
    min-height: 0;
}

.sidebar-card-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    background: rgba(8, 17, 26, 0.38);
    color: var(--text);
    cursor: pointer;
}

.sidebar-card-button span {
    color: var(--muted);
}

.sidebar-card-button strong {
    color: var(--accent-soft);
}

.sidebar-modal {
    position: fixed;
    inset: 0;
    z-index: 90;
}

.sidebar-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 9, 15, 0.7);
    backdrop-filter: blur(6px);
}

.sidebar-modal-card {
    position: absolute;
    left: 22px;
    bottom: 22px;
    width: min(360px, calc(100vw - 44px));
    max-height: min(70vh, 560px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(16, 23, 31, 0.96);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.sidebar-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(110, 193, 228, 0.12);
}

.sidebar-modal-head h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.02rem;
}

.sidebar-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sidebar-modal-list {
    min-height: 0;
    max-height: 100%;
    overflow: auto;
    display: grid;
    gap: 8px;
    padding: 14px;
}

.contact-editor {
    display: grid;
    gap: 8px;
    border: 1px solid rgba(110, 193, 228, 0.16);
    border-radius: 8px;
    background: rgba(8, 17, 26, 0.44);
    padding: 12px;
}

.contact-editor.hidden {
    display: none;
}

.contact-editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
}

.contact-editor input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(16, 23, 31, 0.88);
    color: var(--text);
    padding: 10px 12px;
    outline: 0;
}

.contact-editor textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(16, 23, 31, 0.88);
    color: var(--text);
    padding: 10px 12px;
    outline: 0;
    font-family: inherit;
    resize: vertical;
    font-size: 0.95rem;
    line-height: 1.4;
}

.contact-editor-actions,
.contact-item-actions {
    display: flex;
    gap: 8px;
}

.contact-item-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    gap: 10px;
    align-items: stretch;
    border: 1px solid rgba(110, 193, 228, 0.16);
    border-radius: 8px;
    background: rgba(8, 17, 26, 0.44);
    padding: 10px 10px 10px 12px;
}

.contact-item-actions {
    flex-direction: column;
    justify-content: center;
}

.contact-item {
    display: grid;
    gap: 4px;
    align-content: center;
    text-align: left;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
    color: var(--text);
    cursor: pointer;
}

.contact-item-actions .sidebar-mini-button,
.contact-item-actions form {
    margin: 0;
    width: 36px;
    height: 36px;
    min-height: 36px;
}

.contact-item-actions form button {
    width: 36px;
    height: 100%;
}

.sidebar-modal-list > .contact-item {
    min-height: 58px;
    border-bottom: 1px solid rgba(110, 193, 228, 0.12);
    padding: 8px 2px 10px;
}

.sidebar-modal-list > .contact-item:last-child {
    border-bottom: 0;
}

.contact-item span,
.contact-empty {
    color: var(--muted);
}

.contact-comment {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(110, 193, 228, 0.12);
    color: rgba(177, 199, 212, 0.8);
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.sidebar-context-menu {
    position: fixed;
    z-index: 95;
    min-width: 220px;
    display: grid;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(16, 23, 31, 0.98);
    box-shadow: var(--shadow);
    padding: 10px;
}

.sidebar-context-form {
    display: grid;
    gap: 8px;
}

.sidebar-context-form input,
.sidebar-context-form button {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(8, 17, 26, 0.48);
    color: var(--text);
    padding: 10px 12px;
    outline: 0;
    font: inherit;
    text-align: left;
}

.mail-account span,
.mail-account strong {
    display: block;
}

.mail-account span {
    color: var(--muted);
    font-size: 0.9rem;
}

.mail-account strong {
    color: var(--accent-soft);
    margin-top: 5px;
    overflow-wrap: anywhere;
}

.mail-panel,
.reader-panel {
    min-width: 0;
    background: rgba(8, 17, 26, 0.38);
    min-height: 0;
}

.mail-panel {
    display: grid;
    grid-template-rows: 72px minmax(0, 1fr) 56px;
    overflow: hidden;
}

.mail-toolbar {
    height: 72px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.search-form {
    height: 44px;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 760px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(26, 30, 38, 0.72);
    padding: 0 14px;
    color: var(--muted);
}

.search-form input {
    min-width: 0;
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
}

.icon-button,
.bulk-actions button,
.select-all {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(26, 30, 38, 0.6);
    color: var(--accent-soft);
    cursor: pointer;
}

.select-all input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.bulk-actions {
    height: 52px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    border-bottom: 1px solid rgba(110, 193, 228, 0.14);
}

.action-menu {
    position: relative;
}

.bulk-actions .action-menu-trigger {
    width: auto;
    min-width: max-content;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(26, 30, 38, 0.6);
    color: var(--accent-soft);
    padding: 0 16px;
    cursor: pointer;
    font: inherit;
    white-space: nowrap;
}

.action-menu-list {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    display: grid;
    padding: 8px;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(16, 23, 31, 0.98);
    box-shadow: var(--shadow);
    z-index: 12;
}

.action-menu-list button {
    width: 100%;
    height: auto;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 12px;
    font: inherit;
}

.action-menu-empty {
    min-height: 40px;
    display: flex;
    align-items: center;
    color: var(--muted);
    padding: 0 12px;
}

.message-list-form {
    min-height: 0;
    display: grid;
    grid-template-rows: 52px minmax(0, 1fr);
    height: 100%;
    overflow: hidden;
}

.message-list {
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}

/* Custom scrollbar for message list - Chrome/Edge */
.message-list::-webkit-scrollbar {
    width: 10px;
}

.message-list::-webkit-scrollbar-track {
    background: transparent;
    margin: 4px 0;
}

.message-list::-webkit-scrollbar-thumb {
    background-color: rgba(110, 193, 228, 0.35);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
    min-height: 40px;
}

.message-list::-webkit-scrollbar-thumb:hover {
    background-color: rgba(110, 193, 228, 0.6);
    background-clip: padding-box;
}

.message-list::-webkit-scrollbar-thumb:active {
    background-color: rgba(110, 193, 228, 0.85);
    background-clip: padding-box;
}

/* Firefox scrollbar */
.message-list {
    scrollbar-color: rgba(110, 193, 228, 0.35) transparent;
    scrollbar-width: thin;
}

.message-row {
    min-height: 58px;
    display: grid;
    grid-template-columns: 30px 34px minmax(0, 1fr);
    align-items: center;
    border-bottom: 1px solid rgba(110, 193, 228, 0.12);
    padding: 0 18px;
    background: rgba(8, 17, 26, 0.12);
}

.message-row:hover {
    background: rgba(110, 193, 228, 0.08);
}

.message-row.unread {
    background: rgba(110, 193, 228, 0.12);
}

.custom-check-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.custom-check {
    width: 18px;
    height: 18px;
    display: inline-grid;
    place-items: center;
    border: 1px solid rgba(110, 193, 228, 0.42);
    border-radius: 5px;
    background: rgba(8, 17, 26, 0.42);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.custom-check::after {
    content: "";
    width: 8px;
    height: 4px;
    border-left: 2px solid #101821;
    border-bottom: 2px solid #101821;
    opacity: 0;
    transform: rotate(-45deg) translateY(-1px);
}

.custom-check-input:checked + .custom-check {
    background: var(--accent);
    border-color: var(--accent);
}

.custom-check-input:checked + .custom-check::after {
    opacity: 1;
}

.star {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    padding: 0;
    background: transparent;
    color: rgba(177, 199, 212, 0.5);
    cursor: pointer;
    transition: color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.star:hover {
    background: rgba(242, 209, 107, 0.12);
    color: rgba(242, 209, 107, 0.86);
}

.star:active {
    transform: scale(0.92);
}

.star.on {
    color: #f2d16b;
}

.message-link {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(180px, 320px) minmax(0, 1fr) 152px;
    gap: 16px;
    align-items: center;
}

.sender,
.subject,
.date {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sender {
    color: var(--text);
}

.subject,
.date {
    color: var(--muted);
}

.message-row.unread .sender,
.message-row.unread .subject {
    color: var(--text);
    font-weight: 700;
}

.date {
    text-align: right;
    font-size: 0.88rem;
    white-space: nowrap;
    text-overflow: clip;
}

.empty-state {
    height: 100%;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    color: var(--muted);
}

.empty-state i {
    color: var(--accent);
    font-size: 2.2rem;
}

.empty-state h2 {
    color: var(--text);
    margin: 0;
}

.empty-state p {
    margin: 0;
}

.mail-statusbar {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    color: var(--muted);
    padding: 0 24px;
    border-top: 1px solid var(--border);
}

.reader-panel {
    overflow: auto;
    padding: 22px clamp(18px, 4vw, 54px);
}

.reader-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.icon-text {
    min-height: 40px;
    padding: 0 13px;
    border: 1px solid var(--border);
    background: rgba(26, 30, 38, 0.55);
    color: var(--accent-soft);
}

.message-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 18px;
}

.message-header h1 {
    font-family: Ubuntu, sans-serif;
    color: var(--accent);
    font-size: clamp(1.8rem, 3vw, 3rem);
    margin: 0 0 18px;
    overflow-wrap: anywhere;
}

.message-meta {
    display: grid;
    gap: 8px;
    color: var(--muted);
}

.message-meta div {
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 10px;
}

.message-meta strong {
    color: var(--text);
    overflow-wrap: anywhere;
}

.attachments {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 18px 0 22px;
    align-items: flex-start;
}

.attachment-item {
    width: min(760px, 100%);
    min-height: 58px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(26, 30, 38, 0.54);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.attachment-info {
    min-width: 0;
    min-height: 58px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
    text-align: left;
    transition: background 0.2s ease;
}

.attachment-info:hover {
    background: rgba(110, 193, 228, 0.08);
}

.attachment-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(110, 193, 228, 0.1);
    color: var(--accent-soft);
}

.attachment-text {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.attachment-name {
    min-width: 0;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-size {
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.attachment-download {
    min-width: 46px;
    min-height: 58px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-left: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    gap: 8px;
    padding: 0 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
    font-size: 0.95rem;
    white-space: nowrap;
}

.attachment-download:hover {
    background: rgba(110, 193, 228, 0.12);
    color: var(--accent-soft);
}

.image-attachments {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, max-content));
    gap: 14px;
    margin: 18px 0 22px;
}

.image-attachment {
    margin: 0;
    max-width: min(520px, 100%);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(26, 30, 38, 0.54);
}

.image-attachment-preview {
    display: block;
    width: 100%;
    overflow: hidden;
    border: 0;
    background: rgba(8, 17, 26, 0.36);
    padding: 0;
    cursor: pointer;
}

.image-attachment img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 360px;
    object-fit: contain;
}

.image-attachment figcaption {
    min-height: 52px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 10px 12px;
    font-size: 0.9rem;
}

.image-attachment figcaption .attachment-name,
.image-attachment figcaption .attachment-size {
    grid-column: 1;
}

.image-attachment figcaption .attachment-size {
    font-size: 0.82rem;
}

.image-download {
    grid-row: 1 / span 2;
    grid-column: 2;
    min-height: 38px;
    width: 38px;
    min-width: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0;
}

.message-body {
    margin-top: 24px;
    max-width: 980px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.message-body pre {
    white-space: pre-wrap;
    font-family: inherit;
}

.compose-shell,
.settings-shell,
.setup-shell {
    min-height: calc(100vh - 68px);
    display: grid;
    place-items: start center;
    gap: 18px;
    padding: 32px 18px;
}

.compose-card,
.settings-card,
.setup-card {
    width: min(980px, 100%);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.compose-head,
.settings-head,
.setup-head {
    padding: 22px;
    border-bottom: 1px solid var(--border);
}

.compose-head h1,
.settings-head h1,
.setup-head h1 {
    font-family: Ubuntu, sans-serif;
    color: var(--accent);
    margin: 0 0 6px;
}

.compose-head span,
.settings-head p,
.setup-head p {
    color: var(--muted);
    margin: 0;
}

.compose-fields,
.settings-card {
    display: grid;
}

.compose-fields label,
.settings-field {
    min-height: 48px;
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: center;
    border-bottom: 1px solid rgba(110, 193, 228, 0.13);
    padding: 0 18px;
    color: var(--muted);
}

.recipient-block {
    min-height: 48px;
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: start;
    border-bottom: 1px solid rgba(110, 193, 228, 0.13);
    padding: 14px 18px;
    color: var(--muted);
}

.recipient-block > span {
    min-height: 40px;
    display: flex;
    align-items: center;
}

.recipient-list {
    display: grid;
    gap: 10px;
}

.recipient-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px 40px 40px;
    gap: 8px;
    align-items: center;
}

.icon-ghost {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(8, 17, 26, 0.38);
    color: var(--accent-soft);
    cursor: pointer;
}

.icon-ghost.danger {
    color: var(--danger);
}

.icon-ghost.active {
    color: #f2d16b;
    background: rgba(242, 209, 107, 0.12);
}

.confirm-card {
    max-width: 420px;
}

.confirm-body {
    gap: 14px;
}

.confirm-body p {
    margin: 0;
    color: var(--text);
    line-height: 1.45;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.primary-action[disabled] {
    opacity: 0.7;
    pointer-events: none;
}

.compose-fields input,
.compose-fields textarea,
.settings-field input,
.settings-field textarea,
.address-input input {
    width: 100%;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
}

.compose-fields textarea {
    min-height: 320px;
    padding: 18px;
    resize: vertical;
    border: 0;
}

.field-invalid {
    color: var(--danger) !important;
}

.compose-bottom {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
}

.file-picker {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-soft);
    cursor: pointer;
}

.file-picker input {
    display: none;
}

.compose-actions {
    display: flex;
    gap: 10px;
}

.settings-card {
    padding-bottom: 22px;
}

.settings-field {
    grid-template-columns: 160px minmax(0, 1fr);
    margin: 0 22px;
    padding: 16px 0;
}

.settings-field textarea,
.settings-field input {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(8, 17, 26, 0.38);
    padding: 12px;
}

.settings-card .primary-action {
    justify-self: end;
    margin: 18px 22px 0;
}

.compact-settings {
    padding-bottom: 22px;
}

.settings-list {
    display: grid;
    gap: 8px;
    margin: 18px 22px 0;
}

.settings-list div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid rgba(110, 193, 228, 0.16);
    border-radius: 8px;
    padding: 10px 12px;
    background: rgba(8, 17, 26, 0.28);
}

.settings-list span {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.setup-card {
    width: min(620px, 100%);
}

.address-picker {
    display: grid;
    gap: 10px;
    padding: 22px;
    color: var(--muted);
}

.address-input {
    min-height: 50px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(8, 17, 26, 0.38);
    padding: 0 14px;
}

.address-input strong {
    color: var(--accent-soft);
    white-space: nowrap;
}

.setup-card .primary-action {
    justify-self: end;
    margin: 18px 22px 22px;
}

.not-found-shell {
    min-height: calc(100vh - 68px);
    display: grid;
    place-items: center;
    padding: 32px 18px;
}

.not-found-card {
    width: min(620px, 100%);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 34px;
    text-align: center;
}

/* Attachment previews */
.compose-attachments {
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 16px;
    background: rgba(8, 17, 26, 0.5);
}

.attachments-list {
    display: grid;
    gap: 12px;
}

.file-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(26, 30, 38, 0.6);
}

.file-item-preview {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(110, 193, 228, 0.15);
    flex-shrink: 0;
}

.file-item-preview img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    object-fit: cover;
}

.file-item-preview i {
    color: var(--accent-soft);
    font-size: 1.4rem;
}

.file-item-info {
    min-width: 0;
}

.file-item-name {
    color: var(--text);
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}

.file-item-size {
    color: var(--muted);
    font-size: 0.85rem;
}

.file-item-delete {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 6px;
    background: rgba(241, 140, 155, 0.15);
    color: var(--danger);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.file-item-delete:hover {
    background: rgba(241, 140, 155, 0.3);
    color: #ff6b7a;
}

.file-item-delete:active {
    transform: scale(0.92);
}

/* Image preview modal */
.image-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.image-preview-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 90vw;
    max-height: 90vh;
}

.image-preview-img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 12px;
    object-fit: contain;
    background: rgba(26, 30, 38, 0.5);
    padding: 10px;
    border: 1px solid var(--border);
}

.image-preview-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: none;
    background: rgba(241, 140, 155, 0.2);
    border-radius: 8px;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.2s ease;
}

.image-preview-close:hover {
    background: rgba(241, 140, 155, 0.4);
}

.image-preview-info {
    min-width: min(520px, 90vw);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--muted);
    text-align: center;
    font-size: 0.9rem;
}

.image-preview-info > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.preview-download {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(26, 30, 38, 0.72);
    color: var(--accent-soft);
    padding: 0 12px;
    cursor: pointer;
    font: inherit;
    white-space: nowrap;
}

.file-preview-content {
    width: min(980px, 94vw);
}

.file-preview-frame {
    width: 100%;
    height: min(72vh, 760px);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.file-preview-empty {
    min-height: 260px;
    width: min(520px, 90vw);
    display: grid;
    place-items: center;
    align-content: center;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(26, 30, 38, 0.82);
    color: var(--muted);
    text-align: center;
    padding: 24px;
}

.file-preview-empty i {
    color: var(--accent);
    font-size: 2rem;
}

.file-preview-empty strong {
    color: var(--text);
}

.not-found-code {
    font-family: Ubuntu, sans-serif;
    color: var(--accent);
    font-size: clamp(4rem, 12vw, 8rem);
    line-height: 0.9;
    margin-bottom: 16px;
}

.not-found-card h1 {
    margin: 0 0 10px;
    color: var(--text);
}

.not-found-card p {
    margin: 0 auto 22px;
    max-width: 420px;
    color: var(--muted);
    line-height: 1.55;
}

@media (max-width: 920px) {
    .welcome-hero {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .mail-preview {
        grid-template-columns: 74px 1fr;
        transform: none;
    }

    .preview-message {
        display: none;
    }

    .mail-app {
        grid-template-columns: 1fr;
        height: auto;
        min-height: calc(100dvh - 66px);
        overflow: visible;
    }

    .mail-sidebar {
        position: static;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .folder-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .message-list {
        height: auto;
        min-height: 380px;
        max-height: none;
    }

    .message-link {
        grid-template-columns: minmax(0, 1fr) 126px;
    }

    .sender {
        display: none;
    }
}

@media (max-width: 640px) {
    .welcome-page {
        overflow: auto;
    }

    .topbar {
        height: auto;
        min-height: 68px;
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 14px 18px;
    }

    .topnav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .welcome-shell {
        height: auto;
        min-height: calc(100vh - 166px);
        padding: 24px 18px;
    }

    .hero-copy h1 {
        font-size: 3.5rem;
    }

    .mail-preview {
        min-height: 300px;
        height: 360px;
    }

    .footer-content {
        padding: 0 18px;
        font-size: 0.86rem;
    }

    .social-icons {
        gap: 14px;
    }

    .mail-toolbar,
    .bulk-actions,
    .compose-bottom {
        flex-wrap: wrap;
        height: auto;
    }

    .message-row {
        grid-template-columns: 30px 28px minmax(0, 1fr);
        padding: 0 10px;
    }

    .compose-fields label,
    .recipient-block,
    .settings-field {
        grid-template-columns: 1fr;
        gap: 6px;
        align-items: start;
        padding: 12px 14px;
    }

    .settings-field {
        margin: 0 14px;
    }

    .recipient-row {
        grid-template-columns: minmax(0, 1fr) 40px 40px;
    }

    .action-menu-trigger {
        width: 100%;
    }
}
