:root {
    --bg: #071315;
    --panel: #0f1f22;
    --panel-soft: #15282c;
    --paper: #f8faf9;
    --ink: #101719;
    --muted: #6c7a80;
    --line: rgba(255, 255, 255, 0.1);
    --line-dark: rgba(16, 23, 25, 0.1);
    --accent: #0f766e;
    --accent-bright: #2dd4bf;
    --gold: #d99a48;
    --danger: #e35d5b;
    --shadow: 0 26px 80px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(45, 212, 191, 0.2), transparent 34rem),
        linear-gradient(145deg, #071315 0%, #13272b 54%, #f3eee5 54%, #f8faf9 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

.auth-screen {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.auth-shell {
    width: min(100%, 440px);
}

.auth-panel {
    padding: 28px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(248, 250, 249, 0.96);
    box-shadow: var(--shadow);
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 34px;
    font-weight: 850;
}

.auth-mark,
.empty-mark,
.avatar {
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 850;
}

.auth-mark {
    width: 38px;
    height: 38px;
}

.auth-copy h1 {
    margin: 0 0 10px;
    font-size: clamp(2rem, 8vw, 3.2rem);
    line-height: 1;
    letter-spacing: 0;
}

.auth-copy p {
    margin: 0 0 26px;
    color: var(--muted);
}

.eyebrow,
.mini-label {
    margin: 0;
    color: var(--gold);
    font-size: 0.75rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-form,
.field {
    display: grid;
    gap: 12px;
}

.bot-trap {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.field span {
    color: #334146;
    font-size: 0.86rem;
    font-weight: 750;
}

.field input,
.inline-form input,
.composer textarea {
    width: 100%;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    outline: none;
}

.field input {
    min-height: 48px;
    padding: 0 14px;
}

.field input:focus,
.inline-form input:focus,
.composer textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.field small,
.form-error {
    color: var(--danger);
    font-size: 0.84rem;
    font-weight: 700;
}

.form-error {
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(227, 93, 91, 0.1);
}

.form-error.compact {
    margin: 8px 0 0;
}

.primary-action,
.inline-form button,
.composer button {
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 850;
    cursor: pointer;
}

.primary-action {
    min-height: 50px;
    margin-top: 8px;
}

.auth-switch {
    margin: 20px 0 0;
    color: var(--muted);
    text-align: center;
}

.auth-switch a {
    color: var(--accent);
    font-weight: 800;
}

.app-screen {
    min-height: 100vh;
    background: var(--bg);
}

.mobile-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
    margin: 0 auto;
    overflow: hidden;
    background: var(--paper);
}

.app-header,
.chat-header {
    position: sticky;
    z-index: 3;
    top: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 76px;
    padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
    border-bottom: 1px solid var(--line-dark);
    background: rgba(248, 250, 249, 0.9);
    backdrop-filter: blur(18px);
}

.app-header {
    justify-content: space-between;
}

.app-header > div:first-child {
    min-width: 0;
}

.app-header h1 {
    margin: 4px 0 0;
    font-size: 1.85rem;
    line-height: 1;
    letter-spacing: 0;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.header-avatar,
.header-avatar-image {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    flex: 0 0 auto;
}

.header-avatar {
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #fff;
    font-size: 0.84rem;
    font-weight: 850;
}

.header-avatar-image {
    object-fit: cover;
    border: 1px solid var(--line-dark);
    background: #fff;
}

.account-chip {
    display: inline-flex;
    max-width: 100%;
    min-height: 28px;
    align-items: center;
    margin-top: 5px;
    padding: 0 9px;
    border-radius: 8px;
    background: rgba(15, 118, 110, 0.1);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 850;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-button,
.back-link,
.logout-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
    background: var(--panel-soft);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 850;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.header-actions form {
    margin: 0;
}

.logout-button {
    border: 0;
    padding: 0 12px;
    background: rgba(227, 93, 91, 0.12);
    color: var(--danger);
    cursor: pointer;
}

.logout-button:hover {
    background: rgba(227, 93, 91, 0.18);
}

.conversation-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 14px calc(128px + env(safe-area-inset-bottom));
    scrollbar-color: rgba(15, 118, 110, 0.55) transparent;
    scrollbar-width: thin;
}

.conversation-main::-webkit-scrollbar,
.search-results::-webkit-scrollbar {
    width: 10px;
}

.conversation-main::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.55);
    background-clip: content-box;
}

.conversation-main::-webkit-scrollbar-track,
.search-results::-webkit-scrollbar-track {
    background: transparent;
}

.quick-start,
.search-window,
.empty-state,
.people-strip {
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background: #fff;
}

.quick-start,
.search-window {
    padding: 16px;
    margin-bottom: 14px;
}

.quick-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.quick-links a {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    padding: 0 12px;
    border-radius: 8px;
    background: rgba(15, 118, 110, 0.1);
    color: var(--accent);
    font-size: 0.86rem;
    font-weight: 850;
}

.quick-start h2,
.search-window h2,
.empty-state h2 {
    margin: 4px 0 14px;
    font-size: 1.2rem;
    letter-spacing: 0;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.inline-form input {
    min-height: 46px;
    padding: 0 12px;
}

.inline-form button {
    min-width: 76px;
    padding: 0 14px;
}

.group-avatar-form {
    display: grid;
    gap: 10px;
}

.group-avatar-form .primary-action {
    min-height: 46px;
    margin-top: 0;
}

.search-form {
    grid-template-columns: minmax(0, 1fr) auto;
}

.search-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 800;
}

.search-meta a {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    padding: 0 10px;
    border-radius: 8px;
    background: rgba(15, 118, 110, 0.1);
    color: var(--accent);
}

.search-results {
    display: grid;
    gap: 1px;
    max-height: min(360px, 42vh);
    overflow-y: auto;
    margin-top: 12px;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background: var(--line-dark);
    scrollbar-color: rgba(15, 118, 110, 0.55) transparent;
    scrollbar-width: thin;
}

.search-row {
    min-height: 68px;
}

.search-empty {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.thread-list {
    display: grid;
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background: var(--line-dark);
}

.thread-row {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-height: 76px;
    padding: 12px;
    background: #fff;
}

.avatar-stack {
    display: flex;
}

.avatar {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    overflow: hidden;
}

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

.group-avatar {
    background: var(--panel-soft);
}

.thread-copy {
    min-width: 0;
}

.thread-copy strong,
.thread-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-copy strong {
    margin-bottom: 3px;
}

.thread-copy small,
.thread-time,
.chat-identity small,
.empty-state p {
    color: var(--muted);
}

.thread-time {
    align-self: start;
    padding-top: 5px;
    font-size: 0.78rem;
}

.request-list {
    display: grid;
    gap: 8px;
}

.request-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-height: 64px;
    padding: 10px;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background: rgba(15, 118, 110, 0.04);
}

.request-actions,
.contact-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.request-actions form,
.contact-actions form {
    margin: 0;
}

.request-actions button,
.contact-actions button,
.contact-action,
.pending-badge {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid rgba(15, 118, 110, 0.2);
    background: rgba(15, 118, 110, 0.1);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 850;
    cursor: pointer;
}

.request-actions .soft-danger,
.contact-actions .soft-danger {
    border-color: rgba(227, 93, 91, 0.3);
    background: rgba(227, 93, 91, 0.1);
    color: var(--danger);
}

.contact-row {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
}

.contact-row .thread-copy {
    align-self: center;
}

.contact-row .contact-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-top: 2px;
}

.pending-badge {
    cursor: default;
    border-style: dashed;
}

.empty-state {
    display: grid;
    justify-items: center;
    padding: 42px 24px;
    text-align: center;
}

.empty-mark {
    width: 56px;
    height: 56px;
    margin-bottom: 18px;
}

.empty-state p {
    max-width: 280px;
    margin: 0;
}

.people-strip {
    margin-top: 14px;
    padding: 14px;
}

.people-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-top: 12px;
}

