:root {
    --bg: #f3f4fb;
    --panel: #ffffff;
    --border: #e3e5f0;
    --text: #1c1f2e;
    --muted: #6b7189;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef0fd;
    --accent: #14b8a6;
    --warning: #f59e0b;
    --danger: #dc2626;
    --success: #16a34a;
    --shadow-sm: 0 1px 2px rgba(23, 24, 45, 0.06);
    --shadow-md: 0 6px 20px rgba(23, 24, 45, 0.08);
    --radius: 12px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.wrap {
    max-width: 920px;
    margin: 0 auto;
    padding: 0 16px;
}

.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    vertical-align: -3px;
}
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 40px; height: 40px; }

/* Header */
.site-header {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}
.site-header .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    padding-bottom: 14px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
    font-size: 19px;
    letter-spacing: -0.02em;
    color: var(--text);
    text-decoration: none;
}
.brand-mark {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}
.lang-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
.lang-switch a {
    padding: 5px 9px;
    border-radius: 7px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}
.lang-switch a:hover { background: var(--primary-light); color: var(--primary); }
.lang-switch a.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 700;
}

/* Ad slots */
.ad-slot {
    max-width: 920px;
    margin: 16px auto;
    text-align: center;
    overflow-x: auto;
}

main.wrap { padding-top: 28px; padding-bottom: 48px; flex: 1 0 auto; width: 100%; }

/* Sticky sidebar ads (skyscraper) - only shown when viewport is wide enough to not overlap content */
.ad-sidebar {
    display: none;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 160px;
    max-height: 80vh;
    overflow: hidden;
    z-index: 5;
}
.ad-sidebar-left { left: 12px; }
.ad-sidebar-right { right: 12px; }
@media (min-width: 1400px) {
    .ad-sidebar { display: block; }
}

/* Floating collapsible bottom banner */
.ad-sticky-bottom {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background: var(--panel);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(23, 24, 45, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 120px;
    overflow: hidden;
    padding: 8px 44px 8px 8px;
    transition: max-height 0.2s ease, padding 0.2s ease;
}
.ad-sticky-bottom.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top-color: transparent;
    box-shadow: none;
}
.ad-sticky-content {
    max-width: 920px;
    width: 100%;
    overflow-x: auto;
    text-align: center;
}
.ad-sticky-toggle {
    position: absolute;
    top: -28px;
    right: 12px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: var(--panel);
    color: var(--muted);
}
.ad-sticky-toggle svg { transition: transform 0.2s ease; }
.ad-sticky-bottom.collapsed .ad-sticky-toggle svg { transform: rotate(180deg); }
.ad-sticky-toggle:hover { color: var(--primary); background: var(--primary-light); }

/* Hero (home page intro) */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border-radius: var(--radius);
    padding: 32px 28px;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.hero::after {
    content: "";
    position: absolute;
    right: -40px;
    top: -40px;
    width: 220px;
    height: 220px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}
.hero-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.hero-icon .icon { width: 26px; height: 26px; color: #fff; }
.hero h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.02em; }
.hero .tagline { color: rgba(255, 255, 255, 0.85); margin: 0; position: relative; z-index: 1; }

