:root {
    --wm-primary-rgb: 51, 144, 236;
    --wm-surface: #ffffff;
    --wm-surface-soft: #f8fafc;
    --wm-surface-elevated: rgba(255, 255, 255, 0.92);
    --wm-border-soft: rgba(148, 163, 184, 0.22);
    --wm-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 3px 12px rgba(15, 23, 42, 0.04);
    --wm-shadow-md: 0 12px 32px rgba(15, 23, 42, 0.10);
    --wm-radius-sm: 10px;
    --wm-radius-md: 16px;
    --wm-radius-lg: 24px;
    --wm-safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
    --wm-surface: #111b27;
    --wm-surface-soft: #0c1520;
    --wm-surface-elevated: rgba(17, 27, 39, 0.92);
    --wm-border-soft: rgba(148, 163, 184, 0.16);
    --wm-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0, 0, 0, 0.1);
    --wm-shadow-md: 0 16px 40px rgba(0, 0, 0, 0.28);
}

html {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100dvh;
}

/* Modern authentication */
.login-page {
    min-height: 100dvh;
    overflow-x: hidden;
    background: #f5f8fc;
}

.auth-shell {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(420px, 1.05fr) minmax(430px, 0.95fr);
}

.auth-showcase {
    position: relative;
    min-height: 100dvh;
    padding: clamp(34px, 5vw, 72px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    isolation: isolate;
    color: #fff;
    background:
        radial-gradient(circle at 18% 14%, rgba(125, 211, 252, 0.28), transparent 30%),
        linear-gradient(145deg, #0f4c9a 0%, #246fd2 46%, #635bdf 100%);
}

.auth-showcase::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -2;
    opacity: 0.18;
    background-image:
        linear-gradient(rgba(255,255,255,.13) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.13) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, #000, transparent 88%);
}

.auth-showcase::after {
    content: "";
    position: absolute;
    width: 460px;
    height: 460px;
    inset-inline-end: -210px;
    bottom: -180px;
    z-index: -1;
    border: 80px solid rgba(255,255,255,.07);
    border-radius: 50%;
}

.auth-showcase-orb {
    position: absolute;
    z-index: -1;
    border-radius: 50%;
    filter: blur(2px);
    pointer-events: none;
}

.auth-showcase-orb-one {
    width: 190px;
    height: 190px;
    inset-inline-start: -75px;
    top: 35%;
    background: rgba(56, 189, 248, 0.14);
}

.auth-showcase-orb-two {
    width: 110px;
    height: 110px;
    inset-inline-end: 12%;
    top: 12%;
    background: rgba(255,255,255,.09);
}

.auth-showcase-content {
    width: min(100%, 650px);
    margin: auto;
}

.auth-showcase-brand,
.auth-mobile-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-showcase-brand {
    position: absolute;
    top: clamp(28px, 4vw, 52px);
    inset-inline-start: clamp(30px, 5vw, 72px);
}

.auth-showcase-brand strong {
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.auth-brand-mark {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 14px;
    color: #1d4ed8;
    font-size: 1.35rem;
    background: #fff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
}

.auth-brand-mark-image {
    overflow: hidden;
}

.auth-brand-mark-image img {
    width: 100%;
    height: 100%;
    padding: 5px;
    object-fit: contain;
}

.auth-showcase-copy {
    max-width: 570px;
}

.auth-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 20px;
    padding: 7px 12px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    color: rgba(255,255,255,.9);
    font-size: 0.74rem;
    background: rgba(255,255,255,.1);
    backdrop-filter: blur(10px);
}

.auth-showcase-copy h1 {
    margin: 0;
    font-size: clamp(2.5rem, 5vw, 4.8rem);
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: -0.055em;
}

.auth-showcase-copy h1 span {
    color: #bae6fd;
}

.auth-showcase-copy p {
    max-width: 530px;
    margin: 24px 0 0;
    color: rgba(255,255,255,.74);
    font-size: clamp(0.88rem, 1.3vw, 1.05rem);
    line-height: 2;
}

.auth-feature-grid {
    max-width: 560px;
    margin-top: 42px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.auth-feature {
    min-width: 0;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 11px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 16px;
    background: rgba(255,255,255,.08);
    backdrop-filter: blur(12px);
}

.auth-feature > i {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 11px;
    color: #dbeafe;
    background: rgba(255,255,255,.13);
}

.auth-feature span,
.auth-feature strong,
.auth-feature small {
    display: block;
    min-width: 0;
}

.auth-feature strong {
    font-size: 0.78rem;
}

.auth-feature small {
    margin-top: 3px;
    color: rgba(255,255,255,.62);
    font-size: 0.65rem;
}

.auth-showcase-footer {
    position: absolute;
    inset-inline-start: clamp(30px, 5vw, 72px);
    bottom: clamp(24px, 4vw, 44px);
    display: flex;
    align-items: center;
    gap: 7px;
    color: rgba(255,255,255,.66);
    font-size: 0.7rem;
}

.auth-showcase-footer .status-dot.online {
    box-shadow: 0 0 0 4px rgba(74, 222, 128, .15);
}

.auth-form-side {
    min-height: 100dvh;
    padding: clamp(24px, 5vw, 68px);
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 90% 4%, rgba(var(--wm-primary-rgb), .08), transparent 25%),
        #f8fafc;
}

.auth-mobile-brand {
    display: none;
}

.auth-card {
    width: min(100%, 430px);
    padding: clamp(26px, 4vw, 42px);
    border: 1px solid rgba(148, 163, 184, .2);
    border-radius: 28px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .10);
    backdrop-filter: blur(18px);
}

.auth-card-header {
    margin-bottom: 28px;
    text-align: center;
}

.auth-card-icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 17px;
    color: #fff;
    font-size: 1.35rem;
    background: linear-gradient(135deg, var(--wm-primary), #6366f1);
    box-shadow: 0 12px 25px rgba(var(--wm-primary-rgb), .25);
}

.auth-card-header h2 {
    margin: 0;
    color: #0f172a;
    font-size: 1.55rem;
    font-weight: 900;
    letter-spacing: -0.035em;
}

.auth-card-header p {
    margin: 9px 0 0;
    color: #64748b;
    font-size: 0.78rem;
    line-height: 1.8;
}

.auth-alert {
    margin-bottom: 20px;
    padding: 11px 13px;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    border: 1px solid rgba(239, 68, 68, .16);
    border-radius: 13px;
    color: #b91c1c;
    font-size: 0.76rem;
    background: #fef2f2;
}

.auth-form {
    display: grid;
    gap: 18px;
}

.auth-field label {
    margin-bottom: 7px;
    display: block;
    color: #334155;
    font-size: 0.74rem;
    font-weight: 700;
}

.auth-input-wrap {
    position: relative;
}

.auth-input-wrap > i {
    position: absolute;
    top: 50%;
    inset-inline-start: 15px;
    z-index: 2;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.auth-input-wrap .form-control {
    height: 50px;
    padding-inline: 43px 45px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    color: #0f172a;
    font-size: 0.79rem;
    background: #f8fafc;
    box-shadow: none;
}

.auth-input-wrap .form-control::placeholder {
    color: #a1aab8;
}

.auth-input-wrap .form-control:hover {
    border-color: #cbd5e1;
}

.auth-input-wrap .form-control:focus {
    border-color: rgba(var(--wm-primary-rgb), .65);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(var(--wm-primary-rgb), .1);
}

.auth-password-toggle {
    position: absolute;
    top: 50%;
    inset-inline-end: 8px;
    z-index: 3;
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    border: 0;
    border-radius: 9px;
    color: #64748b;
    background: transparent;
}

.auth-password-toggle:hover {
    color: var(--wm-primary);
    background: rgba(var(--wm-primary-rgb), .08);
}

.auth-captcha {
    display: grid;
    gap: 9px;
}

.auth-captcha-image {
    height: 54px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
}

.auth-captcha-image img {
    height: 44px;
    max-width: calc(100% - 45px);
    object-fit: contain;
}

.auth-captcha-image button {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 0;
    border-radius: 10px;
    color: var(--wm-primary);
    background: rgba(var(--wm-primary-rgb), .08);
}

.auth-captcha-image button.is-rotating i {
    animation: authRotate .45s ease;
}

.auth-submit {
    min-height: 51px;
    margin-top: 4px;
    padding: 11px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    border-radius: 14px;
    color: #fff;
    font-size: 0.84rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--wm-primary), #4f46e5);
    box-shadow: 0 12px 24px rgba(var(--wm-primary-rgb), .23);
    transition: transform .15s ease, box-shadow .15s ease;
}

