:root {
    --bg-color: #0c0c0e;
    --card-bg: rgba(24, 24, 27, 0.7);
    --border-color: rgba(63, 63, 70, 0.5);
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --accent: #6366f1;
    --accent-2: #a855f7;
    --accent-glow: rgba(99, 102, 241, 0.35);
    --success: #22c55e;
    --error: #ef4444;
    --input-bg: rgba(39, 39, 42, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem 1.25rem 3rem;
    -webkit-font-smoothing: antialiased;
    background-image:
        radial-gradient(circle at 12% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 42%),
        radial-gradient(circle at 88% 85%, rgba(168, 85, 247, 0.12) 0%, transparent 42%);
}

.page {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    animation: fadeIn 0.6s ease-out;
}

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

/* Header */
.app-header {
    position: relative;
    text-align: center;
    margin-bottom: 2rem;
}
.home-link {
    position: absolute;
    left: 0;
    top: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}
.home-link:hover { color: var(--text-primary); }
.app-header h1 {
    font-size: clamp(2rem, 6vw, 2.75rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 0.75rem;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 520px;
    margin: 0 auto;
}

/* Card */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Input */
.field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.6rem;
}
#input {
    width: 100%;
    min-height: 200px;
    resize: vertical;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.6;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}
.field-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.link-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.78rem;
    transition: color 0.2s ease;
}
.link-btn:hover { color: var(--error); }

/* Primary button */
.primary-btn {
    width: 100%;
    margin-top: 1.25rem;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(99, 102, 241, 0.4);
    filter: brightness(1.08);
}
.primary-btn:active { transform: translateY(0); }

/* Results */
.results {
    margin-top: 2rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--border-color);
    animation: fadeIn 0.35s ease-out;
}
.results-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.count { font-size: 1rem; color: var(--text-secondary); }
.count strong { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); }
.results-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}
.action-btn:hover { background: rgba(99, 102, 241, 0.12); border-color: var(--accent); }
.action-btn:active { transform: scale(0.97); }
.action-btn svg { width: 16px; height: 16px; }

.dup-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.85rem;
}

.email-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
}
.email-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.9rem;
    word-break: break-all;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.email-list li:hover { background: rgba(99, 102, 241, 0.1); border-color: var(--accent); }
.email-list li .idx {
    flex-shrink: 0;
    min-width: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.email-list li .email-text { flex: 1; }
.email-list li .copy-hint {
    flex-shrink: 0;
    font-size: 0.7rem;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.15s ease;
}
.email-list li:hover .copy-hint { opacity: 1; }

.hint {
    margin-top: 0.85rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Empty state */
.empty-state {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    animation: fadeIn 0.35s ease-out;
}
.empty-icon { display: flex; justify-content: center; margin-bottom: 0.75rem; color: var(--text-secondary); }
.empty-icon svg { width: 40px; height: 40px; opacity: 0.5; }
.empty-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.35rem; }
.empty-sub { font-size: 0.85rem; color: var(--text-secondary); }

/* Page footer */
.page-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    margin-top: 2rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.page-footer a { color: var(--text-secondary); text-decoration: none; transition: color 0.2s ease; }
.page-footer a:hover { color: var(--text-primary); }
.page-footer .sep { opacity: 0.4; }

/* Toast */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    padding: 0.7rem 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #18181b;
    color: var(--text-primary);
    font-size: 0.85rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    opacity: 0;
    z-index: 100;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { border-color: rgba(34, 197, 94, 0.5); }

@media (max-width: 640px) {
    body { padding: 1.25rem 1rem 2.5rem; }
    .card { border-radius: 18px; }
    .home-link { position: static; display: inline-block; margin-bottom: 1rem; }
    .results-head { flex-direction: column; align-items: flex-start; }
    .results-actions { width: 100%; }
    .action-btn { flex: 1; justify-content: center; }
}