.person-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 6px 12px 6px 6px;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    white-space: nowrap;
}

.person-pill .avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    font-size: 0.85rem;
}

.bottom-nav {
    position: fixed;
    z-index: 4;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 860px;
    margin: 0 auto;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line-dark);
    background:
        linear-gradient(180deg, rgba(248, 250, 249, 0.78), rgba(248, 250, 249, 0.99)),
        rgba(248, 250, 249, 0.96);
    backdrop-filter: blur(18px);
    box-shadow: 0 -18px 42px rgba(16, 23, 25, 0.1);
}

.bottom-nav a {
    display: inline-grid;
    min-height: 46px;
    place-items: center;
    padding: 0 6px;
    border-radius: 8px;
    border: 1px solid rgba(16, 23, 25, 0.08);
    background: #fff;
    color: #46555b;
    font-size: 0.84rem;
    font-weight: 850;
    line-height: 1.1;
    text-align: center;
    box-shadow: 0 8px 18px rgba(16, 23, 25, 0.05);
    transition: background 160ms ease, color 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.bottom-nav a:hover {
    border-color: rgba(15, 118, 110, 0.18);
    color: var(--accent);
    transform: translateY(-1px);
}

.bottom-nav a.active {
    border-color: rgba(15, 118, 110, 0.24);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.22);
}

