body {
    background-color: #f8f9fa;
}
.owner-main {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}
.owner-main .card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-height: 0;
    padding: 1rem 1.2rem 1.2rem;
}
.history-panel {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.history-panel .history-section {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
}
.owner-main .card-body > .panel {
    margin-bottom: 0.75rem;
    flex: 0 0 auto;
}
.owner-main .card-body > .panel.history-panel {
    flex: 1 1 0;
    min-height: 0;
}
.owner-main .card-body > .panel:last-child {
    margin-bottom: 0;
}
.composer.panel {
    flex: 0 0 auto;
}
.footer-spacer {
    flex-shrink: 0;
}
.owner-main .card-body {
    padding: 1.75rem;
}
.nav-pills .nav-link.active {
    background-color: #0d6efd;
}
.small-badge {
    font-size: 0.75rem;
    margin-right: 0.35rem;
}
.panel {
    background: #fff;
    border-radius: 1rem;
    border: 1px solid #e9ecef;
    padding: 0.95rem 1.15rem;
    margin-bottom: 0.75rem;
}
.profile-summary-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    margin-bottom: 1rem;
}
.profile-meta-item {
    padding: 0.75rem;
    border: 1px solid #e9ecef;
    border-radius: 0.75rem;
    background: #f8f9fa;
}
.profile-form-grid,
.trigger-grid {
    display: grid;
    gap: 0.6rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.profile-meta-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.8rem;
    align-items: flex-start;
}
.profile-meta-summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 140px;
}
.profile-meta-summary-label-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.profile-meta-summary .meta-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6c757d;
}
.profile-meta-summary .meta-value {
    font-weight: 600;
    color: #0d6efd;
}
.profile-header-edit-trigger {
    padding: 0.05rem;
    text-decoration: none;
    color: inherit;
}
.profile-header-edit-icon {
    font-size: 0.85rem;
    line-height: 1;
    color: #6c757d;
}
.profile-header-edit-panel {
    margin-top: 0.35rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid #dee2e6;
    background: #fff;
}
.profile-header-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}
.profile-header-text {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}
.status-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: flex-end;
}
.meta-tags {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}
.meta-tag {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
}
.realtime-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    z-index: 1050;
    pointer-events: none;
}
.realtime-toast {
    background: rgba(33, 37, 41, 0.95);
    color: #fff;
    border-radius: 0.5rem;
    padding: 0.65rem 0.9rem;
    font-size: 0.85rem;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: auto;
}
.realtime-toast.toast-success {
    background: #198754;
}
.realtime-toast.toast-danger {
    background: #dc3545;
}
.realtime-toast.toast-warning {
    background: #ffc107;
    color: #0f172a;
}
.realtime-toast.toast-dark {
    background: rgba(33, 37, 41, 0.95);
}
.realtime-toast-visible {
    opacity: 1;
    transform: translateY(0);
}
.control-action {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    border-radius: 0.65rem;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.control-action .icon {
    line-height: 1;
    font-size: 1.15rem;
    font-family: "Bootstrap Icons";
    color: inherit;
}
.summary-panel {
    background: #fff;
    border-radius: 1rem;
    border: 1px solid #e9ecef;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.summary-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.summary-card {
    background: #f8f9fa;
    border-radius: 0.75rem;
    border: 1px solid #e9ecef;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.summary-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6c757d;
}
.summary-value {
    font-size: 1.6rem;
    font-weight: 600;
    color: #0d6efd;
}
.avatar-circle {
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    background: #e9ecef !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    color: #2c2c2c !important;
    text-transform: uppercase;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 0.15rem 0.45rem rgba(0, 0, 0, 0.08);
    line-height: 1;
    min-width: 48px;
    min-height: 48px;
    overflow: hidden;
    letter-spacing: 0.05em;
}


.avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    display: block;
}

