* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    color: #333;
    line-height: 1.5;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 24px;
}

header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    color: #1a1a1a;
}

header .subtitle {
    font-size: 0.85rem;
    color: #999;
    margin-top: 6px;
}

/* 邮箱生成区 */
.mailbox-section {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid #e8e8e8;
}

.mailbox-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.mailbox-input-group {
    flex: 1;
    display: flex;
    align-items: center;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0 12px;
    transition: border-color 0.2s;
}

.mailbox-input-group:focus-within {
    border-color: #999;
}

.mailbox-input-group input {
    flex: 1;
    padding: 10px 0;
    font-size: 0.9rem;
    border: none;
    background: transparent;
    color: #333;
    min-width: 0;
}

.mailbox-input-group input:focus {
    outline: none;
}

.at-symbol {
    color: #999;
    padding: 0 8px;
}

.mailbox-input-group select {
    padding: 10px 0;
    font-size: 0.9rem;
    border: none;
    background: transparent;
    color: #333;
    cursor: pointer;
}

.mailbox-input-group select:focus {
    outline: none;
}


.btn-primary {
    padding: 10px 20px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-primary:hover {
    background: #333;
}

.mailbox-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding: 10px 14px;
    background: #f0f7ff;
    border-radius: 8px;
}

.mailbox-result #emailAddress {
    font-size: 0.95rem;
    color: #1a1a1a;
    font-family: 'SF Mono', Monaco, monospace;
}

.btn-copy {
    padding: 6px 14px;
    background: transparent;
    color: #666;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: #fff;
    border-color: #999;
}

/* 同步密码区域 */
.sync-section {
    background: #fff;
    border-radius: 10px;
    margin-bottom: 16px;
    border: 1px solid #e8e8e8;
    overflow: hidden;
}