.cat-shell {
    background: #f7f4ee;
}

.cat-main {
    display: grid;
    gap: 18px;
    padding: 18px 14px calc(30px + env(safe-area-inset-bottom));
}

.cat-hero,
.cat-card,
.cat-alert {
    overflow: hidden;
    border: 1px solid rgba(16, 23, 25, 0.1);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(16, 23, 25, 0.08);
}

.cat-hero {
    position: relative;
    min-height: 460px;
    color: #fff;
    background: var(--panel);
}

.cat-hero img,
.cat-card img,
.cat-alert img {
    display: block;
    width: 100%;
    object-fit: cover;
}

.cat-hero img {
    position: absolute;
    inset: 0;
    height: 100%;
}

.cat-hero::after {
    position: absolute;
    inset: 0;
    content: "";
    background:
        linear-gradient(90deg, rgba(7, 19, 21, 0.88), rgba(7, 19, 21, 0.46) 46%, rgba(7, 19, 21, 0.08)),
        linear-gradient(0deg, rgba(7, 19, 21, 0.42), transparent 48%);
}

.cat-hero-copy {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 460px;
    max-width: 560px;
    flex-direction: column;
    justify-content: flex-end;
    padding: 26px;
}

.cat-hero h2,
.cat-alert h2,
.cat-card h2 {
    margin: 6px 0 12px;
    letter-spacing: 0;
    line-height: 1.05;
}

.cat-hero h2 {
    font-size: clamp(2.35rem, 7vw, 4.9rem);
}

.cat-hero p,
.cat-card p,
.cat-alert p {
    margin: 0;
}

.cat-hero-copy > p:last-of-type {
    max-width: 34rem;
    color: rgba(255, 255, 255, 0.86);
    font-size: 1.04rem;
}

.cat-meta,
.cat-action {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.cat-meta {
    margin-top: 18px;
}

.cat-meta span {
    min-height: 34px;
    padding: 8px 11px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 850;
    backdrop-filter: blur(12px);
}

.cat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.cat-card {
    padding: 18px;
}

.cat-card img {
    height: 230px;
    margin: -18px -18px 18px;
    width: calc(100% + 36px);
}

.cat-feature-card {
    grid-row: span 2;
}

.cat-card h2,
.cat-alert h2 {
    font-size: 1.35rem;
}

.cat-card p,
.cat-alert p {
    color: #4d5b60;
}

.cat-alert {
    display: grid;
    grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
    align-items: center;
}

.cat-alert img {
    height: 100%;
    min-height: 320px;
}

.cat-alert div {
    padding: 24px;
}

.cat-action {
    display: inline-flex;
    justify-content: center;
    min-height: 42px;
    margin-top: 18px;
    padding: 0 14px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 850;
}

.chat-shell {
    height: 100vh;
    min-height: 100vh;
}

.chat-header {
    flex: 0 0 auto;
}

.chat-identity {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
}

.chat-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chat-header-actions form {
    margin: 0;
}

.leave-group {
    border-color: rgba(227, 93, 91, 0.28);
    background: rgba(227, 93, 91, 0.12);
    color: var(--danger);
}

.chat-identity div {
    min-width: 0;
}

.chat-identity strong,
.chat-identity small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-status {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-dark);
    background: rgba(15, 118, 110, 0.08);
}

