/* SryMail — Temp Mail Style UI */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-hover: #1a1a25;
    --bg-input: #0e0e16;
    --border: #1e1e2e;
    --border-focus: #6366f1;
    --text: #e4e4e7;
    --text-dim: #9191a8;
    --text-muted: #5b5b70;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.08);
    --green-border: rgba(34, 197, 94, 0.2);
    --orange: #f59e0b;
    --red: #ef4444;
    --radius: 10px;
    --radius-sm: 6px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100%;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 680px;
    margin: 0 auto;
}

/* ─── Header ─── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.02em;
}

.header-stats {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--mono);
}

/* ─── Hero / Address Bar ─── */
.hero {
    padding: 16px 16px 8px;
}

.hero-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    font-weight: 600;
}

.address-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.address-display {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    gap: 2px;
    min-height: 52px;
    flex-wrap: wrap;
}

.address-text {
    font-family: var(--mono);
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    word-break: break-all;
    line-height: 1.4;
}

.address-text.placeholder {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 14px;
}

.address-domain {
    font-family: var(--mono);
    font-size: 16px;
    font-weight: 400;
    color: var(--text-dim);
    line-height: 1.4;
}

.address-actions {
    display: flex;
    border-top: 1px solid var(--border);
}

.btn-action {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    transition: all 0.15s;
    position: relative;
}

.btn-action:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    height: 60%;
    width: 1px;
    background: var(--border);
}

.btn-action:active {
    background: var(--bg-hover);
}

.btn-shuffle { color: var(--accent); }
.btn-shuffle:hover { background: rgba(99, 102, 241, 0.08); }
.btn-copy:hover { color: var(--green); background: var(--green-bg); }
.btn-refresh:hover { color: var(--text); }
.btn-refresh.spinning svg {
    animation: spin 0.6s linear;
}

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

/* ─── Search ─── */
.search-section {
    padding: 8px 16px 4px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 36px 10px 38px;
    font-size: 14px;
    color: var(--text);
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s;
}

.search-box input:focus {
    border-color: var(--border-focus);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-clear {
    position: absolute;
    right: 8px;
    background: var(--bg-hover);
    border: none;
    color: var(--text-dim);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ─── Inbox ─── */
.inbox {
    flex: 1;
    padding: 8px 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
    overflow-y: auto;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    text-align: center;
}

.empty-icon {
    color: var(--text-muted);
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.empty-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.quick-picks {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.quick-label {
    font-size: 12px;
    color: var(--text-muted);
}

.quick-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-family: var(--mono);
    cursor: pointer;
    transition: all 0.15s;
}

.quick-btn:active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Loading */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Email Cards */
.email-cards {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.email-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.email-card:active {
    background: var(--bg-hover);
    transform: scale(0.99);
}

.email-card.unread {
    border-left: 3px solid var(--accent);
}

.email-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
    border: 1px solid var(--border);
    text-transform: uppercase;
}

.email-body {
    flex: 1;
    min-width: 0;
}

.email-row-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 3px;
}

.email-from {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    font-family: var(--mono);
}

.email-subject {
    font-size: 13px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.email-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.email-otp-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--green-bg);
    border: 1px solid var(--green-border);
    color: var(--green);
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    margin-top: 4px;
}

.email-otp-pill svg {
    width: 12px;
    height: 12px;
}

/* Alias suggestions while searching */
.alias-suggestions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.alias-suggestion {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.1s;
}

.alias-suggestion:active {
    background: var(--bg-hover);
}

.alias-suggestion-name {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
}

.alias-suggestion-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 10px;
    font-family: var(--mono);
}

.alias-suggestion-count.has-mail {
    background: var(--accent);
    color: white;
}

.no-results {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ─── Detail Overlay ─── */
.detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
}

.detail-overlay.open {
    display: flex;
    flex-direction: column;
}

.detail-panel {
    flex: 1;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.detail-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-card);
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    padding: 4px 0;
}

.btn-back:active { opacity: 0.7; }

.detail-date {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--mono);
}

.detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
    -webkit-overflow-scrolling: touch;
}

/* OTP Banner */
.otp-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--green-bg);
    border: 1px solid var(--green-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}

.otp-icon {
    color: var(--green);
    flex-shrink: 0;
}

.otp-info { flex: 1; min-width: 0; }

.otp-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--green);
    font-weight: 700;
    margin-bottom: 2px;
}

.otp-code {
    font-family: var(--mono);
    font-size: 28px;
    font-weight: 800;
    color: var(--green);
    letter-spacing: 0.12em;
    line-height: 1.2;
}

.otp-copy {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--green);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    flex-shrink: 0;
    white-space: nowrap;
}

.otp-copy:active { opacity: 0.8; }

/* Meta Card */
.detail-meta-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.meta-row {
    display: flex;
    padding: 6px 0;
    gap: 12px;
}

.meta-row:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.meta-label {
    font-size: 12px;
    color: var(--text-muted);
    width: 56px;
    flex-shrink: 0;
    font-weight: 500;
    padding-top: 1px;
}

.meta-value {
    font-size: 13px;
    color: var(--text);
    word-break: break-all;
    line-height: 1.5;
}

.meta-subject {
    font-weight: 600;
    font-size: 14px;
}

/* Email Content */
.detail-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
    word-break: break-word;
    overflow-wrap: break-word;
}

.detail-content pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font);
    margin: 0;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
    max-width: 100%;
    overflow-x: hidden;
}

.detail-content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(99, 102, 241, 0.3);
}

/* HTML email rendering */
.detail-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.detail-content table {
    max-width: 100%;
    border-collapse: collapse;
}

.detail-content td, .detail-content th {
    padding: 4px 8px;
    font-size: 13px;
}

/* ─── Toast ─── */
.toast {
    position: fixed;
    bottom: calc(24px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-card);
    color: var(--text);
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    transition: transform 0.25s ease;
    z-index: 100;
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* ─── Responsive ─── */
@media (min-width: 480px) {
    .address-display { padding: 16px 20px; }
    .address-text, .address-domain { font-size: 18px; }
    .otp-code { font-size: 32px; }
}

@media (min-width: 640px) {
    .app {
        margin-top: 20px;
        border-radius: 16px 16px 0 0;
        border: 1px solid var(--border);
        border-bottom: none;
        min-height: calc(100vh - 20px);
        min-height: calc(100dvh - 20px);
    }

    .address-actions {
        border-top: none;
        border-left: 1px solid var(--border);
        flex-direction: column;
        width: 48px;
    }

    .address-bar {
        display: flex;
    }

    .address-display { flex: 1; }

    .btn-action:not(:last-child)::after {
        right: 20%;
        top: auto;
        bottom: 0;
        height: 1px;
        width: 60%;
    }

    .email-card:hover {
        background: var(--bg-hover);
        border-color: rgba(99, 102, 241, 0.2);
    }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── Selection ─── */
::selection {
    background: rgba(99, 102, 241, 0.3);
    color: white;
}
