* {
    box-sizing: border-box;
}

:root {
    --bg: #0d131d;
    --green: #3b82f6;
    --green-dark: #2563eb;
    --bubble-me: #18345c;
    --bubble-other: #202a38;
    --muted: #91a0b5;
    --line: #2b3748;
    --panel: #161f2c;
    --text: #e7edf6;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

.auth-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: radial-gradient(circle at 50% 0%, #223a5e 0, #111927 38%, #090e16 100%);
}

.auth-card {
    width: 100%;
    max-width: 430px;
    background: rgba(22,31,44,.97);
    border: 1px solid #324158;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 22px 70px rgba(0,0,0,.55);
}

.logo,
.big-logo {
    width: 82px;
    height: 82px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: #172b49;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
}

.big-logo {
    width: 120px;
    height: 120px;
    font-size: 58px;
}

h1,
h2 {
    margin-top: 0;
}

.auth-card h1 {
    text-align: center;
}

.auth-card p {
    color: var(--muted);
    line-height: 1.45;
    text-align: center;
}

label {
    display: block;
    font-weight: 700;
    margin-top: 14px;
    margin-bottom: 6px;
}

input,
textarea {
    width: 100%;
    border: 1px solid #d1d7db;
    border-radius: 10px;
    padding: 12px;
    font-size: 15px;
    outline: none;
    background: #111a27;
    color: var(--text);
}

textarea {
    resize: none;
}

input:focus,
textarea:focus {
    border-color: var(--green);
}

.btn {
    display: block;
    width: 100%;
    border: none;
    border-radius: 10px;
    padding: 13px;
    margin-top: 14px;
    text-align: center;
    text-decoration: none;
    font-weight: 800;
    font-size: 16px;
    cursor: pointer;
}

.primary {
    background: var(--green);
    color: white;
}

.secondary {
    background: #253247;
    color: #c8d7ec;
}

.link {
    display: block;
    text-align: center;
    margin-top: 16px;
    color: var(--green-dark);
    text-decoration: none;
    font-weight: 700;
}

.error {
    background: #ffe0e0;
    color: #900;
    padding: 12px;
    border-radius: 10px;
    font-weight: 700;
    margin-bottom: 14px;
    text-align: center;
}

.hidden {
    display: none !important;
}

.hint {
    font-size: 14px;
    color: var(--muted);
}

.success {
    padding: 12px;
    margin-bottom: 14px;
    border-radius: 10px;
    background: #132f4c;
    color: #b8d8ff;
}

.dev-token {
    background: #fff7d6;
    border: 1px solid #eadca6;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    word-break: break-word;
}

.app-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: 360px 1fr;
    background: var(--bg);
}

.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--line);
    overflow-y: auto;
}

.sidebar-header {
    min-height: 70px;
    background: #111a27;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
}

.sidebar-header h2 {
    margin: 0;
}

.sidebar-header p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.logout {
    color: var(--green-dark);
    text-decoration: none;
    font-weight: 700;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    font: inherit;
}

.new-chat {
    display: block;
    padding: 14px 16px;
    background: #182334;
    color: var(--green-dark);
    text-decoration: none;
    font-weight: 800;
    border-bottom: 1px solid var(--line);
}

.chat-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--line);
}

.chat-item:hover {
    background: #202d40;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(145deg,#334a69,#1e2b3d);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}
.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-info strong {
    display: block;
}

.chat-info span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

.empty-list {
    color: var(--muted);
    padding: 18px;
    text-align: center;
}

.empty-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--muted);
}

.empty-chat h1 {
    color: var(--text);
}