.location-status > span:nth-child(2) {
    flex: 1;
}

.location-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 5px rgba(15, 118, 110, 0.12);
}

.location-status span:last-child {
    display: grid;
    gap: 1px;
    min-width: 0;
}

.location-status strong,
.location-status small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-status strong {
    color: var(--accent);
    font-size: 0.82rem;
}

.location-status small {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
}

.location-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 34px;
    border: 0;
    border-radius: 8px;
    padding: 0 12px;
    background: var(--accent);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 850;
    cursor: pointer;
}

.location-action[hidden] {
    display: none;
}

.message-window {
    flex: 1;
    overflow-y: auto;
    padding: 18px 12px 98px;
    background:
        linear-gradient(rgba(248, 250, 249, 0.95), rgba(248, 250, 249, 0.95)),
        radial-gradient(circle at top left, rgba(45, 212, 191, 0.24), transparent 28rem);
}

.message-bubble {
    width: fit-content;
    max-width: min(78%, 560px);
    margin-bottom: 10px;
    padding: 10px 12px 7px;
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(17, 24, 28, 0.08);
}

.message-bubble {
    cursor: pointer;
}

.message-bubble p {
    margin: 0;
    overflow-wrap: anywhere;
}

.message-bubble time {
    color: rgba(255, 255, 255, 0.66);
    font-size: 0.72rem;
}

.message-bubble.mine {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
}

.message-bubble.theirs {
    margin-right: auto;
    background: #fff;
    color: var(--ink);
}

.message-bubble.theirs time {
    color: var(--muted);
}

.reaction-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    margin-top: 8px;
    padding: 0;
}

.message-bubble.mine .reaction-summary {
    justify-content: flex-end;
}

.message-bubble.theirs .reaction-summary {
    justify-content: flex-start;
}

.reaction-summary form {
    margin: 0;
}

.reaction-summary-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.reaction-summary-chip {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 999px;
    padding: 0 9px;
    background: rgba(255, 255, 255, 0.22);
    color: inherit;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(16, 23, 25, 0.12);
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.message-bubble.theirs .reaction-summary-chip {
    border-color: rgba(15, 118, 110, 0.24);
    background: rgba(15, 118, 110, 0.1);
}

.reaction-summary-chip:hover,
.reaction-summary-chip.active {
    border-color: rgba(217, 154, 72, 0.68);
    background: rgba(217, 154, 72, 0.24);
    transform: translateY(-1px);
}

.reaction-summary-chip span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.92rem;
    line-height: 1;
}

.reaction-summary-chip small {
    min-width: 0;
    font-size: 0.66rem;
    font-weight: 900;
    line-height: 1;
    opacity: 0.92;
}

.reaction-summary-remove-form {
    margin: 0;
}

.reaction-summary-remove {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    padding: 0;
    background: rgba(16, 23, 25, 0.22);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.message-bubble.theirs .reaction-summary-remove {
    border-color: rgba(15, 118, 110, 0.28);
    background: rgba(15, 118, 110, 0.14);
    color: var(--accent);
}

.reaction-summary-remove:hover {
    border-color: rgba(227, 93, 91, 0.52);
    background: rgba(227, 93, 91, 0.2);
    transform: translateY(-1px);
}

.reaction-picker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: flex-end;
    max-width: 100%;
    max-height: 0;
    margin-top: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translateY(-4px);
    transition: max-height 180ms ease, margin-top 180ms ease, opacity 160ms ease, transform 180ms ease;
}