.auth-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 15px 30px rgba(var(--wm-primary-rgb), .3);
}

.auth-submit:disabled {
    opacity: .72;
    transform: none;
}

.auth-card-footer {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid #eef2f7;
    color: #94a3b8;
    font-size: 0.67rem;
    text-align: center;
}

.auth-card-footer i {
    margin-inline-end: 4px;
    color: #22c55e;
}

@keyframes authRotate {
    to { transform: rotate(-360deg); }
}

.btn {
    border-radius: var(--wm-radius-sm);
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

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

.btn-primary {
    border: 0;
    background: linear-gradient(135deg, var(--wm-primary), color-mix(in srgb, var(--wm-primary) 72%, #2563eb));
    box-shadow: 0 7px 18px rgba(var(--wm-primary-rgb), 0.22);
}

.form-control,
.form-select {
    border-radius: var(--wm-radius-sm);
    border-color: var(--wm-border-soft);
    background-color: var(--wm-surface);
    color: var(--wm-text);
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(var(--wm-primary-rgb), 0.54);
    box-shadow: 0 0 0 3px rgba(var(--wm-primary-rgb), 0.12);
}

.modal-content,
.dropdown-menu {
    border: 1px solid var(--wm-border-soft);
    border-radius: var(--wm-radius-md);
    box-shadow: var(--wm-shadow-md);
}

/* Modern messenger shell */
html.wm-viewport-lock,
html.wm-viewport-lock body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

.messenger-page {
    overflow: hidden;
    background:
        radial-gradient(circle at 90% 0%, rgba(var(--wm-primary-rgb), 0.08), transparent 28%),
        var(--wm-surface-soft);
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overscroll-behavior: none;
    touch-action: manipulation;
}

.messenger-app {
    position: fixed;
    top: var(--wm-vv-top, 0px);
    left: 0;
    right: 0;
    width: 100%;
    height: var(--wm-app-height, 100dvh);
    max-height: var(--wm-app-height, 100dvh);
    overflow: hidden;
    background: var(--wm-surface);
    /* Keep composer / chat list above Android system nav in installed PWA */
    padding-bottom: var(--wm-safe-bottom, env(safe-area-inset-bottom, 0px));
}

.chat-sidebar {
    width: clamp(310px, 27vw, 390px);
    background: var(--wm-surface);
    border-color: var(--wm-border-soft);
    box-shadow: 8px 0 28px rgba(15, 23, 42, 0.035);
    z-index: 20;
}

.sidebar-header,
.chat-header {
    min-height: 72px;
    background: var(--wm-surface-elevated);
    border-color: var(--wm-border-soft) !important;
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.sidebar-header {
    position: relative;
    z-index: 30;
    padding: 14px 16px !important;
}

.sidebar-header .dropdown-menu {
    z-index: 1050;
}

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

.sidebar-brand-mark {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, var(--wm-primary), #7c3aed);
    box-shadow: 0 8px 18px rgba(var(--wm-primary-rgb), 0.22);
}

.sidebar-brand small {
    display: block;
    margin-top: 2px;
    color: var(--wm-text-muted);
    font-size: 0.64rem;
}

.sidebar-brand .sidebar-brand-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sidebar-title {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.sidebar-header-actions {
    display: flex !important;
    align-items: center;
    gap: 4px !important;
}

.sidebar-header-actions > .dropdown {
    display: inline-flex;
    align-items: center;
    align-self: center;
}

.sidebar-header-actions .btn,
.chat-actions .btn,
#btnBack,
#btnExpandSidebar {
    width: 38px;
    height: 38px;
    padding: 0;
    align-items: center;
    justify-content: center;
    align-self: center;
    flex-shrink: 0;
    line-height: 1;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--wm-text-muted);
}

/* Do not use !important on display — it breaks Bootstrap d-none / d-md-* on mobile. */
.sidebar-header-actions .btn:not(.d-none),
.chat-actions .btn:not(.d-none),
#btnBack:not(.d-none),
#btnExpandSidebar:not(.d-none) {
    display: inline-flex;
}

.sidebar-header-actions .btn i,
.chat-actions .btn i,
#btnBack i,
#btnExpandSidebar i,
#btnCollapseSidebar i {
    display: block;
    line-height: 1;
    font-size: 1.1rem;
}

/* Back chevron: points left in LTR, right in RTL */
[dir="rtl"] .wm-back-icon {
    transform: scaleX(-1);
}

.sidebar-header-actions .btn:hover,
.chat-actions .btn:hover,
#btnBack:hover,
#btnExpandSidebar:hover {
    background: rgba(var(--wm-primary-rgb), 0.1);
    color: var(--wm-primary);
}

.messenger-account-menu {
    width: 230px;
    padding: 8px;
}

.messenger-account-menu-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
}

.messenger-account-menu-head > span:last-child {
    min-width: 0;
}

.messenger-account-menu-head strong,
.messenger-account-menu-head small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.messenger-account-menu-head strong {
    color: var(--wm-text);
    font-size: 0.82rem;
}

.messenger-account-menu-head small {
    color: var(--wm-text-muted);
    font-size: 0.68rem;
}

.messenger-account-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 9px;
    font-size: 0.78rem;
}

.messenger-account-menu .dropdown-item i {
    width: 20px;
    color: var(--wm-text-muted);
    text-align: center;
}

.chat-more-menu {
    min-width: 200px;
    padding: 8px;
}

.chat-more-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 9px;
    font-size: 0.78rem;
    line-height: 1.35;
}

.chat-more-menu .dropdown-item i {
    width: 18px;
    font-size: 0.95em;
    color: var(--wm-text-muted);
    text-align: center;
}

.chat-more-menu .dropdown-item.text-danger i {
    color: inherit;
}

.chat-more-menu .dropdown-divider {
    margin: 6px 4px;
}

#searchContacts {
    height: 44px;
    padding-inline-start: 42px;
    border: 0;
    border-radius: 14px;
    background:
        linear-gradient(var(--wm-surface-soft), var(--wm-surface-soft)) padding-box,
        linear-gradient(135deg, rgba(var(--wm-primary-rgb), 0.18), transparent) border-box;
    box-shadow: inset 0 0 0 1px var(--wm-border-soft);
}

.sidebar-search {
    position: relative;
    z-index: 1;
}

.sidebar-search::before {
    content: "\F52A";
    position: absolute;
    inset-inline-start: 29px;
    top: 11px;
    z-index: 2;
    font-family: "bootstrap-icons";
    color: var(--wm-text-muted);
    pointer-events: none;
}

.chat-list {
    padding: 4px 8px 12px;
    scrollbar-width: thin;
}

