:root {
    /* Brand colors, sourced from the SafeShmooze shield-and-bubble logo */
    --color-primary: #146a78;
    --color-primary-dark: #0d4f59;
    --color-accent: #f7941d;
    --color-accent-dark: #d97c0a;
    --color-accent-bg: #fef1de;
    --color-bg: #f7f7f5;
    --color-card: #ffffff;
    --color-text: #1c1c1c;
    --color-muted: #6b6b6b;
    --color-error: #b3261e;
    --color-error-bg: #fdecea;
    --color-success: #146a78;
    --color-success-bg: #e4f0f1;
    --radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
}

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

.btn {
    display: inline-block;
    padding: 12px 22px;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: #fff;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

.btn-secondary:hover {
    background: var(--color-accent-bg);
    border-color: var(--color-accent);
    color: var(--color-accent-dark);
}

.btn-danger {
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid transparent;
}

.btn-danger:hover {
    background: var(--color-error);
    color: #fff;
}

/* Brand lockup: logo mark + wordmark, used in every header */
.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-mark {
    flex-shrink: 0;
    display: block;
}

.brand-wordmark {
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1;
    white-space: nowrap;
}

.brand-wordmark .brand-safe {
    color: var(--color-primary-dark);
}

.brand-wordmark .brand-shmooze {
    color: var(--color-accent);
}

.brand-tagline {
    display: block;
    color: var(--color-primary);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 2px;
}

.brand-lockup--light .brand-safe,
.brand-lockup--light .brand-tagline {
    color: #fff;
}

/* Auth pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.auth-card h1 {
    margin-top: 0;
    color: var(--color-primary);
}

.auth-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.auth-brand .brand-lockup {
    flex-direction: column;
    text-align: center;
}

.auth-brand .brand-wordmark {
    font-size: 1.4rem;
    margin-top: 6px;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 16px;
}

.auth-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.auth-card input {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-size: 1rem;
}

.password-field {
    position: relative;
    display: flex;
}

.password-field input {
    flex: 1;
    padding-right: 42px !important;
}

.password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-muted);
}

.password-toggle:hover {
    color: var(--color-primary);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

.remember-me-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: -6px;
    font-size: 0.85rem;
}

.remember-me-row .checkbox-row {
    display: flex;
    font-size: 0.85rem;
    color: var(--color-muted);
}

.errors, .success {
    list-style: none;
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 8px;
}

.errors {
    background: var(--color-error-bg);
    color: var(--color-error);
}

.success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

/* Home page */
.home-page {
    background:
        radial-gradient(1200px 500px at 10% -10%, #e7f4f0 0%, transparent 60%),
        radial-gradient(900px 500px at 110% 10%, #eef7ec 0%, transparent 55%),
        var(--color-bg);
}

.home-nav {
    padding: 18px 24px;
}

.home-nav-inner {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.home-nav-link {
    text-decoration: none;
    color: var(--color-primary-dark);
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--color-primary);
}

.home-hero {
    padding: 40px 24px 60px;
}

.home-hero-grid {
    max-width: 1080px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 48px;
    align-items: start;
}

@media (max-width: 860px) {
    .home-hero-grid {
        grid-template-columns: 1fr;
    }
}

.home-pitch h1 {
    font-size: 2.8rem;
    line-height: 1.1;
    color: var(--color-primary-dark);
    margin: 8px 0 18px;
    letter-spacing: -0.02em;
}

.home-tagline {
    color: var(--color-muted);
    font-size: 1.15rem;
    line-height: 1.55;
    max-width: 46ch;
    margin-bottom: 36px;
}

.feature-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.feature-list li {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.feature-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.feature-list strong {
    display: block;
    color: var(--color-text);
    margin-bottom: 2px;
}

.feature-list span {
    color: var(--color-muted);
    font-size: 0.92rem;
    line-height: 1.4;
}

.home-card {
    background: var(--color-card);
    border-radius: 18px;
    padding: 32px;
    box-shadow: 0 12px 40px rgba(31, 111, 92, 0.12);
    position: sticky;
    top: 24px;
}

.home-card h2 {
    margin-top: 0;
    color: var(--color-primary-dark);
}

.home-card form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 16px;
}

.home-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.home-card input {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-size: 1rem;
}

.home-card-divider {
    text-align: center;
    color: var(--color-muted);
    font-size: 0.85rem;
    margin: 22px 0 12px;
    position: relative;
}

.home-card-divider::before,
.home-card-divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 30%;
    border-top: 1px solid #eee;
}

.home-card-divider::before { left: 0; }
.home-card-divider::after { right: 0; }

.btn-full {
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}

.install-section {
    max-width: 640px;
    margin: 0 auto 80px;
    padding: 40px 24px;
    background: var(--color-card);
    border-radius: var(--radius);
    text-align: center;
}

.install-section h2 {
    color: var(--color-primary-dark);
    margin-top: 0;
}

.platform-tabs {
    display: inline-flex;
    background: var(--color-bg);
    border-radius: 999px;
    padding: 4px;
    margin: 24px 0 8px;
}

.platform-tab {
    border: none;
    background: transparent;
    padding: 8px 20px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-muted);
    cursor: pointer;
}

.platform-tab.active {
    background: var(--color-primary);
    color: #fff;
}

.platform-panel {
    margin-top: 12px;
}

.install-steps {
    text-align: left;
    max-width: 420px;
    margin: 20px auto;
    line-height: 1.7;
}

.hint {
    color: var(--color-muted);
    font-size: 0.9rem;
    margin-top: 12px;
}

.home-footer {
    text-align: center;
    color: var(--color-muted);
    font-size: 0.85rem;
    padding: 24px;
}

/* App shell (chat pages) */
.app-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    background: var(--color-primary);
    color: #fff;
}

