@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg: #09090b;
    --bg-subtle: #0c0c0f;
    --surface: #111114;
    --surface-raised: #16161a;
    --border: #1c1c22;
    --border-hover: #27272f;
    --border-focus: #3b3b48;

    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --text-tertiary: #52525b;
    --text-quaternary: #3f3f46;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-muted: rgba(59, 130, 246, 0.12);
    --accent-subtle: rgba(59, 130, 246, 0.06);

    --success: #22c55e;
    --success-muted: rgba(34, 197, 94, 0.12);
    --warning: #eab308;
    --warning-muted: rgba(234, 179, 8, 0.12);
    --danger: #ef4444;
    --danger-muted: rgba(239, 68, 68, 0.1);

    --radius: 10px;
    --radius-sm: 6px;
    --radius-xs: 4px;
}

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

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Manrope', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* ─── Noise texture ─── */

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* ─── Layout ─── */

.shell {
    max-width: 640px;
    margin: 0 auto;
    padding: 3rem 1.5rem 4rem;
    position: relative;
    z-index: 1;
}

/* ─── Header ─── */

.header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.header__logo {
    font-family: 'Manrope', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    margin-bottom: 0.4rem;
}

.header__sub {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: 400;
    letter-spacing: 0;
}

/* ─── Status bar ─── */

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.85rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 0.7rem;
    color: var(--text-tertiary);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.status-bar__dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 0.5rem;
    background: var(--text-quaternary);
    vertical-align: middle;
    transition: background 0.3s, box-shadow 0.3s;
}

.status-bar__dot--active {
    background: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

/* ─── Generate section ─── */

.generate-section {
    text-align: center;
    padding: 2rem 0;
}

.btn-generate {
    font-family: 'Manrope', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.75rem 2rem;
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    letter-spacing: -0.01em;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 0 0 1px rgba(59,130,246,0.15);
}

.btn-generate:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px rgba(59,130,246,0.2), 0 0 0 1px rgba(59,130,246,0.25);
}

.btn-generate:active {
    transform: scale(0.98);
}

.btn-generate:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-generate--secondary {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: none;
}

.btn-generate--secondary:hover {
    background: var(--border);
    box-shadow: none;
}

/* ─── Create form ─── */

.create-form {
    text-align: left;
}

.form-row {
    display: flex;
    align-items: flex-end;
    gap: 0;
    margin-bottom: 0.75rem;
}

.form-row--options {
    gap: 0.75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group--local {
    flex: 1;
}

.form-group--at {
    padding: 0 0.15rem;
    padding-bottom: 0.55rem;
}

.at-sign {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-quaternary);
    font-weight: 500;
}

.form-group--domain {
    flex: 0 0 auto;
    min-width: 140px;
}

.form-group--ttl {
    flex: 0 0 auto;
    min-width: 140px;
}

.form-group--password {
    flex: 1;
}

.form-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.35rem;
}

.form-hint {
    text-transform: none;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--text-quaternary);
}

.form-input {
    font-family: 'Manrope', sans-serif;
    font-size: 0.8rem;
    padding: 0.55rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

.form-input--mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.form-input::placeholder {
    color: var(--text-quaternary);
}

.form-select {
    font-family: 'Manrope', sans-serif;
    font-size: 0.8rem;
    padding: 0.55rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s;
    width: 100%;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2352525b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 2rem;
}

.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.form-select option {
    background: var(--surface);
    color: var(--text);
}

.input-with-btn {
    display: flex;
    gap: 0;
    position: relative;
}

.input-with-btn .form-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.65rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: none;
    border-top-right-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.btn-icon:hover {
    color: var(--text);
    background: var(--surface-raised);
}

.form-actions {
    margin-top: 0.5rem;
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.5rem;
    min-height: 1.2em;
}

/* ─── Reopen section ─── */

.reopen-section {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.btn-link {
    font-family: 'Manrope', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-tertiary);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.15s;
    padding: 0;
}

.btn-link:hover {
    color: var(--accent);
}

.reopen-form {
    margin-top: 0.75rem;
    text-align: left;
}

.reopen-form .form-input {
    margin-bottom: 0;
}

/* ─── Session ─── */

.session {
    animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ─── Address block ─── */

.address-block {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

.address-block:hover {
    border-color: var(--border-hover);
}

.address-block__label {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin-bottom: 0.6rem;
}

.address-block__value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text);
    word-break: break-all;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: color 0.15s;
    user-select: all;
}

.address-block__value:hover {
    color: var(--accent);
}

.copy-icon {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    opacity: 0.25;
    transition: opacity 0.15s;
    color: var(--text-secondary);
}

.address-block__value:hover .copy-icon {
    opacity: 0.6;
}

.copy-flash {
    font-family: 'Manrope', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--success);
    letter-spacing: 0.04em;
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: auto;
}

.copy-flash--visible {
    opacity: 1;
}