.chat-list .chat-item {
    min-height: 72px;
    margin: 3px 0;
    padding: 10px 11px;
    border: 0;
    border-radius: 15px;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.chat-item-name,
.chat-item-preview,
.chat-item-time,
.sidebar-title,
.sidebar-brand-status,
.chat-header .chat-title,
#chatTitle,
#chatStatus {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.chat-list .chat-item:hover {
    background: rgba(var(--wm-primary-rgb), 0.07);
}

.chat-list .chat-item.active {
    background: linear-gradient(135deg, rgba(var(--wm-primary-rgb), 0.16), rgba(var(--wm-primary-rgb), 0.07));
    box-shadow: inset 0 0 0 1px rgba(var(--wm-primary-rgb), 0.12);
}

.chat-list .avatar-circle {
    box-shadow: 0 0 0 3px var(--wm-surface), 0 4px 14px rgba(15, 23, 42, 0.12);
}

.chat-item-name {
    font-size: 0.92rem;
    letter-spacing: -0.01em;
}

.chat-item-preview {
    margin-top: 4px;
    font-size: 0.78rem;
}

.unread-badge {
    min-width: 21px;
    height: 21px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border-radius: 999px;
    box-shadow: 0 4px 10px rgba(var(--wm-primary-rgb), 0.25);
}

.chat-main {
    position: relative;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    background:
        linear-gradient(rgba(var(--wm-primary-rgb), 0.018), rgba(var(--wm-primary-rgb), 0.018)),
        var(--wm-bg);
}

.chat-header {
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    padding: 10px 18px !important;
    box-shadow: var(--wm-shadow-sm);
}

.chat-header .avatar-circle {
    width: 44px;
    height: 44px;
    font-size: 1rem;
}

#chatTitle {
    font-size: 0.97rem;
}

#chatStatus {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
}

.chat-empty {
    background:
        radial-gradient(circle at center, rgba(var(--wm-primary-rgb), 0.09), transparent 34%);
}

.chat-empty > div {
    padding: 28px 32px;
    border: 1px solid var(--wm-border-soft);
    border-radius: var(--wm-radius-lg);
    background: var(--wm-surface-elevated);
    box-shadow: var(--wm-shadow-sm);
}

.chat-empty .bi {
    color: var(--wm-primary);
}

.messages-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.messages-area {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    padding: 20px clamp(14px, 4vw, 64px) 32px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.message-row {
    margin-bottom: 6px;
}

.message-bubble {
    padding: 9px 12px;
    border-radius: 16px;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.07);
}

/* Sharp corner only on first message of a consecutive cluster */
[dir="ltr"] .message-bubble.sent.bubble-cluster-start,
[dir="rtl"] .message-bubble.sent.bubble-cluster-start {
    border-top-right-radius: 5px;
}

[dir="ltr"] .message-bubble.received.bubble-cluster-start,
[dir="rtl"] .message-bubble.received.bubble-cluster-start {
    border-top-left-radius: 5px;
    border-color: var(--wm-border-soft);
}

.message-bubble.received,
.message-bubble.is-media-bubble,
.message-bubble:has(.msg-image-wrap),
.message-bubble:has(.msg-video-wrap),
.message-bubble:has(.media-load-placeholder) {
    border-color: var(--wm-border-soft);
}

.messages-date-sticky,
.message-date-divider span {
    border: 1px solid var(--wm-border-soft);
    border-radius: 999px;
    background: var(--wm-surface-elevated);
    color: var(--wm-text);
    box-shadow: var(--wm-shadow-sm);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

.chat-input {
    z-index: 12;
    flex-shrink: 0;
    border-color: var(--wm-border-soft) !important;
    background: var(--wm-surface-elevated);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    /* Shell (.messenger-app) already reserves --wm-safe-bottom for system nav */
    padding-bottom: 0;
}

body.wm-keyboard-open .chat-input {
    padding-bottom: 6px;
}

#messageBody {
    scroll-margin: 0;
}

.select-toolbar,
.chat-search-bar {
    flex-shrink: 0;
}

.chat-composer {
    padding: 10px clamp(12px, 2vw, 24px) !important;
}

#messageForm {
    max-width: 980px;
    margin: 0 auto;
    align-items: center !important;
    gap: 7px !important;
}

#messageForm > .dropdown > .btn,
#messageForm > .composer-attach-wrap > .btn,
#btnEmoji {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--wm-text-muted);
    background: var(--wm-surface-soft);
}

#messageBody {
    min-height: 44px;
    padding: 10px 15px;
    border: 1px solid var(--wm-border-soft);
    border-radius: 15px;
    background: var(--wm-surface);
}

#btnSend {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.composer-send-btn {
    color: var(--wm-primary) !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 1.42rem;
    text-decoration: none !important;
}

.composer-send-btn:hover,
.composer-send-btn:focus {
    color: color-mix(in srgb, var(--wm-primary) 78%, #1d4ed8) !important;
    background: rgba(var(--wm-primary-rgb), 0.08) !important;
}

.composer-mic-btn {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0 !important;
    border-radius: 14px;
    color: var(--wm-primary) !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 1.28rem;
    text-decoration: none !important;
}

.composer-mic-btn:hover,
.composer-mic-btn:focus {
    background: rgba(var(--wm-primary-rgb), 0.08) !important;
}

.composer-mic-btn.is-send-mode {
    color: #fff !important;
    background: var(--wm-primary) !important;
    border-radius: 50%;
}

.composer-mic-btn.is-send-mode:hover,
.composer-mic-btn.is-send-mode:focus {
    background: color-mix(in srgb, var(--wm-primary) 88%, #0f172a) !important;
}

.composer-voice-stop {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 14px;
    color: #fff;
    background: #e11d48;
    box-shadow: 0 2px 10px rgba(225, 29, 72, 0.28);
}

.composer-voice-stop:hover,
.composer-voice-stop:focus {
    background: #be123c;
    color: #fff;
}

.composer-voice-stop.is-cancel {
    background: var(--wm-surface-soft);
    color: var(--wm-text-muted);
    box-shadow: none;
}

.composer-voice-stop.is-cancel:hover,
.composer-voice-stop.is-cancel:focus {
    background: rgba(225, 29, 72, 0.12);
    color: #e11d48;
}

.composer-voice-stop-icon {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: currentColor;
}

.composer-voice-stop.is-cancel .bi {
    font-size: 1.1rem;
    line-height: 1;
}

.composer-voice-bar {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--wm-border-soft);
    border-radius: 15px;
    background: var(--wm-surface);
}

.composer-voice-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.composer-voice-play {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: var(--wm-primary);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16);
}

.composer-voice-play:hover,
.composer-voice-play:focus {
    filter: brightness(1.06);
    color: #fff;
}

.composer-voice-play i {
    font-size: 1.15rem;
    line-height: 1;
    margin-inline-start: 1px;
}

.composer-voice-play.is-playing i {
    margin-inline-start: 0;
}

#messageForm.is-voice-ready .composer-voice-levels {
    cursor: pointer;
}

#messageForm.is-voice-ready .composer-voice-levels > i {
    background: color-mix(in srgb, var(--wm-primary) 28%, #cbd5e1);
}

#messageForm.is-voice-ready .composer-voice-levels > i.is-played {
    background: var(--wm-primary);
}

.composer-voice-levels {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 22px;
    width: 100%;
    direction: ltr;
}

.composer-voice-levels > i {
    flex: 1 1 0;
    min-width: 2px;
    height: 20%;
    border-radius: 99px;
    background: color-mix(in srgb, var(--wm-primary) 55%, #94a3b8);
    transform-origin: bottom center;
    transition: height 0.08s linear;
}

#messageForm.is-voice-recording .composer-voice-levels > i {
    background: #e11d48;
}

.composer-voice-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 12px;
    line-height: 1.2;
    color: var(--wm-text-muted);
}

.composer-voice-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #e11d48;
}

