:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --white: #ffffff;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.12);
}

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

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    padding: 0 20px;
}

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 18px;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: var(--white);
    border-radius: 9px;
    font-size: 16px;
}

.brand-tag {
    font-size: 13px;
    color: var(--text-secondary);
}

main.container {
    padding-top: 28px;
    padding-bottom: 48px;
    flex: 1;
}

.panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.mail-panel {
    padding: 28px;
    margin-bottom: 20px;
}

.mail-header {
    margin-bottom: 20px;
}

.mail-title {
    font-size: 22px;
    font-weight: 700;
}

.mail-sub {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.mail-box {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mail-box-empty {
    text-align: center;
    padding: 20px 0;
}

.mail-empty-tip {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 12px;
}

.mail-box-ready {
    width: 100%;
    text-align: center;
}

.mail-address-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.mail-address {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary);
    word-break: break-all;
    letter-spacing: 0.3px;
}

.mail-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 10px;
}

.mail-meta code {
    background: var(--primary-soft);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
}

.countdown {
    font-variant-numeric: tabular-nums;
}

.countdown.warning {
    color: var(--danger);
    font-weight: 600;
}

.mail-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    padding: 9px 18px;
    transition: background 0.15s ease, transform 0.05s ease;
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-ghost {
    background: var(--white);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg);
    border-color: #cbd5e1;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 15px;
    border-radius: 10px;
}

.inbox-panel {
    overflow: hidden;
}

.inbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.inbox-title {
    font-size: 18px;
    font-weight: 700;
}

.inbox-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.inbox-timer {
    font-size: 12px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    min-width: 44px;
    text-align: right;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: #cbd5e1;
    border-radius: 20px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.switch-slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: var(--white);
    border-radius: 50%;
    transition: transform 0.2s;
}

.switch input:checked + .switch-slider {
    background: var(--primary);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(16px);
}

.inbox-body {
    min-height: 160px;
}

.inbox-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.inbox-state .spin {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.mail-list {
    list-style: none;
}

.mail-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.12s;
}

.mail-item:last-child {
    border-bottom: none;
}

.mail-item:hover {
    background: var(--primary-soft);
}

.mail-item.unread {
    background: var(--primary-soft);
}

.mail-item.unread:hover {
    background: #dbeafe;
}

.mail-item-read-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}

.mail-item.unread .mail-item-read-dot {
    background: var(--danger);
}

.mail-item-content {
    flex: 1;
    min-width: 0;
}

.mail-item-subject {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-item-from {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.mail-item-time {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
}

.modal-box {
    position: relative;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    word-break: break-all;
}

.modal-close {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 4px;
}

.modal-close:hover {
    color: var(--text);
}

.modal-meta {
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg);
    word-break: break-all;
}

.modal-meta p {
    margin: 2px 0;
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--white);
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    max-width: 90vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hidden {
    display: none !important;
}

@media (max-width: 640px) {
    .container {
        padding: 0 12px;
    }

    .mail-panel {
        padding: 20px 16px;
    }

    .mail-address {
        font-size: 20px;
    }

    .mail-meta {
        flex-direction: column;
        gap: 6px;
    }

    .mail-item {
        padding: 14px 16px;
        gap: 10px;
    }

    .mail-item-time {
        font-size: 11px;
    }

    .inbox-header {
        padding: 16px;
    }

    .brand-tag {
        display: none;
    }
}