.avatar-list {
    width: 34px;
    height: 34px;
    font-size: 0.75rem;
    border-width: 1px;
    box-shadow: none;
    background: #dee2e6;
    border-color: #fff;
    min-width: 34px;
    min-height: 34px;
}
.history-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 0.25rem;
    padding-bottom: 0.75rem;
}
.history-prepend-loader {
    display: flex;
    justify-content: center;
    padding: 0.25rem 0 0.5rem;
}
.history-section::-webkit-scrollbar {
    width: 6px;
}
.history-section::-webkit-scrollbar-thumb {
    background: rgba(13, 110, 253, 0.4);
    border-radius: 999px;
}
.message-row {
    display: flex;
    gap: 0.75rem;
}
.message-row.outgoing {
    justify-content: flex-end;
}
.message-row.incoming {
    justify-content: flex-start;
}
.bubble {
    max-width: 520px;
    padding: 0.65rem 0.85rem;
    border-radius: 0.65rem;
    position: relative;
    border: 1px solid transparent;
    box-shadow: 0 0.12rem 0.35rem rgba(0, 0, 0, 0.04);
    display: inline-flex;
    flex-direction: column;
    gap: 0.25rem;
    word-break: break-word;
    padding-right: 2.6rem;
}
.bubble.media-only {
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
    gap: 0.25rem;
    padding-right: 0;
}
.bubble .message-text {
    white-space: pre-wrap;
    line-height: 1.35;
    font-size: 0.95rem;
}
.bubble .media-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    padding: 0.2rem 0.48rem;
    border-radius: 999px;
    font-size: 0.85rem;
    background: #eef4ff;
    color: #0d47a1;
    border: 1px solid #d6e4ff;
    margin-bottom: 0.3rem;
    margin-right: 0.3rem;
}
.bubble .media-chip.voice {
    background: #f0f7ff;
    color: #0b5394;
    border-color: #d5e6ff;
}
.bubble .media-chip.video {
    background: #fef3e6;
    color: #8b4a0f;
    border-color: #f7d8ae;
}
.bubble a.media-link {
    text-decoration: none;
}
.bubble .media-embed {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    position: relative;
}
.bubble .media-embed .media-loader {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    background: rgba(255,255,255,0.45);
    border-radius: inherit;
    z-index: 2;
}
.bubble .media-embed video.media-video.video-note + .media-loader,
.bubble .media-embed video.media-video + .media-loader,
.bubble .media-embed img.media-image + .media-loader {
    display: flex;
}
.bubble .media-embed .media-loader .spinner-border {
    color: #6c757d;
}
.bubble .media-embed .video-note-wrapper {
    position: relative;
    display: inline-block;
}
.bubble .media-embed .video-note-pulse {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    pointer-events: none;
    box-shadow: 0 0 0 0 rgba(0, 183, 74, 0.35);
    opacity: 0;
    transition: opacity 0.2s ease, box-shadow 0.2s ease;
}
.bubble .media-embed .video-note-wrapper.unmuting .video-note-pulse {
    opacity: 1;
    animation: pulse-ring 1.2s ease-out 2;
}
.bubble .media-embed .video-note-play {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 1.35rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
    transition: background 0.2s ease, transform 0.1s ease;
}
.bubble .media-embed .video-note-play:hover {
    background: rgba(0,0,0,0.7);
}
.bubble .media-embed .video-note-play:active {
    transform: scale(0.96);
}
@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(0,183,74,0.45); }
    100% { box-shadow: 0 0 0 22px rgba(0,183,74,0); }
}
.bubble .media-embed audio,
.bubble .media-embed video {
    width: 100%;
    max-width: 300px;
    border-radius: 0.5rem;
    background: #f8f9fa;
    position: relative;
    z-index: 1;
}
.bubble .media-embed img.media-image {
    width: 100%;
    max-width: 260px;
    border-radius: 0.55rem;
    display: block;
    height: auto;
    object-fit: cover;
    box-shadow: 0 0.18rem 0.35rem rgba(0,0,0,0.06);
    position: relative;
    z-index: 1;
}
.bubble .media-embed img.media-image.sticker-image {
    max-width: 220px;
    max-height: 220px;
    width: 100%;
    height: auto;
    border-radius: 0.45rem;
    object-fit: contain;
}
.sticker-image {
    max-width: 512px;
    max-height: 512px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}
