:root {
    --md-sys-color-background: #121212;
    --md-sys-color-surface: #121212;
    --md-sys-color-surface-container: #1e1e1e;
    --md-sys-color-surface-container-high: #2b2b2b;
    --md-sys-color-on-surface: #e2e2e2;
    --md-sys-color-on-surface-variant: #c4c7c5;
    --md-sys-color-primary: #a8c7fa;
    --md-sys-color-on-primary: #062e6f;
    --md-sys-color-primary-container: #0842a0;
    --md-sys-color-on-primary-container: #d3e3fd;
    --md-sys-color-secondary-container: #004a77;
    --md-sys-color-on-secondary-container: #c2e7ff;
    --md-sys-color-outline: #8e918f;
    --md-sys-color-error: #ffb4ab;

    --radius-l: 16px;
    --radius-full: 9999px;

    --font-family: 'Roboto', sans-serif;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-family);
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-surface);
    overflow: hidden;
}

/* Helpers */
.icon-btn,
.icon-btn-small {
    background: transparent;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.icon-btn {
    width: 40px;
    height: 40px;
    padding: 8px;
}

.icon-btn-small {
    width: 32px;
    height: 32px;
    padding: 4px;
}

/* Login Screen */
.screen {
    display: none;
    height: 100%;
    width: 100%;
}

.screen.active {
    display: flex;
}

#login-screen {
    justify-content: center;
    align-items: center;
}

.login-card {
    background: var(--md-sys-color-surface-container);
    padding: 2rem;
    border-radius: 28px;
    width: 360px;
    text-align: center;
}

.login-card .brand {
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 48px;
    color: var(--md-sys-color-primary);
}

.login-card h2 {
    margin: 10px 0 0;
    font-weight: 400;
}

.input-group {
    background: var(--md-sys-color-surface-container-high);
    border-radius: 4px 4px 0 0;
    border-bottom: 1px solid var(--md-sys-color-outline);
    display: flex;
    align-items: center;
    padding: 0 12px;
    margin-bottom: 1rem;
}

.input-group input {
    background: transparent;
    border: none;
    color: white;
    padding: 16px 12px;
    width: 100%;
    outline: none;
    font-size: 16px;
}

.btn-primary {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    margin-top: 1rem;
}

/* App Layout */
.app-bar {
    height: 64px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    background: var(--md-sys-color-background);
}

.app-bar .start {
    display: flex;
    align-items: center;
    width: 256px;
    gap: 12px;
}

.app-bar .logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    color: var(--md-sys-color-on-surface-variant);
}

.logo-colored {
    color: #ea4335;
    font-size: 28px;
}

.app-bar .middle {
    flex: 1;
    display: flex;
    justify-content: start;
    max-width: 720px;
}

.search-bar {
    background: var(--md-sys-color-surface-container-high);
    border-radius: 24px;
    height: 48px;
    width: 100%;
    display: flex;
    align-items: center;
    padding: 0 8px;
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--md-sys-color-on-surface);
    flex: 1;
    font-size: 16px;
    outline: none;
}

.app-bar .end {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-right: 8px;
}

.user-avatar {
    cursor: pointer;
    color: var(--md-sys-color-primary-container);
    font-size: 32px;
}

.user-avatar span {
    font-size: 36px;
    color: #a8c7fa;
}

/* Main Container */
.main-layout {
    display: flex;
    width: 100%;
    height: calc(100% - 64px);
}

/* Sidebar */
.sidebar {
    width: 256px;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
}

.compose-wrapper {
    padding: 8px 0 16px 0;
}

.fab-compose {
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    border: none;
    border-radius: 16px;
    height: 56px;
    min-width: 56px;
    padding: 0 24px 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.fab-compose:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    background: #353535;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-list li {
    height: 32px;
    padding: 0 12px 0 26px;
    border-radius: 0 16px 16px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: var(--md-sys-color-on-surface);
    font-size: 14px;
}