/* ─── Session meta / Timer ─── */

.session-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    padding: 0.6rem 0;
    font-size: 0.75rem;
}

.timer {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.25rem 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    letter-spacing: 0.04em;
    transition: color 0.3s, background 0.3s, border-color 0.3s;
}

.timer--urgent {
    color: var(--danger);
    background: var(--danger-muted);
    border-color: rgba(239, 68, 68, 0.2);
    animation: pulse-urgent 2s ease-in-out infinite;
}

.timer--unlimited {
    color: var(--success);
    background: var(--success-muted);
    border-color: rgba(34, 197, 94, 0.2);
    font-size: 1rem;
}

@keyframes pulse-urgent {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.session-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-sm {
    font-family: 'Manrope', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-sm:hover {
    background: var(--surface-raised);
    border-color: var(--border-hover);
    color: var(--text);
}

.btn-sm--danger:hover {
    background: var(--danger-muted);
    border-color: rgba(239, 68, 68, 0.25);
    color: var(--danger);
}

/* ─── Inbox ─── */

.inbox-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border);
}

.inbox-header__title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.inbox-header__count {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.inbox-empty {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-quaternary);
    font-size: 0.8rem;
    font-weight: 500;
}

.inbox-empty__spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1.5px solid var(--border-hover);
    border-top-color: var(--text-tertiary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.6rem;
    vertical-align: -1px;
}

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

/* ─── Messages ─── */

.message {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    margin-bottom: 0.4rem;
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
}

.message:hover {
    border-color: var(--border-hover);
    background: var(--surface-raised);
}

.message--new {
    border-left: 2.5px solid var(--accent);
}

.message__header {
    padding: 0.75rem 1rem 0.15rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.message__from {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 65%;
}

.message__date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-quaternary);
    white-space: nowrap;
    flex-shrink: 0;
}

.message__subject {
    padding: 0.15rem 1rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Modal overlay ─── */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay--visible {
    opacity: 1;
    visibility: visible;
}

.modal-overlay--visible .modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* ─── Modal ─── */

.modal {
    width: 100%;
    max-width: 680px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.03) inset;
    transform: translateY(12px) scale(0.97);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    overflow: hidden;
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.1rem 1.25rem 0.5rem;
    gap: 1rem;
}

.modal__meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.modal__from {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal__date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-quaternary);
}

.modal__close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.15s;
}

.modal__close svg {
    width: 16px;
    height: 16px;
}

.modal__close:hover {
    background: var(--surface-raised);
    border-color: var(--border);
    color: var(--text);
}

.modal__subject {
    padding: 0 1.25rem 0.85rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.4;
}

.modal__toolbar {
    padding: 0 1.25rem;
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.btn-sm--images {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.65rem;
    padding: 0.3rem 0.65rem;
    background: var(--warning-muted);
    border-color: rgba(234, 179, 8, 0.18);
    color: var(--warning);
}

.btn-sm--images:hover {
    background: rgba(234, 179, 8, 0.18);
    border-color: rgba(234, 179, 8, 0.3);
    color: var(--warning);
}

.btn-sm--images:disabled {
    opacity: 0.5;
    cursor: default;
    background: var(--success-muted);
    border-color: rgba(34, 197, 94, 0.18);
    color: var(--success);
}

.modal__body {
    flex: 1;
    overflow-y: auto;
    border-top: 1px solid var(--border);
    min-height: 120px;
}

.modal__iframe {
    width: 100%;
    border: none;
    min-height: 150px;
    background: var(--bg-subtle);
    display: block;
}

.modal__pre {
    white-space: pre-wrap;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.7;
    color: var(--text-secondary);
    padding: 1.25rem;
    margin: 0;
}

/* ─── Responsive modal ─── */

@media (max-width: 600px) {
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal {
        max-width: 100%;
        max-height: 90vh;
        border-radius: var(--radius) var(--radius) 0 0;
        border-bottom: none;
    }

    .modal-overlay--visible .modal {
        transform: translateY(0);
    }
}

/* ─── Footer ─── */

.footer {
    margin-top: 3.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-quaternary);
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ─── Scrollbar ─── */

::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-focus);
}

/* ─── Responsive ─── */

@media (max-width: 600px) {
    .shell {
        padding: 1.5rem 1rem 3rem;
    }

    .header__logo {
        font-size: 1.3rem;
    }

    .generate-section {
        padding: 1.5rem 0;
    }

    .form-row {
        flex-wrap: wrap;
    }

    .form-row--options {
        flex-direction: column;
        gap: 0.75rem;
    }

    .form-group--domain {
        min-width: 120px;
    }

    .form-group--ttl,
    .form-group--password {
        width: 100%;
    }

    .address-block__value {
        font-size: 0.95rem;
    }

    .session-meta {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .session-controls {
        width: 100%;
    }

    .btn-sm {
        flex: 1;
        text-align: center;
    }
}