#messageForm.is-voice-recording .composer-voice-dot {
    animation: composerVoicePulse 1s ease-in-out infinite;
}

#messageForm.is-voice-ready .composer-voice-dot {
    background: var(--wm-primary);
    animation: none;
}

.composer-voice-timer {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--wm-text);
    direction: ltr;
}

.composer-voice-status {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@keyframes composerVoicePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(0.85); }
}

#messageForm.is-voice-recording .composer-attach-wrap,
#messageForm.is-voice-recording #btnEmoji,
#messageForm.is-voice-recording #messageBody,
#messageForm.is-voice-recording #btnSend,
#messageForm.is-voice-ready .composer-attach-wrap,
#messageForm.is-voice-ready #btnEmoji,
#messageForm.is-voice-ready #messageBody,
#messageForm.is-voice-ready #btnSend {
    display: none !important;
}

#messageForm.is-voice-recording #composerVoiceBar,
#messageForm.is-voice-ready #composerVoiceBar,
#messageForm.is-voice-recording #btnVoiceStop,
#messageForm.is-voice-ready #btnVoiceStop {
    display: flex !important;
}

#messageForm.is-voice-ready #btnComposerVoicePlay {
    display: inline-flex !important;
}

#messageForm.is-voice-recording #btnRecordVoice,
#messageForm.is-voice-ready #btnRecordVoice {
    display: inline-flex !important;
}

.reply-bar {
    max-width: 980px;
    margin-inline: auto;
    margin-bottom: 8px;
    border-radius: 13px;
    background: var(--wm-surface-soft);
}

/* In-app camera / microphone capture */
.media-capture-modal .modal-dialog {
    width: min(94vw, 520px);
    max-height: calc(100dvh - 1.5rem);
}

.media-capture-modal .modal-content {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 1.5rem);
    overflow: hidden;
    background: var(--wm-surface);
}

.media-capture-modal .modal-header {
    flex-shrink: 0;
    padding: 14px 16px;
    border-color: var(--wm-border-soft);
}

.media-capture-modal .modal-title {
    margin-bottom: 2px;
    font-size: 1rem;
    font-weight: 800;
}

.media-capture-modal .modal-header small {
    font-size: 0.67rem;
}

.media-capture-modal .modal-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.media-capture-stage {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    min-height: min(340px, 46dvh);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #fff;
    background:
        radial-gradient(circle at 50% 35%, rgba(59, 130, 246, 0.26), transparent 38%),
        #0b1220;
}

.media-capture-stage > video,
.media-capture-stage > img {
    width: 100%;
    height: 100%;
    max-height: min(56dvh, 480px);
    display: block;
    object-fit: contain;
    background: #020617;
}

.media-capture-stage > video.mirrored {
    transform: scaleX(-1);
}

.media-capture-stage > audio {
    display: none;
}

.media-capture-rec-badge {
    position: absolute;
    top: 14px;
    inset-inline-start: 14px;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    color: #fff;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.media-capture-rec-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.22);
    animation: capturePulse 1.2s ease-in-out infinite;
}

.media-capture-voice-preview {
    position: absolute;
    inset-inline: 18px;
    bottom: 18px;
    z-index: 4;
    width: calc(100% - 36px);
    max-width: 420px;
    margin-inline: auto;
}

.media-capture-audio-state {
    width: 100%;
    min-height: min(340px, 46dvh);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
}

.media-capture-mic {
    width: 88px;
    height: 88px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-size: 2rem;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    box-shadow: 0 0 0 12px rgba(59, 130, 246, 0.09);
}