.nav-list li:hover {
    background: rgba(255, 255, 255, 0.05);
}

.nav-list li.active {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    font-weight: 700;
}

.nav-list li .material-icons-outlined {
    font-size: 20px;
}

/* Content Area */
.content-area {
    flex: 1;
    background: var(--md-sys-color-surface-container);
    border-radius: 16px;
    margin: 0 12px 12px 0;
    display: flex;
    overflow: hidden;
}

/* Message List */
.message-list-panel {
    width: 40%;
    min-width: 320px;
    border-right: 1px solid var(--md-sys-color-surface-container-high);
    display: flex;
    flex-direction: column;
}

.panel-header {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.panel-header h3 {
    font-size: 14px;
    margin: 0;
    font-weight: 500;
}

.msg-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
}

.msg-list li {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px;
}

.msg-list li:hover {
    background: rgba(255, 255, 255, 0.03);
}

.msg-list li.active {
    background: #262a33;
    border-left: 3px solid var(--md-sys-color-primary);
}

.msg-row-subject {
    font-weight: 600;
    font-size: 14px;
    color: var(--md-sys-color-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-row-from {
    font-size: 14px;
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
}

.msg-row-date {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    text-align: right;
}

.msg-snippet {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    grid-column: 1 / -1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Detail */
.message-detail-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--md-sys-color-surface-container);
    position: relative;
    overflow: hidden;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--md-sys-color-on-surface-variant);
}

.empty-state span {
    font-size: 64px;
}

#detail-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.detail-toolbar {
    height: 48px;
    display: flex;
    padding: 0 8px;
    align-items: center;
    gap: 8px;
}

.detail-header {
    padding: 0 24px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.detail-header h2 {
    font-size: 22px;
    font-weight: 400;
    margin: 0 0 16px 0;
}

.sender-info {
    display: flex;
    gap: 12px;
    align-items: center;
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--md-sys-color-primary-container);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-primary-container);
}

.meta {
    display: flex;
    flex-direction: column;
}

.from-name {
    font-weight: 700;
    font-size: 14px;
}

.date-text {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
}

.detail-body-scroll {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.email-body {
    font-size: 14px;
    line-height: 1.5;
    color: var(--md-sys-color-on-surface);
}

/* Attachments */
.attachments-area {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.chips-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.att-chip {
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    background: transparent;
}

.att-chip:hover {
    background: rgba(255, 255, 255, 0.05);
}

.att-chip-icon {
    color: #ea4335;
    font-size: 20px;
}

/* Compose Modal (Bottom Right) */
.modal-overlay {
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    /* Let clicks pass usually, block for full modal */
}

.modal-overlay.active {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.5);
}

#compose-modal {
    display: none;
}

#compose-modal.active {
    display: block;
    pointer-events: auto;
}

/* Gmail doesn't dim usually, but we will for focus */

.compose-window {
    position: absolute;
    bottom: 0;
    right: 60px;
    width: 500px;
    height: 600px;
    background: var(--md-sys-color-surface-container);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

.window-header {
    background: #353535;
    padding: 10px 16px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    font-size: 14px;
}

.window-actions {
    display: flex;
    gap: 8px;
}

#compose-form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.field-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.field-row input {
    background: transparent;
    border: none;
    width: 100%;
    padding: 12px 16px;
    color: white;
    outline: none;
}

.compose-area {
    flex: 1;
    background: transparent;
    border: none;
    padding: 16px;
    color: white;
    resize: none;
    outline: none;
    font-family: inherit;
}

.window-footer {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-send {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    padding: 8px 24px;
    border-radius: 18px;
    font-weight: 500;
    cursor: pointer;
}

.spacer {
    flex: 1;
}

.full-screen {
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
}

.preview-window {
    width: 90%;
    height: 90%;
    background: white;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
}

.preview-bar {
    background: #333;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-content {
    flex: 1;
    overflow: auto;
    padding: 16px;
    background: #e0e0e0;
    color: black;
}