:root {
    --bg: #000;
    --card: #182346;
    --card-deep: #111a36;
    --accent: #14ffe4;
    --accent-dark: #0ed6bf;
    --accent-gradient: linear-gradient(135deg, #14ffe4 0%, #0ed6bf 100%);
    --text: #fff;
    --text-muted: rgba(255, 255, 255, 0.65);
    --danger: #ff4d5e;
    --radius: 16px;
}

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

html,
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a {
    color: var(--accent);
}

button,
input,
textarea {
    font: inherit;
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 1.25rem;
    border: 1px solid transparent;
    border-radius: 5px;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    color: #000;
    background: var(--accent-gradient);
}

.btn-primary:hover:not(:disabled) {
    background: #fff;
}

.btn-outline {
    color: var(--accent);
    background: transparent;
    border-color: var(--accent);
}

.btn-outline:hover:not(:disabled) {
    color: #000;
    background: #fff;
    border-color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.9rem;
    font-size: 0.9rem;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--accent);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.icon-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* Brand header */
.brand-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    padding: 0.5rem 5.5rem;
    background: var(--bg);
}

.brand-logo {
    display: block;
    max-width: 100%;
    max-height: 56px;
}

.page-chat .brand-header {
    justify-content: flex-start;
    padding-left: 0.75rem;
}

.brand-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.credits {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 64px;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--accent);
    border-radius: 10px;
    color: var(--text) !important;
    text-decoration: none;
    line-height: 1.15;
    transition: background 0.15s, border-color 0.15s;
}

.credits[href]:hover,
.credits[href]:focus-visible {
    background: rgba(20, 255, 228, 0.15);
    outline: none;
}

.credits[href] .credits-label {
    font-weight: 600;
    color: var(--accent);
}

.credits-count {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
}

.credits-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.credits.is-low .credits-count {
    color: var(--danger);
}

/* Verify page */
.page-verify .brand-header {
    padding: 1.5rem 1rem;
}

.page-verify .brand-logo {
    max-height: 90px;
}

.form-card {
    width: calc(100% - 20px);
    max-width: 460px;
    margin: 0 auto 2rem;
    padding: 1.75rem 1.25rem;
    background: var(--card);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
}