.media-capture-audio-state.is-recording .media-capture-mic {
    background: linear-gradient(135deg, #ef4444, #e11d48);
    box-shadow: 0 0 0 12px rgba(239, 68, 68, 0.1);
    animation: capturePulse 1.4s ease-in-out infinite;
}

.media-capture-audio-state.is-ready .media-capture-mic {
    color: #d1fae5;
    background: linear-gradient(135deg, #059669, #10b981);
}

.media-capture-audio-state strong {
    font-size: 1.55rem;
    font-variant-numeric: tabular-nums;
}

.media-capture-audio-state small {
    color: #94a3b8;
}

.media-capture-bars {
    height: 30px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.media-capture-bars i {
    width: 4px;
    height: 8px;
    border-radius: 999px;
    background: #60a5fa;
}

.media-capture-audio-state.is-recording .media-capture-bars i {
    animation: captureBar 0.8s ease-in-out infinite alternate;
}

.media-capture-bars i:nth-child(2) { animation-delay: 0.12s !important; }
.media-capture-bars i:nth-child(3) { animation-delay: 0.24s !important; }
.media-capture-bars i:nth-child(4) { animation-delay: 0.36s !important; }
.media-capture-bars i:nth-child(5) { animation-delay: 0.48s !important; }

.media-capture-actions {
    flex-shrink: 0;
    flex-wrap: wrap;
    min-height: 70px;
    justify-content: center;
    gap: 8px;
    border-color: var(--wm-border-soft);
}

.media-capture-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.media-record-btn.is-recording {
    color: #fff;
    border-color: #dc2626;
    background: #dc2626;
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.25);
}

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

@keyframes captureBar {
    from { height: 8px; }
    to { height: 28px; }
}

/* Compact WhatsApp-like voice-note player
 * [play] [wave]
 *        0:12 ........................ clock
 */
.voice-note {
    --voice-play-size: 28px;
    --voice-play-gap: 8px;
    direction: ltr;
    unicode-bidi: isolate;
    display: block;
    width: 100%;
    max-width: 280px;
    min-width: 0;
    padding: 0;
    margin: 0;
    border-radius: 0;
    background: transparent;
}

.media-capture-voice-preview {
    --voice-play-size: 28px;
    --voice-play-gap: 8px;
    direction: ltr;
    unicode-bidi: isolate;
    display: block;
    width: 100%;
    max-width: none;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.78);
    color: #fff;
    position: relative;
}

.message-bubble.sent .voice-note,
.message-bubble.received .voice-note {
    background: transparent;
}

.voice-note-row {
    display: flex;
    align-items: center;
    gap: var(--voice-play-gap);
    width: 100%;
    min-width: 0;
}

.voice-note-play {
    width: var(--voice-play-size);
    height: var(--voice-play-size);
    min-width: var(--voice-play-size);
    min-height: var(--voice-play-size);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0;
    padding: 0;
    color: var(--wm-primary, #3390ec);
    background: transparent;
    box-shadow: none;
}

.message-bubble.sent .voice-note-play {
    color: #166534;
}

[data-theme="dark"] .message-bubble.sent .voice-note-play {
    color: #fff;
}

.voice-note-play i {
    font-size: 1.85rem;
    line-height: 1;
    margin: 0;
}

.voice-note-play.is-playing i {
    font-size: 1.55rem;
    margin: 0;
}

.voice-note-wave {
    flex: 1;
    min-width: 0;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5px;
    cursor: pointer;
}

.voice-note-wave > i {
    flex: 1 1 0;
    max-width: 3px;
    min-width: 2px;
    height: calc(var(--h, 40) * 0.28px);
    min-height: 4px;
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.45);
    transition: background-color 0.12s ease;
}

.voice-note-wave > i.is-played {
    background: var(--wm-primary, #3390ec);
}

.message-bubble.sent .voice-note-wave > i {
    background: rgba(22, 101, 52, 0.35);
}

.message-bubble.sent .voice-note-wave > i.is-played {
    background: #166534;
}

[data-theme="dark"] .message-bubble.sent .voice-note-wave > i {
    background: rgba(255, 255, 255, 0.38);
}

[data-theme="dark"] .message-bubble.sent .voice-note-wave > i.is-played {
    background: #fff;
}

.voice-note-wave.is-loading > i {
    animation: voiceWavePulse 1s ease-in-out infinite alternate;
}

.voice-note-wave.is-loading > i:nth-child(3n) { animation-delay: 0.12s; }
.voice-note-wave.is-loading > i:nth-child(3n + 1) { animation-delay: 0.24s; }
.voice-note-wave.is-loading > i:nth-child(3n + 2) { animation-delay: 0.36s; }

@keyframes voiceWavePulse {
    from { opacity: 0.45; }
    to { opacity: 1; }
}

.voice-note-pending .voice-note-wave {
    cursor: default;
    opacity: 0.72;
}

.message-bubble:has(.voice-note) {
    position: relative;
}

/* Below wave, after play button, same baseline as message clock */
.voice-note-time {
    position: absolute;
    left: calc(12px + var(--voice-play-size) + var(--voice-play-gap));
    bottom: 9px;
    z-index: 1;
    margin: 0;
    float: none;
    min-width: 0;
    text-align: start;
    direction: ltr;
    font-size: 11px;
    line-height: 1.2;
    color: var(--wm-text-muted, #64748b);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

.voice-note-time.voice-note-size {
    font-weight: 600;
    min-width: 0;
}

.message-bubble.sent .voice-note-time {
    color: rgba(22, 101, 52, 0.85);
}

[data-theme="dark"] .message-bubble.sent .voice-note-time {
    color: rgba(255, 255, 255, 0.85);
}

.message-bubble:has(.voice-note) .message-meta {
    margin-top: 5px;
    font-size: 11px;
    line-height: 1.2;
    position: relative;
    z-index: 1;
}

.voice-note-audio,
.msg-audio {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

.media-capture-voice-preview .voice-note-row {
    display: flex;
}

.media-capture-voice-preview .voice-note-play {
    color: #fff;
}

.media-capture-voice-preview .voice-note-time {
    position: static;
    left: auto;
    bottom: auto;
    display: block;
    margin-top: 4px;
    margin-inline-start: calc(var(--voice-play-size) + var(--voice-play-gap));
    color: rgba(255, 255, 255, 0.85);
    pointer-events: auto;
}

.media-capture-voice-preview .voice-note-wave > i {
    background: rgba(255, 255, 255, 0.35);
}

.media-capture-voice-preview .voice-note-wave > i.is-played {
    background: #fff;
}

.attach-preview-audio-wrap {
    width: 100%;
}

.attach-preview-audio-wrap .voice-note {
    max-width: 100%;
}

.message-attachment-media:has(.voice-note) .attachment-top {
    display: none;
}

.message-attachment-media:has(.voice-note) {
    gap: 0;
}

.call-recording-player.voice-note {
    max-width: 280px;
    margin-top: 0.35rem;
}

/* Admin design system */
.admin-page {
    --admin-bg: #f4f7fb;
    --admin-card: #ffffff;
    --admin-text: #0f172a;
    --admin-muted: #64748b;
    --admin-line: #e7edf5;
    --admin-sidebar: #0b1220;
    overflow-x: hidden;
    background: var(--admin-bg);
    color: var(--admin-text);
}

.admin-shell,
.admin-page > .d-flex {
    min-height: 100dvh;
}

.admin-sidebar {
    position: sticky;
    top: 0;
    width: 274px;
    min-width: 274px;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #e2e8f0;
    background:
        radial-gradient(circle at 10% 0%, rgba(59, 130, 246, 0.18), transparent 34%),
        linear-gradient(180deg, #0f172a 0%, #080e19 100%);
    border-inline-end: 1px solid rgba(148, 163, 184, 0.12);
    z-index: 1042;
}

.admin-brand {
    min-height: 88px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.admin-brand-mark {
    width: 45px;
    height: 45px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 14px;
    color: #fff;
    font-size: 1.25rem;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    box-shadow: 0 10px 24px rgba(59, 130, 246, 0.26);
}

.admin-brand strong,
.admin-brand small {
    display: block;
}

.admin-brand strong {
    color: #fff;
    font-size: 0.95rem;
}

.admin-brand small {
    margin-top: 3px;
    color: #94a3b8;
    font-size: 0.72rem;
}

.admin-sidebar-close {
    display: none;
    margin-inline-start: auto;
    border: 0;
    color: #cbd5e1;
    background: transparent;
}

.admin-nav {
    flex: 1;
    overflow-y: auto;
    padding: 15px 12px;
    scrollbar-width: thin;
}

.admin-nav-label {
    display: block;
    padding: 13px 12px 7px;
    color: #64748b;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.admin-sidebar .admin-nav a {
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 3px 0;
    padding: 8px 10px;
    border-radius: 12px;
    color: #aebdd0;
    font-size: 0.86rem;
    font-weight: 600;
    background: transparent;
}

.admin-sidebar .admin-nav a:hover {
    color: #fff;
    background: rgba(148, 163, 184, 0.1);
}

.admin-sidebar .admin-nav a.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.32), rgba(139, 92, 246, 0.2));
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.18);
}

.admin-nav-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.09);
}

.admin-sidebar .admin-nav a.active .admin-nav-icon {
    color: #bfdbfe;
    background: rgba(59, 130, 246, 0.22);
}

.admin-sidebar-footer {
    padding: 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.admin-user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-user-avatar {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 12px;
    color: #fff;
    font-weight: 800;
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
}

.admin-user-copy {
    min-width: 0;
    flex: 1;
}

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

.admin-user-copy strong {
    color: #f8fafc;
    font-size: 0.8rem;
}

.admin-user-copy small {
    color: #64748b;
    font-size: 0.68rem;
}

.admin-footer-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.admin-sidebar .admin-footer-actions a {
    width: 36px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 10px;
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.08);
}

.admin-content {
    min-width: 0;
    flex: 1;
    padding: clamp(20px, 3vw, 42px);
    background:
        radial-gradient(circle at 90% 0%, rgba(59, 130, 246, 0.08), transparent 27%),
        var(--admin-bg);
}

.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.admin-eyebrow,
.admin-panel-kicker {
    color: #3b82f6;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.admin-page-header h1 {
    margin: 5px 0 6px;
    color: var(--admin-text);
    font-size: clamp(1.55rem, 2.5vw, 2.15rem);
    font-weight: 850;
    letter-spacing: -0.045em;
}

.admin-page-header p {
    margin: 0;
    color: var(--admin-muted);
    font-size: 0.88rem;
}

.admin-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    border: 1px solid #d7f4e7;
    border-radius: 999px;
    color: #047857;
    font-size: 0.75rem;
    font-weight: 700;
    background: #ecfdf5;
}

.admin-live-pill span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

