:root {
    --bg: #ece5db;
    --panel: rgba(255, 255, 255, 0.86);
    --text: #2e2a26;
    --muted: #70655d;
    --border: rgba(46, 42, 38, 0.1);
    --accent: #d1694f;
    --accent-soft: rgba(209, 105, 79, 0.14);
    --success: #2f7d57;
    --error: #b44747;
    --bubble-self: #ffe6dc;
    --bubble-other: #ffffff;
    --shadow: 0 20px 50px rgba(62, 43, 31, 0.12);
}

body.theme-friend {
    --bg: #edf4f0;
    --accent: #2d8d6d;
    --accent-soft: rgba(45, 141, 109, 0.14);
    --bubble-self: #dff5ec;
}

body.theme-business {
    --bg: #edf2f9;
    --accent: #446699;
    --accent-soft: rgba(68, 102, 153, 0.14);
    --bubble-self: #e0ebfb;
}

body.theme-family {
    --bg: #fff4e8;
    --accent: #cc8a24;
    --accent-soft: rgba(204, 138, 36, 0.14);
    --bubble-self: #fff0d9;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "PingFang SC", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.75), transparent 28%),
        linear-gradient(160deg, var(--bg), #faf7f3);
    color: var(--text);
}

a {
    color: var(--accent);
    text-decoration: none;
}

.page-shell {
    max-width: 1240px;
    margin: 0 auto;
    padding: 20px;
}

.app-frame {
    min-height: 100vh;
}

.site-header,
.main-nav,
.user-pill,
.section-title,
.stats,
.chat-panel-header,
.composer-bar,
.copy-row,
.invite-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.site-header,
.main-nav,
.card,
.chat-panel {
    background: var(--panel);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.site-header {
    padding: 18px 22px;
    border-radius: 24px;
}

.main-nav {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 20px;
    flex-wrap: wrap;
}

.main-nav a {
    padding: 10px 14px;
    border-radius: 14px;
}

.main-nav a:hover {
    background: var(--accent-soft);
}

.card {
    border-radius: 28px;
    padding: 24px;
}

.chat-shell {
    margin-top: 20px;
}

.chat-panel {
    border-radius: 30px;
    padding: 24px;
    min-height: 72vh;
    display: flex;
    flex-direction: column;
}

.login-shell {
    max-width: 720px;
    margin: 24px auto 0;
}

.login-panel {
    min-height: auto;
}

.chat-summary {
    text-align: right;
    color: var(--muted);
}

.chat-summary strong {
    display: block;
    font-size: 26px;
    color: var(--text);
}

.chat-stream {
    margin-top: 20px;
    padding: 8px 2px 12px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.chat-row.is-self {
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #f1a893);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.chat-bubble-wrap {
    max-width: min(70%, 680px);
}

.chat-bubble-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
}

.chat-row.is-self .chat-bubble-meta {
    justify-content: flex-end;
}

.chat-bubble {
    background: var(--bubble-other);
    border: 1px solid var(--border);
    border-radius: 20px 20px 20px 8px;
    padding: 14px 16px;
}

.chat-row.is-self .chat-bubble {
    background: var(--bubble-self);
    border-radius: 20px 20px 8px 20px;
}

.chat-bubble p,
.moment-card p,
.login-copy p {
    margin: 0;
    line-height: 1.6;
}

.chat-composer {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 12px;
}

.form-grid,
.moments-list,
.invite-list {
    display: grid;
    gap: 12px;
}

input,
textarea,
button,
select {
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 12px 14px;
    font: inherit;
}

textarea {
    resize: vertical;
    min-height: 96px;
}

button {
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    border: none;
}

.copy-button {
    width: auto;
    min-width: 92px;
}

.invite-box,
.moment-card,
.invite-item,
.empty-state,
.version-box {
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px 16px;
}

.version-box p,
.update-notes p {
    margin: 6px 0;
}

.update-notes {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.invite-item p {
    margin: 6px 0 0;
    word-break: break-all;
    color: var(--muted);
}

.copy-row input {
    flex: 1;
}

.layout-grid {
    margin-top: 20px;
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.profile-grid {
    align-items: start;
}

.hero-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.92), var(--accent-soft));
}

.stats {
    flex-wrap: wrap;
    margin-top: 18px;
}

.stats div {
    min-width: 120px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.55);
}

.stats strong {
    display: block;
    font-size: 28px;
}

.alert,
.inline-error {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 16px;
}

.alert-success {
    background: rgba(47, 125, 87, 0.12);
    color: var(--success);
}

.alert-error,
.inline-error {
    background: rgba(180, 71, 71, 0.12);
    color: var(--error);
}

.admin-links-column {
    display: grid;
    gap: 12px;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 18px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
}

.site-footer {
    margin-top: 18px;
    text-align: center;
    color: var(--muted);
}

@media (max-width: 900px) {
    .page-shell {
        padding: 14px;
    }

    .chat-panel {
        min-height: calc(100vh - 170px);
        padding: 18px;
        border-radius: 24px;
    }

    .chat-bubble-wrap {
        max-width: 82%;
    }
}

@media (max-width: 640px) {
    body {
        background: linear-gradient(180deg, var(--bg), #f9f6f2);
    }

    .page-shell {
        padding: 0;
    }

    .site-header,
    .main-nav,
    .chat-panel,
    .card {
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
    }

    .site-header,
    .main-nav,
    .card,
    .chat-panel {
        padding-left: 16px;
        padding-right: 16px;
    }

    .main-nav,
    .site-header,
    .chat-panel-header,
    .composer-bar,
    .invite-item,
    .copy-row,
    .stats {
        flex-direction: column;
        align-items: stretch;
    }

    .chat-panel {
        min-height: calc(100vh - 124px);
    }

    .chat-bubble-wrap {
        max-width: calc(100% - 54px);
    }

    .layout-grid {
        grid-template-columns: 1fr;
        gap: 0;
        margin-top: 0;
    }
}