.message-bubble.reactions-open .reaction-picker {
    max-height: 64px;
    margin-top: 7px;
    opacity: 1;
    overflow-x: auto;
    overflow-y: hidden;
    pointer-events: auto;
    transform: translateY(0);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.message-bubble.theirs .reaction-picker {
    justify-content: flex-start;
}

.reaction-picker::-webkit-scrollbar {
    display: none;
}

.reaction-picker form {
    display: inline-flex;
    flex: 0 0 auto;
    margin: 0;
}

.reaction-button {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 30px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    padding: 0 10px;
    background: rgba(255, 255, 255, 0.16);
    color: inherit;
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.message-bubble.theirs .reaction-button {
    border-color: rgba(15, 118, 110, 0.2);
    background: rgba(15, 118, 110, 0.1);
}

.reaction-button:hover,
.reaction-button.active {
    border-color: rgba(217, 154, 72, 0.62);
    background: rgba(217, 154, 72, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(16, 23, 25, 0.12);
}

.reaction-button span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.96rem;
    line-height: 1;
}

.reaction-button small {
    min-width: 0;
    color: inherit;
    font-size: 0.68rem;
    font-weight: 900;
    opacity: 0.92;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 5px;
}

.message-delete-form {
    margin: 0;
}

.message-action {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0 9px;
    font-size: 0.72rem;
    font-weight: 850;
    cursor: pointer;
    line-height: 1;
}

.message-action.delete {
    border-color: rgba(227, 93, 91, 0.26);
    background: rgba(255, 255, 255, 0.94);
    color: var(--danger);
    box-shadow: 0 4px 12px rgba(16, 23, 25, 0.08);
}

.message-action.delete:hover {
    border-color: rgba(227, 93, 91, 0.46);
    background: rgba(227, 93, 91, 0.12);
}

.chat-empty {
    margin: 9vh auto 0;
    max-width: 360px;
}

.composer {
    position: fixed;
    z-index: 5;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    max-width: 860px;
    margin: 0 auto;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line-dark);
    background: rgba(248, 250, 249, 0.96);
}

.composer-error {
    grid-column: 1 / -1;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(227, 93, 91, 0.1);
    color: var(--danger);
    font-size: 0.84rem;
    font-weight: 800;
}

.composer textarea {
    min-height: 46px;
    max-height: 130px;
    resize: vertical;
    padding: 11px 12px;
}

.composer button {
    min-width: 70px;
    padding: 0 14px;
}

.file-chip {
    position: relative;
    display: grid;
    max-width: 120px;
    min-width: 58px;
    min-height: 46px;
    place-items: center;
    padding: 0 10px;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background: #fff;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 850;
    overflow: hidden;
}

.file-chip span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-chip input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.sender-name {
    display: block;
    margin-bottom: 4px;
    color: var(--accent-bright);
    font-size: 0.78rem;
}

.attachment-card {
    margin-top: 8px;
    margin-bottom: 2px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    color: inherit;
}

.message-bubble.theirs .attachment-card {
    border-color: rgba(15, 118, 110, 0.1);
    background: rgba(15, 118, 110, 0.08);
}

.attachment-card img,
.attachment-card video,
.attachment-card iframe {
    display: block;
    width: min(320px, 100%);
    max-height: 260px;
    background: #081112;
}

.attachment-card img,
.attachment-card video {
    object-fit: cover;
}

.attachment-card iframe {
    height: 220px;
    border: 0;
    background: #fff;
}

.attachment-card audio {
    display: block;
    width: min(320px, 100%);
    padding: 8px;
}

.document-preview {
    display: grid;
    width: min(320px, 100%);
    min-height: 132px;
    place-items: center;
    background: rgba(255, 255, 255, 0.16);
}

.document-preview span,
.file-badge {
    display: grid;
    width: 64px;
    height: 64px;
    place-items: center;
    border-radius: 8px;
    background: var(--panel-soft);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 900;
}

.attachment-card figcaption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    font-size: 0.86rem;
    font-weight: 800;
}

.attachment-card figcaption span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-card figcaption a {
    flex: 0 0 auto;
    color: inherit;
    text-decoration: underline;
}

.message-bubble.theirs .attachment-card figcaption a {
    color: var(--accent);
}

.profile-card,
.settings-form,
.member-picker,
.danger-zone {
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background: #fff;
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
    padding: 16px;
}

.profile-avatar {
    width: 74px;
    height: 74px;
    flex: 0 0 74px;
    border-radius: 8px;
    object-fit: cover;
}

.profile-avatar.fallback {
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #fff;
    font-size: 1.7rem;
    font-weight: 850;
}

.profile-card h2,
.profile-card p {
    margin: 0;
}

.profile-card p {
    color: var(--muted);
}