.admin-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.admin-page .stat-card {
    position: relative;
    min-height: 132px;
    display: flex;
    align-items: flex-start;
    gap: 13px;
    overflow: hidden;
    padding: 18px;
    border: 1px solid var(--admin-line);
    border-radius: 18px;
    background: var(--admin-card);
    box-shadow: 0 5px 20px rgba(15, 23, 42, 0.045);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-page .stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.stat-card-icon {
    width: 45px;
    height: 45px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 14px;
    font-size: 1.1rem;
}

.stat-card-copy {
    min-width: 0;
}

.stat-card-copy .stat-label,
.stat-card-copy small {
    display: block;
}

.stat-card-copy .stat-label {
    color: var(--admin-muted);
    font-size: 0.74rem;
    font-weight: 650;
}

.admin-page .stat-card .stat-value {
    display: block;
    margin: 4px 0 2px;
    color: var(--admin-text);
    font-size: 1.65rem;
    font-weight: 850;
    line-height: 1.25;
    letter-spacing: -0.035em;
}

.stat-card-copy small {
    color: #94a3b8;
    font-size: 0.65rem;
}

.stat-card-glow {
    position: absolute;
    width: 70px;
    height: 70px;
    inset-inline-end: -26px;
    bottom: -30px;
    border-radius: 50%;
    opacity: 0.09;
    filter: blur(1px);
}

.stat-card-blue .stat-card-icon, .stat-card-blue .stat-card-glow { color: #2563eb; background: #dbeafe; }
.stat-card-green .stat-card-icon, .stat-card-green .stat-card-glow { color: #059669; background: #d1fae5; }
.stat-card-cyan .stat-card-icon, .stat-card-cyan .stat-card-glow { color: #0891b2; background: #cffafe; }
.stat-card-violet .stat-card-icon, .stat-card-violet .stat-card-glow { color: #7c3aed; background: #ede9fe; }
.stat-card-amber .stat-card-icon, .stat-card-amber .stat-card-glow { color: #d97706; background: #fef3c7; }
.stat-card-rose .stat-card-icon, .stat-card-rose .stat-card-glow { color: #e11d48; background: #ffe4e6; }
.stat-card-indigo .stat-card-icon, .stat-card-indigo .stat-card-glow { color: #4f46e5; background: #e0e7ff; }
.stat-card-slate .stat-card-icon, .stat-card-slate .stat-card-glow { color: #475569; background: #e2e8f0; }

.admin-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.75fr);
    gap: 18px;
}

.admin-panel {
    min-width: 0;
    padding: 20px;
    border: 1px solid var(--admin-line);
    border-radius: 20px;
    background: var(--admin-card);
    box-shadow: 0 5px 22px rgba(15, 23, 42, 0.045);
}

.admin-panel-wide {
    min-height: 390px;
}

.admin-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 18px;
}

.admin-panel h2 {
    margin: 4px 0 0;
    color: var(--admin-text);
    font-size: 1rem;
    font-weight: 800;
}

.chart-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--admin-muted);
    font-size: 0.68rem;
}

.chart-legend span,
.compact-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 50%;
}

.legend-dot.messages { background: #3b82f6; }
.legend-dot.calls { background: #8b5cf6; }
.legend-dot.users, .legend-dot.active { background: #10b981; }
.legend-dot.inactive { background: #cbd5e1; }
.legend-dot.blocked { background: #f43f5e; }

.activity-chart-wrap {
    position: relative;
    height: 300px;
}

.donut-chart-wrap {
    position: relative;
    height: 210px;
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.donut-center strong {
    color: var(--admin-text);
    font-size: 1.45rem;
    font-weight: 850;
}

.donut-center span {
    color: var(--admin-muted);
    font-size: 0.66rem;
}

.compact-legend {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    color: var(--admin-muted);
    font-size: 0.67rem;
}

.compact-legend span {
    justify-content: center;
}

.compact-legend b {
    color: var(--admin-text);
}

.content-mix-list {
    display: grid;
    gap: 10px;
}

.content-mix-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 13px;
    background: #f8fafc;
}

.content-mix-icon {
    width: 35px;
    height: 35px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
}

.content-mix-icon.blue { color: #2563eb; background: #dbeafe; }
.content-mix-icon.violet { color: #7c3aed; background: #ede9fe; }
.content-mix-icon.amber { color: #d97706; background: #fef3c7; }
.content-mix-row span:nth-child(2) { flex: 1; color: var(--admin-muted); font-size: 0.78rem; }
.content-mix-row strong { color: var(--admin-text); }

.admin-panel-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 16px;
    color: #2563eb;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
}

.admin-quick-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
}

.admin-quick-grid a {
    min-height: 82px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--admin-line);
    border-radius: 14px;
    color: var(--admin-muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    background: #fbfdff;
    transition: border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.admin-quick-grid a i {
    color: #3b82f6;
    font-size: 1.18rem;
}

.admin-quick-grid a:hover {
    color: #2563eb;
    border-color: #bfdbfe;
    transform: translateY(-2px);
}

.admin-mobile-menu,
.admin-sidebar-backdrop {
    display: none;
}

/* Upgrade existing admin pages without changing their PHP */
.admin-page .admin-content > h4 {
    margin-bottom: 22px !important;
    color: var(--admin-text);
    font-size: 1.55rem;
    font-weight: 850;
    letter-spacing: -0.035em;
}

.admin-page .card {
    border: 1px solid var(--admin-line);
    border-radius: 18px;
    box-shadow: 0 5px 22px rgba(15, 23, 42, 0.045);
}

.admin-page .card-header {
    padding: 15px 18px;
    border-color: var(--admin-line);
    border-radius: 18px 18px 0 0 !important;
    background: #fbfdff;
}

.admin-page .table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
    font-size: 0.78rem;
}

.admin-page .table > :not(caption) > * > * {
    padding: 13px 12px;
    border-color: var(--admin-line);
    vertical-align: middle;
    font-size: inherit;
    line-height: 1.55;
}

.admin-page .table :is(.btn, .badge, small, code) {
    font-size: inherit;
}

.admin-page .table thead th {
    color: var(--admin-muted);
    font-size: inherit;
    font-weight: 750;
    background: #f8fafc;
}

/* Compact, two-column admin settings */
.admin-settings-form {
    padding-bottom: 84px;
}

.settings-group-nav {
    position: sticky;
    top: 10px;
    z-index: 25;
    padding: 10px;
    border: 1px solid var(--admin-line);
    border-radius: 16px;
    background: rgba(244, 247, 251, 0.9);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

.settings-group-nav .btn {
    padding: 7px 12px;
    border-color: #dbe5f1;
    border-radius: 10px;
    color: #475569;
    background: #fff;
}

.settings-group-nav .btn:hover,
.settings-group-nav .btn:focus {
    color: #2563eb;
    border-color: #bfdbfe;
    background: #eff6ff;
}

.settings-section {
    scroll-margin-top: 84px;
}

.settings-section-header {
    display: flex;
    align-items: center;
    gap: 11px;
}

.settings-section-header > div {
    min-width: 0;
}

.settings-section-header strong,
.settings-section-header small {
    display: block;
}

.settings-section-header strong {
    color: var(--admin-text);
    font-size: 0.9rem;
}

.settings-section-header small {
    margin-top: 3px;
    color: var(--admin-muted);
    font-size: 0.65rem;
    font-weight: 500;
}

.settings-section-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 12px;
    color: #2563eb;
    background: #dbeafe;
}

.settings-fields-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
}

.setting-field {
    min-width: 0;
    margin: 0;
    padding: 13px;
    border: 1px solid #edf1f6;
    border-radius: 13px;
    background: #fbfdff;
}

.setting-field-wide {
    grid-column: 1 / -1;
}

.setting-field .form-label {
    min-height: 20px;
    margin-bottom: 7px;
    color: #334155;
    font-size: 0.75rem;
    font-weight: 750;
}

.setting-field .form-control,
.setting-field .form-select {
    width: 100%;
    min-height: 38px;
    border-color: #dde5ef;
    background-color: #fff;
}

.setting-field textarea.form-control {
    min-height: 68px;
    resize: vertical;
    direction: ltr;
    text-align: left;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
}

.setting-field small.text-muted {
    min-height: 18px;
    margin-top: 6px !important;
    color: #7c8ca1 !important;
    font-size: 0.65rem;
    line-height: 1.55;
}

.settings-save-bar {
    position: sticky;
    bottom: 14px;
    z-index: 24;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    max-width: 760px;
    margin: 0 auto;
    padding: 12px 14px;
    border: 1px solid rgba(191, 219, 254, 0.9);
    border-radius: 16px;
    color: #64748b;
    font-size: 0.72rem;
    background: rgba(255, 255, 255, 0.93);
    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.14);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

.settings-save-bar > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-save-bar > div i {
    color: #3b82f6;
}

.settings-save-bar .btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

@media (max-width: 1199px) {
    .admin-metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991px) {
    .admin-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        transform: translateX(110%);
        transition: transform 0.25s ease;
    }

    [dir="ltr"] .admin-sidebar {
        transform: translateX(-110%);
    }

    .admin-sidebar.is-open {
        transform: translateX(0);
    }

    .admin-sidebar-close {
        display: inline-flex;
    }

    .admin-sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(2, 6, 23, 0.54);
        -webkit-backdrop-filter: blur(2px);
        backdrop-filter: blur(2px);
    }

    .admin-sidebar-backdrop.is-open {
        display: block;
    }

    .admin-mobile-menu {
        position: fixed;
        top: max(14px, env(safe-area-inset-top));
        inset-inline-start: 14px;
        z-index: 1039;
        width: 44px;
        height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--admin-line);
        border-radius: 13px;
        color: #334155;
        font-size: 1.25rem;
        background: rgba(255, 255, 255, 0.92);
        box-shadow: var(--wm-shadow-md);
        -webkit-backdrop-filter: blur(14px);
        backdrop-filter: blur(14px);
    }

    .admin-content {
        padding-top: 74px;
    }

    .admin-page-header {
        align-items: flex-start;
    }
}

@media (max-width: 980px) {
    .auth-shell {
        display: block;
    }

    .auth-showcase {
        display: none;
    }

    .auth-form-side {
        position: relative;
        min-height: 100dvh;
        padding: 90px 20px 28px;
        align-items: center;
        background:
            radial-gradient(circle at 10% 0%, rgba(99, 102, 241, .15), transparent 30%),
            radial-gradient(circle at 90% 15%, rgba(var(--wm-primary-rgb), .15), transparent 34%),
            #f5f8fc;
    }

    .auth-mobile-brand {
        position: absolute;
        top: max(22px, env(safe-area-inset-top));
        inset-inline-start: 24px;
        display: flex;
        color: #0f172a;
    }

    .auth-mobile-brand .auth-brand-mark {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        color: #fff;
        background: linear-gradient(135deg, var(--wm-primary), #6366f1);
        box-shadow: 0 8px 20px rgba(var(--wm-primary-rgb), .22);
    }

    .auth-mobile-brand strong {
        max-width: 220px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: .88rem;
    }
}

@media (max-width: 768px) {
    .login-page {
        background: #f5f8fc;
    }

    .auth-form-side {
        padding: 82px 14px max(18px, env(safe-area-inset-bottom));
    }

    .auth-mobile-brand {
        inset-inline-start: 18px;
    }

    .auth-card {
        width: 100%;
        padding: 25px 20px;
        border-radius: 22px;
        box-shadow: 0 18px 45px rgba(15, 23, 42, .08);
    }

    .auth-card-header {
        margin-bottom: 23px;
    }

    .auth-card-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 13px;
        border-radius: 15px;
    }

    .auth-card-header h2 {
        font-size: 1.35rem;
    }

    .auth-form {
        gap: 15px;
    }

    .auth-input-wrap .form-control {
        height: 48px;
    }

    .messenger-page {
        background: var(--wm-surface);
    }

    .messenger-app {
        width: 100%;
    }

    .chat-sidebar {
        width: 100%;
        min-width: 100%;
        height: 100%;
        max-height: 100%;
        border: 0;
    }

    .sidebar-header {
        min-height: 64px;
        padding-top: max(10px, env(safe-area-inset-top)) !important;
    }

    .sidebar-title {
        max-width: 110px;
    }

    .sidebar-header-actions .btn {
        width: 36px;
        height: 36px;
    }

    .chat-list {
        padding-inline: 6px;
    }

    .chat-list .chat-item {
        min-height: 70px;
        padding-inline: 10px;
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }

    .message-text,
    .message-caption {
        -webkit-user-select: text;
        user-select: text;
        -webkit-touch-callout: default;
    }

    .chat-header {
        min-height: 64px;
        padding: max(8px, env(safe-area-inset-top)) 10px 8px !important;
    }

    .chat-header .avatar-circle {
        width: 40px;
        height: 40px;
    }

    .chat-actions {
        gap: 0 !important;
    }

    .chat-actions .btn,
    #btnBack {
        width: 36px;
        height: 36px;
    }

    .messages-area {
        padding: 13px 8px 16px;
    }

    .message-row {
        max-width: 88%;
    }

    .message-bubble {
        padding: 8px 10px;
        border-radius: 15px;
    }

    /* Photo/video: 1px inset + border like text bubbles */
    .message-bubble.is-media-bubble,
    .message-bubble:has(.msg-image-wrap),
    .message-bubble:has(.msg-video-wrap),
    .message-bubble:has(.media-load-placeholder) {
        padding: 1px 1px 1px !important;
        flex: 0 1 auto !important;
        width: fit-content !important;
        max-width: min(100%, var(--wm-media-max-w, 240px)) !important;
        border-radius: 14px;
        border: 1px solid var(--wm-border-soft, var(--wm-border));
    }

    .message-bubble.is-media-bubble:has(.message-caption),
    .message-bubble:has(.msg-image-wrap):has(.message-caption),
    .message-bubble:has(.msg-video-wrap):has(.message-caption),
    .message-bubble:has(.media-load-placeholder):has(.message-caption) {
        padding: 1px 1px 8px !important;
    }

    .message-row.is-media-row {
        max-width: 88%;
    }

    .message-bubble.is-media-bubble .message-attachment,
    .message-bubble.is-media-bubble .message-attachment-media,
    .message-bubble.is-media-bubble .attachment-media {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    .message-bubble.is-media-bubble .msg-image-wrap,
    .message-bubble.is-media-bubble .msg-video-wrap,
    .message-bubble.is-media-bubble .media-load-placeholder {
        border-radius: 12px !important;
        max-width: 100% !important;
        overflow: hidden;
    }

    .chat-composer {
        padding: 8px !important;
    }

    #messageForm {
        gap: 5px !important;
    }

    #messageForm > .dropdown > .btn,
    #messageForm > .composer-attach-wrap > .btn,
    #btnEmoji {
        width: 39px;
        height: 39px;
        border-radius: 12px;
    }

    #messageBody {
        min-height: 42px;
        padding: 9px 12px;
    }

    #btnSend,
    .composer-mic-btn,
    .composer-voice-stop {
        width: 42px;
        height: 42px;
    }

    .media-capture-modal {
        --bs-modal-margin: 0;
        padding: 0 !important;
    }

    .media-capture-modal .modal-dialog {
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        align-items: stretch;
    }

    .media-capture-modal .modal-content {
        height: 100dvh;
        max-height: 100dvh;
        min-height: 0;
        border: 0;
        border-radius: 0;
    }

    .media-capture-modal .modal-header {
        padding: 10px 14px;
        padding-top: max(10px, env(safe-area-inset-top, 0px));
    }

    .media-capture-modal .modal-title {
        font-size: 0.95rem;
    }

    .media-capture-modal .modal-header small {
        display: none;
    }

    .media-capture-modal .modal-body {
        display: flex;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    .media-capture-stage {
        width: 100%;
        min-height: 0;
        flex: 1 1 auto;
        height: auto;
    }

    .media-capture-stage > video,
    .media-capture-stage > img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        object-fit: cover;
    }

    .media-capture-audio-state {
        min-height: 0;
        height: 100%;
        gap: 10px;
    }

    .media-capture-mic {
        width: 72px;
        height: 72px;
        font-size: 1.6rem;
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0.09);
    }

    .media-capture-audio-state strong {
        font-size: 1.3rem;
    }

    .media-capture-actions {
        min-height: 0;
        gap: 6px;
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .media-capture-actions .btn {
        padding: 0.45rem 0.7rem;
        font-size: 0.82rem;
    }

    .call-modal .modal-footer {
        padding-bottom: calc(16px + var(--wm-safe-bottom)) !important;
    }

    .admin-content {
        padding: 70px 14px 24px;
    }

    .admin-page-header {
        display: block;
        margin-bottom: 20px;
    }

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

    .admin-page-header p {
        font-size: 0.78rem;
    }

    .admin-header-actions {
        margin-top: 14px;
    }

    .admin-live-pill {
        display: none;
    }

    .admin-metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .admin-page .stat-card {
        min-height: 126px;
        display: block;
        padding: 14px;
    }

    .stat-card-icon {
        width: 38px;
        height: 38px;
        margin-bottom: 10px;
        border-radius: 12px;
    }

    .admin-page .stat-card .stat-value {
        font-size: 1.35rem;
    }

    .stat-card-copy small {
        display: none;
    }

    .admin-panel {
        padding: 16px;
        border-radius: 17px;
    }

    .admin-panel-header {
        display: block;
    }

    .chart-legend {
        margin-top: 10px;
    }

    .activity-chart-wrap {
        height: 255px;
    }

    .admin-quick-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .admin-page .table-responsive {
        margin-inline: -16px;
        width: calc(100% + 32px);
    }

    .settings-group-nav {
        top: 64px;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .settings-group-nav::-webkit-scrollbar {
        display: none;
    }

    .settings-group-nav .btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .settings-fields-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px;
    }

    .setting-field-wide {
        grid-column: auto;
    }

    .setting-field {
        padding: 11px;
    }

    .settings-save-bar {
        bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }

    .settings-save-bar > div {
        display: none;
    }

    .settings-save-bar .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 420px) {
    .sidebar-header-actions .btn:nth-of-type(2) {
        display: none;
    }

    .admin-metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .compact-legend {
        grid-template-columns: 1fr;
    }
}

/* Short / landscape viewports: keep camera capture inside the screen */
@media (max-height: 640px) {
    .media-capture-modal {
        --bs-modal-margin: 0;
        padding: 0 !important;
    }

    .media-capture-modal .modal-dialog {
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        align-items: stretch;
    }

    .media-capture-modal .modal-content {
        height: 100dvh;
        max-height: 100dvh;
        min-height: 0;
        border: 0;
        border-radius: 0;
    }

    .media-capture-modal .modal-header {
        padding: 8px 12px;
        padding-top: max(8px, env(safe-area-inset-top, 0px));
    }

    .media-capture-modal .modal-header small {
        display: none;
    }

    .media-capture-modal .modal-body {
        display: flex;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    .media-capture-stage {
        min-height: 0;
        flex: 1 1 auto;
    }

    .media-capture-stage > video,
    .media-capture-stage > img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        object-fit: cover;
    }

    .media-capture-audio-state {
        min-height: 0;
        height: 100%;
        gap: 8px;
    }

    .media-capture-mic {
        width: 56px;
        height: 56px;
        font-size: 1.35rem;
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.09);
    }

    .media-capture-actions {
        min-height: 0;
        padding: 8px 10px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }
}

/* —— Video trim (after record, before send) —— */
.video-trim-modal .modal-dialog {
    width: min(94vw, 520px);
    max-height: calc(100dvh - 1.5rem);
    margin: 0.75rem auto;
}

.video-trim-modal .modal-content {
    display: flex;
    flex-direction: column;
    height: min(720px, calc(100dvh - 1.5rem));
    max-height: calc(100dvh - 1.5rem);
    border: 0;
    border-radius: 18px;
    overflow: hidden;
    background: #0f172a;
    color: #f8fafc;
}

.video-trim-modal .modal-header {
    flex-shrink: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    padding: 0.75rem 1rem;
}

.video-trim-modal .modal-title {
    font-size: 1rem;
    font-weight: 700;
}

.video-trim-modal .btn-close {
    filter: invert(1) grayscale(1);
    opacity: 0.75;
}

.video-trim-modal .modal-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.video-trim-modal .modal-footer,
.video-trim-footer {
    flex-shrink: 0;
    display: flex;
    gap: 0.6rem;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    padding: 0.75rem 1rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
}

.video-trim-footer .btn {
    flex: 1 1 0;
    min-height: 44px;
}

.video-trim-footer .btn-outline-light {
    border-color: rgba(148, 163, 184, 0.45);
    color: #e2e8f0;
}

.video-trim-footer .btn-outline-light:hover,
.video-trim-footer .btn-outline-light:focus {
    background: rgba(148, 163, 184, 0.16);
    border-color: rgba(148, 163, 184, 0.65);
    color: #fff;
}

.video-trim-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #020617;
}