.app-header a {
    color: #fff;
}

.app-header-logout {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    flex-shrink: 0;
}

.app-header-logout:hover {
    opacity: 1;
}

.app-header-logout svg {
    width: 22px;
    height: 22px;
}

.chat-shell {
    padding: 24px;
    max-width: 640px;
    margin: 0 auto;
}

/* Chat bubbles (foundation for the chat UI milestone) */
.bubble-row {
    display: flex;
    margin: 6px 0;
}

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

.bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.4;
    font-size: 0.95rem;
}

.bubble-row.mine .bubble {
    background: var(--color-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.bubble-row:not(.mine) .bubble {
    background: #fff;
    border: 1px solid #eee;
    border-bottom-left-radius: 4px;
}

.bubble-sender {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 2px;
}

.bubble-image {
    max-width: 100%;
    border-radius: 10px;
    display: block;
}

.bubble-decrypt-error {
    font-style: italic;
    color: var(--color-error);
    font-size: 0.85rem;
}

.bubble-report-btn {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.35;
    font-size: 0.8rem;
    margin-left: 6px;
    float: right;
}

.bubble-report-btn:hover {
    opacity: 1;
}

/* App body: leaves room for the bottom tab bar and header */
.app-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 64px;
}

.page-content {
    flex: 1;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
}

.page-content h1 {
    color: var(--color-primary);
}

.card {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.card input[type="text"],
.card input[type="email"] {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.checkbox-row {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
    color: var(--color-text) !important;
}

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

.inline-form input {
    flex: 1;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.contact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    flex-wrap: wrap;
}

.contact-row form {
    margin: 0;
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.9rem;
}

.btn-icon {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Bottom tab bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: #fff;
    border-top: 1px solid #eee;
    z-index: 10;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 10px;
    color: var(--color-muted);
    text-decoration: none;
    font-size: 0.72rem;
}

.bottom-nav-item svg {
    width: 24px;
    height: 24px;
}

.bottom-nav-item.active {
    color: var(--color-primary);
}

/* Chats list */
.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.conversation-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: var(--color-text);
}

.avatar-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.conversation-row-body {
    display: flex;
    flex-direction: column;
}

/* Thread view */
.chat-page {
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    max-width: 720px;
}

.conversation-list-view,
.thread-view {
    padding: 16px 20px;
}

.thread-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.back-link {
    font-size: 1.4rem;
    text-decoration: none;
    color: var(--color-primary);
}

.thread-messages {
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    min-height: 50vh;
    max-height: 65vh;
    overflow-y: auto;
}

.composer {
    position: sticky;
    bottom: 64px;
    background: var(--color-bg);
    padding: 8px 0 10px;
}

.composer-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.composer-input-wrap {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 22px;
    padding: 6px 6px 6px 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.composer-input-wrap textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
    padding: 7px 0;
    max-height: 130px;
    overflow-y: auto;
}

.composer-attach-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-muted);
    cursor: pointer;
}

.composer-attach-btn:hover {
    background: var(--color-bg);
    color: var(--color-primary);
}

.composer-attach-btn svg {
    width: 22px;
    height: 22px;
}

.composer-send-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.composer-send-btn:hover {
    background: var(--color-primary-dark);
}

.composer-send-btn svg {
    width: 19px;
    height: 19px;
}

.composer .errors {
    margin-bottom: 8px;
    font-size: 0.85rem;
}