.profile-card .sigs-number {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    margin-top: 8px;
    padding: 0 10px;
    border-radius: 8px;
    background: rgba(15, 118, 110, 0.1);
    color: var(--accent);
    font-size: 0.86rem;
    font-weight: 850;
}

.settings-form {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.settings-form textarea,
.settings-form select,
.settings-form input {
    width: 100%;
}

.field textarea {
    min-height: 94px;
    padding: 12px;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    resize: vertical;
}

.upload-field {
    position: relative;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-height: 72px;
    padding: 12px;
    border: 1px dashed rgba(15, 118, 110, 0.35);
    border-radius: 8px;
    background: rgba(15, 118, 110, 0.06);
    color: var(--ink);
    cursor: pointer;
    overflow: hidden;
}

.upload-field:hover {
    border-color: rgba(15, 118, 110, 0.65);
    background: rgba(15, 118, 110, 0.09);
}

.upload-field input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 900;
}

.upload-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid rgba(15, 118, 110, 0.35);
    background: #fff;
}

.upload-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.avatar-upload-field {
    grid-template-columns: 1fr;
    gap: 10px;
    justify-items: start;
    align-items: start;
}

.avatar-upload-field .upload-thumb,
.avatar-upload-field .upload-icon {
    width: 72px;
    height: 72px;
    border-radius: 12px;
}

.avatar-upload-field .upload-copy {
    gap: 4px;
}

.upload-copy strong {
    font-size: 0.95rem;
}

.upload-copy small,
.field-error {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.field-error {
    color: var(--danger);
}

.member-picker {
    padding: 14px;
}

.member-picker ul {
    display: grid;
    gap: 10px;
    padding: 12px 0 0;
    margin: 0;
    list-style: none;
}

.member-picker label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
}

.member-row {
    grid-template-columns: 50px minmax(0, 1fr);
}

.member-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-left: 62px;
}

.member-actions button,
.danger-zone button {
    min-height: 34px;
    border: 0;
    border-radius: 8px;
    background: rgba(15, 118, 110, 0.12);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 850;
}

.member-actions button {
    padding: 0 10px;
}

.member-actions button.danger,
.danger-zone button {
    background: rgba(227, 93, 91, 0.12);
    color: var(--danger);
}

.danger-zone {
    margin-top: 14px;
    padding: 14px;
}

.danger-zone button {
    width: 100%;
}

.files-main {
    padding-top: 14px;
}

.file-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
    gap: 12px;
}

.file-card {
    display: grid;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(17, 24, 28, 0.05);
}

.file-preview {
    position: relative;
    display: grid;
    aspect-ratio: 1;
    place-items: center;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(217, 154, 72, 0.1)),
        #eef4f1;
}

.file-preview img,
.file-preview video,
.file-preview iframe {
    width: 100%;
    height: 100%;
}

.file-preview img,
.file-preview video {
    display: block;
    object-fit: cover;
}

.file-preview iframe {
    border: 0;
    background: #fff;
    pointer-events: none;
}

.file-preview.audio {
    align-content: center;
    gap: 12px;
    padding: 14px;
}

.file-preview audio {
    width: 100%;
    max-width: 100%;
}

.file-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 10px 12px 0;
}

.file-copy strong,
.file-copy span,
.file-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-copy strong {
    font-size: 0.94rem;
}

.file-copy span,
.file-copy small {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
}

.file-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 12px 12px;
}

.file-action {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(15, 118, 110, 0.1);
    color: var(--accent);
    font-size: 0.84rem;
    font-weight: 850;
    text-align: center;
}

.file-action.download {
    background: var(--accent);
    color: #fff;
}

.maps-shell {
    height: 100vh;
    min-height: 100vh;
}

.maps-main {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    padding: 14px 14px calc(116px + env(safe-area-inset-bottom));
}

.map-canvas {
    position: relative;
    flex: 1;
    min-height: 360px;
    overflow: hidden;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.08) 25%, transparent 25%) 0 0 / 28px 28px,
        linear-gradient(225deg, rgba(15, 118, 110, 0.08) 25%, transparent 25%) 0 0 / 28px 28px,
        #eef4f1;
}