.video-trim-stage video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
    object-fit: contain;
}

.video-trim-play {
    position: absolute;
    z-index: 2;
    inset-inline-start: 50%;
    inset-block-start: 50%;
    translate: -50% -50%;
    width: 64px;
    height: 64px;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    font-size: 1.75rem;
    display: grid;
    place-items: center;
    backdrop-filter: blur(6px);
    transition: opacity 0.15s ease;
}

.video-trim-play.is-playing {
    opacity: 0.4;
}

.video-trim-status {
    position: absolute;
    z-index: 3;
    inset-inline: 12px;
    inset-block-end: 12px;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.78);
    color: #e2e8f0;
    font-size: 0.78rem;
    text-align: center;
    pointer-events: none;
}

.video-trim-status:empty {
    display: none;
}

.video-trim-controls {
    flex-shrink: 0;
    padding: 0.75rem 1rem 0.4rem;
    background: #0f172a;
}

.video-trim-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    color: #cbd5e1;
    margin-bottom: 0.55rem;
}

.video-trim-summary .video-trim-range,
.video-trim-range {
    font-weight: 700;
    color: #fff;
}

.video-trim-track-wrap {
    margin-bottom: 0.7rem;
}

.video-trim-track {
    position: relative;
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.28);
    overflow: hidden;
}