/* Colored circle icon badge (light bg, on white panels) */
.icon-badge {
    width: 56px;
    height: 56px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.panel + .panel { margin-top: 20px; }
.panel h1 { margin-top: 0; }
.panel h2 {
    margin-top: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel h2 .icon { color: var(--primary); }
.tagline { color: var(--muted); }

/* Mail controls (home page) */
.mail-controls { margin: 4px 0 20px; }
.control-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.control-row input[type="text"],
.control-row input[type="email"],
.control-row select {
    flex: 1;
    min-width: 180px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
.control-row input[type="text"]:focus,
.control-row input[type="email"]:focus,
.control-row select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
#inputEmail { font-weight: 600; color: var(--primary-dark); background: var(--primary-light); border-color: var(--primary-light); }

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 16px;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    border-radius: 9px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    transition: background 0.15s ease, transform 0.05s ease;
}
button:hover, .button:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
button:active, .button:active { transform: translateY(1px); }
button.secondary, .button.secondary {
    background: #fff;
    color: var(--primary);
}
button.secondary:hover, .button.secondary:hover { background: var(--primary-light); }

.add-domain { align-items: center; }
.hint { color: var(--muted); font-size: 13px; }
#addDomainMsg.error { color: var(--danger); font-weight: 600; }
#addDomainMsg.success { color: var(--success); font-weight: 600; }

/* Inbox table */
.inbox-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
}
.inbox-table th, .inbox-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 14px;
}
.inbox-table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.inbox-table tbody tr { transition: background 0.1s ease; }
.inbox-table tbody tr:hover td { background: var(--primary-light); }
.inbox-table td a:not(.button) { color: var(--text); text-decoration: none; font-weight: 600; }
.inbox-table td a:not(.button):hover { color: var(--primary); }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: var(--primary-light);
    color: var(--primary-dark);
}
.badge.badge-warning { background: #fef3c7; color: #92400e; }
.badge.badge-danger { background: #fee2e2; color: #991b1b; }

/* Domain add section (bottom of home page) */
.domain-add-section .hint { font-size: 14px; line-height: 1.65; }
.domain-add-section .add-domain { margin-top: 14px; }
.domain-add-section .hint strong { color: var(--text); }

/* Mail view page */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}
.back-link:hover { color: var(--primary-dark); }
.mail-view {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.mail-meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; color: var(--muted); margin-bottom: 16px; }
.mail-frame {
    display: block;
    width: 100%;
    height: 480px;
    min-height: 200px;
    max-height: 80vh;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
}
.mail-empty {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    color: var(--muted);
}
.mail-empty .icon { color: var(--muted); margin-bottom: 10px; }

/* Forms */
.form label, .admin-section label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.form input, .form select, .form textarea,
.admin-section input, .admin-section textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: 14px;
    font-family: inherit;
}
.form input:focus, .form select:focus, .form textarea:focus,
.admin-section input:focus, .admin-section textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 9px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}
.alert-success { background: #dcfce7; color: #14532d; }
.alert-error { background: #fee2e2; color: #7f1d1d; }

/* Legal pages */
.legal h2 { margin-top: 28px; font-size: 18px; }
.legal table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.legal table th, .legal table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 44px; padding: 26px 0 30px; color: var(--muted); font-size: 13px; flex-shrink: 0; }
.site-footer nav { margin-bottom: 10px; }
.site-footer nav a { color: var(--text); margin-right: 16px; text-decoration: none; font-weight: 600; }
.site-footer nav a:hover { color: var(--primary); }
.site-footer .disclaimer { max-width: 700px; }

/* Admin */
.admin-body { background: var(--bg); }
.admin-login {
    max-width: 340px;
    margin: 15vh auto 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    box-shadow: var(--shadow-md);
}
.admin-login .icon-xl { color: var(--primary); margin-bottom: 8px; }
.admin-login input { width: 100%; margin-bottom: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-family: inherit; }
.admin-wrap { max-width: 920px; margin: 0 auto; padding: 24px 16px 60px; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.admin-topbar h1 { display: flex; align-items: center; gap: 9px; margin: 0; }
.admin-topbar .icon { color: var(--primary); }
.admin-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.admin-section .hint { color: var(--muted); font-size: 13px; margin-top: -4px; }
.ad-slot-form { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.ad-slot-form:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.inline-form { display: inline-flex; gap: 8px; margin: 10px 0; }
.inline-form input { padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; font-family: inherit; }
.banned-list { list-style: none; padding: 0; }
.banned-list li { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.admin-table th { color: var(--muted); font-weight: 600; }

@media (max-width: 600px) {
    .control-row { flex-direction: column; }
    .inbox-table { font-size: 13px; }
    .hero { padding: 24px 20px; }
    .hero h1 { font-size: 22px; }
}