.bubble .media-embed video.media-video.video-note {
    max-width: 260px;
    aspect-ratio: 1 / 1;
    border-radius: 999px;
    object-fit: cover;
    background: #000;
}
.bubble .media-embed video.media-video.video-note::-webkit-media-controls {
    display: none !important;
}
.bubble .media-embed video.media-video.video-note::-webkit-media-controls-start-playback-button {
    display: none !important;
}
.bubble .media-embed video.media-video.video-note::-webkit-media-controls-start-playback-button {
    display: none !important;
}
.bubble .message-text a {
    color: inherit;
    text-decoration: underline;
}
.bubble .message-text code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.05rem 0.35rem;
    border-radius: 0.25rem;
    font-size: 0.95em;
}
.bubble .message-text pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.65rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.95em;
    overflow-x: auto;
}
.bubble .tg-spoiler {
    background: rgba(0, 0, 0, 0.15);
    color: transparent;
    border-radius: 0.35rem;
    padding: 0.1rem 0.35rem;
}
.bubble .tg-spoiler:hover,
.bubble .tg-spoiler:focus-within {
    color: inherit;
}
.bubble .tg-tag {
    background: rgba(13, 110, 253, 0.08);
    color: #0d6efd;
    border-radius: 0.35rem;
    padding: 0.05rem 0.4rem;
    font-weight: 600;
}
.bubble.incoming {
    background: #f8f9fa;
    border-color: #e9ecef;
}
.bubble.outgoing {
    background: #e3f5f0;
    color: #0c4a3a;
    border-color: #b3e0d2;
}
.bubble.outgoing.owner {
    background: #edeff3;
    color: #48536b;
    border-color: #d6d9e5;
}
.bubble.outgoing.auto {
    background: #fff7eb;
    color: #6b4e22;
    border-color: #f0d8b2;
}
.timestamp {
    font-size: 0.75rem;
    color: inherit;
    align-self: flex-end;
}
.owner-timestamp {
    color: rgba(0, 0, 0, 0.5);
}
.quote-bubble {
    background: rgba(13, 110, 253, 0.08);
    border-left: 3px solid rgba(13, 110, 253, 0.5);
    border-radius: 0.35rem;
    padding: 0.35rem 0.65rem;
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    font-style: italic;
    color: #0d3b71;
}
.composer {
    border-radius: 1rem;
}
.reply-button {
    border: none;
    background: transparent;
    color: inherit;
    font-size: 1rem;
    margin-left: 0.25rem;
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}
.reply-button span {
    font-weight: 600;
}
.timestamp {
    font-size: 0.75rem;
    color: inherit;
    align-self: flex-start;
    margin-bottom: 0.15rem;
}
.owner-timestamp {
    color: rgba(0, 0, 0, 0.5);
}
.meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}
.meta-tag {
    background: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
    padding: 0.15rem 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.composer-note {
    font-size: 0.85rem;
    color: #6c757d;
}

.trigger-template .meta-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6c757d;
    font-weight: 600;
    display: block;
    margin-bottom: 0.35rem;
}
.template-preview {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.75rem;
    padding: 0.75rem;
    line-height: 1.5;
    font-size: 0.95rem;
    color: #212529;
    white-space: pre-line;
}
.template-preview--rendered {
    border-color: rgba(13, 110, 253, 0.4);
    background: #fff;
}
.template-preview-note {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}
.trigger-template textarea,
.trigger-template .form-control {
    min-height: 140px;
    border-radius: 0.75rem;
    border: 1px solid #ced4da;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}
.trigger-card {
    border: none;
    border-radius: 0.6rem;
    margin-bottom: 0.75rem;
    background: #fff;
    box-shadow: 0 0.15rem 0.35rem rgba(0, 0, 0, 0.05);
}
.trigger-card .accordion-button {
    font-weight: 600;
    padding: 0.35rem 0.45rem;
    font-size: 0.85rem;
    min-height: 40px;
}
.trigger-card .accordion-button .meta {
    color: #6c757d;
    margin-bottom: 0;
    font-size: 0.7rem;
}
.trigger-card .trigger-icon {
    margin-right: 0.5rem;
    font-size: 1rem;
    color: #6c757d;
    border: none;
    background: transparent;
}
.trigger-card.dragging {
    opacity: 0.75;
}
.trigger-card .accordion-collapse {
    margin-top: 0;
}
.trigger-card .accordion-body {
    padding: 0.4rem 0.6rem 0.5rem;
    background: #f8f9ff;
}
.trigger-grid {
    gap: 0.25rem;
}
.trigger-column {
    gap: 0.25rem;
}
.trigger-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
}
.trigger-icon.trigger-drag-icon i {
    font-size: 1.25rem;
}
.trigger-icon.trigger-lock-icon i {
    font-size: 1rem;
}
.trigger-icon.trigger-lock-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.template-controls {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    align-items: center;
}
.template-controls .btn {
    padding: 0.2rem 0.8rem;
    text-transform: none;
}
.template-controls .btn:hover {
    text-decoration: none;
}
.template-controls .btn-group {
    display: inline-flex;
}
.trigger-column {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
