/* Mobile-first WebChat */

:root {
    --bg-app: #0b141a;
    --bg-panel: #111b21;
    --bg-bubble-in: #202c33;
    --bg-bubble-out: #005c4b;
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --accent: #00a884;
    --accent-dark: #008069;
    --danger: #ea4335;
    --header-h: 56px;
    --composer-h: 62px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

body {
    font-family: var(--font);
    background: var(--bg-app);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Login ── */

.page-login {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    padding-top: calc(24px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
    background: linear-gradient(160deg, #0b141a 0%, #1a2a32 100%);
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--bg-panel);
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

/* ── Safia entry gate ── */

body.entry-gate-active #chatApp,
body.entry-gate-active #photoUploadPreview,
body.entry-gate-active #photoLightbox {
    display: none !important;
}

.entry-gate {
    position: fixed;
    inset: 0;
    z-index: 160;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(11, 20, 26, 0.92);
}

.entry-gate[hidden] {
    display: none !important;
}

.entry-gate-card {
    position: relative;
    width: 100%;
    max-width: 340px;
    padding: 32px 22px 22px;
    border-radius: 14px;
    background: var(--bg-panel);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.entry-gate-close {
    position: absolute;
    top: 8px;
    left: 10px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.15rem;
    line-height: 1;
    opacity: 0.4;
    cursor: pointer;
}

.entry-gate-close:active {
    opacity: 0.65;
}

.entry-gate-text {
    margin: 0 0 18px;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--text-primary);
    text-align: center;
}

.entry-gate-continue {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.entry-gate-continue:active {
    opacity: 0.9;
}

.setup-card h1 {
    margin: 0 0 8px;
    font-size: 1.4rem;
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.login-brand h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.login-sub {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-error {
    background: rgba(234, 67, 53, 0.15);
    color: #ff8a80;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    margin: 0 0 16px;
}

.setup-ok {
    color: var(--accent);
    font-size: 0.875rem;
    margin: 8px 0;
}

.setup-ok a {
    color: var(--text-primary);
}

.login-form input[type="password"],
.login-form input.login-secret {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #2a3942;
    border-radius: 10px;
    background: #1e2a30;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.25;
    margin-bottom: 12px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-form input.login-secret::placeholder {
    color: #8696a0;
    letter-spacing: normal;
    opacity: 1;
}

.login-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.22);
}

.btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    padding: 14px 20px;
    transition: background 0.15s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

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

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

.btn-block {
    width: 100%;
}

/* ── Chat layout ── */

.page-chat,
.page-chat * {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.page-chat *::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.page-chat {
    height: 100dvh;
    overflow: hidden;
}

body.photo-lightbox-open {
    overflow: hidden;
}

.chat-app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 720px;
    margin: 0 auto;
    background: var(--bg-app);
}

.chat-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: calc(var(--header-h) + var(--safe-top));
    padding: var(--safe-top) 12px 0 16px;
    background: var(--bg-panel);
    border-bottom: 1px solid #222d34;
    z-index: 10;
}

.chat-header-info {
    min-width: 0;
    flex: 1;
}

.btn-header-fotos {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 10px;
    margin-right: 2px;
    border: none;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.btn-header-fotos.active {
    background: rgba(0, 168, 132, 0.2);
    color: var(--accent);
}

.btn-header-fotos:active {
    background: rgba(255, 255, 255, 0.1);
}

/* Main content area — both views share the same space below the header */
.app-main {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.view-panel {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    z-index: 0;
}

.view-panel.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 1;
}

html.prefers-photos-view .view-chat {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 0;
}

html.prefers-photos-view .view-photos {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 1;
}

html.prefers-photos-view .btn-header-fotos {
    background: rgba(0, 168, 132, 0.2);
    color: var(--accent);
}

.view-chat {
    /* messages + composer live here; composer hidden automatically when panel inactive */
}

.view-photos {
    background: var(--bg-app);
}


.photos-fab {
    position: absolute;
    left: 50%;
    bottom: calc(14px + var(--safe-bottom));
    z-index: 4;
    transform: translateX(-50%);
    pointer-events: none;
}

.photos-fab .btn-upload-photo {
    pointer-events: auto;
    box-shadow: 0 4px 22px rgba(0, 0, 0, 0.45);
}

.btn-upload-photo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 24px;
    background: var(--accent);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-upload-photo:active {
    background: var(--accent-dark);
}

.photos-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(76px + var(--safe-bottom));
}

.photos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 2px;
    align-content: start;
}

.photos-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

body.photo-upload-open {
    overflow: hidden;
}

.photo-upload-preview {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(11, 20, 26, 0.96);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.photo-upload-preview.is-open {
    animation: photoPreviewIn 0.2s ease;
}

.photo-upload-preview[hidden] {
    display: none !important;
}

@keyframes photoPreviewIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.photo-upload-preview-card {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.photo-upload-preview-media {
    width: 100%;
    min-height: 120px;
}

.photo-upload-preview-media img,
.photo-upload-preview-media video {
    width: 100%;
    max-height: min(52dvh, 420px);
    object-fit: contain;
    border-radius: 12px;
    background: #000;
    display: block;
}

.photo-preview-meta-pill {
    margin: 0;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(30, 42, 48, 0.92);
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.3;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
}

.photo-preview-meta-pill .photo-preview-compression {
    flex-shrink: 0;
    color: var(--text-secondary);
    opacity: 0.9;
}

.photo-preview-meta-pill .photo-preview-compression[hidden],
.photo-preview-meta-pill .photo-preview-sep[hidden] {
    display: none !important;
}

.photo-preview-meta-pill .photo-preview-counter {
    flex-shrink: 0;
}

.photo-preview-meta-pill .photo-preview-sep {
    flex-shrink: 0;
    opacity: 0.55;
}

.photo-preview-meta-pill .photo-preview-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-preview-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.photo-preview-nav[hidden] {
    display: none !important;
}

.btn-preview-nav {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.btn-preview-nav:active {
    background: rgba(255, 255, 255, 0.16);
}

.photo-preview-actions {
    display: flex;
    gap: 10px;
}

.btn-preview-discard,
.btn-preview-send {
    flex: 1;
    min-height: 46px;
    border: none;
    border-radius: 23px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-preview-discard {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-preview-discard:active {
    background: rgba(255, 255, 255, 0.14);
}

.btn-preview-send {
    background: var(--accent);
    color: #fff;
}

.btn-preview-send:active {
    background: var(--accent-dark);
}

.btn-preview-send:disabled,
.btn-preview-discard:disabled {
    opacity: 0.55;
    cursor: default;
}

.photos-status {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(72px + var(--safe-bottom));
    z-index: 5;
    margin: 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(30, 42, 48, 0.96);
    color: var(--text-primary);
    font-size: 0.85rem;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.photos-status[hidden] {
    display: none !important;
}

.photos-status.is-error {
    color: #ffb4a9;
}

.photo-item {
    position: relative;
    overflow: hidden;
    background: var(--bg-panel);
}

/* Sicherer Hintergrund für Safia (iOS Download-Schutz) */
.photo-safe-bg {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.photo-safe-bg--lightbox {
    background-size: contain;
}


.photo-thumb-btn {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    aspect-ratio: 1;
    overflow: hidden;
}

.photo-thumb-btn img,
.photo-thumb-btn video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.media-play-badge {
    position: absolute;
    left: 50%;
    top: 42%;
    z-index: 1;
    transform: translate(-50%, -50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.82rem;
    line-height: 1;
    pointer-events: none;
}

.photo-meta {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    margin: 0;
    padding: 16px 4px 4px;
    font-size: 0.58rem;
    line-height: 1.2;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.38) 55%, transparent 100%);
    pointer-events: none;
}

.photo-download {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    text-decoration: none;
}

.photo-download:active {
    background: rgba(0, 0, 0, 0.75);
}

.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.96);
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
}

.photo-lightbox[hidden] {
    display: none !important;
}

.photo-lightbox-close {
    position: absolute;
    top: calc(10px + var(--safe-top));
    right: 10px;
    z-index: 3;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.photo-lightbox-counter {
    position: absolute;
    top: calc(18px + var(--safe-top));
    left: 50%;
    z-index: 3;
    transform: translateX(-50%);
    margin: 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.72);
    pointer-events: none;
}

.photo-lightbox-viewport {
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
    cursor: grab;
}

.photo-lightbox-viewport.is-dragging {
    cursor: grabbing;
    touch-action: none;
}

.photo-lightbox-track {
    display: flex;
    height: 100%;
    will-change: transform;
}

.photo-lightbox-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 52px 8px 8px;
    box-sizing: border-box;
}

.photo-lightbox-slide img,
.photo-lightbox-slide video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 2px;
    pointer-events: auto;
    -webkit-user-drag: none;
    user-drag: none;
}

.photo-lightbox-slide video {
    background: #000;
}

.photo-lightbox-meta {
    flex-shrink: 0;
    margin: 0;
    padding: 6px 16px 0;
    text-align: center;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.78);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-lightbox-actions {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 12px;
    padding: 0 12px;
}

.btn-lightbox-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 22px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-lightbox-download:active {
    background: var(--accent-dark);
}

.btn-lightbox-delete {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: 22px;
    background: rgba(255, 90, 90, 0.18);
    color: #ffb4a9;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-lightbox-delete:active {
    background: rgba(255, 90, 90, 0.32);
}

.btn-lightbox-delete:disabled {
    opacity: 0.55;
    cursor: default;
}

.chat-header h1 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-status {
    margin: 2px 0 0;
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-status.online {
    color: var(--accent);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: var(--text-secondary);
    text-decoration: none;
    flex-shrink: 0;
}

.btn-icon:active {
    background: rgba(255, 255, 255, 0.06);
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 12px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background:
        radial-gradient(circle at 20% 30%, rgba(0, 168, 132, 0.04) 0%, transparent 50%),
        var(--bg-app);
}

.chat-messages::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.msg-date-separator {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 10px 0 6px;
    pointer-events: none;
}

.msg-date-pill {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 8px;
    background: rgba(30, 42, 48, 0.92);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.msg-row {
    display: flex;
    width: 100%;
}

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

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

.msg-row.msg-enter {
    /* animation on .msg-bubble */
}

.msg-bubble.bubble-enter {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    will-change: opacity, transform;
}

.msg-row.mine .msg-bubble.bubble-enter {
    transform: translateY(10px) translateX(6px) scale(0.98);
}

.msg-row.theirs .msg-bubble.bubble-enter {
    transform: translateY(10px) translateX(-6px) scale(0.98);
}

.msg-bubble.bubble-enter-active {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
    transition: opacity 0.24s ease-out, transform 0.24s ease-out;
}

.msg-bubble {
    max-width: 82%;
    padding: 8px 10px 6px;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.msg-row.mine .msg-bubble {
    background: var(--bg-bubble-out);
    border-bottom-right-radius: 4px;
}

.msg-row.theirs .msg-bubble {
    background: var(--bg-bubble-in);
    border-bottom-left-radius: 4px;
}

.msg-text {
    font-size: 0.95rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

.msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
}

.msg-time {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.55);
}

.msg-read {
    display: inline-flex;
    align-items: center;
    margin-left: 3px;
    line-height: 0;
    color: rgba(255, 255, 255, 0.45);
}

.msg-read.read {
    color: #53b7f1;
}

.msg-read.read .tick-icon {
    filter: drop-shadow(0 0 1px rgba(83, 183, 241, 0.4));
}

.msg-read .tick-icon {
    display: block;
    overflow: visible;
}

.msg-read .tick-icon:not(.tick-double) {
    width: 13px;
    height: 11px;
}

.msg-read .tick-double {
    width: 18px;
    height: 11px;
}

.msg-read .tick-back {
    opacity: 0.9;
}

.msg-voice {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: min(240px, 72vw);
    padding: 2px 0;
}

.voice-waveform {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    width: 100%;
    height: 28px;
    min-width: 0;
    overflow: hidden;
}

.voice-wave-bar {
    flex: 0 0 3px;
    width: 3px;
    min-width: 3px;
    max-width: 3px;
    height: calc(var(--h, 0.2) * 100%);
    min-height: 3px;
    max-height: 100%;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.38);
    align-self: center;
    transition: height 0.08s ease, background-color 0.12s ease;
}

.voice-waveform .voice-wave-bar.played {
    background: #53b7f1;
}

.voice-duration {
    flex-shrink: 0;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.65);
    min-width: 2.2rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.composer-voice-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 6px 12px;
    border-radius: 22px;
    background: #1e2a30;
}

.composer-voice-wrap[hidden] {
    display: none !important;
}

.composer-recording-waveform {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    width: 100%;
    height: 28px;
    min-width: 0;
    overflow: hidden;
}

.composer-recording-waveform .voice-wave-bar {
    flex: 0 0 3px;
    width: 3px;
    min-width: 3px;
    max-width: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
}

.composer-voice-wrap.is-recording .composer-recording-waveform .voice-wave-bar {
    background: rgba(234, 67, 53, 0.8);
}

.composer-recording-timer {
    flex-shrink: 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.75);
    font-variant-numeric: tabular-nums;
    min-width: 2.4rem;
}

.composer-voice-wrap.is-recording .composer-recording-timer {
    color: var(--danger);
}

.composer-voice-wrap.is-preview .composer-recording-waveform .voice-wave-bar {
    background: rgba(255, 255, 255, 0.5);
    transition: none;
}

.voice-play-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.voice-play-btn:active:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.voice-play-btn:disabled {
    opacity: 0.6;
}

.voice-play-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.voice-play-icon .voice-icon-svg {
    width: 22px;
    height: 22px;
    display: block;
}

.voice-play-btn.is-playing .voice-icon-svg {
    width: 20px;
    height: 20px;
}

.voice-duration.voice-play-error,
.voice-play-label.voice-play-error {
    color: #ffb4a9;
    font-size: 0.75rem;
}

.msg-voice audio {
    display: none;
}

/* ── Composer ── */

.chat-composer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 8px calc(8px + var(--safe-bottom));
    background: var(--bg-panel);
    border-top: 1px solid #222d34;
}

.composer-input-wrap {
    flex: 1;
    min-width: 0;
}

.composer-input-wrap textarea {
    width: 100%;
    max-height: 120px;
    min-height: 44px;
    padding: 11px 14px;
    border: none;
    border-radius: 22px;
    background: #1e2a30;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.35;
    resize: none;
    outline: none;
}

.btn-voice,
.btn-send {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    background: transparent;
    position: relative;
}

.btn-voice:active,
.btn-send:active {
    background: rgba(255, 255, 255, 0.06);
}

.btn-voice.recording {
    color: var(--danger);
    background: rgba(234, 67, 53, 0.15);
    animation: pulse-rec 1s ease infinite;
}

.btn-voice .icon-trash {
    display: none;
}

.btn-voice.preview-mode .icon-mic {
    display: none;
}

.btn-voice.preview-mode .icon-trash {
    display: block !important;
    color: var(--danger);
}

.btn-voice.preview-mode {
    color: var(--danger);
    animation: none;
}

@keyframes pulse-rec {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

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

.btn-send:disabled {
    background: #2a3942;
    color: #667781;
    cursor: default;
}

.btn-send:not(:disabled):active {
    background: var(--accent-dark);
}

/* ── Desktop tweaks ── */

@media (min-width: 721px) {
    .chat-app {
        border-left: 1px solid #222d34;
        border-right: 1px solid #222d34;
    }

    .msg-bubble {
        max-width: 65%;
    }
}