.sync-toggle {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.sync-toggle:hover {
    background: #fafafa;
}

.sync-icon {
    font-size: 0.9rem;
    margin-right: 8px;
}

.sync-title {
    flex: 1;
    font-size: 0.85rem;
    color: #666;
}

.sync-arrow {
    font-size: 0.7rem;
    color: #999;
    transition: transform 0.2s;
}

.sync-section.expanded .sync-arrow {
    transform: rotate(180deg);
}

.sync-content {
    display: none;
    padding: 0 16px 16px;
    border-top: 1px solid #f0f0f0;
}

.sync-section.expanded .sync-content {
    display: block;
}

.sync-desc {
    font-size: 0.8rem;
    color: #888;
    line-height: 1.6;
    margin: 12px 0;
}

.sync-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.sync-input-row input {
    flex: 1;
    padding: 10px 12px;
    font-size: 0.85rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fafafa;
    font-family: 'SF Mono', Monaco, monospace;
}

.sync-input-row input:focus {
    outline: none;
    border-color: #999;
}

.btn-secondary {
    padding: 10px 16px;
    background: #fff;
    color: #333;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-secondary:hover {
    background: #f5f5f5;
    border-color: #999;
}

.btn-icon {
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-icon:hover {
    background: #f5f5f5;
    border-color: #999;
}

.sync-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.sync-status {
    margin-top: 10px;
    font-size: 0.8rem;
    color: #666;
    min-height: 20px;
}

.sync-status.success {
    color: #52c41a;
}

.sync-status.error {
    color: #ff4d4f;
}

/* 邮件区域 */
.email-section {
    flex: 1;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    min-height: 0;
}

.email-list-wrapper {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e8e8e8;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.email-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
    color: #666;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-history {
    padding: 4px 10px;
    font-size: 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fff;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-history:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.refresh-info {
    color: #999;
    font-size: 0.75rem;
}

.refresh-info.refreshing {
    color: #4a90d9;
}

.btn-refresh {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    color: #666;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.email-list {
    flex: 1;
    overflow-y: auto;
}

.email-item {
    padding: 14px 16px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background 0.15s;
}

.email-item:hover {
    background: #fafafa;
}

.email-item:last-child {
    border-bottom: none;
}

.email-item.active {
    background: #f0f7ff;
}

.email-item.unread .subject {
    font-weight: 600;
}

.email-item .subject {
    color: #1a1a1a;
    font-size: 0.88rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-item .from {
    color: #999;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-item .time {
    color: #bbb;
    font-size: 0.7rem;
    margin-top: 4px;
}

.email-detail {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e8e8e8;
    padding: 24px;
    overflow-y: auto;
}

.email-header {
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.email-header h2 {
    color: #1a1a1a;
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.email-header .meta {
    color: #888;
    font-size: 0.8rem;
    line-height: 1.7;
}

.email-body {
    color: #444;
    font-size: 0.9rem;
    line-height: 1.7;
}

.email-body .html-content {
    width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.email-body .html-content * {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.email-body .html-content table {
    width: 100% !important;
    min-width: 100% !important;
    table-layout: auto !important;
}

.email-body .html-content td,
.email-body .html-content th {
    width: auto !important;
    min-width: 0 !important;
}

.email-body .html-content img {
    height: auto !important;
    max-width: 100% !important;
}

.email-body .html-content div,
.email-body .html-content span,
.email-body .html-content p {
    width: auto !important;
    min-width: 0 !important;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 120px;
    color: #ccc;
    font-size: 0.85rem;
}

.password-required {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 120px;
    text-align: center;
    padding: 20px;
}

.password-required p {
    color: #666;
    font-size: 0.9rem;
    margin: 4px 0;
}

.password-required .hint {
    color: #999;
    font-size: 0.8rem;
}

/* 公众号 */
.qrcode-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e8e8e8;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.qrcode-widget img {
    width: 80px;
    height: 80px;
    border-radius: 6px;
}

.qrcode-widget span {
    margin-top: 8px;
    font-size: 0.7rem;
    color: #999;
}

/* 历史邮箱面板 */
.history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 100;
}

.history-overlay.show {
    opacity: 1;
    visibility: visible;
}

.history-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: #fff;
    border-radius: 12px;
    width: 420px;
    max-width: 90vw;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 101;
}

.history-panel.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a1a1a;
}

.history-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-clear-history {
    padding: 4px 10px;
    font-size: 0.75rem;
    border: 1px solid #ff4d4f;
    border-radius: 4px;
    background: #fff;
    color: #ff4d4f;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear-history:hover {
    background: #ff4d4f;
    color: #fff;
}

.btn-close {
    width: 28px;
    height: 28px;
    border: none;
    background: #f5f5f5;
    border-radius: 6px;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: #eee;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    transition: background 0.15s;
}

.history-item:hover {
    background: #fafafa;
}

.history-item.active {
    background: #f0f7ff;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-email {
    font-size: 0.85rem;
    color: #1a1a1a;
    font-family: 'SF Mono', Monaco, monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.history-time {
    font-size: 0.7rem;
    color: #999;
}

.history-source-tag {
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
}

.history-source-tag.cloud {
    background: #e6f7ff;
    color: #1890ff;
}

.history-source-tag.local {
    background: #f6ffed;
    color: #52c41a;
}

.history-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
}

.btn-delete {
    padding: 4px 8px;
    font-size: 0.75rem;
    border: 1px solid #ffccc7;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: #fff1f0;
    border-color: #ff4d4f;
}

.history-loading {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-size: 0.85rem;
}

.btn-switch {
    padding: 6px 12px;
    font-size: 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 12px;
}

.btn-switch:hover {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

.history-empty {
    padding: 40px 20px;
    text-align: center;
    color: #ccc;
    font-size: 0.85rem;
}

/* 手机版公众号提示 */
.mobile-follow {
    display: none;
}

@media (max-width: 768px) {
    .container {
        padding: 20px 12px;
        padding-bottom: 56px;
    }
    
    .email-section {
        grid-template-columns: 1fr;
    }
    
    .mailbox-row {
        flex-direction: column;
    }
    
    .mailbox-input-group {
        width: 100%;
    }
    
    .btn-primary {
        width: 100%;
    }
    
    .qrcode-widget {
        display: none;
    }
    
    .history-panel {
        width: 95vw;
    }
    
    .mobile-follow {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        text-align: center;
        padding: 12px 16px;
        background: #f0f7ff;
        color: #1890ff;
        font-size: 0.8rem;
        border-top: 1px solid #d6e8fa;
        z-index: 50;
    }
}