.video-trim-track-fill {
    position: absolute;
    inset-block: 0;
    border-radius: inherit;
    background: #3390ec;
}

.video-trim-row {
    display: grid;
    grid-template-columns: 2.4rem 1fr;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.45rem;
}

.video-trim-row label {
    margin: 0;
    font-size: 0.78rem;
    color: #94a3b8;
    white-space: nowrap;
}

.video-trim-row input[type="range"] {
    width: 100%;
    margin: 0;
    accent-color: #3390ec;
    height: 28px;
}

.video-trim-progress {
    margin-top: 0.55rem;
}

.video-trim-progress-bar {
    height: 4px;
    width: 0;
    border-radius: 999px;
    background: #3390ec;
    transition: width 0.12s linear;
}

.video-trim-progress small {
    display: block;
    margin-top: 0.35rem;
    color: #94a3b8;
    font-size: 0.75rem;
}

@media (max-width: 767.98px) {
    .video-trim-modal {
        --bs-modal-margin: 0;
        padding: 0 !important;
    }

    .video-trim-modal .modal-dialog {
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        align-items: stretch;
    }

    .video-trim-modal .modal-content {
        height: 100dvh;
        max-height: 100dvh;
        min-height: 0;
        border-radius: 0;
    }

    .video-trim-modal .modal-header {
        padding: 10px 14px;
        padding-top: max(10px, env(safe-area-inset-top, 0px));
    }

    .video-trim-stage {
        min-height: 0;
    }

    .video-trim-controls {
        padding: 0.65rem 0.9rem 0.2rem;
    }

    .video-trim-footer {
        padding: 0.65rem 0.9rem;
        padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