.chat-main {
    height: 100vh;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    background:
        radial-gradient(circle at 15% 20%, rgba(48,93,153,.16), transparent 32%),
        linear-gradient(160deg,#0e1622,#0a1019);
}

.chat-top {
    min-height: 70px;
    background: #131d2a;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
}

.chat-top h1 {
    margin: 0;
    font-size: 20px;
}

.chat-top p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.mobile-back {
    color: var(--green-dark);
    text-decoration: none;
    font-weight: 800;
}

.secret-panel {
    background: #101c2c;
    border-bottom: 1px solid #29466b;
    padding: 10px 18px;
}

.secret-form {
    display: flex;
    gap: 8px;
}

.secret-form input {
    flex: 1;
}

.secret-panel p {
    margin: 6px 0 0;
    font-size: 13px;
    color: #8399b6;
}

.mini-btn {
    border: none;
    border-radius: 9px;
    background: var(--green);
    color: white;
    padding: 10px 12px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.light-mini {
    background: #263348;
    color: #dce9f9;
    border: 1px solid #40516a;
}

.messages-area {
    overflow-y: auto;
    padding: 18px;
}

.bubble-row {
    display: flex;
    margin-bottom: 10px;
}

.bubble-row.mine {
    justify-content: flex-end;
}

.bubble-row.theirs {
    justify-content: flex-start;
}

.bubble {
    max-width: min(680px, 78%);
    border-radius: 12px;
    padding: 8px 10px 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,.2);
    border: 1px solid rgba(125,155,195,.14);
}

.mine .bubble {
    background: var(--bubble-me);
    border-top-right-radius: 2px;
}

.theirs .bubble {
    background: var(--bubble-other);
    border-top-left-radius: 2px;
}

.bubble-name {
    color: #79adff;
    font-weight: 800;
    font-size: 13px;
    margin-bottom: 3px;
}

.bubble-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.38;
    font-size: 15px;
}

.bubble-text.encrypted {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: #8190a5;
}

.bubble-time {
    color: var(--muted);
    font-size: 11px;
    text-align: right;
    margin-top: 4px;
}

.empty-messages {
    text-align: center;
    color: var(--muted);
    margin-top: 40px;
}

.send-bar {
    display: grid;
    grid-template-columns: 1fr 52px;
    gap: 8px;
    padding: 12px;
    background: #131d2a;
    border-top: 1px solid var(--line);
}

.send-bar textarea {
    height: 46px;
    min-height: 46px;
    max-height: 120px;
    border-radius: 18px;
}

.send-bar button {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: var(--green);
    color: white;
    font-size: 22px;
    font-weight: 900;
    cursor: pointer;
}

.participants-box,
.invite-box {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.participants-box strong {
    display: block;
    margin-bottom: 8px;
}

.participants-box span {
    display: inline-block;
    background: #24354c;
    color: #b9d5fa;
    border-radius: 20px;
    padding: 6px 10px;
    margin: 4px 4px 0 0;
    font-size: 13px;
    font-weight: 700;
}

.invite-box input {
    margin-bottom: 8px;
}

.chat-error {
    margin: 10px 18px 0;
}

.user-results {
    border: 1px solid #d1d7db;
    border-radius: 10px;
    margin-top: 6px;
    overflow: hidden;
    background: #151f2d;
}

.user-result-item {
    display: block;
    width: 100%;
    border: none;
    background: #151f2d;
    color: var(--text);
    padding: 10px;
    text-align: left;
    cursor: pointer;
    border-bottom: 1px solid var(--line);
}

.user-result-item:hover {
    background: #223047;
}

@media (max-width: 800px) {
    .app-shell {
        display: block;
        height: auto;
        min-height: 100vh;
    }

    .mobile-hidden {
        display: none;
    }

    .chat-main {
        height: 100vh;
    }

    .bubble {
        max-width: 88%;
    }

    .auth-bg {
        align-items: flex-start;
    }

    .auth-card {
        margin-top: 24px;
    }

    .secret-form {
        display: block;
    }

    .secret-form .mini-btn {
        margin-top: 8px;
        width: 100%;
    }
}


.send-bar button:disabled,
.send-bar textarea:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
