:root {
    color-scheme: dark;
    --bg: #07090c;
    --surface: rgba(16, 20, 26, .92);
    --surface-2: #141920;
    --line: #262d36;
    --text: #f5f7f8;
    --muted: #8d98a7;
    --green: #53fc18;
    --green-deep: #173d14;
    --danger: #ff5f6d;
    --shadow: 0 24px 80px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 12% -10%, rgba(83, 252, 24, .10), transparent 32rem),
        radial-gradient(circle at 86% 8%, rgba(52, 211, 153, .06), transparent 28rem),
        var(--bg);
}

button, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.topbar {
    min-height: 72px;
    padding: 0 clamp(20px, 4vw, 64px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,.08);
    background: rgba(7, 9, 12, .78);
    backdrop-filter: blur(18px);
}

.brand {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(145deg, #6aff36, #2acb16);
    color: #071006;
    font-size: 12px;
    font-weight: 950;
    box-shadow: 0 10px 30px rgba(83, 252, 24, .18);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: -.02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
.session { display: flex; align-items: center; gap: 12px; }
.session-user { color: #cbd3db; font-size: 13px; font-weight: 700; }

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 42px auto;
}

.card {
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.gate {
    width: min(720px, 100%);
    min-height: 440px;
    margin: 8vh auto 0;
    padding: clamp(30px, 6vw, 72px);
    border-radius: 24px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.gate::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(83, 252, 24, .07), transparent 48%);
    pointer-events: none;
}

.lock-visual {
    width: 68px;
    height: 60px;
    margin: 0 auto 24px;
    border: 2px solid rgba(83, 252, 24, .58);
    border-radius: 18px;
    position: relative;
    background: rgba(83, 252, 24, .08);
}

.lock-visual::before {
    content: "";
    position: absolute;
    width: 32px;
    height: 28px;
    left: 16px;
    top: -23px;
    border: 3px solid rgba(83, 252, 24, .58);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
}

.lock-visual span {
    position: absolute;
    width: 8px;
    height: 16px;
    border-radius: 99px;
    background: var(--green);
    left: 28px;
    top: 21px;
    box-shadow: 0 0 18px rgba(83, 252, 24, .8);
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--green);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .18em;
}

.gate h1 {
    max-width: 580px;
    margin: 0 auto;
    font-size: clamp(34px, 6vw, 58px);
    line-height: .98;
    letter-spacing: -.055em;
}

.lead {
    max-width: 540px;
    margin: 22px auto;
    color: #aab4c0;
    font-size: 15px;
    line-height: 1.7;
}

.microcopy {
    max-width: 480px;
    margin: 20px auto 0;
    color: #737f8e;
    font-size: 11px;
    line-height: 1.6;
}

.primary-button, .secondary-button, .danger-button, .send-button, .text-button {
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 800;
    transition: transform .16s ease, opacity .16s ease, border-color .16s ease;
}

button:hover { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.primary-button { padding: 13px 20px; background: var(--green); color: #071006; box-shadow: 0 12px 28px rgba(83, 252, 24, .16); }
.secondary-button { padding: 9px 12px; background: #1c222a; border: 1px solid var(--line); font-size: 11px; }
.danger-button { padding: 9px 12px; background: rgba(255, 95, 109, .10); border: 1px solid rgba(255, 95, 109, .25); color: #ff8993; font-size: 11px; }
.text-button { padding: 7px 10px; background: transparent; color: var(--muted); font-size: 12px; }

.messenger {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 16px;
    min-height: 680px;
}

.sidebar, .chat { border-radius: 20px; overflow: hidden; }
.sidebar { display: flex; flex-direction: column; padding: 20px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px 16px; border-bottom: 1px solid var(--line); }
.sidebar h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.secure-pill { padding: 5px 8px; border-radius: 99px; color: var(--green); background: rgba(83,252,24,.08); border: 1px solid rgba(83,252,24,.18); font-size: 9px; font-weight: 900; letter-spacing: .08em; }

.invite-card {
    margin: 14px 0;
    padding: 15px;
    border: 1px solid rgba(83, 252, 24, .24);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(83,252,24,.09), rgba(83,252,24,.02));
}

.invite-label { margin: 0 0 7px; color: var(--green); font-size: 9px; font-weight: 900; letter-spacing: .15em; }
.invite-card strong { display: block; font-size: 14px; }
.invite-card > p:not(.invite-label) { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.invite-actions { display: flex; gap: 7px; margin-top: 12px; }

.conversation-list { display: grid; gap: 7px; padding-top: 14px; }
.conversation-button {
    width: 100%;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.conversation-button:hover, .conversation-button.active { background: #171d24; border-color: var(--line); }
.conversation-avatar, .avatar {
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #202731;
    color: var(--green);
    font-weight: 900;
}
.conversation-avatar { width: 38px; height: 38px; }
.conversation-copy { min-width: 0; }
.conversation-copy strong, .conversation-copy small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-copy strong { font-size: 13px; }
.conversation-copy small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.conversation-time { color: #687483; font-size: 9px; }

.empty-list { padding: 54px 10px; text-align: center; color: var(--muted); }
.empty-list > span { display: block; margin-bottom: 10px; color: var(--green); font-size: 28px; }
.empty-list p { margin: 0 0 6px; color: #c7ced6; font-weight: 800; }
.empty-list small { line-height: 1.5; }
.empty-list code { color: var(--green); }

.blocked-panel { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.blocked-panel summary { color: var(--muted); font-size: 11px; cursor: pointer; }
.blocked-list { display: grid; gap: 6px; margin-top: 10px; }
.blocked-row { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #c4ccd4; }
.blocked-row button { border: 0; background: transparent; color: var(--green); cursor: pointer; font-size: 10px; }

.chat { min-width: 0; min-height: 680px; }
.chat-empty { height: 100%; min-height: 680px; display: grid; place-content: center; justify-items: center; padding: 30px; text-align: center; }
.chat-empty-icon { width: 66px; height: 66px; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(83,252,24,.24); color: var(--green); font-size: 30px; box-shadow: inset 0 0 30px rgba(83,252,24,.05); }
.chat-empty h2 { margin: 18px 0 6px; font-size: 22px; }
.chat-empty p { margin: 0; color: var(--muted); font-size: 12px; }
.chat-active { height: 680px; display: grid; grid-template-rows: auto 1fr auto auto; }
.chat-head { min-height: 78px; padding: 14px 18px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--line); }
.avatar { width: 42px; height: 42px; }
.chat-person { min-width: 0; }
.chat-person strong, .chat-person span { display: block; }
.chat-person strong { font-size: 14px; }
.chat-person span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.chat-menu { margin-left: auto; display: flex; gap: 7px; }

.messages { overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 10px; scrollbar-color: #343e49 transparent; }
.message { max-width: min(76%, 580px); }
.message.mine { align-self: flex-end; }
.message.theirs { align-self: flex-start; }
.bubble { padding: 10px 13px; border-radius: 14px; background: #1a2028; border: 1px solid #242c36; font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.mine .bubble { background: var(--green-deep); border-color: rgba(83,252,24,.18); }
.message-time { display: block; margin-top: 4px; color: #687483; font-size: 9px; }
.mine .message-time { text-align: right; }
.corrupted .bubble { color: #ff9da5; font-style: italic; }

.composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 12px 18px 5px; border-top: 1px solid var(--line); }
.composer textarea {
    width: 100%;
    min-height: 44px;
    max-height: 130px;
    resize: none;
    padding: 11px 13px;
    color: var(--text);
    background: #11161c;
    border: 1px solid #29313b;
    border-radius: 12px;
    outline: none;
}
.composer textarea:focus { border-color: rgba(83,252,24,.45); box-shadow: 0 0 0 3px rgba(83,252,24,.05); }
.send-button { align-self: end; min-height: 44px; padding: 0 16px; background: var(--green); color: #061005; }
.composer-meta { padding: 3px 20px 12px; display: flex; justify-content: space-between; gap: 10px; color: #657180; font-size: 9px; }

.privacy-note {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    margin: 20px auto 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--line);
}
.privacy-note div { padding: 14px 16px; background: rgba(12,15,19,.96); }
.privacy-note strong, .privacy-note span { display: block; }
.privacy-note strong { color: #d9dfe5; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.privacy-note span { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.privacy-explainer { max-width: 900px; margin: 14px auto 0; color: #626d7b; font-size: 10px; line-height: 1.65; text-align: center; }

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    max-width: min(420px, calc(100% - 40px));
    padding: 12px 15px;
    border-radius: 11px;
    background: #1b222a;
    border: 1px solid #323c48;
    box-shadow: var(--shadow);
    color: #e8edf1;
    font-size: 12px;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255,95,109,.45); color: #ffacb3; }

@media (max-width: 820px) {
    .page-shell { width: min(100% - 20px, 680px); margin-top: 20px; }
    .messenger { grid-template-columns: 1fr; }
    .sidebar { min-height: 280px; }
    .chat, .chat-empty { min-height: 560px; }
    .chat-active { height: 620px; }
    .privacy-note { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
    .topbar { min-height: 62px; padding: 0 14px; }
    .brand small { display: none; }
    .page-shell { width: 100%; margin: 0; }
    .gate { min-height: calc(100vh - 62px); border: 0; border-radius: 0; display: grid; align-content: center; }
    .messenger { gap: 0; }
    .sidebar, .chat { border-left: 0; border-right: 0; border-radius: 0; }
    .sidebar { padding: 15px; }
    .chat-menu { gap: 4px; }
    .secondary-button, .danger-button { padding: 8px; font-size: 9px; }
    .messages { padding: 16px 12px; }
    .message { max-width: 86%; }
    .privacy-note, .privacy-explainer { margin-left: 10px; margin-right: 10px; }
}