.form-card h1 {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.form-card .lead {
    margin: 0 0 1.25rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.actions-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.actions-row .btn {
    flex: 1;
    font-size: 0.95rem;
}

.field-label {
    font-size: 1rem;
    margin-bottom: -0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 1rem;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 4px;
    font-size: 1.1rem;
}

select.form-control {
    color-scheme: dark;
    background-color: var(--card-deep);
    cursor: pointer;
}

select.form-control option {
    color: var(--text);
    background-color: var(--card-deep);
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.form-control:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(20, 255, 228, 0.15);
}

.pin-input {
    text-align: center;
    font-size: 1.6rem;
    letter-spacing: 0.5em;
}

.cli-display {
    margin: 0 0 1.25rem;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    letter-spacing: 0.04em;
}

.alert {
    margin-bottom: 1.25rem;
    padding: 0.65rem 0.9rem;
    border-radius: 6px;
    font-size: 0.95rem;
}

.alert-error {
    background: rgba(255, 77, 94, 0.15);
    border: 1px solid var(--danger);
}

.alert-notice {
    background: rgba(20, 255, 228, 0.12);
    border: 1px solid var(--accent);
}

.small-print {
    margin: 1.5rem 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* Chat page */
.page-chat {
    overflow: hidden;
}

.chat-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 820px;
    margin: 0 auto;
}

.chat-subheader {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.9rem;
    background: var(--card);
    border-top: 1px solid var(--accent);
    border-bottom: 1px solid var(--accent);
}

.menu {
    position: relative;
}

.menu-toggle[aria-expanded="true"] {
    background: rgba(20, 255, 228, 0.15);
}

.menu-list {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    margin: 0;
    padding: 0.35rem;
    list-style: none;
    background: var(--card);
    border: 1px solid var(--accent);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.menu-list [role="menuitem"] {
    display: block;
    width: 100%;
    padding: 0.6rem 0.9rem;
    color: var(--text);
    background: transparent;
    border: 0;
    border-radius: 6px;
    text-align: left;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

.menu-list [role="menuitem"]:hover,
.menu-list [role="menuitem"]:focus-visible {
    color: #000;
    background: var(--accent-gradient);
    outline: none;
}

.menu-list [role="menuitem"]:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.profile {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    overflow: hidden;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: var(--card-deep);
    color: var(--accent);
    font-weight: 700;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-name {
    overflow: hidden;
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chat-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1rem 0.75rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.chat-empty {
    margin: auto;
    color: var(--text-muted);
    text-align: center;
}

.load-earlier {
    align-self: center;
    margin-bottom: 0.5rem;
}

.modal {
    width: min(400px, calc(100% - 2rem));
    padding: 1.75rem 1.25rem 1.25rem;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    text-align: center;
}

.modal::backdrop {
    background: rgba(0, 0, 0, 0.75);
}

.modal h2 {
    margin: 0 0 0.5rem;
    font-size: 1.35rem;
    font-weight: 600;
}

.modal p {
    margin: 0 0 1.25rem;
    color: rgba(255, 255, 255, 0.9);
}

.modal-close {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    color: var(--text);
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.modal-actions .btn-primary {
    color: #000 !important;
}

.msg {
    display: flex;
    flex-direction: column;
    max-width: 78%;
}

.msg-in {
    align-self: flex-start;
    align-items: flex-start;
}

.msg-out {
    align-self: flex-end;
    align-items: flex-end;
}

.bubble {
    padding: 0.55rem 0.85rem;
    border-radius: 18px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.msg-in .bubble {
    background: var(--card);
    border: 1px solid rgba(20, 255, 228, 0.35);
    border-bottom-left-radius: 4px;
}

.msg-out .bubble {
    color: #000;
    background: var(--accent-gradient);
    border-bottom-right-radius: 4px;
}

.bubble-media {
    padding: 4px;
}

.bubble-media img,
.bubble-media video {
    display: block;
    max-width: 100%;
    max-height: 320px;
    border-radius: 14px;
    background: #000;
}

.bubble-media .caption {
    padding: 0.35rem 0.5rem 0.15rem;
}

.msg-time {
    margin: 0.15rem 0.4rem 0.3rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.msg.is-pending {
    opacity: 0.6;
}

.chat-toast {
    margin: 0 0.75rem 0.5rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--danger);
    border-radius: 8px;
    background: rgba(255, 77, 94, 0.15);
    font-size: 0.9rem;
}

.chat-composer {
    padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid var(--accent);
}

.composer-form {
    display: flex;
    align-items: flex-end;
    gap: 0.35rem;
}

.composer-input {
    flex: 1;
    min-height: 44px;
    max-height: 140px;
    padding: 0.55rem 0.9rem;
    resize: none;
    color: var(--text);
    background: var(--card-deep);
    border: 1px solid var(--accent);
    border-radius: 22px;
    line-height: 1.4;
}

.composer-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(20, 255, 228, 0.15);
}

.send-btn {
    color: #000;
    background: var(--accent-gradient);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.attach-btn:hover,
.icon-btn:focus-visible {
    background: rgba(20, 255, 228, 0.12);
}

.attachment {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 0.5rem;
    padding: 0.35rem 0.5rem;
    border: 1px dashed var(--accent);
    border-radius: 10px;
}

.attachment-preview img,
.attachment-preview video {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
}

.attachment-name {
    flex: 1;
    overflow: hidden;
    font-size: 0.85rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.attachment-remove {
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
}

@media (min-width: 576px) {
    .form-card {
        padding: 2.25rem 2rem;
    }

    .form-card h1 {
        font-size: 2rem;
    }

    .brand-logo {
        max-height: 64px;
    }
}