.map-fallback {
    position: absolute;
    right: 14px;
    bottom: 14px;
    left: 14px;
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
}

.map-fallback strong,
.map-fallback span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-fallback span,
.map-meta {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 750;
}

.map-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 2px 0;
}

.map-meta a {
    color: var(--accent);
}

@media (min-width: 860px) {
    body.app-screen {
        display: grid;
        place-items: center;
        padding: 28px;
    }

    .mobile-shell {
        width: min(100%, 860px);
        min-height: min(920px, calc(100vh - 56px));
        max-height: calc(100vh - 56px);
        overflow: hidden;
        border: 1px solid rgba(255, 255, 255, 0.16);
        border-radius: 8px;
        box-shadow: var(--shadow);
    }

    .bottom-nav {
        position: relative;
        right: auto;
        bottom: auto;
        left: auto;
        max-width: none;
        flex: 0 0 auto;
        box-shadow: none;
    }

    .composer {
        position: sticky;
        max-width: none;
    }

    .conversation-main {
        padding-bottom: 18px;
    }

    .maps-main {
        padding-bottom: 18px;
    }

    .chat-shell {
        height: min(920px, calc(100vh - 56px));
        min-height: 0;
    }
}

@media (max-width: 420px) {
    .auth-screen {
        padding: 0;
        place-items: stretch;
    }

    .auth-panel {
        min-height: 100vh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .app-header,
    .chat-header {
        gap: 10px;
        min-height: 68px;
        padding: calc(12px + env(safe-area-inset-top)) 12px 12px;
    }

    .app-header h1 {
        font-size: 1.55rem;
    }

    .account-chip {
        min-height: 26px;
        font-size: 0.72rem;
    }

    .header-actions {
        gap: 6px;
    }

    .icon-button,
    .back-link,
    .logout-button {
        min-width: 40px;
        min-height: 40px;
        font-size: 0.74rem;
    }

    .logout-button {
        padding: 0 10px;
    }

    .conversation-main {
        padding: 12px 10px calc(116px + env(safe-area-inset-bottom));
    }

    .cat-main {
        gap: 12px;
        padding: 12px 10px calc(24px + env(safe-area-inset-bottom));
    }

    .cat-hero,
    .cat-hero-copy {
        min-height: 440px;
    }

    .cat-hero-copy {
        padding: 20px;
    }

    .cat-hero::after {
        background:
            linear-gradient(0deg, rgba(7, 19, 21, 0.9), rgba(7, 19, 21, 0.34) 66%, rgba(7, 19, 21, 0.04)),
            linear-gradient(90deg, rgba(7, 19, 21, 0.45), transparent 58%);
    }

    .cat-grid,
    .cat-alert {
        grid-template-columns: 1fr;
    }

    .cat-card {
        padding: 14px;
    }

    .cat-card img {
        height: 210px;
        margin: -14px -14px 14px;
        width: calc(100% + 28px);
    }

    .cat-alert img {
        height: 230px;
        min-height: 0;
    }

    .cat-alert div {
        padding: 18px;
    }

    .maps-main {
        padding: 10px 10px calc(112px + env(safe-area-inset-bottom));
    }

    .location-status {
        padding: 9px 12px;
    }

    .quick-start,
    .search-window {
        padding: 12px;
    }

    .quick-start h2,
    .search-window h2,
    .empty-state h2 {
        font-size: 1.05rem;
    }

    .search-results {
        max-height: min(300px, 38vh);
    }

    .thread-row {
        grid-template-columns: 46px minmax(0, 1fr);
        gap: 10px;
        padding: 10px;
    }

    .thread-time {
        display: none;
    }
}

@media (max-width: 360px) {
    .inline-form {
        grid-template-columns: 1fr;
    }

    .inline-form button {
        min-height: 44px;
        width: 100%;
    }

    .quick-links a {
        width: 100%;
        justify-content: center;
    }

    .bottom-nav {
        gap: 6px;
        padding-right: 10px;
        padding-left: 10px;
    }

    .bottom-nav a {
        min-height: 42px;
        font-size: 0.72rem;
    }

    .file-gallery {
        grid-template-columns: 1fr;
    }
}
